commit 27efcbbf962b340724674c8fb0403514a9afedf1
parent 6fa3ad14b384fe2684753a3bec019de8dedfb9be
Author: Francisco Lopes <francisco@oblita.com>
Date: Wed, 29 Nov 2017 23:58:56 -0200
Fix #4: Correctly follows evdev protocol
SYN events and different event timestamps are necessary for sending
sequential key events of the same key.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/caps2esc.c b/caps2esc.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <linux/input.h>
// clang-format off
@@ -13,7 +14,8 @@ ctrl_down = {.type = EV_KEY, .code = KEY_LEFTCTRL, .value = 1},
capslock_down = {.type = EV_KEY, .code = KEY_CAPSLOCK, .value = 1},
esc_repeat = {.type = EV_KEY, .code = KEY_ESC, .value = 2},
ctrl_repeat = {.type = EV_KEY, .code = KEY_LEFTCTRL, .value = 2},
-capslock_repeat = {.type = EV_KEY, .code = KEY_CAPSLOCK, .value = 2};
+capslock_repeat = {.type = EV_KEY, .code = KEY_CAPSLOCK, .value = 2},
+syn = {.type = EV_SYN, .code = SYN_REPORT, .value = 0};
// clang-format on
int equal(const struct input_event *first, const struct input_event *second) {
@@ -55,6 +57,8 @@ int main(void) {
continue;
}
write_event(&esc_down);
+ write_event(&syn);
+ usleep(20000);
write_event(&esc_up);
continue;
}