diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index b1cefec604..948a6d4a7b 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1502,7 +1502,7 @@ void NativeShutdown() { ShutdownWebServer(); -#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) +#if PPSSPP_PLATFORM(ANDROID) System_ExitApp(); #endif diff --git a/ios/AppDelegate.h b/ios/AppDelegate.h index 31cca2a660..06ab74d32a 100644 --- a/ios/AppDelegate.h +++ b/ios/AppDelegate.h @@ -11,7 +11,7 @@ @property (strong, nonatomic) id viewController; -- (void)restart; +- (void)restart:(const char *)args; - (BOOL)launchPPSSPP:(int)argc argv:(char**)argv; @end diff --git a/ios/AppDelegate.mm b/ios/AppDelegate.mm index 89d8a6754c..d1b78c7344 100644 --- a/ios/AppDelegate.mm +++ b/ios/AppDelegate.mm @@ -86,6 +86,9 @@ argv[argc++] = (char*)string; } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil]; + return [self launchPPSSPP:argc argv:argv]; } @@ -113,9 +116,6 @@ [self.window makeKeyAndVisible]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil]; - return YES; } @@ -123,9 +123,19 @@ [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void)restart { +- (void)restart:(const char*)restartArgs { + INFO_LOG(G3D, "Restart requested: %s", restartArgs); + [self.viewController willResignActive]; + self.viewController = nil; + // App was requested to restart, probably. - INFO_LOG(G3D, "Restart requested"); + INFO_LOG(G3D, "viewController nilled"); + + NativeShutdown(); + + // TODO: Ignoring the command line for now. + // Hoping that overwriting the viewController works as expected... + [self launchPPSSPP:0 argv:nullptr]; } -(void) applicationWillResignActive:(UIApplication *)application { diff --git a/ios/main.mm b/ios/main.mm index ff55fed448..8af1a372b0 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -393,7 +393,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string switch (type) { case SystemRequestType::RESTART_APP: dispatch_async(dispatch_get_main_queue(), ^{ - [(AppDelegate *)[[UIApplication sharedApplication] delegate] restart]; + [(AppDelegate *)[[UIApplication sharedApplication] delegate] restart:param1.c_str()]; }); break;