feat: (iso9660) directory read support
[lunaix-os.git] / lunaix-os / kernel / demos / input_test.c
1 #include <lunaix/fctrl.h>
2 #include <lunaix/foptions.h>
3 #include <lunaix/input.h>
4 #include <lunaix/lunaix.h>
5 #include <lunaix/lunistd.h>
6 #include <ulibc/stdio.h>
7
8 #define STDIN 1
9 #define STDOUT 0
10
11 void
12 input_test()
13 {
14     int fd = open("/dev/input/i8042-kbd", 0);
15
16     if (fd < 0) {
17         printf("fail to open (%d)", geterrno());
18         return;
19     }
20
21     struct input_evt_pkt event;
22
23     while (read(fd, &event, sizeof(event)) > 0) {
24         char* action;
25         if (event.pkt_type == PKT_PRESS) {
26             action = "pressed";
27         } else {
28             action = "release";
29         }
30
31         printf("%u: %s '%c', class=0x%x, scan=%x\n",
32                event.timestamp,
33                action,
34                event.sys_code & 0xff,
35                (event.sys_code & 0xff00) >> 8,
36                event.scan_code);
37     }
38     return;
39 }