We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2753 (jbarbe)

Summary: GetKeyboardState not returning hardware keyboard state when using exotic keyboard layout
Product: SDL Reporter: John Barbero Unenge <john.barbero.unenge>
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: target-2.0.6
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   

Description John Barbero Unenge 2014-10-17 16:36:09 UTC
Platform: Debian SID 64bit
SDL Version: 2.1, (but I suspect it's prevalent in previous versions too)
Keyboard layout: Svdvorak (swedish flavor of dvorak)

I'm working on a desktop application which uses SDL and I've noticed an issue with SDL_GetKeyboardState, namely that it returns the software keystate rather than the hardware keystate. The SDL_KeyboardEvent also return text that has been typed with the current keyboard layout, which is expected.

Perhaps this isn't a bug per se, but it is really annoying. I could of course fix this in my particular application, but the issue remains in other software (not written by me).

Most noticable when playing steam games that use SDL. The well established WASD wont work without rebinding ALL THE KEYS!

Current workaround: 
* Switch to se or us layout
* Launch game/application
* While running, switch back to svdvorak

This gives my wanted behavior of se/us layout for hardware keys and svdvorak for text input.

As a developer I'd love to help solve this, that is if anyone else consider this a bug/in need of a fix. Any pointers regarding where to start digging are welcome!

(I haven't checked this behavior in Windows or OS X, but could do so if needed).
Comment 1 Sam Lantinga 2017-08-14 04:58:46 UTC
SDL_GetKeyboardState() actually returns an array indexed by scancodes which are not supposed to move around with layout changes.

Ryan, can you confirm that the X11 code is doing the right thing here?