key config adjustment
authornotaz <notasas@gmail.com>
Sun, 16 Sep 2007 21:56:45 +0000 (21:56 +0000)
committernotaz <notasas@gmail.com>
Sun, 16 Sep 2007 21:56:45 +0000 (21:56 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@251 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/menu.c
gp2x/version.h

index a8d1f9e..c416b63 100644 (file)
@@ -620,30 +620,38 @@ static char *action_binds(int player_idx, int action_mask)
        return strkeys;\r
 }\r
 \r
-static void unbind_action(int action)\r
+static void unbind_action(int action, int pl_idx)\r
 {\r
        int i, u;\r
 \r
-       for (i = 0; i < 32; i++)\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
        for (u = 0; u < 4; u++)\r
-               for (i = 0; i < 32; i++)\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
 \r
-static int count_bound_keys(int action, int joy)\r
+static int count_bound_keys(int action, int pl_idx, int joy)\r
 {\r
        int i, keys = 0;\r
 \r
        if (joy)\r
        {\r
-               for (i = 0; i < 32; i++)\r
+               for (i = 0; i < 32; i++) {\r
+                       if (pl_idx >= 0 && (currentConfig.JoyBinds[joy-1][i]&0x30000) != (pl_idx<<16)) continue;\r
                        if (currentConfig.JoyBinds[joy-1][i] & action) keys++;\r
+               }\r
        }\r
        else\r
        {\r
-               for (i = 0; i < 32; i++)\r
+               for (i = 0; i < 32; i++) {\r
+                       if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue;\r
                        if (currentConfig.KeyBinds[i] & action) keys++;\r
+               }\r
        }\r
        return keys;\r
 }\r
@@ -657,7 +665,7 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i
        gp2x_pd_clone_buffer2();\r
        if (player_idx >= 0) {\r
                text_out16(80, 20, "Player %i controls", player_idx + 1);\r
-               x = 100;\r
+               x = 80;\r
        } else {\r
                text_out16(80, 20, "Emulator controls");\r
                x = 40;\r
@@ -706,16 +714,16 @@ 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);\r
+                               unbind_action(opts[sel].mask, player_idx);\r
                        prev_select = inp & GP2X_SELECT;\r
                        inp &= CONFIGURABLE_KEYS;\r
                        inp &= ~GP2X_SELECT;\r
                        for (i = 0; i < 32; i++)\r
                                if (inp & (1 << i)) {\r
-                                       if (count_bound_keys(opts[sel].mask, 0) >= 2)\r
+                                       if (count_bound_keys(opts[sel].mask, player_idx, 0) >= 2)\r
                                             currentConfig.KeyBinds[i] &= ~opts[sel].mask; // allow to unbind only\r
                                        else currentConfig.KeyBinds[i] ^=  opts[sel].mask;\r
-                                       if (player_idx >= 0) {\r
+                                       if (player_idx >= 0 && currentConfig.KeyBinds[i] & opts[sel].mask) {\r
                                                currentConfig.KeyBinds[i] &= ~(3 << 16);\r
                                                currentConfig.KeyBinds[i] |= player_idx << 16;\r
                                        }\r
@@ -725,10 +733,10 @@ 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, joy) >= 1) // disallow combos for usbjoy\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) {\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
                                        }\r
@@ -1231,7 +1239,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);\r
+               unbind_action(0xf00, -1);\r
        }\r
        scaling_update();\r
 }\r
index a3ccbd3..93ee956 100644 (file)
@@ -1,2 +1,2 @@
-#define VERSION "1.33"\r
+#define VERSION "1.34"\r
 \r