Skip to content

Commit 557c77e

Browse files
committedMar 11, 2025·
Added ImGuiKey_AbntC1, ImGuiKey_AbntC2 + Backends: GLFW, Win32: added support. (#8468)
1 parent 6da2306 commit 557c77e

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed
 

Diff for: ‎backends/imgui_impl_glfw.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
// CHANGELOG
3030
// (minor and older changes stripped away, please see git history for details)
31-
// 2025-03-10: Map GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2 into ImGuiKey_Oem102.
31+
// 2025-03-11: Added support for ImGuiKey_Oem102, ImGuiKey_AbntC1, ImGuiKey_AbntC2.
3232
// 2025-03-03: Fixed clipboard handler assertion when using GLFW <= 3.2.1 compiled with asserts enabled.
3333
// 2024-08-22: Moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
3434
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
@@ -195,7 +195,6 @@ static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
195195
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
196196
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode)
197197
{
198-
IM_UNUSED(scancode);
199198
switch (keycode)
200199
{
201200
case GLFW_KEY_TAB: return ImGuiKey_Tab;
@@ -317,8 +316,15 @@ ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode)
317316
case GLFW_KEY_F22: return ImGuiKey_F22;
318317
case GLFW_KEY_F23: return ImGuiKey_F23;
319318
case GLFW_KEY_F24: return ImGuiKey_F24;
320-
default: return ImGuiKey_None;
319+
default: break;
320+
}
321+
switch (scancode)
322+
{
323+
case 115: return ImGuiKey_AbntC1;
324+
case 126: return ImGuiKey_AbntC2;
325+
default: break;
321326
}
327+
return ImGuiKey_None;
322328
}
323329

324330
// X11 does not include current pressed/released modifier key in 'mods' flags submitted by GLFW

Diff for: ‎backends/imgui_impl_win32.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
// CHANGELOG
2323
// (minor and older changes stripped away, please see git history for details)
24-
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
24+
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468) + Added support for ImGuiKey_Oem102, ImGuiKey_AbntC1, ImGuiKey_AbntC2.
2525
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
2626
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
2727
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
@@ -565,13 +565,15 @@ ImGuiKey ImGui_ImplWin32_KeyEventToImGuiKey(WPARAM wParam, LPARAM lParam)
565565
case 13: return ImGuiKey_Equal;
566566
case 26: return ImGuiKey_LeftBracket;
567567
case 27: return ImGuiKey_RightBracket;
568-
case 86: return ImGuiKey_Oem102;
569568
case 43: return ImGuiKey_Backslash;
570569
case 39: return ImGuiKey_Semicolon;
571570
case 40: return ImGuiKey_Apostrophe;
572571
case 51: return ImGuiKey_Comma;
573572
case 52: return ImGuiKey_Period;
574573
case 53: return ImGuiKey_Slash;
574+
case 86: return ImGuiKey_Oem102;
575+
case 115: return ImGuiKey_AbntC1;
576+
case 126: return ImGuiKey_AbntC2;
575577
}
576578

577579
return ImGuiKey_None;

Diff for: ‎docs/CHANGELOG.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Other changes:
128128
- Examples: Updated all .vcxproj from VS2015 to VS2019 (toolset v140 to v142),
129129
and from Windows SDK 8.1 to Windows SDK 10 ("latest" setting).
130130
- IO: Added ImGuiKey_Oem102 to ImGuiKey enum. (#7136, #7201, #7206, #7306, #8468)
131+
- IO: Added ImGuiKey_AbntC1, ImGuiKey_AbntC2 to ImGuiKey enum. (#8468)
131132
- Backends: reworked key handlers to use/prioritize untranslated scancodes instead of
132133
translated keycodes when dealing with OEM keys which are too difficult to find a reliable
133134
translated mapping on all systems, backends and keyboard layout.
@@ -139,7 +140,8 @@ Other changes:
139140
- Fixes many cases of keys not emitting a ImGuiKey value with certain keyboad layouts.
140141
- Makes emitted ImGuiKey values more consistent regardless of keyboard mapping,
141142
but you may be getting different values as before.
142-
- Win32, SDL2, SDL3: Use scancodes for OEM keys.
143+
- Win32: Use scancodes for OEM keys. Added support for the 3 new keys.
144+
- SDL2, SDL3: Use scancodes for OEM keys. Added support for the Oem102 new key.
143145
- GLFW: GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2 are emitting ImGuiKey_Oem102.
144146
- Backends: GLFW: Fixed clipboard handler assertion when using GLFW <= 3.2.1 compiled
145147
with asserts enabled. (#8452)

Diff for: ‎imgui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8787,7 +8787,7 @@ static const char* const GKeyNames[] =
87878787
"Pause", "Keypad0", "Keypad1", "Keypad2", "Keypad3", "Keypad4", "Keypad5", "Keypad6",
87888788
"Keypad7", "Keypad8", "Keypad9", "KeypadDecimal", "KeypadDivide", "KeypadMultiply",
87898789
"KeypadSubtract", "KeypadAdd", "KeypadEnter", "KeypadEqual",
8790-
"AppBack", "AppForward", "Oem102",
8790+
"AppBack", "AppForward", "Oem102", "AbntC1", "AbntC2",
87918791
"GamepadStart", "GamepadBack",
87928792
"GamepadFaceLeft", "GamepadFaceRight", "GamepadFaceUp", "GamepadFaceDown",
87938793
"GamepadDpadLeft", "GamepadDpadRight", "GamepadDpadUp", "GamepadDpadDown",

Diff for: ‎imgui.h

+2
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@ enum ImGuiKey : int
14941494
ImGuiKey_AppBack, // Available on some keyboard/mouses. Often referred as "Browser Back"
14951495
ImGuiKey_AppForward,
14961496
ImGuiKey_Oem102, // Non-US backslash.
1497+
ImGuiKey_AbntC1, // Brazil ABNT extra keys
1498+
ImGuiKey_AbntC2,
14971499

14981500
// Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION ACTION
14991501
// (download controller mapping PNG/PSD at http://dearimgui.com/controls_sheets)

0 commit comments

Comments
 (0)
Please sign in to comment.