6 Commits

Author SHA1 Message Date
bb09cd8d9a Discard MSC_SCAN events
Given that only EV_KEY events are being mapped, without their scancode
counterparts, we just drop all scancode events to avoid having to map
them too, to syncing it with the corresponding mapped keys. This is
expected to be harmless.
2017-12-04 02:54:55 -02:00
0d88388a9e Add note about Ubuntu/Debian installation 2017-11-30 13:46:42 -02:00
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 19 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 ..
@ -58,6 +56,12 @@ I'm maintaining an Archlinux package on AUR:
- <https://aur.archlinux.org/packages/interception-caps2esc>
I don't use Ubuntu and recommend Archlinux instead, as it provides the AUR, so I
don't maintain PPAs. For more information on Ubuntu/Debian installation check
this:
- <https://askubuntu.com/questions/979359/how-do-i-install-caps2esc>
## Caveats
As always, there's always a caveat:

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) {
@ -37,6 +39,9 @@ int main(void) {
setbuf(stdin, NULL), setbuf(stdout, NULL);
while (read_event(&input)) {
if (input.type == EV_MSC && input.code == MSC_SCAN)
continue;
if (input.type != EV_KEY) {
write_event(&input);
continue;
@ -55,6 +60,8 @@ int main(void) {
continue;
}
write_event(&esc_down);
write_event(&syn);
usleep(20000);
write_event(&esc_up);
continue;
}
@ -62,6 +69,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;