mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-06 07:20:48 +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:
parent
e7b514d8ff
commit
82af42761e
7 changed files with 61 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue