From 3ac80f68646b09262c04687c8793ebceae4c5459 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 24 Nov 2015 22:30:51 -0500 Subject: [PATCH] add a hint so the user can tell between devices with the same name --- configuration.h | 1 + input/input_autodetect.c | 21 ++++++++++++++++++++- menu/menu_displaylist.c | 2 +- menu/menu_setting.c | 5 ++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/configuration.h b/configuration.h index c419e991d9..885961b3db 100644 --- a/configuration.h +++ b/configuration.h @@ -229,6 +229,7 @@ typedef struct settings unsigned joypad_map[MAX_USERS]; unsigned device[MAX_USERS]; char device_names[MAX_USERS][64]; + unsigned device_name_index[MAX_USERS]; bool autodetect_enable; bool netplay_client_swap_input; diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 1af5ba4e2c..25f763b155 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -29,6 +29,25 @@ static bool remote_is_bound = false; +/* adds an index for devices with the same name so they can be identified in the GUI*/ +static void input_reindex_devices() +{ + settings_t *settings = config_get_ptr(); + for(int i=0; i < settings->input.max_users; i++) + settings->input.device_name_index[i]=0; + for(int i=0; i < settings->input.max_users; i++) + { + const char *tmp = settings->input.device_names[i]; + + int k=1; + for(int j=0; j < settings->input.max_users; j++) + { + if(!strcmp(tmp,settings->input.device_names[j]) && settings->input.device_name_index[i]==0) + settings->input.device_name_index[j]=k++; + } + } +} + static void input_autoconfigure_joypad_conf(config_file_t *conf, struct retro_keybind *binds) { @@ -149,7 +168,7 @@ static void input_autoconfigure_joypad_add( if (!block_osd_spam) rarch_main_msg_queue_push(msg, 0, 60, false); } - + input_reindex_devices(); #if 0 RARCH_LOG("Autodetect: %s\n", msg); #endif diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index f83fa96f59..bd82fa392e 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -434,7 +434,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) { if (settings->input.autoconfigured[controller]) { - snprintf(tmp, sizeof(tmp), "Port #%d device name: %s", controller, settings->input.device_names[controller]); + snprintf(tmp, sizeof(tmp), "Port #%d device name: %s (#%d)", controller, settings->input.device_names[controller], settings->input.device_name_index[controller]); menu_entries_push(info->list, tmp, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); snprintf(tmp, sizeof(tmp), "Port #%d device VID/PID: %d/%d", controller, settings->input.vid[controller], settings->input.pid[controller]); menu_entries_push(info->list, tmp, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 3cfa1a1992..05f826a6a0 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2648,7 +2648,10 @@ static void get_string_representation_bind_device(void * data, char *s, const char *device_name = settings->input.device_names[map]; if (*device_name) - strlcpy(s, device_name, len); + snprintf(s, len, + "%s (#%u)", + device_name, + settings->input.device_name_index[map]); else snprintf(s, len, "%s (%s #%u)",