input_config_get_bind_string_hotkey - snprintf concatenation

so we don't repeat the same formatting for every switch case
statement
This commit is contained in:
libretroadmin 2023-01-22 17:33:31 +01:00
parent f7a9d64d73
commit 610194e805

View File

@ -2485,8 +2485,8 @@ void input_config_get_bind_string_joykey(
{ {
if (GET_HAT_DIR(bind->joykey)) if (GET_HAT_DIR(bind->joykey))
{ {
if (bind->joykey_label && if ( bind->joykey_label
!string_is_empty(bind->joykey_label) && !string_is_empty(bind->joykey_label)
&& input_descriptor_label_show) && input_descriptor_label_show)
{ {
size_t len = fill_pathname_join_delim(buf, prefix, size_t len = fill_pathname_join_delim(buf, prefix,
@ -2503,28 +2503,25 @@ void input_config_get_bind_string_joykey(
{ {
const char *na_str = const char *na_str =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE); msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
size_t len = snprintf(buf, size, "%sHat #%u ", prefix,
(unsigned)GET_HAT(bind->joykey));
switch (GET_HAT_DIR(bind->joykey)) switch (GET_HAT_DIR(bind->joykey))
{ {
case HAT_UP_MASK: case HAT_UP_MASK:
snprintf(buf, size, "%sHat #%u up (%s)", prefix, snprintf(buf + len, size - len, " up (%s)", na_str);
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_DOWN_MASK: case HAT_DOWN_MASK:
snprintf(buf, size, "%sHat #%u down (%s)", prefix, snprintf(buf + len, size - len, " down (%s)", na_str);
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_LEFT_MASK: case HAT_LEFT_MASK:
snprintf(buf, size, "%sHat #%u left (%s)", prefix, snprintf(buf + len, size - len, " left (%s)", na_str);
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
case HAT_RIGHT_MASK: case HAT_RIGHT_MASK:
snprintf(buf, size, "%sHat #%u right (%s)", prefix, snprintf(buf + len, size - len, " right (%s)",na_str);
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
default: default:
snprintf(buf, size, "%sHat #%u ? (%s)", prefix, snprintf(buf + len, size - len, " ? (%s)", na_str);
(unsigned)GET_HAT(bind->joykey), na_str);
break; break;
} }
} }