control configurator adjustments
authornotaz <notasas@gmail.com>
Mon, 17 Sep 2007 19:35:47 +0000 (19:35 +0000)
committernotaz <notasas@gmail.com>
Mon, 17 Sep 2007 19:35:47 +0000 (19:35 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@252 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/menu.c

index c416b63..1a67e43 100644 (file)
@@ -617,22 +617,38 @@ static char *action_binds(int player_idx, int action_mask)
                }\r
        }\r
 \r
+       // limit..\r
+       strkeys[20] = 0;\r
+\r
        return strkeys;\r
 }\r
 \r
-static void unbind_action(int action, int pl_idx)\r
+static void unbind_action(int action, int pl_idx, int joy)\r
 {\r
        int i, u;\r
 \r
-       for (i = 0; i < 32; i++) {\r
-               if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue;\r
-               currentConfig.KeyBinds[i] &= ~action;\r
+       if (joy <= 0)\r
+       {\r
+               for (i = 0; i < 32; i++) {\r
+                       if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue;\r
+                       currentConfig.KeyBinds[i] &= ~action;\r
+               }\r
        }\r
-       for (u = 0; u < 4; u++)\r
+       if (joy < 0)\r
+       {\r
+               for (u = 0; u < 4; u++)\r
+                       for (i = 0; i < 32; i++) {\r
+                               if (pl_idx >= 0 && (currentConfig.JoyBinds[u][i]&0x30000) != (pl_idx<<16)) continue;\r
+                               currentConfig.JoyBinds[u][i] &= ~action;\r
+                       }\r
+       }\r
+       else if (joy > 0)\r
+       {\r
                for (i = 0; i < 32; i++) {\r
-                       if (pl_idx >= 0 && (currentConfig.JoyBinds[u][i]&0x30000) != (pl_idx<<16)) continue;\r
-                       currentConfig.JoyBinds[u][i] &= ~action;\r
+                       if (pl_idx >= 0 && (currentConfig.JoyBinds[joy-1][i]&0x30000) != (pl_idx<<16)) continue;\r
+                       currentConfig.JoyBinds[joy-1][i] &= ~action;\r
                }\r
+       }\r
 }\r
 \r
 static int count_bound_keys(int action, int pl_idx, int joy)\r
@@ -714,7 +730,7 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i
                        }\r
                        // if we are here, we want to bind/unbind something\r
                        if ((inp & GP2X_SELECT) && !prev_select)\r
-                               unbind_action(opts[sel].mask, player_idx);\r
+                               unbind_action(opts[sel].mask, player_idx, -1);\r
                        prev_select = inp & GP2X_SELECT;\r
                        inp &= CONFIGURABLE_KEYS;\r
                        inp &= ~GP2X_SELECT;\r
@@ -733,12 +749,14 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i
                {\r
                        for (i = 0; i < 32; i++)\r
                                if (inp & (1 << i)) {\r
-                                       if (count_bound_keys(opts[sel].mask, player_idx, joy) >= 1) // disallow combos for usbjoy\r
-                                            currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask;\r
-                                       else currentConfig.JoyBinds[joy-1][i] ^=  opts[sel].mask;\r
-                                       if (player_idx >= 0 && currentConfig.JoyBinds[joy-1][i] & opts[sel].mask) {\r
-                                               currentConfig.JoyBinds[joy-1][i] &= ~(3 << 16);\r
-                                               currentConfig.JoyBinds[joy-1][i] |= player_idx << 16;\r
+                                       int *bind = &currentConfig.JoyBinds[joy-1][i];\r
+                                       if ((*bind & opts[sel].mask) && (player_idx < 0 || player_idx == ((*bind>>16)&3)))\r
+                                               currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask;\r
+                                       else {\r
+                                               // override\r
+                                               unbind_action(opts[sel].mask, player_idx, joy);\r
+                                               *bind = opts[sel].mask;\r
+                                               if (player_idx >= 0) *bind |= player_idx << 16;\r
                                        }\r
                                }\r
                }\r
@@ -1239,7 +1257,7 @@ static void menu_options_save(void)
        PicoRegionOverride = currentConfig.PicoRegion;\r
        if (!(PicoOpt & 0x20)) {\r
                // unbind XYZ MODE, just in case\r
-               unbind_action(0xf00, -1);\r
+               unbind_action(0xf00, -1, -1);\r
        }\r
        scaling_update();\r
 }\r