-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Description
Version/Branch of Dear ImGui:
Commit 377a387, Branch: master
Back-ends:
imgui_impl_win32.cpp
Compiler, OS:
Windows 11 + MSVC 2022
Full config/build information:
No response
Details:
Our problem:
As mentioned in previous issues (#7136, #7201, #7306), the ImGuiKey enum is missing some keys present in non-US keyboard layouts. This issue is being opened primarily to add more data to the case, as well as reference the Dear ImGui keyboard layout mapping.
OS: Windows
Backend: Win32
Physical KB Layout: ABNT2
Input Layout: PT (Brazil ABNT2)
Physical Markings | Virtual Key Code | ImGuiKey 1.91.8 |
---|---|---|
ç | 0xBA = VK_OEM_1 | ImGuiKey_Semicolon |
; : | 0xBF = VK_OEM_2 | ImGuiKey_Slash |
' " | 0xC0 = VK_OEM_3 | ImGuiKey_GraveAccent |
/?° | 0xC1 | None |
. | 0xC2 | None |
´ ` | 0xDB = VK_OEM_4 | ImGuiKey_LeftBracket |
]}º | 0xDC = VK_OEM_5 | ImGuiKey_Backslash |
[{ª | 0xDD = VK_OEM_6 | ImGuiKey_RightBracket |
~^ | 0xDE = VK_OEM_7 | ImGuiKey_Apostrophe |
\| | 0xE2 = VK_OEM_102 | None |
The following VK Codes: 0xC1, 0xC2, and 0xE2 aren't present in the ImGuiKey enum or ImGui_ImplWin32_KeyEventToImGuiKey. The first two codes don't appear on either the DE or FR keyboard layouts.
Keyboard example:
My POV:
I believe filling the gaps is more important than "fixing" the divergent keys, which can be quite challenging.
case VK_OEM_102: return ImGuiKey_OEM102;
case 0xC1: return ImGuiKey_ReservedC1;
case 0xC2: return ImGuiKey_ReservedC2;
ImGuiKey_OEM102, // "<>" or "\|" on RT 102-key keyboard.
ImGuiKey_ReservedC1, // "/?" on 107-key ABNT2 keyboard.
ImGuiKey_ReservedC2, // "." (Numpad) on 107-key ABNT2 keyboard.
Extra
There's a typo at line 8770 of imgui.cpp:
Current: // Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
Intended?: // These names are provided for debugging purposes and are not meant to be saved persistently or compared.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
Use ImGui::ShowDemoWindow()
or:
ImGui::TextUnformatted("(WinAPI) Key: ");
for (std::uint16_t virtualKey = 1; virtualKey < 255; virtualKey++)
{
if (GetAsyncKeyState(virtualKey) & 0x8000)
{
char buffer[256];
GetKeyNameTextA(static_cast<LONG>(MapVirtualKeyW(virtualKey, MAPVK_VK_TO_VSC)) << 16 | 1 << 25, buffer, sizeof(buffer));
ImGui::SameLine();
ImGui::Text("[0x%X] %s", virtualKey, buffer);
}
}
ImGui::TextUnformatted("(ImGui) Key: ");
for (std::uint16_t imguiKey = ImGuiKey_NamedKey_BEGIN; imguiKey < ImGuiKey_NamedKey_END; imguiKey++)
{
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(imguiKey)))
{
ImGui::SameLine();
ImGui::Text("[%d] %s", imguiKey, ImGui::GetKeyName(static_cast<ImGuiKey>(imguiKey)));
}
}
With an ABNT2 keyboard.