]>
git.scottworley.com Git - keystroke-timestamps/blob - keystroke-timestamps.c
2ab4c42938a2cb3177bd1f00c1a2f413d8ba712c
4 #include <linux/input.h>
11 int main (int argc
, char **argv
)
14 struct option long_options
[] = {
15 {"usec", no_argument
, &print_usec
, 1 },
19 int c
= getopt_long(argc
, argv
, "", long_options
, NULL
);
21 if (c
!= 0) exit(EX_USAGE
);
24 int fd
= open("/dev/input/by-path/platform-i8042-serio-0-event-kbd", O_RDONLY
);
26 err(EX_NOINPUT
, "Could not open keyboard event file");
29 while (read(fd
, &i
, sizeof(i
)) == sizeof(i
)) {
30 if (i
.type
== 1 && i
.value
== 1) {
32 printf("%ld.%ld\n", i
.time
.tv_sec
, i
.time
.tv_usec
);
34 printf("%ld\n", i
.time
.tv_sec
);