Skip to content

Commit b9ab8cf

Browse files
committed
wayland: Add support for the key repeat event (seat v10)
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'.
1 parent 343ad3e commit b9ab8cf

File tree

3 files changed

+233
-73
lines changed

3 files changed

+233
-73
lines changed

src/video/wayland/SDL_waylandevents.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,16 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
20482048

20492049
Wayland_UpdateImplicitGrabSerial(seat, serial);
20502050

2051+
if (state == WL_KEYBOARD_KEY_STATE_REPEATED) {
2052+
// If this key shouldn't be repeated, just return.
2053+
if (seat->keyboard.xkb.keymap && !WAYLAND_xkb_keymap_key_repeats(seat->keyboard.xkb.keymap, key + 8)) {
2054+
return;
2055+
}
2056+
2057+
// SDL automatically handles key tracking and repeat status, so just map 'repeated' to 'pressed'.
2058+
state = WL_KEYBOARD_KEY_STATE_PRESSED;
2059+
}
2060+
20512061
if (seat->keyboard.sdl_keymap != SDL_GetCurrentKeymap(true)) {
20522062
SDL_SetKeymap(seat->keyboard.sdl_keymap, true);
20532063
SDL_SetModState(seat->keyboard.pressed_modifiers | seat->keyboard.locked_modifiers);

src/video/wayland/SDL_waylandvideo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
#define SDL_WL_COMPOSITOR_VERSION 4
8282
#endif
8383

84-
#if SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
84+
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
85+
#define SDL_WL_SEAT_VERSION 10
86+
#elif SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
8587
#define SDL_WL_SEAT_VERSION 9
8688
#elif SDL_WAYLAND_CHECK_VERSION(1, 21, 0)
8789
#define SDL_WL_SEAT_VERSION 8

0 commit comments

Comments
 (0)