-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backends: Win32: Fix ImGuiMod_Super being mapped to VK_APPS #7768
Conversation
The `ImGui_ImplWin32_UpdateKeyModifiers()` function maps `ImGuiMod_Super` to `VK_APPS`, the "Application" key located between the Right Windows (Super) and Right Control keys on the keyboard, see https://conemu.github.io/en/AppsKey.html This means that when using `ImGui::GetIO().KeySuper` to try to get the down state of the `VK_RWIN` or `VK_LWIN` keys, it'll always return FALSE when either of those keys are held down, and only return TRUE when `VK_APPS` is held down. Changing `io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_APPS));` to `io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));` solves the issue and properly maps `KeySuper` to the two Super keys.
Thanks for the PR. (Digging results:) Any idea? Either way, no code seems to use ModSuper on Win32 since I'm not even sure it is legal to do as it triggers Windows behaviors anyhow. |
Pushed as 9504068, thanks! |
… of VK_LWIN||VK_RWIN (#7768, #4858, #2622) Amend 0755767 The `ImGui_ImplWin32_UpdateKeyModifiers()` function maps `ImGuiMod_Super` to `VK_APPS`, the "Application" key located between the Right Windows (Super) and Right Control keys on the keyboard, see https://conemu.github.io/en/AppsKey.html This means that when using `ImGui::GetIO().KeySuper` to try to get the down state of the `VK_RWIN` or `VK_LWIN` keys, it'll always return FALSE when either of those keys are held down, and only return TRUE when `VK_APPS` is held down.
Hi. It's possible the mistake was made due to the factors surrounding I ran into a similar key mistake in another project time where So Microsoft does not make these things simple! 😅 As for how I stumbled upon it, it's because our project makes use of global hotkeys registered through Win32's RegisterHotKey function. In that function, the Windows modifier key can be used for global hotkeys as long as no other app or the OS itself currently makes use of the exact key combination. Making use of Right now this is only implemented in the early experimental Special K Image Viewer (SKIV) tool where it is mapped to capture a screenshot of the desktop or a region on it, but it'll eventually also be implemented in our Special K Injection Frontend (SKIF) tool where we also make use of global hotkeys mapped to the Windows key (in this case to trigger HDR support in Windows on a per-display basis). The Windows key is also technically safe to use as a modifier for a few normal key combos in games, though it's hardly surprising that nobody uses it since any mistake would just result in the OS stealing focus from the game. As Dear ImGui sees more and more use among more classic desktop applications, I wouldn't be surprised to see the use of Thanks for the quick merge, and cheers! |
To be honest I'm equally surprised to see VK_APPS as you're. I cannot recall ever using it. I think using VK_LWIN and VK_RWIN is the right call. |
The
ImGui_ImplWin32_UpdateKeyModifiers()
function mapsImGuiMod_Super
toVK_APPS
, the "Application" key located between the Right Windows (Super) and Right Control keys on the keyboard, see https://conemu.github.io/en/AppsKey.htmlThis means that when using
ImGui::GetIO().KeySuper
to try to get the down state of theVK_RWIN
orVK_LWIN
keys, it'll always return FALSE when either of those keys are held down, and only return TRUE whenVK_APPS
is held down.Changing
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_APPS));
toio.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));
solves the issue and properly mapsKeySuper
to the two Super keys.