Skip to content

Commit

Permalink
Fine-tune device reservation.
Browse files Browse the repository at this point in the history
- add reserved device check against device display name as well
- selected device name matching in menu with or without vid:pid
- cosmetical change in test input file
  • Loading branch information
zoltanvb committed Sep 8, 2024
1 parent 5fcec5d commit 23a2d4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -5624,8 +5624,9 @@ static int menu_displaylist_parse_input_select_reserved_device_list(
0, menu_index, NULL))
{
/* Add checkmark if input is currently
* mapped to this entry */
if (string_is_equal(device_label, &reserved_device_name[10]))
* mapped to this entry - with or without vid:pid prefix */
if (string_is_equal(device_label, &reserved_device_name[10]) ||
string_is_equal(device_label, reserved_device_name))
{
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)info_list->list[menu_index].actiondata;
if (cbs)
Expand Down
10 changes: 7 additions & 3 deletions tasks/task_autodetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static bool input_autoconfigure_scan_config_files_internal(
* (not even the assignment to first free player port)
*/
static void reallocate_port_if_needed(unsigned detected_port, int vendor_id,
int product_id, const char *device_name)
int product_id, const char *device_name, const char *device_display_name)
{
settings_t *settings = config_get_ptr();

Expand Down Expand Up @@ -429,7 +429,9 @@ static void reallocate_port_if_needed(unsigned detected_port, int vendor_id,
{
strlcpy(settings_value_device_name, settings_value,
sizeof(settings_value_device_name));
device_has_reserved_slot = string_is_equal(device_name, settings_value_device_name);
device_has_reserved_slot =
string_is_equal(device_name, settings_value_device_name) ||
string_is_equal(device_display_name, settings_value_device_name);
}
else
device_has_reserved_slot = (vendor_id == settings_value_vendor_id &&
Expand Down Expand Up @@ -590,7 +592,9 @@ static void cb_input_autoconfigure_connect(
input_config_set_autoconfig_binds(port,
autoconfig_handle->autoconfig_file);

reallocate_port_if_needed(port,autoconfig_handle->device_info.vid, autoconfig_handle->device_info.pid,autoconfig_handle->device_info.name);
reallocate_port_if_needed(port,autoconfig_handle->device_info.vid, autoconfig_handle->device_info.pid,
autoconfig_handle->device_info.name,
autoconfig_handle->device_info.display_name);

}

Expand Down
2 changes: 1 addition & 1 deletion tests-other/testinput_device_reservation_test2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Sets up joypad driver, test input file for the joypad driver,
# logging and autoconfig dir, and prevents saving.
# Usage:
# retroarch --appendconfig tests-other/testinput_device_reservation_test.cfg\|tests-other/all_binds_empty.cfg
# retroarch --appendconfig tests-other/testinput_device_reservation_test2.cfg\|tests-other/all_binds_empty.cfg

# Test scenario:
# - Player 1 through 4 has preferred device C
Expand Down

0 comments on commit 23a2d4a

Please sign in to comment.