From 947f0a876ec83e24078c55650c5ca39002c381fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 21 May 2024 14:57:30 +0200 Subject: [PATCH] Delegate shouldn't keep the specific ViewController type --- ios/AppDelegate.h | 4 ++-- ios/AppDelegate.mm | 5 +++-- ios/DisplayManager.mm | 2 +- ios/ViewController.h | 1 + ios/ViewController.mm | 4 ++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ios/AppDelegate.h b/ios/AppDelegate.h index 99aa4df211..bd5bf00795 100644 --- a/ios/AppDelegate.h +++ b/ios/AppDelegate.h @@ -2,13 +2,13 @@ #import -@class PPSSPPViewControllerGL; +@protocol PPSSPPViewController; @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UIScreen *screen; -@property (strong, nonatomic) PPSSPPViewControllerGL *viewController; +@property (strong, nonatomic) id viewController; @end diff --git a/ios/AppDelegate.mm b/ios/AppDelegate.mm index c8389e7c07..fbcb84be8d 100644 --- a/ios/AppDelegate.mm +++ b/ios/AppDelegate.mm @@ -91,14 +91,15 @@ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + PPSSPPViewControllerGL *vc = [[PPSSPPViewControllerGL alloc] init]; // Here we can switch viewcontroller depending on backend. - self.viewController = [[PPSSPPViewControllerGL alloc] init]; + self.viewController = vc; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil]; - self.window.rootViewController = self.viewController; + self.window.rootViewController = vc; [self.window makeKeyAndVisible]; return YES; diff --git a/ios/DisplayManager.mm b/ios/DisplayManager.mm index ba369e64e1..ce669d5dbd 100644 --- a/ios/DisplayManager.mm +++ b/ios/DisplayManager.mm @@ -166,7 +166,7 @@ g_display.pixel_in_dps_x = (float)g_display.pixel_xres / (float)g_display.dp_xres; g_display.pixel_in_dps_y = (float)g_display.pixel_yres / (float)g_display.dp_yres; - [[sharedViewController view] setContentScaleFactor:scale]; + [[sharedViewController getView] setContentScaleFactor:scale]; // PSP native resize PSP_CoreParameter().pixelWidth = g_display.pixel_xres; diff --git a/ios/ViewController.h b/ios/ViewController.h index 35b61b8855..0e91161453 100644 --- a/ios/ViewController.h +++ b/ios/ViewController.h @@ -16,6 +16,7 @@ - (void)shareText:(NSString *)text; - (void)shutdown; - (void)bindDefaultFBO; +- (UIView *)getView; @end @interface PPSSPPViewControllerGL : GLKViewController < diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 0a85ae7e23..10dd5bf70d 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -599,6 +599,10 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { return UIRectEdgeAll; } +- (UIView *)getView { + return [self view]; +} + - (void)setupController:(GCController *)controller { self.gameController = controller;