summaryrefslogtreecommitdiff
path: root/intcp/resc/intcp/main.c
blob: 02dbd3151cd3ca42a71c14344a7e56cfb8686a4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>

int main(void) {
    setbuf(stdin, NULL); setbuf(stdout, NULL);

    struct input_event event;
    while (fread(&event, sizeof(event), 1, stdin)) {
        if (event.type == EV_KEY) {
            switch (event.code) {
                case KEY_CAPSLOCK:
                    event.code = KEY_LEFTCTRL;
                    break;
                case KEY_LEFTALT:
                    event.code = KEY_LEFTMETA;
                    break;
                case KEY_102ND:
                    event.code = KEY_RIGHTALT;
                    break;
            }
        }

        fwrite(&event, sizeof(event), 1, stdout);
    }
}