From 57419bea8cc1ed2db062ea9736c0811e2a2259c0 Mon Sep 17 00:00:00 2001 From: Radius Date: Wed, 12 Aug 2015 20:17:19 +0100 Subject: [PATCH 1/4] remove the generic I/O hack, it's not working reliably --- android/phoenix/project.properties | 2 +- input/drivers/android_input.c | 56 +++++++++++++++++++----------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/android/phoenix/project.properties b/android/phoenix/project.properties index 610052c20f..64ab355f81 100644 --- a/android/phoenix/project.properties +++ b/android/phoenix/project.properties @@ -11,7 +11,7 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-21 +target=android-22 android.library.reference.1=libs/appcompat android.library=false android.library.reference.2=libs/googleplay diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index d1143a20d5..5f0f039b9e 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -637,28 +637,47 @@ static void handle_hotplug(android_input_t *android, else if (strstr(device_name, "SideWinder")) strlcpy(name_buf, "SideWinder Classic", sizeof(name_buf)); } - /* Make sure generic I/O devices are always bound to port one - * should be easier to add these instead of one hack per device - */ - else if (strstr(device_name, "Amazon Fire TV Remote") - || strstr(device_name, "Nexus Remote") - || strstr(device_name, "SHIELD Remote") - || strstr(device_name, "gpio") - || strstr(device_name, "Virtual")) + else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) + { + /* Built-in shield controller is always user 1 */ + *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")) + { + /* If built-in shield controller is detected bind the virtual and gpio devices to the same port */ + *port = 0; + strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); + } + else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") && !strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.03")) { *port = 0; - if (strstr(device_name, "Virtual") || (strstr(device_name, "gpio"))) - strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); - else - strlcpy(name_buf, device_name, sizeof(name_buf)); + 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.03"))) + { + /* If the shield controller is detected bind the virtual and gpio devices to the same port*/ + *port = 0; + strlcpy(name_buf, "NVIDIA SHIELD Controller", sizeof(name_buf)); + } + else if (strstr(device_name, "Amazon Fire TV Remote") + || strstr(device_name, "Nexus Remote") + || strstr(device_name, "SHIELD Remote")) + { + /* hack for remote control type devices, set them always to port 0 */ + *port = 0; + strlcpy(name_buf, device_name, sizeof(name_buf)); } else if ( *port==1 && ( strstr(android->pad_states[0].name,"Amazon Fire TV Remote") || strstr(android->pad_states[0].name,"Nexus Remote") - || strstr(android->pad_states[0].name,"SHIELD Remote") - || strstr(android->pad_states[0].name,"Generic I/O Device"))) + || strstr(android->pad_states[0].name,"SHIELD Remote"))) { - /* then, when binding a new controller in port 1 and one of those remotes - * was bound to port 0, overwrite that binding + /* and then when we are binding a new controller in port 1 and one of those remotes + * was bound to port 0, bind the device as port 0 too, it causes all the controllers to + * rebind on the first button press but at least the remotes can be used to navigate + * the user interface */ *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); @@ -700,10 +719,7 @@ static void handle_hotplug(android_input_t *android, settings->input.vid[*port] = params.vid; strlcpy(params.driver, android_joypad.ident, sizeof(params.driver)); - - // Don't try to autoconfigure GPIO devices - if (!strstr(android->pad_states[0].name,"Generic I/O Device")) - autoconfigured = input_config_autoconfigure_joypad(¶ms); + autoconfigured = input_config_autoconfigure_joypad(¶ms); if (autoconfigured) { From f6e25655c953fb70aa0dc12ded184eb1605ab2e3 Mon Sep 17 00:00:00 2001 From: Radius Date: Thu, 13 Aug 2015 01:13:24 +0100 Subject: [PATCH 2/4] reimplement the shield controller workarounds --- input/drivers/android_input.c | 90 +++++++++++++++++++++-------------- input/input_autodetect.c | 8 +++- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 5f0f039b9e..65c3d01ba6 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -441,8 +441,8 @@ static void *android_input_init(void) return android; } -static int zeus_id = -1; -static int zeus_second_id = -1; +static int xperia1 = -1; +static int xperia2 = -1; static int archos1 = -1; static int archos2 = -1; @@ -581,22 +581,38 @@ static void handle_hotplug(android_input_t *android, return; } - /* FIXME: Ugly hack, see other FIXME note below. */ + /* FIXME - per-device hacks for nVidia Shield, Xperia Play and others + * For Xperia Play We need to keep 'count' of the amount of similar devices + * and group them in a single port. + * + * For the NVIDIA Shield we must make sure that the built-in controllers always + * map to the port + * + * For TTT HT - keep track of how many of these 'pads' are already + * connected, and based on that, assign one of them to be User 1 and + * the other to be User 2. + * + * If this is finally implemented right, then these port conditionals can go. + */ + + /* Xperia Play */ if (strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus")) { - if (zeus_id < 0) + if (xperia1 < 0) { RARCH_LOG("zeus_pad 1 detected: %u\n", id); - zeus_id = id; + xperia1 = id; } else { RARCH_LOG("zeus_pad 2 detected: %u\n", id); - zeus_second_id = id; + xperia2 = id; } strlcpy(name_buf, device_name, sizeof(name_buf)); } + + /* Archos Gamepad */ else if (strstr(device_name, "joy_key") || strstr(device_name, "joystick")) { if (archos1 < 0) @@ -606,30 +622,21 @@ static void handle_hotplug(android_input_t *android, *port = 0; strlcpy(name_buf, "Archos Gamepad", sizeof(name_buf)); } - /* followed by a 4 (hex) char HW id */ + else if (strstr(device_name, "iControlPad-")) strlcpy(name_buf, "iControlPad HID Joystick profile", sizeof(name_buf)); + else if (strstr(device_name, "TTT THT Arcade console 2P USB Play")) { - //FIXME - need to do a similar thing here as we did for nVidia Shield - //and Xperia Play. We need to keep 'count' of the amount of similar (grouped) - //devices. - // - //For Xperia Play - count similar devices and bind them to the same 'user' - //port - // - //For TTT HT - keep track of how many of these 'pads' are already - //connected, and based on that, assign one of them to be User 1 and - //the other to be User 2. - // - //If this is finally implemented right, then these port conditionals can go. if (*port == 0) strlcpy(name_buf, "TTT THT Arcade (User 1)", sizeof(name_buf)); else if (*port == 1) strlcpy(name_buf, "TTT THT Arcade (User 2)", sizeof(name_buf)); } + else if (strstr(device_name, "360 Wireless")) strlcpy(name_buf, "XBox 360 Wireless", sizeof(name_buf)); + else if (strstr(device_name, "Microsoft")) { if (strstr(device_name, "Dual Strike")) @@ -637,36 +644,51 @@ static void handle_hotplug(android_input_t *android, else if (strstr(device_name, "SideWinder")) strlcpy(name_buf, "SideWinder Classic", sizeof(name_buf)); } + + /* NVIDIA Shield Portable + * Built-in controller is always user 1 + * Back button is on a separate HID device with no VID/PID + * so we bind that controller to user 1 too and overwrite + * whenever a gamepad button is pressed + */ else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) { - /* Built-in shield controller is always user 1 */ *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 ((strstr(device_name, "Virtual") || strstr(device_name, "gpio")) && + strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.01")) { - /* If built-in shield controller is detected bind the virtual and gpio devices to the same port */ *port = 0; strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); } - else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") && !strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.03")) + + /* Other NVIDIA Shield Devices + * NVIDIA button on the controller is on a separate HID device + * so whenever that button is hit, bind that device to user 1 and + * overwrite it whenever a SHIELD Controller button is pressed + */ + else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") + && !strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.03")) { *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.03"))) + else if ((strstr(device_name, "Virtual") || strstr(device_name, "gpio")) + && strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.03")) { - /* If the shield controller is detected bind the virtual and gpio devices to the same port*/ *port = 0; strlcpy(name_buf, "NVIDIA SHIELD Controller", sizeof(name_buf)); } + + /* Other uncommon devices + * These are mostly remote control type devices, bind them always to port 01 + * And overwrite the binding whenever a controller button is pressed + */ else if (strstr(device_name, "Amazon Fire TV Remote") || strstr(device_name, "Nexus Remote") || strstr(device_name, "SHIELD Remote")) { - /* hack for remote control type devices, set them always to port 0 */ *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); } @@ -674,22 +696,20 @@ static void handle_hotplug(android_input_t *android, || strstr(android->pad_states[0].name,"Nexus Remote") || strstr(android->pad_states[0].name,"SHIELD Remote"))) { - /* and then when we are binding a new controller in port 1 and one of those remotes - * was bound to port 0, bind the device as port 0 too, it causes all the controllers to - * rebind on the first button press but at least the remotes can be used to navigate - * the user interface - */ *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); } + else if ( strstr(device_name, "PLAYSTATION(R)3") || strstr(device_name, "Dualshock3") || strstr(device_name, "Sixaxis") ) strlcpy(name_buf, "PlayStation3", sizeof(name_buf)); + else if (strstr(device_name, "MOGA")) strlcpy(name_buf, "Moga IME", sizeof(name_buf)); + else if (device_name[0] != '\0') strlcpy(name_buf, device_name, sizeof(name_buf)); @@ -745,8 +765,8 @@ static int android_input_get_id(android_input_t *android, AInputEvent *event) int id = AInputEvent_getDeviceId(event); /* Needs to be cleaned up */ - if (id == zeus_second_id) - id = zeus_id; + if (id == xperia2) + id = xperia1; if (id == archos2) id = archos1; diff --git a/input/input_autodetect.c b/input/input_autodetect.c index e6a6662945..243a3ac639 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -134,8 +134,12 @@ static void input_autoconfigure_joypad_add( if (!strcmp(device_type,"remote")) { - snprintf(msg, sizeof(msg), "%s configured", - params->name); + if (display_name[0] != '\0' || strcmp(display_name, "")) + snprintf(msg, sizeof(msg), "%s configured", + display_name); + else + snprintf(msg, sizeof(msg), "%s configured", + params->name); if(!remote_is_bound) rarch_main_msg_queue_push(msg, 0, 60, false); From cc3b1fd49f7caad93480aee3e1fe6dc0374a9d8c Mon Sep 17 00:00:00 2001 From: Radius Date: Thu, 13 Aug 2015 02:06:15 +0100 Subject: [PATCH 3/4] minor fixes to the workaround --- input/drivers/android_input.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 65c3d01ba6..12b8cc1071 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -660,16 +660,19 @@ static void handle_hotplug(android_input_t *android, strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.01")) { *port = 0; - strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); + strlcpy(name_buf, "NVIDIA SHIELD Portable", sizeof(name_buf)); } /* Other NVIDIA Shield Devices * NVIDIA button on the controller is on a separate HID device * so whenever that button is hit, bind that device to user 1 and * overwrite it whenever a SHIELD Controller button is pressed + * + * In this case we won't map back (4) to menu, instead we map the + * NVIDIA button (84) using an autoconf file */ else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") - && !strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.03")) + && !strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.0")) { *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); From 638db98e7d867991ca953133df67e36a7276c221 Mon Sep 17 00:00:00 2001 From: Radius Date: Thu, 13 Aug 2015 03:14:53 +0100 Subject: [PATCH 4/4] fix the back as menu toggle option, autoconf was returning false even when a controller was succesfully configured... --- input/drivers/android_input.c | 3 +-- input/input_autodetect.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 12b8cc1071..46d6fb63d0 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -729,7 +729,7 @@ static void handle_hotplug(android_input_t *android, if (settings->input.autodetect_enable) { - unsigned autoconfigured = false; + bool autoconfigured = false; autoconfig_params_t params = {{0}}; RARCH_LOG("Port %d: %s VID/PID: %d/%d\n", *port, name_buf, params.vid, params.pid); @@ -743,7 +743,6 @@ static void handle_hotplug(android_input_t *android, strlcpy(params.driver, android_joypad.ident, sizeof(params.driver)); autoconfigured = input_config_autoconfigure_joypad(¶ms); - if (autoconfigured) { if (settings->input.autoconf_binds[*port][RARCH_MENU_TOGGLE].joykey != 0) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 243a3ac639..99d048c431 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -227,6 +227,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( conf = config_file_new(list->elems[index].data); input_autoconfigure_joypad_add(conf, params); config_file_free(conf); + ret = 1; } else {