From 8e7cccb92d27ec38438c034d715a7f2812fa0ced Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 23 Jul 2015 00:38:31 -0400 Subject: [PATCH 1/2] fix autoconfig, it was matching the last profile when no match was found --- input/input_autodetect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 5b18919395..41ce193da5 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -202,7 +202,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( config_file_free(conf); } - if(index >= 0) + if(index >= 0 && current_best > 0) { RARCH_LOG("Autoconf: best configuration score=%d\n", current_best); conf = config_file_new(list->elems[index].data); From 1dc285a0d62563d2ef0af5e00905831d14190eee Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 23 Jul 2015 00:38:59 -0400 Subject: [PATCH 2/2] improve the shield hack and add a generic function to check if a gamepad name is present, implement archos gamepad hack --- input/drivers/android_input.c | 37 +++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 8923c65638..4fec577c95 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -557,6 +557,21 @@ static int android_input_get_id_index_from_name(android_input_t *android, return -1; } +static bool check_pad_names(android_input_t *android, char* name) +{ + bool ret = false; + RARCH_LOG("Checking if %s is connected (%d pads connected)", name, android->pads_connected); + for(int i=0; i < MAX_PADS; i++) + { + if(android->pad_states[i].name) + if(strstr(name, android->pad_states[i].name)) + ret = true; + } + RARCH_LOG("%s found: %d", name, ret); + return ret; +} + + static void handle_hotplug(android_input_t *android, struct android_app *android_app, unsigned *port, unsigned id, int source) @@ -580,6 +595,7 @@ static void handle_hotplug(android_input_t *android, return; } + /* FIXME: Ugly hack, see other FIXME note below. */ if (strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus")) @@ -629,6 +645,8 @@ static void handle_hotplug(android_input_t *android, else if (strstr(device_name, "SideWinder")) strlcpy(name_buf, "SideWinder Classic", sizeof(name_buf)); } + + /* Built-in shield controller is always user 1 */ else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) { /* Built-in shield contrlleris always user 1. FIXME: This is kinda ugly. @@ -638,12 +656,24 @@ static void handle_hotplug(android_input_t *android, *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); } - else if (strstr(device_name, "Virtual") || - (strstr(device_name, "gpio") && strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.01"))) + else if (check_pad_names(&android, "NVIDIA Corporation NVIDIA Controller v01.01") && (strstr(device_name, "virtual") + || strstr(device_name, "gpio") || strstr(device_name, "Virtual") || strstr(device_name, "GPIO"))) { /* If built-in shield controller is detected bind the virtual and gpio devices to the same port*/ + port = 0; + strlcpy(name_buf, "Generic GPIO device", sizeof(name_buf)); + } + + /* Archos gamepad seems to be the worst offender so far, it has the buttons in joy_key, + * the analogs in joystick and the back button is a GPIO device, this part handles the + * hack for the back button + */ + else if (check_pad_names(&android, "joy_key") || check_pad_names(&android, "joystick") && (strstr(device_name, "virtual") + || strstr(device_name, "gpio") || strstr(device_name, "Virtual") || strstr(device_name, "GPIO"))) + { + /* If built-in archos controller is detected bind the virtual and gpio devices to the same port*/ *port = 0; - strlcpy(name_buf, "NVIDIA Corporation NVIDIA Controller v01.01", sizeof(name_buf)); + strlcpy(name_buf, "Generic GPIO device", sizeof(name_buf)); } else if ( strstr(device_name, "PLAYSTATION(R)3") || @@ -680,7 +710,6 @@ static void handle_hotplug(android_input_t *android, params.pid = productId; settings->input.pid[*port] = params.pid; settings->input.vid[*port] = params.vid; - strlcpy(params.driver, android_joypad.ident, sizeof(params.driver)); autoconfigured = input_config_autoconfigure_joypad(¶ms);