mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
menu: make key config more intuitive
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@916 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
0e20e9bd12
commit
67b7b971a0
2 changed files with 47 additions and 35 deletions
|
@ -84,7 +84,7 @@ static void keys_write(FILE *fn, const char *bind_str, int dev_id, const int *bi
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
|
for (i = 0; me_ctrl_actions[i].name != NULL; i++) {
|
||||||
mask = me_ctrl_actions[i].mask;
|
mask = me_ctrl_actions[i].mask;
|
||||||
if (mask & binds[IN_BIND_OFFS(k, IN_BINDTYPE_PLAYER12)]) {
|
if (mask & binds[IN_BIND_OFFS(k, IN_BINDTYPE_PLAYER12)]) {
|
||||||
strncpy(act, me_ctrl_actions[i].name, 31);
|
strncpy(act, me_ctrl_actions[i].name, 31);
|
||||||
|
@ -576,7 +576,7 @@ static int parse_bind_val(const char *val, int *type)
|
||||||
shift = 16;
|
shift = 16;
|
||||||
|
|
||||||
*type = IN_BINDTYPE_PLAYER12;
|
*type = IN_BINDTYPE_PLAYER12;
|
||||||
for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
|
for (i = 0; me_ctrl_actions[i].name != NULL; i++) {
|
||||||
if (strncasecmp(me_ctrl_actions[i].name, val + 8, strlen(val + 8)) == 0)
|
if (strncasecmp(me_ctrl_actions[i].name, val + 8, strlen(val + 8)) == 0)
|
||||||
return me_ctrl_actions[i].mask << shift;
|
return me_ctrl_actions[i].mask << shift;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1039,18 +1039,11 @@ static int menu_loop_savestate(int is_loading)
|
||||||
|
|
||||||
static char *action_binds(int player_idx, int action_mask, int dev_id)
|
static char *action_binds(int player_idx, int action_mask, int dev_id)
|
||||||
{
|
{
|
||||||
int k, count = 0, can_combo = 0, type;
|
int dev = 0, dev_last = IN_MAX_DEVS - 1;
|
||||||
const int *binds;
|
int can_combo = 1, type;
|
||||||
|
|
||||||
static_buff[0] = 0;
|
static_buff[0] = 0;
|
||||||
|
|
||||||
binds = in_get_dev_binds(dev_id);
|
|
||||||
if (binds == NULL)
|
|
||||||
return static_buff;
|
|
||||||
|
|
||||||
in_get_config(dev_id, IN_CFG_BIND_COUNT, &count);
|
|
||||||
in_get_config(dev_id, IN_CFG_DOES_COMBOS, &can_combo);
|
|
||||||
|
|
||||||
type = IN_BINDTYPE_EMU;
|
type = IN_BINDTYPE_EMU;
|
||||||
if (player_idx >= 0) {
|
if (player_idx >= 0) {
|
||||||
can_combo = 0;
|
can_combo = 0;
|
||||||
|
@ -1059,22 +1052,37 @@ static char *action_binds(int player_idx, int action_mask, int dev_id)
|
||||||
if (player_idx == 1)
|
if (player_idx == 1)
|
||||||
action_mask <<= 16;
|
action_mask <<= 16;
|
||||||
|
|
||||||
for (k = 0; k < count; k++)
|
if (dev_id >= 0)
|
||||||
{
|
dev = dev_last = dev_id;
|
||||||
const char *xname;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!(binds[IN_BIND_OFFS(k, type)] & action_mask))
|
for (; dev <= dev_last; dev++) {
|
||||||
|
int k, count = 0, combo = 0;
|
||||||
|
const int *binds;
|
||||||
|
|
||||||
|
binds = in_get_dev_binds(dev);
|
||||||
|
if (binds == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xname = in_get_key_name(dev_id, k);
|
in_get_config(dev, IN_CFG_BIND_COUNT, &count);
|
||||||
len = strlen(static_buff);
|
in_get_config(dev, IN_CFG_DOES_COMBOS, &combo);
|
||||||
if (len) {
|
combo = combo && can_combo;
|
||||||
strncat(static_buff, can_combo ? " + " : ", ",
|
|
||||||
sizeof(static_buff) - len - 1);
|
for (k = 0; k < count; k++) {
|
||||||
len += can_combo ? 3 : 2;
|
const char *xname;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (!(binds[IN_BIND_OFFS(k, type)] & action_mask))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xname = in_get_key_name(dev, k);
|
||||||
|
len = strlen(static_buff);
|
||||||
|
if (len) {
|
||||||
|
strncat(static_buff, combo ? " + " : ", ",
|
||||||
|
sizeof(static_buff) - len - 1);
|
||||||
|
len += combo ? 3 : 2;
|
||||||
|
}
|
||||||
|
strncat(static_buff, xname, sizeof(static_buff) - len - 1);
|
||||||
}
|
}
|
||||||
strncat(static_buff, xname, sizeof(static_buff) - len - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_buff;
|
return static_buff;
|
||||||
|
@ -1126,7 +1134,10 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
text_out16(x, y, "%s : %s", opts[i].name,
|
text_out16(x, y, "%s : %s", opts[i].name,
|
||||||
action_binds(player_idx, opts[i].mask, dev_id));
|
action_binds(player_idx, opts[i].mask, dev_id));
|
||||||
|
|
||||||
dev_name = in_get_dev_name(dev_id, 1, 1);
|
if (dev_id < 0)
|
||||||
|
dev_name = "(all devices)";
|
||||||
|
else
|
||||||
|
dev_name = in_get_dev_name(dev_id, 1, 1);
|
||||||
w = strlen(dev_name) * me_mfont_w;
|
w = strlen(dev_name) * me_mfont_w;
|
||||||
if (w < 30 * me_mfont_w)
|
if (w < 30 * me_mfont_w)
|
||||||
w = 30 * me_mfont_w;
|
w = 30 * me_mfont_w;
|
||||||
|
@ -1155,7 +1166,7 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)
|
static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)
|
||||||
{
|
{
|
||||||
int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0;
|
int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0;
|
||||||
int dev_id, dev_count, kc, is_down, mkey;
|
int dev_id, bind_dev_id, dev_count, kc, is_down, mkey;
|
||||||
int unbind, bindtype, mask_shift;
|
int unbind, bindtype, mask_shift;
|
||||||
|
|
||||||
for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {
|
for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {
|
||||||
|
@ -1171,6 +1182,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev_id = -1; // show all
|
||||||
mask_shift = 0;
|
mask_shift = 0;
|
||||||
if (player_idx == 1)
|
if (player_idx == 1)
|
||||||
mask_shift = 16;
|
mask_shift = 16;
|
||||||
|
@ -1184,18 +1196,18 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;
|
case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;
|
||||||
case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;
|
case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;
|
||||||
case PBTN_LEFT:
|
case PBTN_LEFT:
|
||||||
for (i = 0, dev_id--; i < IN_MAX_DEVS; i++, dev_id--) {
|
for (i = 0, dev_id--; i < IN_MAX_DEVS + 1; i++, dev_id--) {
|
||||||
if (dev_id < 0)
|
if (dev_id < -1)
|
||||||
dev_id = IN_MAX_DEVS - 1;
|
dev_id = IN_MAX_DEVS - 1;
|
||||||
if (in_get_dev_name(dev_id, 1, 0) != NULL)
|
if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case PBTN_RIGHT:
|
case PBTN_RIGHT:
|
||||||
for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) {
|
for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) {
|
||||||
if (dev_id >= IN_MAX_DEVS)
|
if (dev_id >= IN_MAX_DEVS)
|
||||||
dev_id = 0;
|
dev_id = -1;
|
||||||
if (in_get_dev_name(dev_id, 1, 0) != NULL)
|
if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1217,20 +1229,20 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
|
|
||||||
/* wait for some up event */
|
/* wait for some up event */
|
||||||
for (is_down = 1; is_down; )
|
for (is_down = 1; is_down; )
|
||||||
kc = in_update_keycode(&dev_id, &is_down, -1);
|
kc = in_update_keycode(&bind_dev_id, &is_down, -1);
|
||||||
|
|
||||||
i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype);
|
i = count_bound_keys(bind_dev_id, opts[sel].mask << mask_shift, bindtype);
|
||||||
unbind = (i > 0);
|
unbind = (i > 0);
|
||||||
|
|
||||||
/* allow combos if device supports them */
|
/* allow combos if device supports them */
|
||||||
in_get_config(dev_id, IN_CFG_DOES_COMBOS, &does_combos);
|
in_get_config(bind_dev_id, IN_CFG_DOES_COMBOS, &does_combos);
|
||||||
if (i == 1 && bindtype == IN_BINDTYPE_EMU && does_combos)
|
if (i == 1 && bindtype == IN_BINDTYPE_EMU && does_combos)
|
||||||
unbind = 0;
|
unbind = 0;
|
||||||
|
|
||||||
if (unbind)
|
if (unbind)
|
||||||
in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype);
|
in_unbind_all(bind_dev_id, opts[sel].mask << mask_shift, bindtype);
|
||||||
|
|
||||||
in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0);
|
in_bind_key(bind_dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue