mirror of
https://github.com/libretro/RetroArch
synced 2025-03-15 13:21:29 +00:00
Add new option 'Show Autoconfig Descriptor Labels' for more
comprehensible button labels per joypad - needs to be added per autoconfig file
This commit is contained in:
parent
bd40703fa3
commit
82f6c57966
3
driver.h
3
driver.h
@ -152,6 +152,9 @@ struct retro_keybind
|
||||
|
||||
/* Used by input_{push,pop}_analog_dpad(). */
|
||||
uint32_t orig_joyaxis;
|
||||
|
||||
char joykey_label[256];
|
||||
char joyaxis_label[256];
|
||||
};
|
||||
|
||||
struct platform_bind
|
||||
|
@ -378,6 +378,7 @@ struct settings
|
||||
float overlay_scale;
|
||||
|
||||
char autoconfig_dir[PATH_MAX];
|
||||
bool autoconfig_descriptor_label_show;
|
||||
bool input_descriptor_label_show;
|
||||
bool input_descriptor_hide_unbound;
|
||||
} input;
|
||||
|
@ -112,6 +112,8 @@ void input_config_autoconfigure_joypad(unsigned idx,
|
||||
{
|
||||
g_settings.input.autoconf_binds[idx][i].joykey = NO_BTN;
|
||||
g_settings.input.autoconf_binds[idx][i].joyaxis = AXIS_NONE;
|
||||
g_settings.input.autoconf_binds[idx][i].joykey_label[0] = '\0';
|
||||
g_settings.input.autoconf_binds[idx][i].joyaxis_label[0] = '\0';
|
||||
}
|
||||
g_settings.input.autoconfigured[idx] = false;
|
||||
|
||||
|
@ -358,8 +358,10 @@ void input_config_parse_joy_button(config_file_t *conf, const char *prefix,
|
||||
const char *btn, struct retro_keybind *bind)
|
||||
{
|
||||
char tmp[64];
|
||||
char key[64];
|
||||
char *tmp_a = NULL;
|
||||
char key[64], key_label[64];
|
||||
snprintf(key, sizeof(key), "%s_%s_btn", prefix, btn);
|
||||
snprintf(key_label, sizeof(key_label), "%s_%s_btn_label", prefix, btn);
|
||||
|
||||
if (config_get_array(conf, key, tmp, sizeof(tmp)))
|
||||
{
|
||||
@ -374,14 +376,19 @@ void input_config_parse_joy_button(config_file_t *conf, const char *prefix,
|
||||
bind->joykey = strtoull(tmp, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_get_string(conf, key_label, &tmp_a))
|
||||
strlcpy(bind->joykey_label, tmp_a, sizeof(bind->joykey_label));
|
||||
}
|
||||
|
||||
void input_config_parse_joy_axis(config_file_t *conf, const char *prefix,
|
||||
const char *axis, struct retro_keybind *bind)
|
||||
{
|
||||
char tmp[64];
|
||||
char key[64];
|
||||
char *tmp_a = NULL;
|
||||
char key[64], key_label[64];
|
||||
snprintf(key, sizeof(key), "%s_%s_axis", prefix, axis);
|
||||
snprintf(key_label, sizeof(key_label), "%s_%s_axis_label", prefix, axis);
|
||||
|
||||
if (config_get_array(conf, key, tmp, sizeof(tmp)))
|
||||
{
|
||||
@ -399,6 +406,9 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix,
|
||||
/* Ensure that d-pad emulation doesn't screw this over. */
|
||||
bind->orig_joyaxis = bind->joyaxis;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, key_label, &tmp_a))
|
||||
strlcpy(bind->joyaxis_label, tmp_a, sizeof(bind->joyaxis_label));
|
||||
}
|
||||
|
||||
#if !defined(IS_JOYCONFIG)
|
||||
@ -426,11 +436,20 @@ static void input_get_bind_string_joykey(char *buf, const char *prefix,
|
||||
dir = "?";
|
||||
break;
|
||||
}
|
||||
snprintf(buf, size, "%sHat #%u %s ", prefix,
|
||||
(unsigned)GET_HAT(bind->joykey), dir);
|
||||
|
||||
if (bind->joykey_label[0] != '\0' && g_settings.input.autoconfig_descriptor_label_show)
|
||||
snprintf(buf, size, "%s %s ", prefix, bind->joykey_label);
|
||||
else
|
||||
snprintf(buf, size, "%sHat #%u %s ", prefix,
|
||||
(unsigned)GET_HAT(bind->joykey), dir);
|
||||
}
|
||||
else
|
||||
snprintf(buf, size, "%s%u (btn) ", prefix, (unsigned)bind->joykey);
|
||||
{
|
||||
if (bind->joykey_label[0] != '\0' && g_settings.input.autoconfig_descriptor_label_show)
|
||||
snprintf(buf, size, "%s%s (btn) ", prefix, bind->joykey_label);
|
||||
else
|
||||
snprintf(buf, size, "%s%u (btn) ", prefix, (unsigned)bind->joykey);
|
||||
}
|
||||
}
|
||||
|
||||
static void input_get_bind_string_joyaxis(char *buf, const char *prefix,
|
||||
@ -448,7 +467,10 @@ static void input_get_bind_string_joyaxis(char *buf, const char *prefix,
|
||||
dir = '+';
|
||||
axis = AXIS_POS_GET(bind->joyaxis);
|
||||
}
|
||||
snprintf(buf, size, "%s%c%u (axis) ", prefix, dir, axis);
|
||||
if (bind->joyaxis_label[0] != '\0' && g_settings.input.autoconfig_descriptor_label_show)
|
||||
snprintf(buf, size, "%s%s (axis) ", prefix, bind->joyaxis_label);
|
||||
else
|
||||
snprintf(buf, size, "%s%c%u (axis) ", prefix, dir, axis);
|
||||
}
|
||||
|
||||
void input_get_bind_string(char *buf, const struct retro_keybind *bind,
|
||||
|
@ -1004,6 +1004,8 @@ static bool config_load_file(const char *path, bool set_defaults)
|
||||
"input_descriptor_label_show");
|
||||
CONFIG_GET_BOOL(input.input_descriptor_hide_unbound,
|
||||
"input_descriptor_hide_unbound");
|
||||
CONFIG_GET_BOOL(input.autoconfig_descriptor_label_show,
|
||||
"autoconfig_descriptor_label_show");
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
@ -1568,6 +1570,8 @@ bool config_save_file(const char *path)
|
||||
g_settings.input.netplay_client_swap_input);
|
||||
config_set_bool(conf, "input_descriptor_label_show",
|
||||
g_settings.input.input_descriptor_label_show);
|
||||
config_set_bool(conf, "autoconfig_descriptor_label_show",
|
||||
g_settings.input.autoconfig_descriptor_label_show);
|
||||
config_set_bool(conf, "input_descriptor_hide_unbound",
|
||||
g_settings.input.input_descriptor_hide_unbound);
|
||||
config_set_bool(conf, "load_dummy_on_core_shutdown",
|
||||
|
@ -4321,7 +4321,7 @@ static bool setting_data_append_list_input_options(
|
||||
CONFIG_BOOL(
|
||||
g_settings.input.autodetect_enable,
|
||||
"input_autodetect_enable",
|
||||
"Autodetect Enable",
|
||||
"Autoconfig Enable",
|
||||
input_autodetect_enable,
|
||||
"OFF",
|
||||
"ON",
|
||||
@ -4330,6 +4330,18 @@ static bool setting_data_append_list_input_options(
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
CONFIG_BOOL(
|
||||
g_settings.input.autoconfig_descriptor_label_show,
|
||||
"autoconfig_descriptor_label_show",
|
||||
"Show Autoconfig Descriptor Labels",
|
||||
true,
|
||||
"OFF",
|
||||
"ON",
|
||||
group_info.name,
|
||||
subgroup_info.name,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
CONFIG_BOOL(
|
||||
g_settings.input.input_descriptor_label_show,
|
||||
"input_descriptor_label_show",
|
||||
|
Loading…
x
Reference in New Issue
Block a user