diff options
author | Oxore <oxore@protonmail.com> | 2023-02-28 22:23:48 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-02-28 22:25:26 +0300 |
commit | 9439f7b2f2877548da1b30352053ae25c47bd00f (patch) | |
tree | f98c80790db68baf7b8d9f720c8e2b7fb1ef2387 | |
parent | b2392ac420943fdbae7c3de118b7e250535d89d5 (diff) |
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
-rw-r--r-- | main.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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; |