ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.15k stars 10.3k forks source link

Translating between backend keycode and ImGuiKey #7997

Closed rokups closed 1 month ago

rokups commented 1 month ago

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 commented 1 month ago

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