From eae4f28df24605095f890587d4d28e5a94a11908 Mon Sep 17 00:00:00 2001 From: thedmd Date: Sun, 19 Apr 2020 20:26:55 +0200 Subject: [PATCH] When untranslated key has not mapping fallback to KeyMap --- imgui.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 7b040b292492e..e88d7f4a7a8c5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4379,9 +4379,13 @@ int ImGui::GetUntranslatedKeyIndex(ImGuiKey imgui_key) ImGuiContext& g = *GImGui; if (g.IO.BackendFlags & ImGuiBackednFlags_HasUntranslatedKeys) - return g.IO.ScancodeMap[imgui_key]; - else - return g.IO.KeyMap[imgui_key]; + { + int key_index = g.IO.ScancodeMap[imgui_key]; + if (key_index >= 0) + return key_index; + } + + return g.IO.KeyMap[imgui_key]; } // Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]!