-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SDL3 key questions answered! #10156
SDL3 key questions answered! #10156
Conversation
…rrent keyboard layout
Made the symbols uppercase for consistency with the other SDLK_* constants, but the values are still lowercase.
This allows the numpad to work as the user expects based on the numlock state. If the application needs to distinguish the keys, it can check to see whether the scancode is a numpad key or not.
Ship it! |
I would like to discuss the commit f787790 of two days ago. Although it broke some code in Exult, it presented a consistent picture of providing a single Thus Exult received SDLK_4 when I pressed the 4 key either on the main keyboard or on the numlocked numeric keypad, Exult received SDLK_M when I pressed the M key ( right of L on a french keyboard ), whatever mod key I may been holding.
When I press unshifted main 2, I get the correct SDLK_2
When I press shifted main 2, I get the unexpected
In these messages,
If I prevent SDL to handle the french numkeys with |
I moved this comment to #10165, since we can't reopen a merged Pull Request, and are likely to lose this comment if it's not in an open issue/PR. |
Events will have unmodified keys as keycodes. SDL_HINT_KEYCODE_OPTIONS will allow using French number keycodes and forcing English keycodes for non-latin keyboards as user options, but we'll remove the option for modified keys, because that's something applications would have to code for to handle correctly.
Key names are not related to key layout, and the name for both 'a' and 'A' keycodes is "A". We'll document this.
Separately we'll rename SDLK_[a-z] to SDLK_[A-Z], but leave the values lower case.
The keycode in the event and the layout will be SDLK_LEFT or SDLK_4 when the scancode is SDL_SCANCODE_KP_4, depending on the numlock modifier state.
In addition, this adds non-US layout support on the Emscripten platform. @icculus, I can't build this, so please review and test!
Fixes #10139
Fixes #10150
Affects #3559 in that if you want to get the keycode with modifiers applied for an event, you'll need to call SDL_GetKeyFromScancode(), rather than setting a hint for that.