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:
1 parent
343ad3eddd
commit
b9ab8cf03d
3 files changed
+233
-73
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user