Ignore keyboard inputs when debugger is focused

This commit is contained in:
Crementif 2026-01-06 02:21:59 +01:00
parent ca73549717
commit 0fa11da218
4 changed files with 33 additions and 0 deletions

View File

@ -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)
{

View File

@ -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 <wx/language.h>
#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);
}

View File

@ -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);

View File

@ -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<uint32, 16> pressedKeys;
WindowSystem::GetWindowInfo().iter_keystates([&pressedKeys](const std::pair<const uint32, bool>& keyState) { if (keyState.second) pressedKeys.emplace_back(keyState.first); });
result.buttons.SetPressedButtons(pressedKeys);