git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: the correct way to detect ahci LBA48 support
[lunaix-os.git]
/
lunaix-os
/
kernel
/
demos
/
input_test.c
diff --git
a/lunaix-os/kernel/demos/input_test.c
b/lunaix-os/kernel/demos/input_test.c
index ebb93756d9e81d2beee9f908a38be6db48cf8331..47e0081190ca066fa035be7a7a8e7fac44e0281f 100644
(file)
--- a/
lunaix-os/kernel/demos/input_test.c
+++ b/
lunaix-os/kernel/demos/input_test.c
@@
-1,7
+1,9
@@
#include <lunaix/fctrl.h>
#include <lunaix/foptions.h>
#include <lunaix/input.h>
#include <lunaix/fctrl.h>
#include <lunaix/foptions.h>
#include <lunaix/input.h>
+#include <lunaix/lunaix.h>
#include <lunaix/lunistd.h>
#include <lunaix/lunistd.h>
+#include <ulibc/stdio.h>
#define STDIN 1
#define STDOUT 0
#define STDIN 1
#define STDOUT 0
@@
-12,21
+14,26
@@
input_test()
int fd = open("/dev/input/i8042-kbd", 0);
if (fd < 0) {
int fd = open("/dev/input/i8042-kbd", 0);
if (fd < 0) {
-
write(STDOUT, "fail to open", 13
);
+
printf("fail to open (%d)", geterrno()
);
return;
}
struct input_evt_pkt event;
while (read(fd, &event, sizeof(event)) > 0) {
return;
}
struct input_evt_pkt event;
while (read(fd, &event, sizeof(event)) > 0) {
+ char* action;
if (event.pkt_type == PKT_PRESS) {
if (event.pkt_type == PKT_PRESS) {
-
write(STDOUT, "PRESSED: ", 10)
;
+
action = "pressed"
;
} else {
} else {
-
write(STDOUT, "RELEASE: ", 10)
;
+
action = "release"
;
}
}
- char c = event.sys_code & 0xff;
- write(STDOUT, &c, 1);
- write(STDOUT, "\n", 2);
+
+ printf("%u: %s '%c', class=0x%x, scan=%x\n",
+ event.timestamp,
+ action,
+ event.sys_code & 0xff,
+ (event.sys_code & 0xff00) >> 8,
+ event.scan_code);
}
return;
}
\ No newline at end of file
}
return;
}
\ No newline at end of file