diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2015-01-29 22:16:59 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2015-01-29 22:16:59 +0000 |
commit | ed19352e642b99f5f0ade1b071c865cf85aea595 (patch) | |
tree | c314dc9880575597f1efa7a60c357711c56e3a4f | |
parent | 5cd50e60263353def3d7dc1f910f3a97c3bf8fd1 (diff) | |
download | c-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.tar.gz c-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.tar.xz c-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.zip |
event.c: evdev inspector
-rw-r--r-- | event.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software. It is licensed under version 3 of the + * GNU General Public License. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see [http://www.gnu.org/licenses/]. + */ +#include <linux/input.h> +#include <sys/time.h> +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + struct input_event *ie; + FILE *evdev; + + if (argc != 2) { + fprintf(stderr, "\aError: No evdev file.\n"); + exit(EXIT_FAILURE); + } + + ie = malloc(sizeof(struct input_event)); + evdev = fopen(argv[1], "r"); + + while (!feof(evdev)) { + fread(ie, 1, sizeof(struct input_event), evdev); + printf("Time: Sec: %d,\tUSec: %d,\tType: %d,\tCode: %d,\tValue: %d\n", + ie->time.tv_sec, ie->time.tv_usec, + ie->type, ie->code, ie->value); + } + + return EXIT_SUCCESS; +} |