mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-24 03:58:28 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user