mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Implement the RESTART_APP system request for Mac
This commit is contained in:
parent
2507fcb89b
commit
c81d996475
@ -75,7 +75,8 @@ SDLJoystick *joystick = NULL;
|
||||
GlobalUIState lastUIState = UISTATE_MENU;
|
||||
GlobalUIState GetUIState();
|
||||
|
||||
static int g_QuitRequested = 0;
|
||||
static bool g_QuitRequested = false;
|
||||
static bool g_RestartRequested = false;
|
||||
|
||||
static int g_DesktopWidth = 0;
|
||||
static int g_DesktopHeight = 0;
|
||||
@ -189,8 +190,10 @@ void System_Vibrate(int length_ms) {
|
||||
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||
switch (type) {
|
||||
case SystemRequestType::RESTART_APP:
|
||||
g_RestartRequested = true;
|
||||
return true;
|
||||
case SystemRequestType::EXIT_APP:
|
||||
case SystemRequestType::RESTART_APP: // Not sure how we best do this, but do a clean exit, better than being stuck in a bad state.
|
||||
// Do a clean exit
|
||||
g_QuitRequested = true;
|
||||
return true;
|
||||
@ -1277,14 +1280,15 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g_QuitRequested)
|
||||
if (g_QuitRequested || g_RestartRequested)
|
||||
break;
|
||||
const uint8_t *keys = SDL_GetKeyboardState(NULL);
|
||||
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
||||
UpdateRunLoop();
|
||||
}
|
||||
if (g_QuitRequested)
|
||||
if (g_QuitRequested || g_RestartRequested)
|
||||
break;
|
||||
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (lastUIState != GetUIState()) {
|
||||
lastUIState = GetUIState();
|
||||
@ -1334,10 +1338,8 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
graphicsContext->SwapBuffers();
|
||||
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(g_mutexWindow);
|
||||
if (g_windowState.update) {
|
||||
@ -1393,5 +1395,12 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef HAVE_LIBNX
|
||||
socketExit();
|
||||
#endif
|
||||
|
||||
// If a restart was requested (and supported on this platform), respawn the executable.
|
||||
if (g_RestartRequested) {
|
||||
#if PPSSPP_PLATFORM(MAC)
|
||||
RestartMacApp();
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -351,8 +351,6 @@ static void CustomApplicationMain (int argc, char **argv)
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#ifdef main
|
||||
# undef main
|
||||
#endif
|
||||
|
@ -33,3 +33,4 @@ private:
|
||||
#endif // PPSSPP_PLATFORM(IOS)
|
||||
};
|
||||
|
||||
void RestartMacApp();
|
||||
|
@ -115,3 +115,13 @@ void DarwinFileSystemServices::setUserPreferredMemoryStickDirectory(Path path) {
|
||||
g_Config.memStickDirectory = path;
|
||||
}
|
||||
|
||||
void RestartMacApp() {
|
||||
#if PPSSPP_PLATFORM(MAC)
|
||||
NSURL *bundleURL = NSBundle.mainBundle.bundleURL;
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.executableURL = [NSURL fileURLWithPath:@"/usr/bin/open"];
|
||||
task.arguments = @[@"-n", bundleURL.path];
|
||||
[task launch];
|
||||
exit(0);
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user