mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 14:01:17 +12: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
|
@ -110,7 +110,8 @@ ImFont* ImGui_GetFont(float size)
|
|||
void ImGui_UpdateWindowInformation(bool mainWindow)
|
||||
{
|
||||
extern WindowInfo g_window_info;
|
||||
|
||||
static std::map<uint32, ImGuiKey> keyboard_mapping;
|
||||
static uint32 current_key = 0;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
|
@ -130,9 +131,17 @@ void ImGui_UpdateWindowInformation(bool mainWindow)
|
|||
bool padDown;
|
||||
const auto pos = instance.get_left_down_mouse_info(&padDown);
|
||||
io.MouseDown[0] = padDown != mainWindow && pos.has_value();
|
||||
|
||||
std::fill_n(io.KeysDown, std::size(io.KeysDown), false);
|
||||
std::copy(std::cbegin(g_window_info.keydown), std::cend(g_window_info.keydown), io.KeysDown);
|
||||
auto get_mapping = [&](uint32 key_code)
|
||||
{
|
||||
auto key = keyboard_mapping.find(key_code);
|
||||
if (key != keyboard_mapping.end())
|
||||
return key->second;
|
||||
ImGuiKey mapped_key = current_key + ImGuiKey_NamedKey_BEGIN;
|
||||
current_key = (current_key + 1) % ImGuiKey_NamedKey_COUNT ;
|
||||
keyboard_mapping[key_code] = mapped_key;
|
||||
return mapped_key;
|
||||
};
|
||||
g_window_info.iter_keystates([&](auto&& el){ io.AddKeyEvent(get_mapping(el.first), el.second); });
|
||||
|
||||
// printf("%f %f %d\n", io.MousePos.x, io.MousePos.y, io.MouseDown[0]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue