return xname;
}
-int in_bind_key(int dev_id, int keycode, int bind_type, int mask, int force_unbind)
+int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind)
{
int ret, count;
in_dev_t *dev;
return 0;
}
+void in_unbind_all(int dev_id, int act_mask, int bind_type)
+{
+ int i, count;
+ in_dev_t *dev;
+
+ if (dev_id < 0 || dev_id >= IN_MAX_DEVS || bind_type >= IN_BINDTYPE_COUNT)
+ return;
+
+ dev = &in_devices[dev_id];
+ count = dev->key_count;
+
+ if (dev->binds == NULL)
+ return;
+
+ for (i = 0; i < count; i++)
+ dev->binds[IN_BIND_OFFS(i, bind_type)] &= ~act_mask;
+}
+
/* returns device id, or -1 on error */
int in_config_parse_dev(const char *name)
{
static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx,\r
int sel, int dev_id, int dev_count, int is_bind)\r
{\r
+ char buff[64], buff2[32];\r
const char *dev_name;\r
int x, y, w, i;\r
\r
\r
x = g_screen_width / 2 - w / 2;\r
\r
- if (dev_count > 1) {\r
- text_out16(x, g_screen_height - 4 * me_mfont_h, "Viewing binds for:");\r
- text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name);\r
+ if (!is_bind) {\r
+ snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK));\r
+ snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2,\r
+ in_get_key_name(-1, -PBTN_MA2));\r
+ text_out16(x, g_screen_height - 4 * me_mfont_h, buff);\r
}\r
+ else\r
+ text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind");\r
\r
- if (is_bind)\r
- text_out16(x, g_screen_height - 2 * me_mfont_h, "Press a button to bind/unbind");\r
- else if (dev_count > 1)\r
+ if (dev_count > 1) {\r
+ text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name);\r
text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs");\r
+ }\r
\r
plat_video_menu_end();\r
}\r
{\r
int i, sel = 0, menu_sel_max = opt_cnt - 1;\r
int dev_id, dev_count, kc, is_down, mkey;\r
- int unbind, bindtype, mask;\r
+ int unbind, bindtype, mask_shift;\r
\r
for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {\r
if (in_get_dev_name(i, 1, 0) != NULL) {\r
return;\r
}\r
\r
+ mask_shift = 0;\r
+ if (player_idx == 1)\r
+ mask_shift = 16;\r
+ bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU;\r
+\r
for (;;)\r
{\r
draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);\r
- mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK, 100);\r
+ mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK|PBTN_MA2, 100);\r
switch (mkey) {\r
case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;\r
case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;\r
return;\r
while (in_menu_wait_any(30) & PBTN_MOK);\r
break;\r
+ case PBTN_MA2:\r
+ in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype);\r
+ continue;\r
default:continue;\r
}\r
\r
for (is_down = 1; is_down; )\r
kc = in_update_keycode(&dev_id, &is_down, -1);\r
\r
- bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU;\r
- mask = opts[sel].mask;\r
- if (player_idx == 1)\r
- mask <<= 16;\r
-\r
- i = count_bound_keys(dev_id, mask, bindtype);\r
+ i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype);\r
unbind = (i > 0);\r
\r
/* allow combos if device supports them */\r
in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS))\r
unbind = 0;\r
\r
- in_bind_key(dev_id, kc, bindtype, mask, unbind);\r
+ in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, unbind);\r
}\r
}\r
\r
static int menu_loop_keyconfig(menu_id id, int keys)\r
{\r
static int sel = 0;\r
+\r
+ me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded);\r
me_loop(e_menu_keyconfig, &sel);\r
return 0;\r
}\r