SDL: Use scancodes for keyboard bindings (#905)#2605
SDL: Use scancodes for keyboard bindings (#905)#2605depp wants to merge 1 commit intomgba-emu:masterfrom
Conversation
Core key bindings for SDL >= 2.0 are now independent of the keyboard layout. QWERTY users get ZXAS, German users get YXAS, French layouts get WXQS, etc. Existing customizations will be ignored, users with customized bindings for SDL will get the new defaults and have to create a new configuration. Existing functionality is preserved for SDL 1.x.
endrift
left a comment
There was a problem hiding this comment.
I have some reservations about this change:
The first and foremost one is that it won't load custom SDLK bindings if there are any present, instead falling back to the new SDLS bindings.
Secondly, which OSes have you tested this on? I seem to recall trying something like this years ago, but running into issues with it on some OSes. It'll need broader testing.
Third, it might (might) be desirable to be able to select at runtime whether or not scancodes or keysyms are used. But I'm not sure.
I have one implementation nitpick, specifically that I use #define DEF and #ifdef DEF instead of #define DEF 1 and #if DEF but that's a simple enough change once more prominent concerns are allayed or addressed.
Targeting this for 0.11 though since 0.10 is frozen for this kind of change.
You could do this with
I've only personally tested this code on Linux, but I've written similar code and tested it on Windows and macOS before. I can test on additional systems.
I have a hard time seeing the benefit. SDL scancodes are portable. Keysyms are not portable, they are fragile and break on some systems. Some people even change keyboard layout while programs are running--and this would break any keysym layout. |
|
I know I'm several years late, but I am amenable to this change, but only with an SDLK -> SDLS migration path. I'm not sure offhand what the best way to detect if SDLS should be used/if a migration has already happened though. Perhaps a config key for "isMigrated" that's set when a migration happens. |
Core key bindings for SDL >= 2.0 are now independent of the keyboard
layout. QWERTY users get ZXAS, German users get YXAS, French layouts get
WXQS, etc. Existing customizations will be ignored, users with
customized bindings for SDL will get the new defaults and have to create
a new configuration.
Existing functionality is preserved for SDL 1.x.