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

wayland: fix keycodes of swapped xkb modifier keys #5085

Merged
merged 1 commit into from Dec 9, 2021

Conversation

vially
Copy link
Contributor

@vially vially commented Dec 9, 2021

Description

When using xkb to swap modifier keys on Wayland, SDL did not correctly translate scancodes into keycodes. This pull-request attempts to fix that.

This bug seems very similar to #3471 which was closed in #4303. However, trying to checkout that particular commit results in a broken checkkeys app on Sway (window is not shown) so I'm unable to test if the bug was still reproducible at that point.

Steps to reproduce

  1. Swap the physical caps-lock and left-control key on the keyboard using XKB.

This step is compositor specific, but on sway this can be configured using the XKB_DEFAULT_OPTIONS=ctrl:swapcaps environment variable (this needs to be set before starting the compositor).

  1. Run the test/checkkeys app and press/release once the physical caps-lock key (which has been remapped to left-control).

Before the changes in this pull-request, the (wrong) output will be:

INFO: Initial state: modifiers: (none)
INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS
INFO: Key released:  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS

After these changes, the (correct) output will be:

INFO: Initial state: modifiers: (none)
INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x400000E0 = Left Ctrl  modifiers: LCTRL
INFO: Key released:  scancode 57 = CapsLock, keycode 0x400000E0 = Left Ctrl  modifiers: (none)

Existing Issue(s)

@slouken slouken merged commit cb8fa5f into libsdl-org:main Dec 9, 2021
@vially vially deleted the fix-wayland-xmodmap branch December 9, 2021 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants