hidapi: Add support for Wii U/Switch USB GameCube controller adapter.

Note that a single USB device is responsible for all 4 joysticks, so a large
rewrite of the DeviceDriver functions was necessary to allow a single device to
produce multiple joysticks.
This commit is contained in:
Ethan Lee 2019-03-12 20:27:54 -04:00
parent 938a5508d1
commit c528615626
13 changed files with 724 additions and 176 deletions

View file

@ -1033,6 +1033,11 @@ SDL_JoystickUpdate(void)
/* Make sure the list is unlocked while dispatching events to prevent application deadlocks */
SDL_UnlockJoysticks();
/* Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks */
#ifdef SDL_JOYSTICK_HIDAPI
SDL_HIDAPI_UpdateDevices();
#endif /* SDL_JOYSTICK_HIDAPI */
for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
if (joystick->attached) {
joystick->driver->Update(joystick);
@ -1187,6 +1192,12 @@ SDL_IsJoystickXboxOne(Uint16 vendor, Uint16 product)
return (GuessControllerType(vendor, product) == k_eControllerType_XBoxOneController);
}
SDL_bool
SDL_IsJoystickGameCube(Uint16 vendor, Uint16 product)
{
return (GuessControllerType(vendor, product) == k_eControllerType_GameCube);
}
SDL_bool
SDL_IsJoystickXInput(SDL_JoystickGUID guid)
{