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'.
This commit is contained in:
Frank Praznik
2024-09-13 10:41:26 -04:00
parent 343ad3eddd
commit b9ab8cf03d
3 changed files with 233 additions and 73 deletions

View File

@@ -2048,6 +2048,16 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
Wayland_UpdateImplicitGrabSerial(seat, serial);
if (state == WL_KEYBOARD_KEY_STATE_REPEATED) {
// If this key shouldn't be repeated, just return.
if (seat->keyboard.xkb.keymap && !WAYLAND_xkb_keymap_key_repeats(seat->keyboard.xkb.keymap, key + 8)) {
return;
}
// SDL automatically handles key tracking and repeat status, so just map 'repeated' to 'pressed'.
state = WL_KEYBOARD_KEY_STATE_PRESSED;
}
if (seat->keyboard.sdl_keymap != SDL_GetCurrentKeymap(true)) {
SDL_SetKeymap(seat->keyboard.sdl_keymap, true);
SDL_SetModState(seat->keyboard.pressed_modifiers | seat->keyboard.locked_modifiers);

View File

@@ -81,7 +81,9 @@
#define SDL_WL_COMPOSITOR_VERSION 4
#endif
#if SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
#define SDL_WL_SEAT_VERSION 10
#elif SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
#define SDL_WL_SEAT_VERSION 9
#elif SDL_WAYLAND_CHECK_VERSION(1, 21, 0)
#define SDL_WL_SEAT_VERSION 8