Improved GCController handling on Apple platforms

Automatically map controllers as gamepads when using the GCController framework and prefer the physicalInputProfile when possible.

Testing with macOS 13.4.1, macOS 14.1.1, iOS 15.7.4, tvOS 17.1:
* iBuffalo Classic USB Gamepad (macOS only)
* Logitech F310 (macOS only)
* Apple TV remote (tvOS only)
* Nimbus MFi controller
* PS4 DualShock controller
* PS5 DualSense controller
* Xbox Series X controller
* Xbox Elite Series 2 controller
* Nintendo Switch Pro controller
* Nintendo Switch Joy-Con controllers
This commit is contained in:
Sam Lantinga 2023-11-14 12:58:33 -08:00
parent aaf54b09a1
commit 0fe5713964
5 changed files with 446 additions and 157 deletions

View file

@ -2436,6 +2436,22 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_JoystickGUID guid, const char *na
return type;
}
SDL_bool SDL_JoystickGUIDUsesVersion(SDL_JoystickGUID guid)
{
Uint16 vendor, product;
if (SDL_IsJoystickMFI(guid)) {
/* The version bits are used as button capability mask */
return SDL_FALSE;
}
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL);
if (vendor && product) {
return SDL_TRUE;
}
return SDL_FALSE;
}
SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id)
{
EControllerType eType = GuessControllerType(vendor_id, product_id);
@ -2656,6 +2672,11 @@ SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid)
return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE;
}
SDL_bool SDL_IsJoystickMFI(SDL_JoystickGUID guid)
{
return (guid.data[14] == 'm') ? SDL_TRUE : SDL_FALSE;
}
SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid)
{
return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE;