]>
git.scottworley.com Git - keystroke-timestamps/blob - keystroke-timestamps.c
693560025031b7a521cde6a196b145e90be07ce3
4 #include <linux/input.h>
11 int main (int argc
, char **argv
)
14 char* device
= strdup("/dev/input/by-path/platform-i8042-serio-0-event-kbd");
15 struct option long_options
[] = {
16 {"device", required_argument
, 0, 'd' },
17 {"usec", no_argument
, &print_usec
, 1 },
21 int c
= getopt_long(argc
, argv
, "", long_options
, NULL
);
25 device
= strdup(optarg
);
28 if (c
!= 0) exit(EX_USAGE
);
31 int fd
= open(device
, O_RDONLY
);
33 err(EX_NOINPUT
, "Could not open keyboard event file");
37 while (read(fd
, &i
, sizeof(i
)) == sizeof(i
)) {
38 if (i
.type
== 1 && i
.value
== 1) {
40 printf("%ld.%06ld\n", i
.time
.tv_sec
, i
.time
.tv_usec
);
42 printf("%ld\n", i
.time
.tv_sec
);