From c0979104398992aeca388e1459ac9156a45be5d8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Dec 2017 14:11:39 -0800 Subject: [PATCH] UI: Reset touch controls after config load. This is potentially earlier than full init, better to move the controls as soon as possible. --- Core/Host.h | 1 + Core/PSPLoaders.cpp | 1 + UI/EmuScreen.cpp | 6 +++++- UI/HostTypes.h | 8 ++++++++ Windows/WindowsHost.cpp | 4 ++++ Windows/WindowsHost.h | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Core/Host.h b/Core/Host.h index 0268a7587f..c7eed94de1 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -63,6 +63,7 @@ public: 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) {} + virtual void SendUIMessage(const std::string &message, const std::string &value) {} // Used for headless. virtual bool ShouldSkipUI() { return false; } diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 64577f4e1b..9df9f4e5ef 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -248,6 +248,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) { //in case we didn't go through EmuScreen::boot g_Config.loadGameConfig(id); + host->SendUIMessage("config_loaded", ""); INFO_LOG(LOADER,"Loading %s...", bootpath.c_str()); return __KernelLoadExec(bootpath.c_str(), 0, error_string); } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 83944908ea..62c5478f55 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -144,7 +144,6 @@ void EmuScreen::bootGame(const std::string &filename) { return; } bootComplete(); - RecreateViews(); } return; } @@ -155,6 +154,8 @@ void EmuScreen::bootGame(const std::string &filename) { std::shared_ptr info = g_gameInfoCache->GetInfo(nullptr, filename, 0); if (info && !info->id.empty()) { g_Config.loadGameConfig(info->id); + // Reset views in case controls are in a different place. + RecreateViews(); } invalid_ = true; @@ -356,6 +357,9 @@ void EmuScreen::sendMessage(const char *message, const char *value) { bootPending_ = true; gamePath_ = value; } + } else if (!strcmp(message, "config_loaded")) { + // In case we need to position touch controls differently. + RecreateViews(); } else if (!strcmp(message, "control mapping") && screenManager()->topScreen() == this) { UpdateUIState(UISTATE_MENU); releaseButtons(); diff --git a/UI/HostTypes.h b/UI/HostTypes.h index 137684ec7f..102d583ce7 100644 --- a/UI/HostTypes.h +++ b/UI/HostTypes.h @@ -53,6 +53,10 @@ public: 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); } + + void SendUIMessage(const std::string &message, const std::string &value) override { + NativeMessageReceived(message.c_str(), value.c_str()); + } }; #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI) @@ -134,6 +138,10 @@ public: osm.Show(message, duration, color, -1, true, id); } + void SendUIMessage(const std::string &message, const std::string &value) override { + NativeMessageReceived(message.c_str(), value.c_str()); + } + bool GPUDebuggingActive() { auto dialogDisplayList = mainWindow->GetDialogDisplaylist(); diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 302545f190..921f195167 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -371,3 +371,7 @@ void WindowsHost::ToggleDebugConsoleVisibility() { void WindowsHost::NotifyUserMessage(const std::string &message, float duration, u32 color, const char *id) { osm.Show(message, duration, color, -1, true, id); } + +void WindowsHost::SendUIMessage(const std::string &message, const std::string &value) { + NativeMessageReceived(message.c_str(), value.c_str()); +} diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index cb5cba2f1f..d7d2198c35 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -65,6 +65,7 @@ public: bool CreateDesktopShortcut(std::string argumentPath, std::string title) override; void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override; + void SendUIMessage(const std::string &message, const std::string &value) override; std::shared_ptr keyboard;