diff --git a/Common/System/System.h b/Common/System/System.h index dd2c184918..a1e3c936a2 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -134,12 +134,24 @@ enum SystemProperty { SYSPROP_KEYBOARD_LAYOUT, }; +enum class SystemNotification { + UI, + MEM_VIEW, + DISASSEMBLY, + DEBUG_MODE, + BOOT_DONE, // this is sent from EMU thread! Make sure that Host handles it properly! + SYMBOL_MAP_UPDATED, + SWITCH_UMD_UPDATED, +}; + std::string System_GetProperty(SystemProperty prop); std::vector System_GetPropertyStringVec(SystemProperty prop); int System_GetPropertyInt(SystemProperty prop); float System_GetPropertyFloat(SystemProperty prop); bool System_GetPropertyBool(SystemProperty prop); +void System_Notify(SystemNotification notification); + std::vector System_GetCameraDeviceList(); bool System_AudioRecordingIsAvailable(); bool System_AudioRecordingState(); diff --git a/Core/Debugger/WebSocket/GameSubscriber.cpp b/Core/Debugger/WebSocket/GameSubscriber.cpp index c48f396bb7..efa8ff2da6 100644 --- a/Core/Debugger/WebSocket/GameSubscriber.cpp +++ b/Core/Debugger/WebSocket/GameSubscriber.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "Common/System/System.h" #include "Core/Config.h" #include "Core/Debugger/WebSocket/GameSubscriber.h" #include "Core/Debugger/WebSocket/WebSocketUtils.h" @@ -54,7 +55,7 @@ void WebSocketGameReset(DebuggerRequest &req) { ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str()); return req.Fail("Could not reset"); } - host->BootDone(); + System_Notify(SystemNotification::BOOT_DONE); host->UpdateDisassembly(); req.Respond(); diff --git a/Core/Host.h b/Core/Host.h index 044ad16823..ff5179b3e2 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -26,12 +26,13 @@ class GraphicsContext; class Host { public: virtual ~Host() {} - virtual void UpdateUI() {} + virtual void UpdateUI() {} virtual void UpdateMemView() {} virtual void UpdateDisassembly() {} - + virtual void NotifySymbolMapUpdated() {} virtual void SetDebugMode(bool mode) { } + virtual void NotifySwitchUMDUpdated() {} virtual bool InitGraphics(std::string *error_string, GraphicsContext **ctx) = 0; virtual void ShutdownGraphics() = 0; @@ -42,12 +43,8 @@ public: virtual void PollControllers() {} virtual void ToggleDebugConsoleVisibility() {} - //this is sent from EMU thread! Make sure that Host handles it properly! - virtual void BootDone() {} - virtual bool AttemptLoadSymbolMap(); virtual void SaveSymbolMap() {} - virtual void NotifySymbolMapUpdated() {} virtual void SetWindowTitle(const char *message) {} virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;} @@ -55,8 +52,6 @@ public: virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {} virtual void SendUIMessage(const std::string &message, const std::string &value) {} - virtual void NotifySwitchUMDUpdated() {} - // Used for headless. virtual bool ShouldSkipUI() { return false; } virtual void SendDebugOutput(const std::string &output) {} diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 3f51aebbc6..c35d1c9230 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -23,6 +23,7 @@ #include "Common/Data/Text/I18n.h" #include "Common/Thread/ThreadUtil.h" #include "Common/Data/Text/Parsers.h" +#include "Common/System/System.h" #include "Common/File/FileUtil.h" #include "Common/Serialize/Serializer.h" @@ -1078,7 +1079,7 @@ namespace SaveState Core_Stop(); return; } - host->BootDone(); + System_Notify(SystemNotification::BOOT_DONE); host->UpdateDisassembly(); needsRestart = false; } diff --git a/Qt/QtHost.h b/Qt/QtHost.h index a0327474c1..f559265494 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -40,8 +40,7 @@ public: mainWindow->updateMenus(); } - void SetDebugMode(bool mode) override { - } + void SetDebugMode(bool mode) override {} bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; } void ShutdownGraphics() override {} @@ -50,12 +49,6 @@ public: void UpdateSound() override {} void ShutdownSound() override; - // this is sent from EMU thread! Make sure that Host handles it properly! - void BootDone() override { - g_symbolMap->SortSymbols(); - mainWindow->Notify(MainWindowMsg::BOOT_DONE); - } - bool AttemptLoadSymbolMap() override { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); return g_symbolMap->LoadSymbolMap(fn); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 354ea7399b..1305137ccc 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -254,6 +254,17 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +void System_Notify(SystemNotification notification) { + switch (notification) { + case SystemNotification::BOOT_DONE: + g_symbolMap->SortSymbols(); + mainWindow->Notify(MainWindowMsg::BOOT_DONE); + break; + default: + break; + } +} + void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { qApp->exit(0); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index c11a50476b..f59a2dd22a 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -436,6 +436,13 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +void System_Notify(SystemNotification notification) { + switch (notification) { + default: + break; + } +} + // returns -1 on failure static int parseInt(const char *str) { int val; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index a86a460acb..09ee8b2629 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -354,7 +354,8 @@ void EmuScreen::bootGame(const Path &filename) { void EmuScreen::bootComplete() { UpdateUIState(UISTATE_INGAME); - host->BootDone(); + System_Notify(SystemNotification::BOOT_DONE); + host->UpdateDisassembly(); NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str()); @@ -1300,7 +1301,7 @@ static void DrawFPS(UIContext *ctx, const Bounds &bounds) { snprintf(fpsbuf, sizeof(fpsbuf), "%s Speed: %0.1f%%", fpsbuf, vps / (59.94f / 100.0f)); } } - + #ifdef CAN_DISPLAY_CURRENT_BATTERY_CAPACITY if (g_Config.iShowStatusFlags & (int)ShowStatusFlags::BATTERY_PERCENT) { snprintf(fpsbuf, sizeof(fpsbuf), "%s Battery: %d%%", fpsbuf, getCurrentBatteryCapacity()); diff --git a/UI/HostTypes.h b/UI/HostTypes.h index 528ae90f73..2cdc0a9d84 100644 --- a/UI/HostTypes.h +++ b/UI/HostTypes.h @@ -38,9 +38,6 @@ public: void UpdateSound() override {} void ShutdownSound() override; - // this is sent from EMU thread! Make sure that Host handles it properly! - void BootDone() override {} - bool AttemptLoadSymbolMap() override {return false;} void NotifySymbolMapUpdated() override {} void SetWindowTitle(const char *message) override {} diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 87e7fff4c6..a1630b9166 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -436,6 +436,20 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +void System_Notify(SystemNotification notification) { + switch (notification) { + case SystemNotification::BOOT_DONE: + g_symbolMap->SortSymbols(); + + SetDebugMode(false); + Core_EnableStepping(false); + break; + + default: + break; + } +} + void System_SendMessage(const char *command, const char *parameter) { using namespace concurrency; diff --git a/UWP/UWPHost.cpp b/UWP/UWPHost.cpp index b187f4fff5..f8ddcfc22d 100644 --- a/UWP/UWPHost.cpp +++ b/UWP/UWPHost.cpp @@ -85,8 +85,7 @@ void UWPHost::UpdateMemView() { void UWPHost::UpdateDisassembly() { } -void UWPHost::SetDebugMode(bool mode) { -} +void UWPHost::SetDebugMode(bool mode) {} void UWPHost::PollControllers() { for (const auto& device : this->input) @@ -114,13 +113,6 @@ void UWPHost::PollControllers() { */ } -void UWPHost::BootDone() { - g_symbolMap->SortSymbols(); - - SetDebugMode(false); - Core_EnableStepping(false); -} - static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { File::FileInfo info; // can't fail, definitely exists if it gets this far diff --git a/UWP/UWPHost.h b/UWP/UWPHost.h index 7913e5964e..4e604222bb 100644 --- a/UWP/UWPHost.h +++ b/UWP/UWPHost.h @@ -26,7 +26,6 @@ public: void UpdateSound() override; void ShutdownSound() override; - void BootDone() override; bool AttemptLoadSymbolMap() override; void SaveSymbolMap() override; void NotifySymbolMapUpdated() override; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 945526d841..d39c172abe 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -264,14 +264,6 @@ void WindowsHost::PollControllers() { HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = g_mouseDeltaY; } -void WindowsHost::BootDone() { - if (g_symbolMap) - g_symbolMap->SortSymbols(); - PostMessage(mainWindow_, WM_USER + 1, 0, 0); - - SetDebugMode(!g_Config.bAutoRun); -} - static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { File::FileInfo info{}; // can't fail, definitely exists if it gets this far diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index a62dc4d1cf..94436f5479 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -48,7 +48,6 @@ public: void UpdateSound() override; void ShutdownSound() override; - void BootDone() override; bool AttemptLoadSymbolMap() override; void SaveSymbolMap() override; void NotifySymbolMapUpdated() override; diff --git a/Windows/main.cpp b/Windows/main.cpp index b776533ddc..af0f555e8d 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -74,6 +74,7 @@ #include "Windows/Debugger/CtrlDisAsmView.h" #include "Windows/Debugger/CtrlMemView.h" #include "Windows/Debugger/CtrlRegisterList.h" +#include "Windows/Debugger/DebuggerShared.h" #include "Windows/InputBox.h" #include "Windows/WindowsHost.h" @@ -369,6 +370,24 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, LPARAM lParam = 0) { + return PostMessage(dialog->GetDlgHandle(), message, wParam, lParam); +} + +void System_Notify(SystemNotification notification) { + switch (notification) { + case SystemNotification::BOOT_DONE: + if (g_symbolMap) + g_symbolMap->SortSymbols(); + PostMessage(MainWindow::GetHWND(), WM_USER + 1, 0, 0); + + bool mode = !g_Config.bAutoRun; + if (disasmWindow) + PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode); + break; + } +} + void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { if (!NativeIsRestarting()) { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index c67300d53b..65a483e519 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -540,6 +540,11 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +void System_Notify(SystemNotification notification) { + switch (notification) { + } +} + std::string Android_GetInputDeviceDebugString() { if (!nativeActivity) { return "(N/A)"; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 8258c58593..55316a348a 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -112,7 +112,7 @@ bool System_GetPropertyBool(SystemProperty prop) { return false; } } - +void System_Notify(SystemNotification notification) {} void System_SendMessage(const char *command, const char *parameter) {} void System_InputBoxGetString(const std::string &title, const std::string &defaultValue, std::function cb) { cb(false, ""); } void System_AskForPermission(SystemPermission permission) {} @@ -201,7 +201,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const return false; } - host->BootDone(); + System_Notify(SystemNotification::BOOT_DONE); Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops); diff --git a/headless/StubHost.h b/headless/StubHost.h index 5dc0f5a258..585baf4646 100644 --- a/headless/StubHost.h +++ b/headless/StubHost.h @@ -41,9 +41,6 @@ public: void UpdateSound() override {} void ShutdownSound() override {} - // this is sent from EMU thread! Make sure that Host handles it properly - void BootDone() override {} - bool AttemptLoadSymbolMap() override { g_symbolMap->Clear(); return false; } void NotifySymbolMapUpdated() override {} diff --git a/ios/main.mm b/ios/main.mm index 8ab82e7431..155bf79995 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -170,6 +170,11 @@ bool System_GetPropertyBool(SystemProperty prop) { } } +void System_Notify(SystemNotification notification) { + switch (notification) { + } +} + void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { exit(0); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 11563409fe..726902f31d 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -1872,6 +1872,13 @@ bool System_GetPropertyBool(SystemProperty prop) std::string System_GetProperty(SystemProperty prop) { return ""; } std::vector System_GetPropertyStringVec(SystemProperty prop) { return std::vector(); } +void System_Notify(SystemNotification notification) { + switch (notification) { + default: + break; + } +} + void System_SendMessage(const char *command, const char *parameter) {} void NativeUpdate() {} void NativeRender(GraphicsContext *graphicsContext) {} diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 457d51727b..89ce7551c8 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -87,6 +87,7 @@ bool System_GetPropertyBool(SystemProperty prop) { return false; } } +void System_Notify(SystemNotification notification) {} #if PPSSPP_PLATFORM(ANDROID) JNIEnv *getEnv() {