Turn it into char pointer array

This commit is contained in:
twinaphex 2017-09-27 20:08:37 +02:00
parent 9302e5627e
commit b79f95668b
3 changed files with 13 additions and 5 deletions

View File

@ -2318,7 +2318,10 @@ void input_config_parse_joy_button(void *data, const char *prefix,
if (config_get_string(conf, key_label, &tmp_a))
{
strlcpy(bind->joykey_label, tmp_a, sizeof(bind->joykey_label));
if (!string_is_empty(bind->joykey_label))
free(bind->joykey_label);
bind->joykey_label = strdup(tmp_a);
free(tmp_a);
}
}
@ -2375,7 +2378,8 @@ static void input_config_get_bind_string_joykey(
if (GET_HAT_DIR(bind->joykey))
{
if (!string_is_empty(bind->joykey_label) && label_show)
if (bind->joykey_label &&
!string_is_empty(bind->joykey_label) && label_show)
snprintf(buf, size, "%s %s ", prefix, bind->joykey_label);
else
{
@ -2405,7 +2409,8 @@ static void input_config_get_bind_string_joykey(
}
else
{
if (!string_is_empty(bind->joykey_label) && label_show)
if (bind->joykey_label &&
!string_is_empty(bind->joykey_label) && label_show)
snprintf(buf, size, "%s%s (btn) ", prefix, bind->joykey_label);
else
snprintf(buf, size, "%s%u (%s) ", prefix, (unsigned)bind->joykey,

View File

@ -114,7 +114,7 @@ struct retro_keybind
/* Used by input_{push,pop}_analog_dpad(). */
uint32_t orig_joyaxis;
char joykey_label[64];
char *joykey_label;
char joyaxis_label[64];
};

View File

@ -475,7 +475,10 @@ bool input_autoconfigure_connect(
{
input_autoconf_binds[state->idx][i].joykey = NO_BTN;
input_autoconf_binds[state->idx][i].joyaxis = AXIS_NONE;
input_autoconf_binds[state->idx][i].joykey_label[0] = '\0';
if (input_autoconf_binds[state->idx][i].joykey_label
&& !string_is_empty(input_autoconf_binds[state->idx][i].joykey_label))
free(input_autoconf_binds[state->idx][i].joykey_label);
input_autoconf_binds[state->idx][i].joykey_label = NULL;
input_autoconf_binds[state->idx][i].joyaxis_label[0] = '\0';
}