diff --git a/Core/Config.h b/Core/Config.h index bd14637d33..00432e2ee1 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -72,8 +72,12 @@ public: bool bTopMost; std::string sFont; bool bIgnoreWindowsKey; - bool bEscapeExitsEmulator; #endif + +#if !defined(MOBILE_DEVICE) + bool bPauseExitsEmulator; +#endif + // Core bool bIgnoreBadMemAccess; bool bFastMemory; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 4729203dee..48433fc698 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -28,6 +28,11 @@ // in NativeShutdown. #include +// Linux doesn't like using std::find with std::vector without this :/ +#if !defined(MOBILE_DEVICE) +#include +#endif + #ifdef _WIN32 #include #include "ext/jpge/jpge.h" @@ -79,6 +84,10 @@ #include "UI/MiscScreens.h" #include "UI/TiltEventProcessor.h" +#if !defined(MOBILE_DEVICE) +#include "Common/KeyMap.h" +#endif + // The new UI framework, for initialization static UI::Theme ui_theme; @@ -320,6 +329,10 @@ void NativeInit(int argc, const char *argv[], fileToLog = argv[i] + strlen("--log="); if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state=")) stateToLoad = argv[i] + strlen("--state="); +#if !defined(MOBILE_DEVICE) + if (!strncmp(argv[i], "--escape-exit", strlen("--escape-exit"))) + g_Config.bPauseExitsEmulator = true; +#endif break; } } else { @@ -684,6 +697,18 @@ void NativeTouch(const TouchInput &touch) { void NativeKey(const KeyInput &key) { // ILOG("Key code: %i flags: %i", key.keyCode, key.flags); +#if !defined(MOBILE_DEVICE) + if (g_Config.bPauseExitsEmulator) { + static std::vector pspKeys; + pspKeys.clear(); + if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &pspKeys)) { + if (std::find(pspKeys.begin(), pspKeys.end(), VIRTKEY_PAUSE) != pspKeys.end()) { + System_SendMessage("finish", ""); + return; + } + } + } +#endif g_buttonTracker.Process(key); if (screenManager) screenManager->key(key); diff --git a/Windows/RawInput.cpp b/Windows/RawInput.cpp index 343a1479d1..1646d2294a 100644 --- a/Windows/RawInput.cpp +++ b/Windows/RawInput.cpp @@ -118,11 +118,6 @@ namespace WindowsRawInput { return; } - if (g_Config.bEscapeExitsEmulator && raw->data.keyboard.VKey == VK_ESCAPE) { - PostMessage(MainWindow::GetHWND(), WM_CLOSE, 0, 0); - return; - } - KeyInput key; key.deviceId = DEVICE_ID_KEYBOARD; diff --git a/Windows/main.cpp b/Windows/main.cpp index 517d77d711..b03a2eecf1 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -168,7 +168,11 @@ std::string System_GetProperty(SystemProperty prop) { } } -void System_SendMessage(const char *command, const char *parameter) {} +void System_SendMessage(const char *command, const char *parameter) { + if (!strcmp(command, "finish")) { + PostMessage(MainWindow::GetHWND(), WM_CLOSE, 0, 0); + } +} void EnableCrashingOnCrashes() { @@ -340,9 +344,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin if (!strncmp(__argv[i], "--windowed", strlen("--windowed"))) g_Config.bFullScreen = false; - - if (!strncmp(__argv[i], "--escapeexitsemu", strlen("--escapeexitsemu"))) - g_Config.bEscapeExitsEmulator = true; } } #ifdef _DEBUG