#include #include #include #include #include int main (int argc, char **argv) { int fd; char str[64]; struct input_event ie; struct tm *tm; if (argc!=2) { fprintf(stderr, "usage: %s /dev/input/eventX\n",argv[0]); exit(errno); } if ((fd=open(argv[1], O_RDONLY))<0) { fprintf(stderr, "%s: can't open device %s\n",argv[0],argv[1]); exit(errno); } for (;;) { read(fd, &ie, sizeof(ie)); tm = gmtime(&ie.time.tv_sec); strftime(str, 63, "%c", tm); printf("%s: %d, %d, %d\n", str, ie.type, ie.code, ie.value); } }