From 39a07a033cc05df929f418cab3fa5f1dfc83d000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 12 Nov 2024 12:20:14 +0100 Subject: [PATCH] Make imdebugger visibility a config option instead of emuscreen state --- Core/Config.cpp | 1 + Core/Config.h | 2 ++ UI/EmuScreen.cpp | 40 +++++++++++++++++++++------------------- UI/EmuScreen.h | 1 - 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 14a8c98c7b..3792308eec 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -206,6 +206,7 @@ static const ConfigSetting generalSettings[] = { ConfigSetting("IgnoreBadMemAccess", &g_Config.bIgnoreBadMemAccess, true, CfgFlag::DEFAULT), ConfigSetting("CurrentDirectory", &g_Config.currentDirectory, "", CfgFlag::DEFAULT), ConfigSetting("ShowDebuggerOnLoad", &g_Config.bShowDebuggerOnLoad, false, CfgFlag::DEFAULT), + ConfigSetting("ShowImDebugger", &g_Config.bShowImDebugger, false, CfgFlag::DONT_SAVE), ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true, CfgFlag::DEFAULT), ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion, CfgFlag::DEFAULT), ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, CfgFlag::PER_GAME), diff --git a/Core/Config.h b/Core/Config.h index 7055b09a78..801aadbdcb 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -190,6 +190,8 @@ public: bool bIgnoreScreenInsets; // Android: Center screen disregarding insets if this is enabled. bool bVSync; + bool bShowImDebugger; + int iFrameSkip; int iFrameSkipType; int iFastForwardMode; // See FastForwardMode in ConfigValues.h. diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 39e0fc23e3..b12bd1e4d6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -656,7 +656,7 @@ bool EmuScreen::UnsyncTouch(const TouchInput &touch) { } } - if (!(imguiVisible_ && imguiInited_)) { + if (!(g_Config.bShowImDebugger && imguiInited_)) { GamepadTouch(); } @@ -673,7 +673,7 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) { switch (virtualKeyCode) { case VIRTKEY_TOGGLE_DEBUGGER: if (down) { - imguiVisible_ = !imguiVisible_; + g_Config.bShowImDebugger = !g_Config.bShowImDebugger; } break; case VIRTKEY_FASTFORWARD: @@ -952,10 +952,10 @@ void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) { bool EmuScreen::UnsyncKey(const KeyInput &key) { System_Notify(SystemNotification::ACTIVITY); - if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) { + if (UI::IsFocusMovementEnabled() || (g_Config.bShowImDebugger && imguiInited_)) { // Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode). // We need to manually implement it here :/ - if (imguiVisible_ && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) { + if (g_Config.bShowImDebugger && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) { InputMapping mapping(key.deviceId, key.keyCode); std::vector pspButtons; bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons); @@ -976,7 +976,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { bool EmuScreen::key(const KeyInput &key) { bool retval = UIScreen::key(key); - if (!retval && imguiVisible_ && imguiInited_) { + if (!retval && g_Config.bShowImDebugger && imguiInited_) { ImGui_ImplPlatform_KeyEvent(key); } @@ -993,7 +993,7 @@ bool EmuScreen::key(const KeyInput &key) { } void EmuScreen::touch(const TouchInput &touch) { - if (imguiVisible_ && imguiInited_) { + if (g_Config.bShowImDebugger && imguiInited_) { ImGui_ImplPlatform_TouchEvent(touch); } else { UIScreen::touch(touch); @@ -1637,23 +1637,25 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { darken(); } - if (imguiVisible_ && !imguiInited_) { - imguiInited_ = true; - imDebugger_ = std::make_unique(); - ImGui_ImplThin3d_Init(draw); - } + if (g_Config.bShowImDebugger) { + if (!imguiInited_) { + imguiInited_ = true; + imDebugger_ = std::make_unique(); + ImGui_ImplThin3d_Init(draw); + } - if (imguiVisible_ && imguiInited_ && PSP_IsInited()) { - _dbg_assert_(imDebugger_); + if (PSP_IsInited()) { + _dbg_assert_(imDebugger_); - ImGui_ImplPlatform_NewFrame(); - ImGui_ImplThin3d_NewFrame(draw, ui_draw2d.GetDrawMatrix()); + ImGui_ImplPlatform_NewFrame(); + ImGui_ImplThin3d_NewFrame(draw, ui_draw2d.GetDrawMatrix()); - ImGui::NewFrame(); - imDebugger_->Frame(currentDebugMIPS); + ImGui::NewFrame(); + imDebugger_->Frame(currentDebugMIPS); - ImGui::Render(); - ImGui_ImplThin3d_RenderDrawData(ImGui::GetDrawData(), draw); + ImGui::Render(); + ImGui_ImplThin3d_RenderDrawData(ImGui::GetDrawData(), draw); + } } return flags; } diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 3200c633ff..d7bb7060e8 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -134,5 +134,4 @@ private: std::unique_ptr imDebugger_ = nullptr; bool imguiInited_ = false; - bool imguiVisible_ = false; };