aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
+}