Skip to content

Commit

Permalink
Input reserved device menu item cleanup (#16946)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos authored Sep 4, 2024
1 parent 98c79b3 commit 5ed4a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -5625,7 +5625,7 @@ static int menu_displaylist_parse_input_select_reserved_device_list(
{
/* Add checkmark if input is currently
* mapped to this entry */
if (string_is_equal(device_label, reserved_device_name))
if (string_is_equal(device_label, &reserved_device_name[10]))
{
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)info_list->list[menu_index].actiondata;
if (cbs)
Expand Down
15 changes: 7 additions & 8 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,9 @@ static int setting_action_ok_select_reserved_device(
char enum_idx[16];
if (!setting)
return -1;

snprintf(enum_idx, sizeof(enum_idx), "%d", setting->enum_idx);

generic_action_ok_displaylist_push(
enum_idx, /* we will pass the enumeration index of the string as a path */
NULL, NULL, 0, idx, 0,
Expand Down Expand Up @@ -7790,6 +7792,8 @@ static int setting_action_start_input_device_reserved_device_name(rarch_setting_
configuration_set_string(settings,
settings->arrays.input_reserved_devices[setting->index_offset],
"");

command_event(CMD_EVENT_REINIT, NULL);
return 0;
}

Expand Down Expand Up @@ -8194,17 +8198,11 @@ static void get_string_representation_input_device_reservation_type(
map = settings->uints.input_device_reservation_type[setting->index_offset];

if (map == INPUT_DEVICE_RESERVATION_NONE)
{
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DEVICE_RESERVATION_NONE), len);
}
else if (map == INPUT_DEVICE_RESERVATION_PREFERRED)
{
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DEVICE_RESERVATION_PREFERRED), len);
}
else if (map == INPUT_DEVICE_RESERVATION_RESERVED)
{
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DEVICE_RESERVATION_RESERVED), len);
}
else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), len);
}
Expand All @@ -8219,7 +8217,9 @@ static void setting_get_string_representation_input_device_reserved_device_name(
if (!setting)
return;

if (sscanf(setting->value.target.string, "%04x:%04x ", &dev_vendor_id, &dev_product_id) != 2)
if (string_is_empty(setting->value.target.string))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE), len);
else if (sscanf(setting->value.target.string, "%04x:%04x ", &dev_vendor_id, &dev_product_id) != 2)
strlcpy(s, setting->value.target.string, len);
else
strlcpy(s, &setting->value.target.string[10], len);
Expand Down Expand Up @@ -9736,7 +9736,6 @@ static bool setting_append_list_input_player_options(
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_input_device_reserved_device_name;
(*list)[list_info->index - 1].action_start = &setting_action_start_input_device_reserved_device_name;

MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_DEVICE_RESERVED_DEVICE_NAME + user));
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_VALUE_IDX(list, list_info,
Expand Down

0 comments on commit 5ed4a3c

Please sign in to comment.