4 Commits

Author SHA1 Message Date
9f353f96c6 Another evdev protocol infringement
Even though Peter Hutterer commented that it's not technically needed to
send SYN/delay when the sequence of events is of different keys, it
seems to be shown necessary to do so, otherwise events are dropped in
random situations.
2017-11-30 01:58:02 -02:00
27efcbbf96 Fix #4: Correctly follows evdev protocol
SYN events and different event timestamps are necessary for sending
sequential key events of the same key.
2017-11-29 23:59:07 -02:00
6fa3ad14b3 Fix README build instructions 2017-11-24 13:33:03 -02:00
40137670a4 Fix link 2017-08-13 14:25:50 -03:00
2 changed files with 10 additions and 6 deletions

View File

@ -4,9 +4,7 @@ _Transforming the most useless key **ever** in the most useful one._
<sub>_For vi/Vim/NeoVim addicts at least_.</sub>
<a href="http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/">
![ADM-3A terminal](http://www.catonmat.net/images/why-vim-uses-hjkl/lsi-adm3a-full-keyboard.jpg)
<img src="http://www.catonmat.net/images/why-vim-uses-hjkl/lsi-adm3a-full-keyboard.jpg" alt="ADM-3A terminal">
</a>
## What is it?
@ -28,8 +26,8 @@ ESC when pressed alone is quite handy, specially in vi.
## Building
```
$ git clone git@gitlab.com:interception/linux/tools.git
$ cd tools
$ git clone git@gitlab.com:interception/linux/plugins/caps2esc.git
$ cd caps2esc
$ mkdir build
$ cd build
$ cmake ..

View File

@ -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;
}
@ -62,6 +66,8 @@ int main(void) {
if (!esc_give_up && input.value) {
esc_give_up = 1;
write_event(&ctrl_down);
write_event(&syn);
usleep(20000);
}
} else if (equal(&input, &capslock_down)) {
capslock_is_down = 1;