summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-02-28 22:23:48 +0300
committerOxore <oxore@protonmail.com>2023-02-28 22:25:26 +0300
commit9439f7b2f2877548da1b30352053ae25c47bd00f (patch)
treef98c80790db68baf7b8d9f720c8e2b7fb1ef2387 /main.c
parentb2392ac420943fdbae7c3de118b7e250535d89d5 (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
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files 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;