diff --git a/src/gui/interface/WindowSystem.h b/src/gui/interface/WindowSystem.h index dc614691..89e35ee6 100644 --- a/src/gui/interface/WindowSystem.h +++ b/src/gui/interface/WindowSystem.h @@ -44,6 +44,7 @@ namespace WindowSystem std::atomic_int32_t restored_pad_width = -1, restored_pad_height = -1; std::atomic_bool is_fullscreen; + std::atomic_bool debugger_focused; void set_keystate(uint32 keycode, bool state) { diff --git a/src/gui/wxgui/CemuApp.cpp b/src/gui/wxgui/CemuApp.cpp index 1c803bf6..a900f10b 100644 --- a/src/gui/wxgui/CemuApp.cpp +++ b/src/gui/wxgui/CemuApp.cpp @@ -12,6 +12,7 @@ #include "wxgui/helpers/wxHelpers.h" #include "Cemu/ncrypto/ncrypto.h" #include "wxgui/input/HotkeySettings.h" +#include "wxgui/debugger/DebuggerWindow2.h" #include #if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND @@ -434,6 +435,30 @@ int CemuApp::FilterEvent(wxEvent& event) g_window_info.set_keystatesup(); } + // track if debugger window or its child windows are focused + if (g_debugger_window && (event.GetEventType() == wxEVT_SET_FOCUS || event.GetEventType() == wxEVT_ACTIVATE)) + { + wxWindow* target_window = wxDynamicCast(event.GetEventObject(), wxWindow); + + if (target_window && event.GetEventType() == wxEVT_ACTIVATE && !((wxActivateEvent&)event).GetActive()) + target_window = nullptr; + + if (target_window) + { + g_window_info.debugger_focused = false; + wxWindow* window_it = target_window; + while (window_it) + { + if (window_it == g_debugger_window) g_window_info.debugger_focused = true; + window_it = window_it->GetParent(); + } + } + } + else if (!g_debugger_window) + { + g_window_info.debugger_focused = false; + } + return wxApp::FilterEvent(event); } diff --git a/src/gui/wxgui/debugger/DebuggerWindow2.h b/src/gui/wxgui/debugger/DebuggerWindow2.h index b06601ba..89cc303f 100644 --- a/src/gui/wxgui/debugger/DebuggerWindow2.h +++ b/src/gui/wxgui/debugger/DebuggerWindow2.h @@ -26,6 +26,8 @@ wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent); wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent); wxDECLARE_EVENT(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, wxCommandEvent); +extern class DebuggerWindow2* g_debugger_window; + struct DebuggerConfig { DebuggerConfig() @@ -82,6 +84,7 @@ public: bool Show(bool show = true) override; std::wstring GetModuleStoragePath(std::string module_name, uint32_t crc_hash) const; + private: void OnBreakpointHit(wxCommandEvent& event); void OnRunProgram(wxCommandEvent& event); diff --git a/src/input/api/Keyboard/KeyboardController.cpp b/src/input/api/Keyboard/KeyboardController.cpp index fedabb9d..0514cd5d 100644 --- a/src/input/api/Keyboard/KeyboardController.cpp +++ b/src/input/api/Keyboard/KeyboardController.cpp @@ -17,6 +17,10 @@ std::string KeyboardController::get_button_name(uint64 button) const ControllerState KeyboardController::raw_state() { ControllerState result{}; + + if (WindowSystem::GetWindowInfo().debugger_focused) + return result; + boost::container::small_vector pressedKeys; WindowSystem::GetWindowInfo().iter_keystates([&pressedKeys](const std::pair& keyState) { if (keyState.second) pressedKeys.emplace_back(keyState.first); }); result.buttons.SetPressedButtons(pressedKeys);