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

Fix ImGuiKey mapping for SDL2 and SDL3 by translation method #7672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eszdman
Copy link

@eszdman eszdman commented Jun 8, 2024

As mentioned in #7670, SDL2 partially reports SDL_Keycode as symbols depending on the keyboard layout in SDL initialization. Since ImGui's target is to use translated symbols in en-US layout, I implemented ImGui_ImplSDL_TranslateUntranslatedKey

@eszdman eszdman changed the title Fix ImGuiKey mapping for SDL2 and SDL3 by implementing Fix ImGuiKey mapping for SDL2 and SDL3 by translation method Jun 8, 2024
@ocornut
Copy link
Owner

ocornut commented Jun 10, 2024

It seems like a bug in SDL that you would get e.g. a keycode of 1081 since this doesn't correspond to a SDL_Keycode value in the enumeration. I think you should bring it to SDL to try to get an explanation about it first.

I see that you converted the logic from GLFW, however:

  • GLFW has an exception for KEYPAD keys (GLFW_KEY_KP_0 to GLFW_KEY_KP_EQUAL) while your conversion does something differently and technically faulty.
  • The result won't be translated keys at all, since it is using scancode names.

There's probably an interesting fallback to use based on scancode, and maybe this is it, but you first need to check with SDL why you are getting those values on your system/setup.

@eszdman
Copy link
Author

eszdman commented Jun 10, 2024

It seems like a bug in SDL that you would get e.g. a keycode of 1081 since this doesn't correspond to a SDL_Keycode value in the enumeration. I think you should bring it to SDL to try to get an explanation about it first.

I issued SDL with this, it's clearly expected behaviour of SDL_Keycode and enumeration declared only as example on an en-US keyboard libsdl-org/SDL#10002 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants