From 9439f7b2f2877548da1b30352053ae25c47bd00f Mon Sep 17 00:00:00 2001 From: Oxore Date: Tue, 28 Feb 2023 22:23:48 +0300 Subject: Announce only really supported keys via UI_SET_KEYBIT By the way it fixes errors on sway that look like this: 00:00:32.178 [ERROR] [wlr] [libseat] [libseat/backend/logind.c:137] Could not take device: No such device 00:00:32.178 [ERROR] [wlr] [backend/session/session.c:321] Failed to open device: '/dev/input/event19': Resource temporarily unavailable --- main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 33bf1b1..5a8f558 100644 --- a/main.c +++ b/main.c @@ -192,8 +192,17 @@ static void setup_output_device(int fd) { * created, to pass key events, in this case the space key. */ ioctl(fd, UI_SET_EVBIT, EV_KEY); - for (ssize_t i = 1; i < KEY_MAX; i++) - ioctl(fd, UI_SET_KEYBIT, i); + for (ssize_t i = 1; i < MAPPINGS_NUM; i++) { + if (-1 == ioctl(fd, UI_SET_KEYBIT, g_mapping[i].code)) { + fprintf( + stderr, + "ioctl(%d, UI_SET_KEYBIT, %u) = -1, errno=%d: ", + fd, + g_mapping[i].code, + errno); + perror(""); + } + } struct uinput_setup usetup; memset(&usetup, 0, sizeof(usetup)); usetup.id.bustype = BUS_USB; -- cgit v1.2.3