3 #include <linux/input.h>
11 FILE *log = fopen("/var/log/keycount.log", "a");
12 struct input_event iev;
13 time_t start = time(NULL);
15 int fd = open("/dev/input/event0", O_RDONLY);
17 perror("/dev/input/event0");
22 int ret = read(fd, &iev, sizeof(iev));
24 if (ret != sizeof(iev)) {
29 if (iev.type != EV_KEY)
34 // see if we want to write out
36 if (now/60 != start/60) {
37 fprintf(log, "%u %u\n", (start/60)*60, count);