frontend/input: make it more modular
[pcsx_rearmed.git] / frontend / linux / in_evdev.c
index d33dbc5..445f8fd 100644 (file)
@@ -51,7 +51,8 @@ typedef struct {
 
 int in_evdev_allow_abs_only;
 
-static const char * const in_evdev_prefix = "evdev:";
+#define IN_EVDEV_PREFIX "evdev:"
+
 static const char * const in_evdev_keys[KEY_CNT] = {
        [0 ... KEY_MAX] = NULL,
        [KEY_RESERVED] = "Reserved",            [KEY_ESC] = "Esc",
@@ -246,11 +247,11 @@ no_abs:
                dev->fd = fd;
                dev->kc_first = kc_first;
                dev->kc_last = kc_last;
-               strcpy(name, in_evdev_prefix);
+               strcpy(name, IN_EVDEV_PREFIX);
                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, KEY_CNT, in_evdev_keys, 0);
+               in_register(name, fd, dev, KEY_CNT, in_evdev_keys, 0);
                continue;
 
 skip:
@@ -283,7 +284,7 @@ static void or_binds(const int *binds, int key, int *result)
 
 /* ORs result with binds of pressed buttons
  * XXX: should measure performance hit of this func, might need to optimize */
-int in_evdev_update(void *drv_data, const int *binds, int *result)
+static int in_evdev_update(void *drv_data, const int *binds, int *result)
 {
        struct input_event ev[16];
        struct input_absinfo ainfo;
@@ -538,43 +539,6 @@ static int in_evdev_menu_translate(void *drv_data, int keycode)
        return 0;
 }
 
-/* FIXME: move to plat */
-#if 0
-static const struct {
-       short code;
-       char btype;
-       char bit;
-} in_evdev_def_binds[] =
-{
-       /* MXYZ SACB RLDU */
-       { KEY_UP,       IN_BINDTYPE_PLAYER12, 0 },
-       { KEY_DOWN,     IN_BINDTYPE_PLAYER12, 1 },
-       { KEY_LEFT,     IN_BINDTYPE_PLAYER12, 2 },
-       { KEY_RIGHT,    IN_BINDTYPE_PLAYER12, 3 },
-       { KEY_S,        IN_BINDTYPE_PLAYER12, 4 },      /* B */
-       { KEY_D,        IN_BINDTYPE_PLAYER12, 5 },      /* C */
-       { KEY_A,        IN_BINDTYPE_PLAYER12, 6 },      /* A */
-       { KEY_ENTER,    IN_BINDTYPE_PLAYER12, 7 },
-       { KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU },
-       /* Pandora */
-       { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, 4 },
-       { KEY_END,      IN_BINDTYPE_PLAYER12, 5 },
-       { KEY_HOME,     IN_BINDTYPE_PLAYER12, 6 },
-       { KEY_LEFTALT,  IN_BINDTYPE_PLAYER12, 7 },
-       { KEY_RIGHTSHIFT,IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
-       { KEY_RIGHTCTRL, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
-       { KEY_LEFTCTRL,  IN_BINDTYPE_EMU, PEVB_MENU },
-       /* Caanoo */
-       { BTN_THUMB,    IN_BINDTYPE_PLAYER12, 4 },      /* B */
-       { BTN_THUMB2,   IN_BINDTYPE_PLAYER12, 5 },      /* C */
-       { BTN_TRIGGER,  IN_BINDTYPE_PLAYER12, 6 },      /* A */
-       { BTN_BASE3,    IN_BINDTYPE_PLAYER12, 7 },
-       { BTN_TOP2,     IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
-       { BTN_PINKIE,   IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
-       { BTN_BASE,     IN_BINDTYPE_EMU, PEVB_MENU },
-};
-#endif
-
 static void in_evdev_get_def_binds(int *binds)
 {
        int i;
@@ -623,18 +587,21 @@ static int in_evdev_clean_binds(void *drv_data, int *binds, int *def_binds)
        return count;
 }
 
-void in_evdev_init(void *vdrv)
+static const in_drv_t in_evdev_drv = {
+       .prefix         = IN_EVDEV_PREFIX,
+       .probe          = in_evdev_probe,
+       .free           = in_evdev_free,
+       .get_key_names  = in_evdev_get_key_names,
+       .get_def_binds  = in_evdev_get_def_binds,
+       .clean_binds    = in_evdev_clean_binds,
+       .set_config     = in_evdev_set_config,
+       .update         = in_evdev_update,
+       .update_keycode = in_evdev_update_keycode,
+       .menu_translate = in_evdev_menu_translate,
+};
+
+void in_evdev_init(void)
 {
-       in_drv_t *drv = vdrv;
-
-       drv->prefix = in_evdev_prefix;
-       drv->probe = in_evdev_probe;
-       drv->free = in_evdev_free;
-       drv->get_key_names = in_evdev_get_key_names;
-       drv->get_def_binds = in_evdev_get_def_binds;
-       drv->clean_binds = in_evdev_clean_binds;
-       drv->set_config = in_evdev_set_config;
-       drv->update_keycode = in_evdev_update_keycode;
-       drv->menu_translate = in_evdev_menu_translate;
+       in_register_driver(&in_evdev_drv);
 }