From 975bb742841244141012c05e0c624672160af3e0 Mon Sep 17 00:00:00 2001 From: Francisco Lopes Date: Fri, 1 Jan 2021 00:18:03 -0300 Subject: [PATCH] Passthrough mouse events To not block mice that have keys, which end up grabbed due to generic configurations that simply filter anything that responds to CAPSLOCK/ESC. Fixes #15 --- caps2esc.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/caps2esc.c b/caps2esc.c index c2c5cba..0dea153 100644 --- a/caps2esc.c +++ b/caps2esc.c @@ -46,25 +46,23 @@ void write_event(const struct input_event *event) { } void write_event_with_mode(struct input_event *event, int mode) { - if (event->type == EV_REL || event->type == EV_ABS) - return; - - switch (mode) { - case 0: - if (event->code == KEY_ESC) - event->code = KEY_CAPSLOCK; - break; - case 2: - switch (event->code) { - case KEY_ESC: - event->code = KEY_GRAVE; - break; - case KEY_GRAVE: + if (event->type == EV_KEY) + switch (mode) { + case 0: + if (event->code == KEY_ESC) event->code = KEY_CAPSLOCK; - break; - } - break; - } + break; + case 2: + switch (event->code) { + case KEY_ESC: + event->code = KEY_GRAVE; + break; + case KEY_GRAVE: + event->code = KEY_CAPSLOCK; + break; + } + break; + } write_event(event); }