aboutsummaryrefslogtreecommitdiffstats
path: root/event.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2015-01-29 22:16:59 +0000
committerTomasz Kramkowski <tk@the-tk.com>2015-01-29 22:16:59 +0000
commited19352e642b99f5f0ade1b071c865cf85aea595 (patch)
treec314dc9880575597f1efa7a60c357711c56e3a4f /event.c
parent5cd50e60263353def3d7dc1f910f3a97c3bf8fd1 (diff)
downloadc-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.tar.gz
c-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.tar.xz
c-stuff-ed19352e642b99f5f0ade1b071c865cf85aea595.zip
event.c: evdev inspector
Diffstat (limited to 'event.c')
-rw-r--r--event.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/event.c b/event.c
new file mode 100644
index 0000000..1ce1594
--- /dev/null
+++ b/event.c
@@ -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;
+}