src/joystick/hidapi/SDL_hidapi_xbox360.c


Log

Author Commit Date CI Message
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga 66058bbb 2021-11-15T16:52:56 Fixed exception accessing Bluetooth devices on Android 12 Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init() Fixes https://github.com/libsdl-org/SDL/issues/4952
Cameron Gutman afccabb8 2021-11-11T12:12:05 joystick: Add capability flags for rumble and trigger rumble When API limitations force us to guess, we favor a false positive (reporting support when it doesn't exist) compared to a false negative.
Cameron Gutman 1ccfbf96 2021-11-11T11:13:08 joystick: Convert HasLED() into a generic GetCapabilities() function
Sam Lantinga 5b646cd1 2021-11-07T22:58:44 Build hidapi code into SDL as a new public API This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
Sam Lantinga d135c076 2021-07-08T13:22:41 Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers See testgamecontroller.c for an example of a custom PS5 trigger effect
Ozkan Sezer dc45a228 2021-02-08T00:20:56 avoid some pedantic warnings in array initializers
Cameron Gutman f4d58689 2021-02-03T18:00:22 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.
Sam Lantinga e2f46ed8 2021-01-14T23:49:20 Always lock the HIDAPI device when closing, in case rumble is pending
Sam Lantinga fbd7c718 2021-01-13T11:02:07 Don't blink the Xbox 360 LED when setting the player slot, it's probably already been set by a driver
Sam Lantinga b2a0c712 2021-01-04T12:24:44 Allow setting the player index to -1, which turns off the player LED for PS5 controllers
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 9fc4a4c9 2020-11-24T22:25:26 Revamped Xbox One HIDAPI init sequence Added support for querying the controller serial number on newer firmware
Sam Lantinga 5b3616c3 2020-11-23T18:24:05 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
Sam Lantinga fcb21aa8 2020-11-17T10:30:20 Added API for sensors on game controllers Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers Also fixed an issue with the accelerometer on iOS having inverted axes
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga 1577366c 2020-11-08T23:49:03 Fixed duplicated switch statement processing Xbox controller dpad state
Sam Lantinga 3a3aaac2 2020-11-06T11:30:52 Added 4 auxiliary buttons to the game controller API Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver PS4 and PS5 controllers use AUX1 to represent the touchpad button Nintendo Switch Pro controllers use AUX1 to represent the capture button
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Bart van der Werf 3d92e8c7 2020-10-21T10:43:46 hidapi: Also parse data[12] with dpad values on the xb1s controller
Ryan C. Gordon 5fe34a40 2020-05-20T17:01:25 hidapi: Fix compiler warning.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga 50b1c195 2020-04-14T09:55:33 Fixed bug 5091 - Suspicious condition in HIDAPI_DriverXbox360_UpdateXInput meyraud705 On line 220 of SDL_hidapi_xbox360.c https://hg.libsdl.org/SDL/file/4608f0e6e8e3/src/joystick/hidapi/SDL_hidapi_xbox360.c#l220 if (!XINPUTGETSTATE(user_index, &xinput_state[user_index].state) == ERROR_SUCCESS) { logical not is only applied to the left hand side of this comparison. I think you mean: if (XINPUTGETSTATE(user_index, &xinput_state[user_index].state) != ERROR_SUCCESS) {
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Jimb Esser 47da53b9 2020-03-16T14:49:20 Fix compiler warnings
Sam Lantinga 4dea340c 2020-03-16T12:23:38 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows Jimb Esser Add new RawInput controller API, and improved correlation with XInput/WGI Reorder joystick init so drivers can ask the others if they handle a device reliably Do not poll disconnected XInput devices (major perf issue) Fix various cases where incorrect correlation could happen Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation Correlate by axis motion as well as button presses Fix failing to zero other trigger Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init() Add missing device to device names Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices Updated to SDL 2.0.13 code with the following notes: New HID driver: xbox360w - no idea what that is, hopefully urelated SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data. SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem. Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason. Something changed in how devices get names, so getting generic names. Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
Sam Lantinga eb19631a 2020-03-02T10:57:57 This controller firmware is supported on Windows, and is covered by the Bluetooth check on Mac OSX
Sam Lantinga 27f346a0 2020-03-02T09:46:37 Fixed compile warning
Sam Lantinga 756d2073 2020-03-02T09:26:12 Updated the HIDAPI Xbox One driver with support for Bluetooth Xbox One controllers
Sam Lantinga 6590d078 2020-03-01T14:52:49 Fixed bug 4996 - Mac: XBoxOne Bluetooth rumble isn't working rofferom I have an annoying issue on MacOS about XBoxOne Bluetooth rumble (Vendor: 0x045e, Product: 0x02fd). When 360controller is installed, rumble is working correctly. However, Bluetooth rumble isn't working at all, with or without 360controller installed (although it is working with Chrome + https://html5gamepad.com). I looked at the code, and it seems that XBox controllers are managed in MacOS in this file: SDL_hidapi_xbox360.c. The XBoxOne file is disabled for MacOS in SDL_hidjoystick_c.h. The function HIDAPI_DriverXbox360_Rumble() is called correctly, and hid_write() returns no error. I have tried a stupid test. I took the rumble packet from 360controller: https://github.com/360Controller/360Controller/blob/ec4e88eb2d2535e9b32561c702f42fb22b0a7f99/XBOBTFF/FFDriver.cpp#L620. With the patch I have attached, I manage to have rumble working on Bluetooth (with some stupid vibration level, but it proves it can if the packet is changed). But it breaks the USB rumble with 360controller. A comment in the function makes an explicit reference to 360controller, I think that's why I have broken this specific usecase. I don't know what is the correct way to fix this, but it seems that the current implementation has a missing case for Bluetooth support. Note that I also tested master this morning, and I have another issue: if (!device->ffservice) { return SDL_Unsupported(); } test fails in DARWIN_JoystickRumble(). This test has been done quickly, I'm not totaly confident about its accuracy.
Sam Lantinga 1684606f 2020-02-04T15:26:56 Fixed long delay on main thread caused by blocking rumble writes in HIDAPI drivers There is now a thread that handles all HIDAPI rumble requests and a lock that guarantees that we're not reading and writing the device at the same time.
Sam Lantinga 6efebf17 2020-02-04T12:48:53 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests.
Sam Lantinga 9c3d1602 2020-01-19T11:43:36 Refactored code so SDL_GetJoystickGameControllerType() is called less during controller detection
Sam Lantinga 43aa1fa9 2020-01-18T11:21:14 Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 46e1377d 2019-12-20T20:12:03 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks. Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()
Sam Lantinga 6b767872 2019-12-19T21:45:44 Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers
Sam Lantinga 1db56619 2019-12-19T18:03:28 Fixed rare infinite rumble in HIDAPI controller driver
Sam Lantinga e7f7e3f4 2019-12-19T15:01:30 Refactored HIDAPI controller code to support dongles and hubs that dynamically attach controllers
Sam Lantinga 52b6ab21 2019-12-16T17:11:23 Added support for the SteelSeries Stratus Duo
Sam Lantinga a7ae9175 2019-12-16T10:20:03 Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble meyraud705 On a Dualshock 4 controller using hidapi driver, calling SDL_JoystickRumble with a duration too long (SDL_HAPTIC_INFINITY for example) causes the rumble to stop immediately. This happens because of integer overflow on line 301 of SDL_hidapi_ps4.c (https://hg.libsdl.org/SDL/file/a3077169ad23/src/joystick/hidapi/SDL_hidapi_ps4.c#l301), which sets expiration time in the past.
Sam Lantinga 1ac7eaba 2019-12-12T14:25:02 Fixed comment typo
Sam Lantinga 8b50dcb2 2019-12-11T17:46:54 Use the controller product string instead of hard-coding controller names
Sam Lantinga 0b863f8a 2019-11-27T15:27:19 Sorted controller entries by type and VID/PID to more easily find entries in the list
Sam Lantinga 733f2525 2019-11-22T14:09:24 Fixed build
Sam Lantinga b5aff9d7 2019-11-22T13:12:12 Added SDL_GameControllerTypeForIndex() and SDL_GameControllerGetType() to return the type of controller attached.
Sam Lantinga 9da4bfc1 2019-10-22T10:57:07 Added support for the Power A Nintendo Switch Enhanced Wireless Controller
Sam Lantinga be6cda9f 2019-06-19T15:54:21 Rolling back GameCube HIDAPI support It causes the HIDAPI devices to always be opened on enumeration, which causes crashes in the Windows drivers when multiple applications are reading and writing at the same time. We can revisit this after 2.0.10 release.
Zack Middleton 82af4276 2019-06-08T13:36:59 hidapi: Use GameCube adapter controller port for player index The Nintendo USB GameCube adapter has four controller ports. Return the port number as 0 to 3 from SDL_JoystickGetPlayerIndex() and SDL_JoystickGetDevicePlayerIndex().
Cameron Gutman 5cb14f44 2019-04-30T20:37:49 Ignore Xbox One S gamepads with older firmware in HIDAPI This older firmware had a different HID report style that we don't support.
Ethan Lee c5286156 2019-03-12T20:27:54 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.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 9aa8a75d 2018-09-28T01:18:54 Fixed building with Xcode 10.0
Sam Lantinga d07fe7ad 2018-09-21T09:41:21 Removed button logging message
Sam Lantinga e8b0859f 2018-09-20T15:55:52 Added missing call to WindowsDeleteString()
Sam Lantinga 600126c9 2018-09-19T10:03:40 Added experimental support for Windows.Gaming.Input
Sam Lantinga 34237b80 2018-08-31T18:10:21 Better fix to make sure we're only returning controllers from the HIDAPI joystick API
Sam Lantinga fda14741 2018-08-29T18:56:54 Fixed Xbox One S Bluetooth support on Mac OS X
Sam Lantinga 7d3a7ef8 2018-08-15T23:35:54 Use a single hint for both Xbox 360 and Xbox One controllers, since they are often the same driver.
Sam Lantinga a2add1f6 2018-08-15T23:14:45 Use the HIDAPI driver for Xbox controllers on Windows, and determine the XInput mapping at runtime for extended functionality like rumble and guide button.
Sam Lantinga 3f5ff751 2018-08-15T23:14:43 Use a unified name list for Xbox 360 and Xbox One controllers for drivers that can handle both
Sam Lantinga aad340eb 2018-08-15T19:53:36 Added Windows Xbox controller state packet handling, for completeness.
Sam Lantinga 63107524 2018-08-15T19:53:34 Fixed input from the Steam Virtual Gamepad on Mac OS X
Sam Lantinga 51902010 2018-08-15T19:53:26 Remove the HIDAPI device if we get a read error from it This fixes detecting PS4 controller disconnect on Mac OS X, where there isn't any device removed notification
Sam Lantinga d2042e1e 2018-08-09T16:00:17 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms. Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API