From 786424b064cd44b7a1749e0136d1aa9e1109b213 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 01:50:02 -0500 Subject: [PATCH 1/6] Shield Console hack --- input/drivers/android_input.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 880864d39a..a410077f39 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -641,7 +641,7 @@ static void handle_hotplug(android_input_t *android, } else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) { - /* Built-in shield contrlleris always user 1. FIXME: This is kinda ugly. + /* Built-in shield controller is always user 1. FIXME: This is kinda ugly. * We really need to find a way to detect useless input devices * like gpio-keys in a general way. */ @@ -655,6 +655,21 @@ static void handle_hotplug(android_input_t *android, *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")) + { + /* Shield Controller is user 0 by default. FIXME: This is kinda ugly. + * this allows using the NVIDIA button as menu + */ + *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"))) + { + /* If the 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, "Amazon Fire TV Remote") || strstr(device_name, "Nexus Remote") || strstr(device_name, "SHIELD Remote")) From 1edd7af424efb856a68c0c8296911414d5eea7c8 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 01:53:35 -0500 Subject: [PATCH 2/6] better all around hack for GPIO devices --- input/drivers/android_input.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index a410077f39..f805699f1e 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -641,7 +641,7 @@ static void handle_hotplug(android_input_t *android, } else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) { - /* Built-in shield controller is always user 1. FIXME: This is kinda ugly. + /* Built-in shield contrlleris always user 1. FIXME: This is kinda ugly. * We really need to find a way to detect useless input devices * like gpio-keys in a general way. */ @@ -655,21 +655,6 @@ static void handle_hotplug(android_input_t *android, *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")) - { - /* Shield Controller is user 0 by default. FIXME: This is kinda ugly. - * this allows using the NVIDIA button as menu - */ - *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"))) - { - /* If the 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, "Amazon Fire TV Remote") || strstr(device_name, "Nexus Remote") || strstr(device_name, "SHIELD Remote")) @@ -680,7 +665,8 @@ static void handle_hotplug(android_input_t *android, } 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,"SHIELD Remote") + || strstr(android->pad_states[0].name,"Generic I/O Device"))) { /* 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 From bae6dd7c7991c8411e15bc5905825b13d53aeef4 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 01:59:50 -0500 Subject: [PATCH 3/6] better all around hack for GPIO devices --- input/drivers/android_input.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index f805699f1e..a41aa07c98 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -648,20 +648,18 @@ 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"))) - { - /* 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, "Amazon Fire TV Remote") || strstr(device_name, "Nexus Remote") - || strstr(device_name, "SHIELD Remote")) + || strstr(device_name, "SHIELD Remote") + || strstr(device_name, "gpio") + || strstr(device_name, "Virtual")) { /* hack for remote control type devices, set them always to port 0 */ *port = 0; - strlcpy(name_buf, device_name, sizeof(name_buf)); + 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)); } else if ( *port==1 && ( strstr(android->pad_states[0].name,"Amazon Fire TV Remote") || strstr(android->pad_states[0].name,"Nexus Remote") From c8671139e80de4d0a2e1286c74c3280c80e61f6b Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 02:17:25 -0500 Subject: [PATCH 4/6] fix --- input/drivers/android_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index a41aa07c98..7b0e5ca9ca 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -656,9 +656,9 @@ static void handle_hotplug(android_input_t *android, { /* hack for remote control type devices, set them always to port 0 */ *port = 0; - if (strstr(device_name, "Virtual") || (strstr(device_name, "gpio")) + if (strstr(device_name, "Virtual") || (strstr(device_name, "gpio"))) strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); - else + else strlcpy(name_buf, device_name, sizeof(name_buf)); } else if ( *port==1 && ( strstr(android->pad_states[0].name,"Amazon Fire TV Remote") From a5c70560a3190b599387d2525d6bca6f66aedb53 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 13:51:19 -0500 Subject: [PATCH 5/6] remove the shield portable hack, it's not needed anymore --- input/drivers/android_input.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 7b0e5ca9ca..e6d2ad73ef 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -639,22 +639,15 @@ static void handle_hotplug(android_input_t *android, else if (strstr(device_name, "SideWinder")) strlcpy(name_buf, "SideWinder Classic", sizeof(name_buf)); } - else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) - { - /* Built-in shield contrlleris always user 1. FIXME: This is kinda ugly. - * We really need to find a way to detect useless input devices - * like gpio-keys in a general way. - */ - *port = 0; - strlcpy(name_buf, device_name, 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")) { - /* hack for remote control type devices, set them always to port 0 */ *port = 0; if (strstr(device_name, "Virtual") || (strstr(device_name, "gpio"))) strlcpy(name_buf, "Generic I/O Device", sizeof(name_buf)); @@ -666,10 +659,8 @@ static void handle_hotplug(android_input_t *android, || strstr(android->pad_states[0].name,"SHIELD Remote") || strstr(android->pad_states[0].name,"Generic I/O Device"))) { - /* 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 + /* then, when binding a new controller in port 1 and one of those remotes + * was bound to port 0, overwrite that binding */ *port = 0; strlcpy(name_buf, device_name, sizeof(name_buf)); From d52ab85b6057a04522126287d84cb6a4ebdd87e1 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 7 Aug 2015 13:52:05 -0500 Subject: [PATCH 6/6] remove comment --- input/drivers/android_input.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index e6d2ad73ef..d55184efdc 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -618,8 +618,6 @@ static void handle_hotplug(android_input_t *android, //For Xperia Play - count similar devices and bind them to the same 'user' //port // - //For nVidia Shield - see above - // //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.