Skip to content

Commit 82336cb

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 f80e819 commit 82336cb

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
@@ -1972,6 +1972,16 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
19721972

19731973
Wayland_UpdateImplicitGrabSerial(seat, serial);
19741974

1975+
if (state == WL_KEYBOARD_KEY_STATE_REPEATED) {
1976+
// If this key shouldn't be repeated, just return.
1977+
if (seat->keyboard.xkb.keymap && !WAYLAND_xkb_keymap_key_repeats(seat->keyboard.xkb.keymap, key + 8)) {
1978+
return;
1979+
}
1980+
1981+
// SDL automatically handles key tracking and repeat status, so just map 'repeated' to 'pressed'.
1982+
state = WL_KEYBOARD_KEY_STATE_PRESSED;
1983+
}
1984+
19751985
if (seat->keyboard.sdl_keymap != SDL_GetCurrentKeymap(true)) {
19761986
SDL_SetKeymap(seat->keyboard.sdl_keymap, true);
19771987
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
@@ -80,7 +80,9 @@
8080
#define SDL_WL_COMPOSITOR_VERSION 4
8181
#endif
8282

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

0 commit comments

Comments
 (0)