| Summary: | Linux key events do not respect keyboard layout | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Drew Bliss <drewb> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | jwyatt, metalcaedes |
| Version: | HG 2.0 | Keywords: | target-2.0.4 |
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Test patch to check if fixing the group fixes the issue. | ||
|
Description
Drew Bliss
2015-07-06 17:40:57 UTC
you mean without restarting the game? or even after restarting it after changing the keyboard layout? This is with changing the layout before the game has started. Ryan investigated and it looks like the underlying system is translating keys in a way that isn't easily visible to SDL so at the moment this looks like a won't-fix. I'm seeing what looks to be the same bug in Fedora 21. For me, the issue seems to be when multiple layouts are set-up, SDL always ends up using the first one, regardless of which is currently selected. This seems to be caused by using group 0 in X11_XkbKeycodeToKeysym in X11_KeyCodeToUcs4. Hackily adding an XkbGetState to retrieve the current group, and using that instead gives the correct results. Created attachment 2239 [details]
Test patch to check if fixing the group fixes the issue.
Attached is the patch I used to check that specifying the current group is sufficient.
(In reply to Jason Wyatt from comment #4) > Created attachment 2239 [details] > Test patch to check if fixing the group fixes the issue. > > Attached is the patch I used to check that specifying the current group is > sufficient. This looks good to me, so it's now https://hg.libsdl.org/SDL/rev/8a89b58895c1 Thanks! --ryan. Just made a further change here:
https://hg.libsdl.org/SDL/rev/41ce18cb4b3b
Jason's fix solved the mystery, and SDL does the right thing with non-primary keyboard layouts on Ubuntu 12.04 (etc) now, but it doesn't notice if the layout changes at runtime unless the new layout is the first in the list...same problem as before.
Moving to the front of the list makes X send a MappingNotify event, which we handle already, and on newer Ubuntu releases, this event is sent if you choose a layout that isn't at the start of the list, too.
On 12.04, we get a PropertyNotify for XKLAVIER_STATE ("Klavier" is German for keyboard, this is a library that handles layout stuff). So my new patch notices that property and reinits our keymap info.
It works here, but all this explanation is to say: I have no idea what I'm doing, so please tell me if it works on Fedora 21, too, and if anyone knows if this was even close to a correct approach.
Thanks,
--ryan.
|