···475475 CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
476476 }
477477478478+ if (SDL_IsJoystickXboxOne(vendor, product)) {
479479+ // We can't actually use this API for Xbox controllers
480480+ return false;
481481+ }
482482+478483 // get device name
479484 refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey));
480485 if ((!refCF) || (!CFStringGetCString(refCF, manufacturer_string, sizeof(manufacturer_string), kCFStringEncodingUTF8))) {
+4-44
src/joystick/hidapi/SDL_hidapi_xbox360.c
···8080 // This is the chatpad or other input interface, not the Xbox 360 interface
8181 return false;
8282 }
8383-#ifdef SDL_PLATFORM_MACOS
8484- if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0) {
8585- // This is the Steam Virtual Gamepad, which isn't supported by this driver
8686- return false;
8787- }
8888- /* Wired Xbox One controllers are handled by this driver, interfacing with
8989- the 360Controller driver available from:
9090- https://github.com/360Controller/360Controller/releases
9191-9292- Bluetooth Xbox One controllers are handled by the SDL Xbox One driver
9393- */
9494- if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
9595- return false;
9696- }
9797- return (type == SDL_GAMEPAD_TYPE_XBOX360 || type == SDL_GAMEPAD_TYPE_XBOXONE);
8383+#if defined(SDL_PLATFORM_MACOS) && defined(SDL_JOYSTICK_MFI)
8484+ // On macOS you can't write output reports to wired XBox controllers,
8585+ // so we'll just use the GCController support instead.
8686+ return false;
9887#else
9988 return (type == SDL_GAMEPAD_TYPE_XBOX360);
10089#endif
···197186198187static bool HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
199188{
200200-#ifdef SDL_PLATFORM_MACOS
201201- if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) {
202202- Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 };
203203-204204- rumble_packet[4] = (low_frequency_rumble >> 8);
205205- rumble_packet[5] = (high_frequency_rumble >> 8);
206206-207207- if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
208208- return SDL_SetError("Couldn't send rumble packet");
209209- }
210210- } else {
211211- /* On macOS the 360Controller driver uses this short report,
212212- and we need to prefix it with a magic token so hidapi passes it through untouched
213213- */
214214- Uint8 rumble_packet[] = { 'M', 'A', 'G', 'I', 'C', '0', 0x00, 0x04, 0x00, 0x00 };
215215-216216- rumble_packet[6 + 2] = (low_frequency_rumble >> 8);
217217- rumble_packet[6 + 3] = (high_frequency_rumble >> 8);
218218-219219- if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
220220- return SDL_SetError("Couldn't send rumble packet");
221221- }
222222- }
223223-#else
224189 Uint8 rumble_packet[] = { 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
225190226191 rumble_packet[3] = (low_frequency_rumble >> 8);
···229194 if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
230195 return SDL_SetError("Couldn't send rumble packet");
231196 }
232232-#endif
233197 return true;
234198}
235199···267231static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size)
268232{
269233 Sint16 axis;
270270-#ifdef SDL_PLATFORM_MACOS
271271- const bool invert_y_axes = false;
272272-#else
273234 const bool invert_y_axes = true;
274274-#endif
275235 Uint64 timestamp = SDL_GetTicksNS();
276236277237 if (ctx->last_state[2] != data[2]) {
+7-4
src/joystick/hidapi/SDL_hidapi_xboxone.c
···350350351351static bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
352352{
353353-#ifdef SDL_PLATFORM_MACOS
354354- // Wired Xbox One controllers are handled by the 360Controller driver
353353+#if defined(SDL_PLATFORM_MACOS) && defined(SDL_JOYSTICK_MFI)
355354 if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
355355+ // On macOS we get a shortened version of the real report and
356356+ // you can't write output reports for wired controllers, so
357357+ // we'll just use the GCController support instead.
356358 return false;
357359 }
358360#endif
···1552155415531555 while (size > GIP_HEADER_MIN_LENGTH) {
15541556 hdr_len = HIDAPI_GIP_DecodeHeader(&hdr, data, size);
15551555- if ((hdr_len + hdr.packet_length) > (size_t)size) {
15561556- return false;
15571557+ if ((hdr_len + hdr.packet_length) > (Uint32)size) {
15581558+ // On macOS we get a shortened version of the real report
15591559+ hdr.packet_length = (Uint32)(size - hdr_len);
15571560 }
1558156115591562 if (!HIDAPI_GIP_ProcessPacket(joystick, ctx, &hdr, data + hdr_len)) {