diff --git a/Common/System/Request.h b/Common/System/Request.h index 745f4eb555..5c925184a4 100644 --- a/Common/System/Request.h +++ b/Common/System/Request.h @@ -121,3 +121,7 @@ inline void System_ShareText(const std::string &text) { inline void System_NotifyUIState(const std::string &state) { g_requestManager.MakeSystemRequest(SystemRequestType::NOTIFY_UI_STATE, nullptr, state, "", 0); } + +inline void System_SetWindowTitle(const std::string ¶m) { + g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, nullptr, param, "", 0); +} diff --git a/Common/System/System.h b/Common/System/System.h index 71bcb1cb71..6c4922a6c7 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -64,16 +64,17 @@ enum class SystemRequestType { EXIT_APP, RESTART_APP, // For graphics backend changes COPY_TO_CLIPBOARD, + SHARE_TEXT, + SET_WINDOW_TITLE, TOGGLE_FULLSCREEN_STATE, GRAPHICS_BACKEND_FAILED_ALERT, + NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. + // High-level hardware control CAMERA_COMMAND, GPS_COMMAND, MICROPHONE_COMMAND, - - SHARE_TEXT, - NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. }; // Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h). @@ -162,6 +163,8 @@ enum SystemProperty { SYSPROP_CAN_JIT, + SYSPROP_HAS_DEBUGGER, + SYSPROP_KEYBOARD_LAYOUT, SYSPROP_SKIP_UI, diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index d866f008bd..6cac800719 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -206,12 +206,12 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) { return started; } -void SymbolMap::SaveSymbolMap(const Path &filename) const { +bool SymbolMap::SaveSymbolMap(const Path &filename) const { std::lock_guard guard(lock_); // Don't bother writing a blank file. if (!File::Exists(filename) && functions.empty() && data.empty()) { - return; + return true; } // TODO(scoped): Use gzdopen @@ -222,7 +222,7 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const { #endif if (f == Z_NULL) - return; + return false; gzprintf(f, ".text\n"); @@ -241,6 +241,7 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const { gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module)); } gzclose(f); + return true; } bool SymbolMap::LoadNocashSym(const Path &filename) { diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index c0ee42ee75..defe069838 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -71,7 +71,7 @@ public: void SortSymbols(); bool LoadSymbolMap(const Path &filename); - void SaveSymbolMap(const Path &filename) const; + bool SaveSymbolMap(const Path &filename) const; bool LoadNocashSym(const Path &filename); void SaveNocashSym(const Path &filename) const; diff --git a/Core/Host.cpp b/Core/Host.cpp index 2a35248f03..81fb73f9bf 100644 --- a/Core/Host.cpp +++ b/Core/Host.cpp @@ -15,14 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include - #include "Core/Host.h" -#include "Core/Debugger/SymbolMap.h" Host *host = nullptr; - -bool Host::AttemptLoadSymbolMap() { - g_symbolMap->Clear(); - return false; -} diff --git a/Core/Host.h b/Core/Host.h index 0fc4746710..d62d6e27dd 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -31,10 +31,6 @@ public: virtual void PollControllers() {} virtual void ToggleDebugConsoleVisibility() {} - virtual bool AttemptLoadSymbolMap(); - virtual void SaveSymbolMap() {} - virtual void SetWindowTitle(const char *message) {} - virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;} virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {} diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index ab060eb27b..ccf9a349dc 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -19,6 +19,7 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/Thread/ThreadUtil.h" +#include "Common/System/Request.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" @@ -248,7 +249,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) { if (g_paramSFO.ReadSFO(paramsfo)) { std::string title = StringFromFormat("%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title.c_str()); - host->SetWindowTitle(title.c_str()); + System_SetWindowTitle(title); } } @@ -430,7 +431,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { std::string title = StringFromFormat("%s : %s", discID.c_str(), homebrewTitle.c_str()); INFO_LOG(LOADER, "%s", title.c_str()); - host->SetWindowTitle(title.c_str()); + System_SetWindowTitle(title); // Migrate old save states from old versions of fake game IDs. const Path savestateDir = GetSysDirectory(DIRECTORY_SAVESTATE); diff --git a/Core/System.cpp b/Core/System.cpp index 5a1c26b338..66f1546611 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -35,13 +35,14 @@ #include "Common/System/System.h" #include "Common/System/Request.h" #include "Common/File/Path.h" +#include "Common/File/FileUtil.h" +#include "Common/File/DirListing.h" #include "Common/Math/math_util.h" #include "Common/Thread/ThreadUtil.h" #include "Common/Data/Encoding/Utf8.h" - -#include "Common/File/FileUtil.h" #include "Common/TimeUtil.h" #include "Common/GraphicsContext.h" + #include "Core/MemFault.h" #include "Core/HDRemaster.h" #include "Core/MIPS/MIPS.h" @@ -173,6 +174,40 @@ bool CPU_HasPendingAction() { void CPU_Shutdown(); +static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { + File::FileInfo info{}; + // can't fail, definitely exists if it gets this far + File::GetFileInfo(currentFilename, &info); + if (info.isDirectory) { + return currentFilename / (std::string(".ppsspp-symbols") + ext); + } + return currentFilename.WithReplacedExtension(ext); +}; + +static bool LoadSymbolsIfSupported() { + if (System_GetPropertyBool(SYSPROP_HAS_DEBUGGER)) { + if (!g_symbolMap) + return false; + + bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); + // Load the old-style map file. + if (!result1) + result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); + bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); + return result1 || result2; + } else { + g_symbolMap->Clear(); + return true; + } +} + +static bool SaveSymbolMapIfSupported() { + if (g_symbolMap) { + return g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); + } + return false; +} + bool DiscIDFromGEDumpPath(const Path &path, FileLoader *fileLoader, std::string *id) { using namespace GPURecord; @@ -283,7 +318,7 @@ bool CPU_Init(std::string *errorString) { } mipsr4k.Reset(); - host->AttemptLoadSymbolMap(); + LoadSymbolsIfSupported(); CoreTiming::Init(); @@ -324,7 +359,7 @@ void CPU_Shutdown() { PSPLoaders_Shutdown(); if (g_Config.bAutoSaveSymbolMap) { - host->SaveSymbolMap(); + SaveSymbolMapIfSupported(); } Replacement_Shutdown(); @@ -522,7 +557,7 @@ void PSP_Shutdown() { CPU_Shutdown(); GPU_Shutdown(); g_paramSFO.Clear(); - host->SetWindowTitle(0); + System_SetWindowTitle(""); currentMIPS = 0; pspIsInited = false; pspIsIniting = false; diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index 9528d4a5ac..7c323cfc9d 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -16,7 +16,3 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Qt/QtHost.h" - -Path QtHost::SymbolMapFilename(Path currentFilename) { - return currentFilename.WithReplacedExtension(".map"); -} diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 71278529e5..a78ae11a2d 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -23,7 +23,6 @@ #include "Qt/mainwindow.h" #include "Core/Debugger/SymbolMap.h" - class QtHost : public Host { public: QtHost(MainWindow *mainWindow_) @@ -33,24 +32,10 @@ public: void UpdateSound() override {} - bool AttemptLoadSymbolMap() override { - auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); - return g_symbolMap->LoadSymbolMap(fn); - } - void PrepareShutdown() { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); g_symbolMap->SaveSymbolMap(fn); } - void SetWindowTitle(const char *message) override { - std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION; - if (message) - title += std::string(" - ") + message; -#ifdef _DEBUG - title += " (debug)"; -#endif - mainWindow->SetWindowTitleAsync(title); - } void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override { osm.Show(message, duration, color, -1, true, id); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 36a15643dc..86b4caf5d2 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -355,6 +355,17 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::COPY_TO_CLIPBOARD: QApplication::clipboard()->setText(param1.c_str()); return true; + case SystemRequestType::SET_WINDOW_TITLE: + { + std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION; + if (!param1.empty()) + title += std::string(" - ") + param1; +#ifdef _DEBUG + title += " (debug)"; +#endif + g_mainWindow->SetWindowTitleAsync(title); + return true; + } case SystemRequestType::INPUT_TEXT_MODAL: { g_requestId = requestId; diff --git a/UI/HostTypes.h b/UI/HostTypes.h index ede4580f52..05c8e40158 100644 --- a/UI/HostTypes.h +++ b/UI/HostTypes.h @@ -18,6 +18,7 @@ #pragma once #include "Core/Host.h" +#include "Common/System/NativeApp.h" #include "UI/OnScreenDisplay.h" class NativeHost : public Host { @@ -26,9 +27,6 @@ public: void UpdateSound() override {} - bool AttemptLoadSymbolMap() override {return false;} - void SetWindowTitle(const char *message) override {} - void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override { osm.Show(message, duration, color, -1, true, id); } diff --git a/UWP/UWPHost.cpp b/UWP/UWPHost.cpp index d620046e82..d03c78eb65 100644 --- a/UWP/UWPHost.cpp +++ b/UWP/UWPHost.cpp @@ -48,15 +48,6 @@ UWPHost::~UWPHost() { } -void UWPHost::SetConsolePosition() { -} - -void UWPHost::UpdateConsolePosition() { -} - -void UWPHost::SetWindowTitle(const char *message) { -} - void UWPHost::UpdateSound() { } @@ -86,29 +77,6 @@ void UWPHost::PollControllers() { */ } -static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { - File::FileInfo info; - // can't fail, definitely exists if it gets this far - File::GetFileInfo(currentFilename, &info); - if (info.isDirectory) { - return currentFilename / (std::string(".ppsspp-symbols") + ext); - } - return currentFilename.WithReplacedExtension(ext); -} - -bool UWPHost::AttemptLoadSymbolMap() { - bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); - // Load the old-style map file. - if (!result1) - result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); - bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); - return result1 || result2; -} - -void UWPHost::SaveSymbolMap() { - g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); -} - void UWPHost::ToggleDebugConsoleVisibility() { // N/A } diff --git a/UWP/UWPHost.h b/UWP/UWPHost.h index 8e13f6af2a..9341ce2bdd 100644 --- a/UWP/UWPHost.h +++ b/UWP/UWPHost.h @@ -16,19 +16,10 @@ public: void UpdateSound() override; - bool AttemptLoadSymbolMap() override; - void SaveSymbolMap() override; - void SetWindowTitle(const char *message) override; - void ToggleDebugConsoleVisibility() override; void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override; - GraphicsContext *GetGraphicsContext() { return nullptr; } - private: - void SetConsolePosition(); - void UpdateConsolePosition(); - std::list> input; }; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 4748557d18..459bb5ce34 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -4,6 +4,7 @@ #include "Common/System/NativeApp.h" #include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/Data/Text/I18n.h" #include "Common/Input/InputState.h" #include "Common/Data/Encoding/Utf8.h" @@ -151,16 +152,11 @@ bool CreateGraphicsBackend(std::string *error_message, GraphicsContext **ctx) { } void MainThreadFunc() { - if (useEmuThread) { - // We'll start up a separate thread we'll call Emu - SetCurrentThreadName("Render"); - } else { - // This is both Emu and Render. - SetCurrentThreadName("Emu"); - } + // We'll start up a separate thread we'll call Emu + SetCurrentThreadName(useEmuThread ? "Render" : "Emu"); - host = new WindowsHost(MainWindow::GetHInstance(), MainWindow::GetHWND(), MainWindow::GetDisplayHWND()); - host->SetWindowTitle(nullptr); + host = new WindowsHost(); + System_SetWindowTitle(""); // We convert command line arguments to UTF-8 immediately. std::vector wideArgs = GetWideCmdLine(); diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 5217a01463..f737c585e0 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -44,12 +44,14 @@ #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/CoreParameter.h" +#include "Core/HLE/Plugins.h" #include "Core/System.h" #include "Core/Debugger/SymbolMap.h" #include "Core/Instance.h" +#include "UI/OnScreenDisplay.h" + #include "Windows/EmuThread.h" -#include "Windows/WindowsAudio.h" #include "Windows/WindowsHost.h" #include "Windows/MainWindow.h" @@ -63,8 +65,6 @@ #include "Windows/XinputDevice.h" #include "Windows/main.h" -#include "UI/OnScreenDisplay.h" -#include float g_mouseDeltaX = 0; float g_mouseDeltaY = 0; @@ -73,11 +73,7 @@ static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, L return PostMessage(dialog->GetDlgHandle(), message, wParam, lParam); } -WindowsHost::WindowsHost(HINSTANCE hInstance, HWND mainWindow, HWND displayWindow) - : hInstance_(hInstance), - displayWindow_(displayWindow), - mainWindow_(mainWindow) -{ +WindowsHost::WindowsHost() { g_mouseDeltaX = 0; g_mouseDeltaY = 0; @@ -109,29 +105,6 @@ void WindowsHost::UpdateConsolePosition() { } } -void WindowsHost::SetWindowTitle(const char *message) { -#ifdef GOLD - const char *name = "PPSSPP Gold "; -#else - const char *name = "PPSSPP "; -#endif - std::wstring winTitle = ConvertUTF8ToWString(std::string(name) + PPSSPP_GIT_VERSION); - if (message != nullptr) { - winTitle.append(ConvertUTF8ToWString(" - ")); - winTitle.append(ConvertUTF8ToWString(message)); - } -#ifdef _DEBUG - winTitle.append(L" (debug)"); -#endif - lastTitle_ = winTitle; - - MainWindow::SetWindowTitle(winTitle.c_str()); - PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); -} - -// UGLY! -extern WindowsAudioBackend *winAudioBackend; - void WindowsHost::PollControllers() { static int checkCounter = 0; static const int CHECK_FREQUENCY = 71; @@ -182,32 +155,6 @@ void WindowsHost::PollControllers() { HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = g_mouseDeltaY; } -static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { - File::FileInfo info{}; - // can't fail, definitely exists if it gets this far - File::GetFileInfo(currentFilename, &info); - if (info.isDirectory) { - return currentFilename / (std::string(".ppsspp-symbols") + ext); - } - return currentFilename.WithReplacedExtension(ext); -} - -bool WindowsHost::AttemptLoadSymbolMap() { - if (!g_symbolMap) - return false; - bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); - // Load the old-style map file. - if (!result1) - result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); - bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); - return result1 || result2; -} - -void WindowsHost::SaveSymbolMap() { - if (g_symbolMap) - g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); -} - // http://msdn.microsoft.com/en-us/library/aa969393.aspx HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { HRESULT hres; diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index b13032b799..353996987a 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -26,7 +26,7 @@ extern float g_mouseDeltaY; class WindowsHost : public Host { public: - WindowsHost(HINSTANCE hInstance, HWND mainWindow, HWND displayWindow); + WindowsHost(); ~WindowsHost() { UpdateConsolePosition(); @@ -34,10 +34,6 @@ public: void PollControllers() override; - bool AttemptLoadSymbolMap() override; - void SaveSymbolMap() override; - void SetWindowTitle(const char *message) override; - void ToggleDebugConsoleVisibility() override; bool CreateDesktopShortcut(std::string argumentPath, std::string title) override; @@ -49,11 +45,7 @@ private: void SetConsolePosition(); void UpdateConsolePosition(); - HINSTANCE hInstance_; - HWND displayWindow_; - HWND mainWindow_; size_t numDinputDevices_ = 0; - std::wstring lastTitle_; std::list> input; }; diff --git a/Windows/main.cpp b/Windows/main.cpp index 929abafdc8..b78970e879 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -351,6 +351,7 @@ float System_GetPropertyFloat(SystemProperty prop) { bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { + case SYSPROP_HAS_DEBUGGER: case SYSPROP_HAS_FILE_BROWSER: case SYSPROP_HAS_FOLDER_BROWSER: case SYSPROP_HAS_OPEN_DIRECTORY: @@ -467,6 +468,24 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string W32Util::CopyTextToClipboard(MainWindow::GetDisplayHWND(), data); return true; } + case SystemRequestType::SET_WINDOW_TITLE: + { +#ifdef GOLD + const char *name = "PPSSPP Gold "; +#else + const char *name = "PPSSPP "; +#endif + std::wstring winTitle = ConvertUTF8ToWString(std::string(name) + PPSSPP_GIT_VERSION); + if (!param1.empty()) { + winTitle.append(ConvertUTF8ToWString(" - " + param1)); + } +#ifdef _DEBUG + winTitle.append(L" (debug)"); +#endif + MainWindow::SetWindowTitle(winTitle.c_str()); + PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); + return true; + } case SystemRequestType::INPUT_TEXT_MODAL: if (g_dialogRunning) { g_dialogThread.join(); diff --git a/headless/StubHost.h b/headless/StubHost.h index 280997f4d7..2da7c55797 100644 --- a/headless/StubHost.h +++ b/headless/StubHost.h @@ -28,10 +28,6 @@ public: virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {return false;} virtual void ShutdownGraphics() {} - void UpdateSound() override {} - - bool AttemptLoadSymbolMap() override { g_symbolMap->Clear(); return false; } - void SendDebugOutput(const std::string &output) override { if (output.find('\n') != output.npos) { DoFlushDebugOutput(); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 453ac93eba..88b38fb7e5 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -396,7 +396,6 @@ class LibretroHost : public Host int samples = __AudioMix(audio, hostAttemptBlockSize, SAMPLERATE); AudioBufferWrite(audio, samples); } - bool AttemptLoadSymbolMap() override { return false; } }; class PrintfLogger : public LogListener