reimplement the shield controller workarounds

This commit is contained in:
Radius 2015-08-13 01:13:24 +01:00
parent 57419bea8c
commit f6e25655c9
2 changed files with 61 additions and 37 deletions

View File

@ -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;

View File

@ -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);