key combos for new input code
[libpicofe.git] / linux / in_evdev.c
index 984333c..3d0522c 100644 (file)
@@ -195,7 +195,7 @@ no_abs:
                ioctl(fd, EVIOCGNAME(sizeof(name)-6), name+6);
                printf("in_evdev: found \"%s\" with %d events (type %08x)\n",
                        name+6, count, support);
-               in_register(name, IN_DRVID_EVDEV, fd, dev);
+               in_register(name, IN_DRVID_EVDEV, fd, dev, 0);
                continue;
 
 skip:
@@ -306,14 +306,16 @@ static int in_evdev_update_keycode(void *data, int *is_down)
 
        rd = read(dev->fd, &ev, sizeof(ev));
        if (rd < (int) sizeof(ev)) {
-               perror("in_evdev: error reading");
-               sleep(1);
-               return 0;
+               if (errno != EAGAIN) {
+                       perror("in_evdev: error reading");
+                       sleep(1);
+               }
+               return -1;
        }
 
        if (ev.type == EV_KEY) {
                if (ev.value < 0 || ev.value > 1)
-                       return 0;
+                       return -1;
                if (is_down != NULL)
                        *is_down = ev.value;
                return ev.code;
@@ -349,7 +351,7 @@ static int in_evdev_update_keycode(void *data, int *is_down)
                }
        }
 
-       return 0;
+       return -1;
 }
 
 static int in_evdev_menu_translate(int keycode)
@@ -361,11 +363,18 @@ static int in_evdev_menu_translate(int keycode)
                case KEY_RIGHT: return PBTN_RIGHT;
                case KEY_ENTER:
                case BTN_A:
-               case BTN_TRIGGER: return PBTN_MOK;
+               case BTN_TRIGGER:
+                       return PBTN_MOK;
                case KEY_ESC:
                case BTN_B:
-               case BTN_THUMB: return PBTN_MBACK;
-               case KEY_MENU:  return PBTN_MENU;
+               case BTN_THUMB:
+                       return PBTN_MBACK;
+               case KEY_MENU:
+                       return PBTN_MENU;
+               case KEY_LEFTBRACE:
+                       return PBTN_L;
+               case KEY_RIGHTBRACE:
+                       return PBTN_R;
                default:        return 0;
        }
 }
@@ -376,8 +385,7 @@ static int in_evdev_get_key_code(const char *key_name)
 
        for (i = 0; i < KEY_MAX + 1; i++) {
                const char *k = in_evdev_keys[i];
-               if (k != NULL && k[0] == key_name[0] &&
-                               strcasecmp(k, key_name) == 0)
+               if (k != NULL && strcasecmp(k, key_name) == 0)
                        return i;
        }