diff options
author | Cameron Gutman <aicommander@gmail.com> | 2021-02-03 18:00:22 -0600 |
---|---|---|
committer | Cameron Gutman <aicommander@gmail.com> | 2021-02-03 18:00:22 -0600 |
commit | 43683e81627756b3f78f1dda864a861f251966c8 (patch) | |
tree | 34bc4b1b049253f9b86969eeab14d538a7150d8e /src/joystick/hidapi/SDL_hidapi_xboxone.c | |
parent | e4c9bbc66c276a9f8f5ad277a801db2c48f1f9c6 (diff) | |
download | sdl-43683e81627756b3f78f1dda864a861f251966c8.tar.gz |
Fix Xbox Series X controller on macOS
There were two different implementations of IsBluetoothXboxOneController(), one
in SDL_hidapi_xbox360.c and one in SDL_hidapi_xboxone.c. The latter had been
updated to include USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH while the former had
not.
This mismatch led to the Xbox Series X failing on macOS only. We have special
code for handling the 360Controller driver for macOS which requires us to use
the Xbox 360 driver for wired Xbox One controllers, and the SDL_hidapi_xbox360
version of IsBluetoothXboxOneController() was used to determine which devices
were wired.
In addition to adding the missing USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH, this
change moves IsBluetoothXboxOneController() into a single shared function which
will ensure this bug won't happen again.
Diffstat (limited to 'src/joystick/hidapi/SDL_hidapi_xboxone.c')
-rw-r--r-- | src/joystick/hidapi/SDL_hidapi_xboxone.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index fe9f305d5..bcc05d783 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -129,22 +129,6 @@ typedef struct { Uint8 right_trigger_rumble; } SDL_DriverXboxOne_Context; - -static SDL_bool -IsBluetoothXboxOneController(Uint16 vendor_id, Uint16 product_id) -{ - /* Check to see if it's the Xbox One S or Xbox One Elite Series 2 in Bluetooth mode */ - if (vendor_id == USB_VENDOR_MICROSOFT) { - if (product_id == USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH) { - return SDL_TRUE; - } - } - return SDL_FALSE; -} - static SDL_bool ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) { @@ -289,7 +273,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(const char *name, SDL_GameControllerType #endif #ifdef __MACOSX__ /* Wired Xbox One controllers are handled by the 360Controller driver */ - if (!IsBluetoothXboxOneController(vendor_id, product_id)) { + if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { return SDL_FALSE; } #endif @@ -343,7 +327,7 @@ HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst ctx->vendor_id = device->vendor_id; ctx->product_id = device->product_id; - ctx->bluetooth = IsBluetoothXboxOneController(device->vendor_id, device->product_id); + ctx->bluetooth = SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id); ctx->start_time = SDL_GetTicks(); ctx->sequence = 1; ctx->has_paddles = ControllerHasPaddles(ctx->vendor_id, ctx->product_id); |