mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-13 04:36:59 +00:00
Use unordered_map for keydown to allow codes above 255 (#248)
- Adds internal support for 32bit key codes, required for proper keyboard input on Linux - Use gdk_keyval_name to get key name on Linux
This commit is contained in:
parent
5e968eff4f
commit
9f02733a0d
14 changed files with 143 additions and 83 deletions
|
|
@ -35,9 +35,13 @@ std::string KeyboardController::get_button_name(uint64 button) const
|
|||
char key_name[128];
|
||||
if (GetKeyNameTextA(scan_code, key_name, std::size(key_name)) != 0)
|
||||
return key_name;
|
||||
#endif
|
||||
|
||||
else
|
||||
return fmt::format("key_{}", button);
|
||||
#elif BOOST_OS_LINUX
|
||||
return gui_gtkRawKeyCodeToString(button);
|
||||
#else
|
||||
return fmt::format("key_{}", button);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern WindowInfo g_window_info;
|
||||
|
|
@ -47,20 +51,7 @@ ControllerState KeyboardController::raw_state()
|
|||
ControllerState result{};
|
||||
if (g_window_info.app_active)
|
||||
{
|
||||
static_assert(result.buttons.size() == std::size(g_window_info.keydown), "invalid size");
|
||||
for (uint32 i = wxKeyCode::WXK_BACK; i < result.buttons.size(); ++i)
|
||||
{
|
||||
if(const bool v = g_window_info.keydown[i])
|
||||
{
|
||||
result.buttons.set(i, v);
|
||||
}
|
||||
}
|
||||
// ignore generic key codes on Windows when there is also a left/right variant
|
||||
#if BOOST_OS_WINDOWS
|
||||
result.buttons.set(VK_SHIFT, false);
|
||||
result.buttons.set(VK_CONTROL, false);
|
||||
result.buttons.set(VK_MENU, false);
|
||||
#endif
|
||||
g_window_info.get_keystates(result.buttons);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue