diff --git a/Core/Config.h b/Core/Config.h index bd14637d33..a25331cdda 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -72,8 +72,12 @@ public: bool bTopMost; std::string sFont; bool bIgnoreWindowsKey; +#endif + +#if !defined(MOBILE_DEVICE) bool bEscapeExitsEmulator; #endif + // Core bool bIgnoreBadMemAccess; bool bFastMemory; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 4729203dee..a4d1adfcc9 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -320,6 +320,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.bEscapeExitsEmulator = true; +#endif break; } } else { @@ -684,6 +688,11 @@ 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.bEscapeExitsEmulator && key.keyCode == NKCODE_ESCAPE) { + System_SendMessage("finish", ""); + } +#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