Skip to content

Commit

Permalink
Fix oblitum#4: Correctly follows evdev protocol
Browse files Browse the repository at this point in the history
SYN events and different event timestamps are necessary for sending
sequential key events of the same key.
  • Loading branch information
Francisco Lopes committed Nov 30, 2017
1 parent 6fa3ad1 commit 27efcbb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion caps2esc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>

#include <unistd.h>
#include <linux/input.h>

// clang-format off
Expand All @@ -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) {
Expand Down Expand Up @@ -55,6 +57,8 @@ int main(void) {
continue;
}
write_event(&esc_down);
write_event(&syn);
usleep(20000);
write_event(&esc_up);
continue;
}
Expand Down

0 comments on commit 27efcbb

Please sign in to comment.