hidapi: Use GameCube adapter controller port for player index

The Nintendo USB GameCube adapter has four controller ports. Return
the port number as 0 to 3 from SDL_JoystickGetPlayerIndex() and
SDL_JoystickGetDevicePlayerIndex().
This commit is contained in:
Zack Middleton 2019-06-08 13:36:59 -07:00
parent e7b514d8ff
commit 82af42761e
7 changed files with 61 additions and 1 deletions

View file

@ -948,7 +948,19 @@ HIDAPI_JoystickGetDeviceName(int device_index)
static int
HIDAPI_JoystickGetDevicePlayerIndex(int device_index)
{
return -1;
SDL_HIDAPI_Device *device = SDL_HIDAPI_devices;
int joysticks;
while (device) {
if (device->driver) {
joysticks = device->driver->NumJoysticks(&device->devdata);
if (device_index < joysticks) {
break;
}
device_index -= joysticks;
}
device = device->next;
}
return device->driver->PlayerIndexForIndex(&device->devdata, device_index);
}
static SDL_JoystickGUID