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: Add support for the key repeat event (seat v10) #10821

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kontrabant
Copy link
Contributor

@Kontrabant Kontrabant commented Sep 13, 2024

The pending Wayland seat v10 protocol can send explicit key repeat events if the repeat interval is 0.

The internal key repeat mechanism already disables itself if the key repeat interval is 0, and SDL tracks and handles the flagging of repeated keys itself, so just map the 'repeated' event to 'pressed'.

Draft for pending upstream protocol changes.
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/368

@Kontrabant
Copy link
Contributor Author

The changes were merged upstream, so this is good to go once the new core protocols release is tagged.

@mariakeating
Copy link

I believe this condition should be inverted as xkb_keymap_key_repeats returns 0 if the key shouldn't repeat.

diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 29d2f340f..f1394e804 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -1665,7 +1665,7 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
 
     if (state == WL_KEYBOARD_KEY_STATE_REPEATED) {
         // If this key shouldn't be repeated, just return.
-        if (input->xkb.keymap && WAYLAND_xkb_keymap_key_repeats(input->xkb.keymap, key + 8)) {
+        if (input->xkb.keymap && !WAYLAND_xkb_keymap_key_repeats(input->xkb.keymap, key + 8)) {
             return;
         }
 

The internal key repeat mechanism already disables itself if the key repeat interval is 0, and SDL tracks and handles the flagging of repeated keys itself, so just map the 'repeated' event to 'pressed'.
@Kontrabant
Copy link
Contributor Author

Indeed it should be, thanks for pointing it out.

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.

2 participants