X-Git-Url: http://git.scottworley.com/keystroke-timestamps/blobdiff_plain/924be5081f9b06849ac0624f3af4a3ea7bc7ff12..e39f0d25119206ea7412331a24f49911f530a6bd:/keystroke-timestamps.c diff --git a/keystroke-timestamps.c b/keystroke-timestamps.c index 670b43c..7c82a65 100644 --- a/keystroke-timestamps.c +++ b/keystroke-timestamps.c @@ -1,13 +1,18 @@ +#include #include +#include #include +#include #include -#include int main () { struct input_event i; int fd = open("/dev/input/by-path/platform-i8042-serio-0-event-kbd", O_RDONLY); - while (fd && read(fd, &i, sizeof(i)) == sizeof(i)) { + if (fd < 0) { + err(EX_NOINPUT, "Could not open keyboard event file"); + } + while (read(fd, &i, sizeof(i)) == sizeof(i)) { if (i.type == 1 && i.value == 1) { printf("%ld.%ld\n", i.time.tv_sec, i.time.tv_usec); fflush(stdout);