]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_keys.c
mt_server: Use "%s" format string in syslog()
[coffee/mt-apps.git] / mt_keys.c
index 9b1dcadf03beb8651cd74fb5c3c6ec38f91793f0..015b8ae0095d34eb901e97ff7a9f4101d2cdb655 100644 (file)
--- a/mt_keys.c
+++ b/mt_keys.c
@@ -12,8 +12,6 @@
 
 static void keys_cb(EV_P_ ev_io *w_, int revents)
 {
-    static char *type = "keys";
-
     ev_io_keys *w = (ev_io_keys *)w_;
     int fd = w->fd;
     struct input_event ev;
@@ -87,22 +85,24 @@ static void keys_cb(EV_P_ ev_io *w_, int revents)
                 break;
             default:
                 fprintf(stderr, "unsupported event code: %d\n", ev.code);
-                return;
+               key = '?';
+                //return;
         }
 
-        JSON_START();
-        JSON_STR(type);
-        JSON_NEXT();
-        JSON_CHAR(key);
-        JSON_END();
+       keys_json_print(fd, key);
     }
 }
 
 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);
-    if (fd == -1) {
-        perror("/dev/input/by-path/platform-gpio-keys-event");
+    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);
         return -1;
     }