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

Linux/BSD: Modify only keypad keys #102169

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

Riteo
Copy link
Contributor

@Riteo Riteo commented Jan 30, 2025

Should greatly alleviate #102137.
Fixes #102259.

The keycode field of InputEventKey is supposed to be "unshifted"; That is, what the key would output if no modifier keys were pressed. This should match what's written on the key label, but Key enumerates also all keypad keys, which require a modifier. We thus require some extra checks for them.

Note that this can still allow "stuck keys", but that's an even deeper problem.


This should bring both the X11 and Wayland backend to "parity" with Windows. Now only keypad keys should be able to get stuck; Better than having every other "non-US" modifier at least.

Feedback appreciated on the X11 impl.

Also note that I purposely made the "is keypad" method specific to only the related (modified) Key enumerations. If that's excessive, we could replace it with a simple check between XKB_KEY_KP_Space and XKB_KEY_KP_9 (same for the XK equivalent on X11), as all keypad scancodes are consecutive. That would require no other changes as I built the code to allow for "no matches" to the mapping table, just in case.

CC @bruvzg

@tdaven
Copy link
Contributor

tdaven commented Jan 30, 2025

I can confirm this fixes the number pad issue mention on #101848.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. The issue with script editor hover tooltips no longer appearing until you alt-tab out and back in is also fixed with this PR.

Disabling numlock in the script editor works as intended for navigational purposes, but this was also the case in master before this PR.

Code looks good to me.

Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.9-200.fc41.x86_64 (64-bit)
Graphics Platform: X11

Before

Numlock OFF Numlock ON
image image

After

Notice that Unicode is now "Kp 0" instead of "0" for Numlock ON.

Numlock OFF Numlock ON
image image

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to fix Numpad issue, but breaks some layouts on X11.

platform/linuxbsd/x11/display_server_x11.cpp Outdated Show resolved Hide resolved
@Riteo Riteo force-pushed the what-is-even-a-keypad branch from 510f03f to 140a63b Compare February 2, 2025 18:18
The `keycode` field of `InputEventKey` is supposed to be "unshifted";
That is, what the key would output if no modifier keys were pressed.
This should match what's written on the key label, but `Key` enumerates
also all keypad keys, which require a modifier. We thus require some
extra checks for them.

Note that this can still allow "stuck keys", but that's an even deeper
problem.
@Repiteo Repiteo merged commit d2995dc into godotengine:master Feb 3, 2025
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 3, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpad is not properly detected on Wayland
6 participants