]> git.scottworley.com Git - keystroke-timestamps/commitdiff
Initial version
authorScott Worley <scottworley@scottworley.com>
Wed, 4 Sep 2013 18:04:37 +0000 (11:04 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 4 Sep 2013 18:04:37 +0000 (11:04 -0700)
keystroke-timestamps.c [new file with mode: 0644]

diff --git a/keystroke-timestamps.c b/keystroke-timestamps.c
new file mode 100644 (file)
index 0000000..670b43c
--- /dev/null
@@ -0,0 +1,17 @@
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+
+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 (i.type == 1 && i.value == 1) {
+      printf("%ld.%ld\n", i.time.tv_sec, i.time.tv_usec);
+      fflush(stdout);
+    }
+  }
+  return 0;
+}