Avoid wxGetKeyState since it asserts on Linux with wayland GTK

Only modifier keys are allowed, but we used it to test for Escape
This commit is contained in:
Exzap 2023-10-17 13:06:36 +02:00
parent c440ecdf36
commit 66711529be
3 changed files with 6 additions and 2 deletions

View File

@ -191,7 +191,6 @@ int CemuApp::FilterEvent(wxEvent& event)
if(event.GetEventType() == wxEVT_KEY_DOWN) if(event.GetEventType() == wxEVT_KEY_DOWN)
{ {
const auto& key_event = (wxKeyEvent&)event; const auto& key_event = (wxKeyEvent&)event;
wxGetKeyState(wxKeyCode::WXK_F17);
g_window_info.set_keystate(fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags()), true); g_window_info.set_keystate(fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags()), true);
} }
else if(event.GetEventType() == wxEVT_KEY_UP) else if(event.GetEventType() == wxEVT_KEY_UP)

View File

@ -41,18 +41,22 @@ enum struct PlatformKeyCodes : uint32
LCONTROL = VK_LCONTROL, LCONTROL = VK_LCONTROL,
RCONTROL = VK_RCONTROL, RCONTROL = VK_RCONTROL,
TAB = VK_TAB, TAB = VK_TAB,
ESCAPE = VK_ESCAPE,
#elif BOOST_OS_LINUX #elif BOOST_OS_LINUX
LCONTROL = GDK_KEY_Control_L, LCONTROL = GDK_KEY_Control_L,
RCONTROL = GDK_KEY_Control_R, RCONTROL = GDK_KEY_Control_R,
TAB = GDK_KEY_Tab, TAB = GDK_KEY_Tab,
ESCAPE = GDK_KEY_Escape,
#elif BOOST_OS_MACOS #elif BOOST_OS_MACOS
LCONTROL = kVK_Control, LCONTROL = kVK_Control,
RCONTROL = kVK_RightControl, RCONTROL = kVK_RightControl,
TAB = kVK_Tab, TAB = kVK_Tab,
ESCAPE = kVK_Escape,
#else #else
LCONTROL = 0, LCONTROL = 0,
RCONTROL = 0, RCONTROL = 0,
TAB = 0, TAB = 0,
ESCAPE = 0,
#endif #endif
}; };

View File

@ -1,3 +1,4 @@
#include "gui/guiWrapper.h"
#include "gui/input/panels/InputPanel.h" #include "gui/input/panels/InputPanel.h"
#include <wx/textctrl.h> #include <wx/textctrl.h>
@ -26,7 +27,7 @@ void InputPanel::on_timer(const EmulatedControllerPtr& emulated_controller, cons
const auto mapping = reinterpret_cast<uint64>(element->GetClientData()); const auto mapping = reinterpret_cast<uint64>(element->GetClientData());
// reset mapping // reset mapping
if(std::exchange(m_right_down, false) || wxGetKeyState(WXK_ESCAPE)) if(std::exchange(m_right_down, false) || gui_isKeyDown(PlatformKeyCodes::ESCAPE))
{ {
element->SetBackgroundColour(kKeyColourNormalMode); element->SetBackgroundColour(kKeyColourNormalMode);
m_color_backup[element->GetId()] = kKeyColourNormalMode; m_color_backup[element->GetId()] = kKeyColourNormalMode;