From 7ae487057f0f548ecc58a1aa07cf542cc56f95ed Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 17 Jan 2021 21:55:23 -0500 Subject: [PATCH] [client] wayland: implement key handling --- client/displayservers/Wayland/wayland.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/displayservers/Wayland/wayland.c b/client/displayservers/Wayland/wayland.c index d204e518..9618484d 100644 --- a/client/displayservers/Wayland/wayland.c +++ b/client/displayservers/Wayland/wayland.c @@ -22,6 +22,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include #include #include @@ -204,6 +205,10 @@ static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard, uint32_t serial, struct wl_surface * surface, struct wl_array * keys) { wm.keyboardEnterSerial = serial; + + uint32_t * key; + wl_array_for_each(key, keys) + app_handleKeyPress(*key); } static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard, @@ -215,7 +220,10 @@ static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard, static void keyboardKeyHandler(void * data, struct wl_keyboard * keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { - // Do nothing. + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) + app_handleKeyPress(key); + else + app_handleKeyRelease(key); } static void keyboardModifiersHandler(void * data, @@ -457,6 +465,8 @@ static bool waylandEventFilter(SDL_Event * event) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_MOUSEWHEEL: + case SDL_KEYDOWN: + case SDL_KEYUP: return true; }