From 77d2f62c239a92a901e39f3b08046fff8189a3a5 Mon Sep 17 00:00:00 2001 From: QwertyChouskie Date: Tue, 9 Jun 2026 07:33:22 -0700 Subject: [PATCH] Respect SDL_HINT_JOYSTICK_MFI Backport of 0bd95b04307a42f09bb0f3baafc41bd353d6f280 (https://github.com/libsdl-org/SDL/pull/15791) to SDL2 --- src/joystick/hidapi/SDL_hidapi_xbox360.c | 21 +++++++++++---------- src/joystick/hidapi/SDL_hidapi_xboxone.c | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index 3cdee5bee8..c58b6275b0 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -116,18 +116,19 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device } #endif #if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI) - if (SDL_IsJoystickSteamVirtualGamepad(vendor_id, product_id, version)) { - /* GCController support doesn't work with the Steam Virtual Gamepad */ - return SDL_TRUE; - } else { - // On macOS when it isn't controlled by the 360Controller driver and - // it doesn't look like a Steam virtual gamepad we should rely on - // GCController support instead. - return SDL_FALSE; + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { + if (SDL_IsJoystickSteamVirtualGamepad(vendor_id, product_id, version)) { + // GCController support doesn't work with the Steam Virtual Gamepad + return SDL_TRUE; + } else { + // On macOS when it isn't controlled by the 360Controller driver and + // it doesn't look like a Steam virtual gamepad we should rely on + // GCController support instead, if supported. + return SDL_FALSE; + } } -#else - return (type == SDL_CONTROLLER_TYPE_XBOX360) ? SDL_TRUE : SDL_FALSE; #endif + return (type == SDL_CONTROLLER_TYPE_XBOX360) ? SDL_TRUE : SDL_FALSE; } static SDL_bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, SDL_bool on) diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index c97ed4fd9d..adbebc19b7 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -355,10 +355,11 @@ static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void) static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { #if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI) - if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE) && + !SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { /* On macOS we get a shortened version of the real report and you can't write output reports for wired controllers, so - we'll just use the GCController support instead. + we'll just use the GCController support instead, if available. */ return SDL_FALSE; }