]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/commitdiff
Allow using different input event source
authorMichal Sojka <michal.sojka@cvut.cz>
Mon, 6 Aug 2018 11:55:27 +0000 (13:55 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Mon, 6 Aug 2018 11:55:44 +0000 (13:55 +0200)
Useful for testing on different hardware (e.g. my laptop).

mt_keys.c

index a2093405866ff56d4ee80737a659d637dc31e451..5d4145e30ee16775f9d0e218518af4f54edff5c3 100644 (file)
--- a/mt_keys.c
+++ b/mt_keys.c
@@ -100,9 +100,14 @@ static void keys_cb(EV_P_ ev_io *w_, int revents)
 
 int mt_keys_init(mt_keys_t *self, struct ev_loop *loop, int fd)
 {
-    int ev = open("/dev/input/by-path/platform-gpio-keys-event", O_RDONLY);
+    char *dev = getenv("INPUT");
+
+    if (!dev)
+       dev = "/dev/input/by-path/platform-gpio-keys-event";
+
+    int ev = open(dev, O_RDONLY);
     if (ev == -1) {
-        perror("/dev/input/by-path/platform-gpio-keys-event");
+        perror(dev);
         return -1;
     }