mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Implement the RESTART_APP system request for Mac
This commit is contained in:
parent
2507fcb89b
commit
c81d996475
4 changed files with 26 additions and 8 deletions
|
@ -75,7 +75,8 @@ SDLJoystick *joystick = NULL;
|
||||||
GlobalUIState lastUIState = UISTATE_MENU;
|
GlobalUIState lastUIState = UISTATE_MENU;
|
||||||
GlobalUIState GetUIState();
|
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_DesktopWidth = 0;
|
||||||
static int g_DesktopHeight = 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) {
|
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case SystemRequestType::RESTART_APP:
|
||||||
|
g_RestartRequested = true;
|
||||||
|
return true;
|
||||||
case SystemRequestType::EXIT_APP:
|
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
|
// Do a clean exit
|
||||||
g_QuitRequested = true;
|
g_QuitRequested = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1277,14 +1280,15 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g_QuitRequested)
|
if (g_QuitRequested || g_RestartRequested)
|
||||||
break;
|
break;
|
||||||
const uint8_t *keys = SDL_GetKeyboardState(NULL);
|
const uint8_t *keys = SDL_GetKeyboardState(NULL);
|
||||||
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
if (emuThreadState == (int)EmuThreadState::DISABLED) {
|
||||||
UpdateRunLoop();
|
UpdateRunLoop();
|
||||||
}
|
}
|
||||||
if (g_QuitRequested)
|
if (g_QuitRequested || g_RestartRequested)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if !defined(MOBILE_DEVICE)
|
#if !defined(MOBILE_DEVICE)
|
||||||
if (lastUIState != GetUIState()) {
|
if (lastUIState != GetUIState()) {
|
||||||
lastUIState = GetUIState();
|
lastUIState = GetUIState();
|
||||||
|
@ -1334,10 +1338,8 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
graphicsContext->SwapBuffers();
|
graphicsContext->SwapBuffers();
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(g_mutexWindow);
|
std::lock_guard<std::mutex> guard(g_mutexWindow);
|
||||||
if (g_windowState.update) {
|
if (g_windowState.update) {
|
||||||
|
@ -1393,5 +1395,12 @@ int main(int argc, char *argv[]) {
|
||||||
#ifdef HAVE_LIBNX
|
#ifdef HAVE_LIBNX
|
||||||
socketExit();
|
socketExit();
|
||||||
#endif
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,8 +351,6 @@ static void CustomApplicationMain (int argc, char **argv)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef main
|
#ifdef main
|
||||||
# undef main
|
# undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,3 +33,4 @@ private:
|
||||||
#endif // PPSSPP_PLATFORM(IOS)
|
#endif // PPSSPP_PLATFORM(IOS)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void RestartMacApp();
|
||||||
|
|
|
@ -115,3 +115,13 @@ void DarwinFileSystemServices::setUserPreferredMemoryStickDirectory(Path path) {
|
||||||
g_Config.memStickDirectory = 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…
Add table
Reference in a new issue