From 85ee6737d53c999e6b7f63456a83c0246e323591 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 19 Jan 2021 05:01:19 +1100 Subject: [PATCH] [client] x11: implement keyboard event handing via xinput --- client/displayservers/X11/x11.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index f2929e55..95629c60 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -108,6 +108,8 @@ static bool x11Init(SDL_SysWMinfo * info) XISetMask(mask[i].mask, XI_ButtonPress ); XISetMask(mask[i].mask, XI_ButtonRelease); XISetMask(mask[i].mask, XI_Motion ); + XISetMask(mask[i].mask, XI_KeyPress ); + XISetMask(mask[i].mask, XI_KeyRelease ); } XISelectEvents(x11.display, x11.window, mask, num_masks); @@ -208,6 +210,8 @@ static bool x11EventFilter(SDL_Event * event) return false; #if SDL_VIDEO_DRIVER_X11_XINPUT2 + case SDL_KEYDOWN: + case SDL_KEYUP: case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: @@ -292,6 +296,20 @@ static bool x11EventFilter(SDL_Event * event) switch(cookie->evtype) { + case XI_KeyPress: + { + XIDeviceEvent *device = cookie->data; + app_handleKeyPress(device->detail - 8); + return true; + } + + case XI_KeyRelease: + { + XIDeviceEvent *device = cookie->data; + app_handleKeyRelease(device->detail - 8); + return true; + } + case XI_ButtonPress: { XIDeviceEvent *device = cookie->data;