mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
clear binds feature
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@715 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
45deb4099e
commit
92068389d8
3 changed files with 46 additions and 17 deletions
|
@ -530,7 +530,7 @@ const char *in_get_key_name(int dev_id, int keycode)
|
||||||
return xname;
|
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;
|
int ret, count;
|
||||||
in_dev_t *dev;
|
in_dev_t *dev;
|
||||||
|
@ -567,6 +567,24 @@ int in_bind_key(int dev_id, int keycode, int bind_type, int mask, int force_unbi
|
||||||
return 0;
|
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 */
|
/* returns device id, or -1 on error */
|
||||||
int in_config_parse_dev(const char *name)
|
int in_config_parse_dev(const char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,7 +101,8 @@ void in_config_start(void);
|
||||||
int in_config_parse_dev(const char *dev_name);
|
int in_config_parse_dev(const char *dev_name);
|
||||||
int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type);
|
int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type);
|
||||||
void in_config_end(void);
|
void in_config_end(void);
|
||||||
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);
|
||||||
|
void in_unbind_all(int dev_id, int act_mask, int bind_type);
|
||||||
void in_debug_dump(void);
|
void in_debug_dump(void);
|
||||||
|
|
||||||
const int *in_get_dev_binds(int dev_id);
|
const int *in_get_dev_binds(int dev_id);
|
||||||
|
|
|
@ -1151,6 +1151,7 @@ static int count_bound_keys(int dev_id, int action_mask, int bindtype)
|
||||||
static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx,
|
static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx,
|
||||||
int sel, int dev_id, int dev_count, int is_bind)
|
int sel, int dev_id, int dev_count, int is_bind)
|
||||||
{
|
{
|
||||||
|
char buff[64], buff2[32];
|
||||||
const char *dev_name;
|
const char *dev_name;
|
||||||
int x, y, w, i;
|
int x, y, w, i;
|
||||||
|
|
||||||
|
@ -1182,15 +1183,19 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
|
|
||||||
x = g_screen_width / 2 - w / 2;
|
x = g_screen_width / 2 - w / 2;
|
||||||
|
|
||||||
if (dev_count > 1) {
|
if (!is_bind) {
|
||||||
text_out16(x, g_screen_height - 4 * me_mfont_h, "Viewing binds for:");
|
snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK));
|
||||||
text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name);
|
snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2,
|
||||||
|
in_get_key_name(-1, -PBTN_MA2));
|
||||||
|
text_out16(x, g_screen_height - 4 * me_mfont_h, buff);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind");
|
||||||
|
|
||||||
if (is_bind)
|
if (dev_count > 1) {
|
||||||
text_out16(x, g_screen_height - 2 * me_mfont_h, "Press a button to bind/unbind");
|
text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name);
|
||||||
else if (dev_count > 1)
|
|
||||||
text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs");
|
text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs");
|
||||||
|
}
|
||||||
|
|
||||||
plat_video_menu_end();
|
plat_video_menu_end();
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1204,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
{
|
{
|
||||||
int i, sel = 0, menu_sel_max = opt_cnt - 1;
|
int i, sel = 0, menu_sel_max = opt_cnt - 1;
|
||||||
int dev_id, dev_count, kc, is_down, mkey;
|
int dev_id, dev_count, kc, is_down, mkey;
|
||||||
int unbind, bindtype, mask;
|
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++) {
|
||||||
if (in_get_dev_name(i, 1, 0) != NULL) {
|
if (in_get_dev_name(i, 1, 0) != NULL) {
|
||||||
|
@ -1214,10 +1219,15 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mask_shift = 0;
|
||||||
|
if (player_idx == 1)
|
||||||
|
mask_shift = 16;
|
||||||
|
bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);
|
draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);
|
||||||
mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK, 100);
|
mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK|PBTN_MA2, 100);
|
||||||
switch (mkey) {
|
switch (mkey) {
|
||||||
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;
|
||||||
|
@ -1243,6 +1253,9 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
return;
|
return;
|
||||||
while (in_menu_wait_any(30) & PBTN_MOK);
|
while (in_menu_wait_any(30) & PBTN_MOK);
|
||||||
break;
|
break;
|
||||||
|
case PBTN_MA2:
|
||||||
|
in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype);
|
||||||
|
continue;
|
||||||
default:continue;
|
default:continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1252,12 +1265,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
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(&dev_id, &is_down, -1);
|
||||||
|
|
||||||
bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU;
|
i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype);
|
||||||
mask = opts[sel].mask;
|
|
||||||
if (player_idx == 1)
|
|
||||||
mask <<= 16;
|
|
||||||
|
|
||||||
i = count_bound_keys(dev_id, mask, bindtype);
|
|
||||||
unbind = (i > 0);
|
unbind = (i > 0);
|
||||||
|
|
||||||
/* allow combos if device supports them */
|
/* allow combos if device supports them */
|
||||||
|
@ -1265,7 +1273,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
|
||||||
in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS))
|
in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS))
|
||||||
unbind = 0;
|
unbind = 0;
|
||||||
|
|
||||||
in_bind_key(dev_id, kc, bindtype, mask, unbind);
|
in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, unbind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,6 +1377,8 @@ static menu_entry e_menu_keyconfig[] =
|
||||||
static int menu_loop_keyconfig(menu_id id, int keys)
|
static int menu_loop_keyconfig(menu_id id, int keys)
|
||||||
{
|
{
|
||||||
static int sel = 0;
|
static int sel = 0;
|
||||||
|
|
||||||
|
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded);
|
||||||
me_loop(e_menu_keyconfig, &sel);
|
me_loop(e_menu_keyconfig, &sel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue