the old-new win32 port
[libpicofe.git] / common / input.c
index b6df2ba..8950535 100644 (file)
@@ -6,6 +6,7 @@
 #include "plat.h"
 #include "../linux/in_evdev.h"
 #include "../gp2x/in_gp2x.h"
+#include "../win32/in_vk.h"
 
 typedef struct
 {
@@ -237,6 +238,7 @@ int in_update(int *result)
        for (i = 0; i < in_dev_count; i++) {
                in_dev_t *dev = &in_devices[i];
                if (dev->probed && dev->binds != NULL) {
+                       // FIXME: this is stupid, make it indirect
                        switch (dev->drv_id) {
 #ifdef IN_EVDEV
                        case IN_DRVID_EVDEV:
@@ -248,6 +250,9 @@ int in_update(int *result)
                                ret |= in_gp2x_update(dev->drv_data, dev->binds, result);
                                break;
 #endif
+                       case IN_DRVID_VK:
+                               ret |= in_vk_update(dev->drv_data, dev->binds, result);
+                               break;
                        }
                }
        }
@@ -718,7 +723,7 @@ void in_config_end(void)
        int i;
 
        for (i = 0; i < IN_MAX_DEVS; i++) {
-               int n, ret, count, *binds, *def_binds;
+               int n, t, ret, count, *binds, *def_binds;
                in_dev_t *dev = &in_devices[i];
 
                if (dev->binds == NULL)
@@ -728,9 +733,18 @@ void in_config_end(void)
                binds = dev->binds;
                def_binds = binds + count * IN_BINDTYPE_COUNT;
 
-               for (n = 0; n < count * IN_BINDTYPE_COUNT; n++)
-                       if (binds[n] == -1)
-                               binds[n] = def_binds[n];
+               for (n = 0; n < count; n++) {
+                       int is_default = 1;
+                       for (t = 0; t < IN_BINDTYPE_COUNT; t++)
+                               if (binds[IN_BIND_OFFS(n, t)] == -1)
+                                       binds[IN_BIND_OFFS(n, t)] = 0;
+                               else
+                                       is_default = 0;
+
+                       if (is_default)
+                               for (t = 0; t < IN_BINDTYPE_COUNT; t++)
+                                       binds[IN_BIND_OFFS(n, t)] = def_binds[IN_BIND_OFFS(n, t)];
+               }
 
                if (dev->drv_data == NULL)
                        continue;
@@ -799,6 +813,7 @@ void in_init(void)
 #ifdef IN_EVDEV
        in_evdev_init(&in_drivers[IN_DRVID_EVDEV]);
 #endif
+       in_vk_init(&in_drivers[IN_DRVID_VK]);
 }
 
 #if 0