Skip to content
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

Translating between backend keycode and ImGuiKey #7997

Closed
rokups opened this issue Sep 18, 2024 · 1 comment
Closed

Translating between backend keycode and ImGuiKey #7997

rokups opened this issue Sep 18, 2024 · 1 comment

Comments

@rokups
Copy link
Contributor

rokups commented Sep 18, 2024

Version/Branch of Dear ImGui:

Version 1.91, Branch: docking

Back-ends:

imgui_impl_sdl2.cpp

Compiler, OS:

Not applicalbe

Full config/build information:

No response

Details:

My project has a hotkey system which in the past used a mix of SDL keycodes and scancodes. Dear ImGui now handles keys through ImGuiKey enum, which maps to SDL2 keycodes. In order to maintain ability to use scancodes for keybindings i need a way to translate SDL2 scancode to ImGuiKey. This can be done indirectly, by translating SDL2 scancode to SDL2 keycode, and then translating SDL2 keycode to ImGuiKey. ImGui_ImplSDL2_KeyEventToImGuiKey function does exactly this, however this function is private and static. For time being i patched SDL2 backend so it exposes this function and i can use it. It would probably be helpful to more people than me alone if there was an official way to translate between ImGuiKey and backend keycode.

Thanks for considering this 🙏

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut added a commit that referenced this issue Sep 19, 2024
…yEventToImGuiKey(), ImGui_ImplGlfw_KeyToImGuiKey(), ImGui_ImplWin32_KeyEventToImGuiKey(), ImGui_ImplAllegro5_KeyCodeToImGuiKey(), ImGui_ImplOSX_KeyCodeToImGuiKey(), non-static. (#7997)

Backends: Win32: Refactor ImGui_ImplWin32_KeyEventToImGuiKey() logic.
Ref #7672
@ocornut
Copy link
Owner

ocornut commented Sep 19, 2024

Made that change as cfae5ac.
It'd prefer to make it an undocumented thing for now, so you would need to forward declare.

@ocornut ocornut closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants