From 6bedad2aa55af6a5bb8104e06de2a72b97d281ef Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 26 Apr 2014 01:00:45 -0400 Subject: [PATCH 1/4] Enable --escape-exit for all relevant platforms. It makes PPSSPP more front-end friendly by letting escape quit the emu. --- Core/Config.h | 4 ++++ UI/NativeApp.cpp | 9 +++++++++ Windows/RawInput.cpp | 5 ----- Windows/main.cpp | 9 +++++---- 4 files changed, 18 insertions(+), 9 deletions(-) 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 From a7a2bb3b28212870d025b3d0615b42fd43c8f6a1 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 26 Apr 2014 01:14:08 -0400 Subject: [PATCH 2/4] Fix Linux build. --- UI/NativeApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index a4d1adfcc9..98a6490164 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -321,7 +321,7 @@ void NativeInit(int argc, const char *argv[], 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"))) + if (!strncmp(argv[i], "--escape-exit", strlen("--escape-exit"))) g_Config.bEscapeExitsEmulator = true; #endif break; From 731a27dd58bcd56bf4b01e42ce9cd4a032b931e6 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 26 Apr 2014 01:54:32 -0400 Subject: [PATCH 3/4] Instead of using escape only, allow anything mapped to "Pause" to exit as well. --- Core/Config.h | 2 +- UI/NativeApp.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Core/Config.h b/Core/Config.h index a25331cdda..00432e2ee1 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -75,7 +75,7 @@ public: #endif #if !defined(MOBILE_DEVICE) - bool bEscapeExitsEmulator; + bool bPauseExitsEmulator; #endif // Core diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 98a6490164..ee2ccf3d6a 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -79,6 +79,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; @@ -322,7 +326,7 @@ void NativeInit(int argc, const char *argv[], stateToLoad = argv[i] + strlen("--state="); #if !defined(MOBILE_DEVICE) if (!strncmp(argv[i], "--escape-exit", strlen("--escape-exit"))) - g_Config.bEscapeExitsEmulator = true; + g_Config.bPauseExitsEmulator = true; #endif break; } @@ -689,8 +693,15 @@ 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", ""); + 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); From d3f82ff179ad09722175be81f2c64c77dd8eb2b4 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 26 Apr 2014 02:32:43 -0400 Subject: [PATCH 4/4] Fix Linux build, again. --- UI/NativeApp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index ee2ccf3d6a..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"