Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 9217cea

Browse files
author
Francisco Lopes
committed
Fix backports
1 parent 02bd1f4 commit 9217cea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

caps2esc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ int equal(const struct input_event *first, const struct input_event *second) {
4141
int eventmap(const struct input_event *input, struct input_event output[]) {
4242
static int capslock_is_down = 0, esc_give_up = 0;
4343

44+
if (input->type == EV_MSC && input->code == MSC_SCAN)
45+
return 0;
46+
4447
if (input->type != EV_KEY) {
4548
output[0] = *input;
4649
return 1;
@@ -137,10 +140,17 @@ int eventmap_loop(const char *devnode) {
137140
break;
138141

139142
struct input_event output[2];
140-
for (int i = 0, k = eventmap(&input, output); i < k; ++i)
143+
for (int i = 0, k = eventmap(&input, output); i != k; ++i) {
141144
if (libevdev_uinput_write_event(
142145
udev, output[i].type, output[i].code, output[i].value) < 0)
143146
goto teardown_udev;
147+
if (i + 1 != k) {
148+
if (libevdev_uinput_write_event(udev, EV_SYN, SYN_REPORT, 0) <
149+
0)
150+
goto teardown_udev;
151+
usleep(20000);
152+
}
153+
}
144154
}
145155

146156
result = 1;

0 commit comments

Comments
 (0)