src/joystick/hidapi/SDL_hidapi_xboxone.c


Log

Author Commit Date CI Message
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sam Lantinga 89e9f7b4 2022-11-28T23:10:02 Added support for the Xbox Elite controller paddles with firmware version 5.13+
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Sam Lantinga 9d1dbd2a 2022-11-06T01:16:52 Added note about trigger rumble availability across third-party Xbox One controllers
Sam Lantinga e7a56323 2022-11-06T01:43:05 Make sure we wait after sending the rumble packet when initializing the PowerA Xbox One Mini Wired Controller
Sam Lantinga 6875e62a 2022-11-06T01:15:20 Make sure we don't send Xbox controllers rumble so quickly that it overwhelms the firmware Fixes https://github.com/libsdl-org/SDL/issues/6435
Sam Lantinga e45cb5b1 2022-11-06T01:15:18 Fixed initializing the PowerA Xbox One Mini Wired Controller
Sam Lantinga a4626dea 2022-11-05T14:24:41 Fixed initializing the PDP Xbox One and Victrix Gambit controllers
Sam Lantinga 7e11b09b 2022-11-05T13:50:37 The PowerA Xbox One Mini Wired Controller works with the HIDAPI driver now
Sam Lantinga 24cdebe4 2022-11-05T10:34:08 Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED to control the brightness of the Xbox button LED on the Xbox One controller
Sam Lantinga fa2063fb 2022-09-22T23:42:25 Improved detection of third party PS4 and PS5 controllers
Sam Lantinga aa2e2f48 2022-09-22T18:22:17 Make sure HID devices can be opened before making them available to the application This prevents a number of issues where devices are enumerated but not actually able to be opened, like https://github.com/libsdl-org/SDL/issues/5781. We currently leave the devices open, allowing us to more easily do controller feature detection, protocol negotiation, detect dropped Bluetooth connections, etc. with the expectation that the application is likely to open the controllers shortly.
Sam Lantinga cdaafcec 2022-08-30T14:56:11 The Kinvoca Joy-Cons are handled by the Joy-Con driver, not the Switch Pro driver.
Sam Lantinga 52b6899a 2022-08-19T11:11:23 Added hints for more fine grained control over HIDAPI Xbox controller support
Cameron Gutman 3242265f 2022-07-10T12:22:47 joystick: Fix endianness issues in Xbox HIDAPI drivers
chalonverse 3b191580 2022-06-27T17:19:39 Windows GDK Support (#5830) * Added GDK * Simplfied checks in SDL_config_wingdk.h * Added testgdk sample * Added GDK readme * Fixed error in merge of SDL_windows.h * Additional GDK fixes * OpenWatcom should not export _SDL_GDKGetTaskQueue * Formatting fixes * Moved initialization code into SDL_GDKRunApp
Sam Lantinga 68544be4 2022-06-10T11:31:59 Added support for the Nintendo Online controllers
Sam Lantinga b06866ef 2022-01-16T09:44:28 Entirely remove Xbox axis filtering, we don't want this at all.
Sam Lantinga 85961b61 2022-01-16T09:01:56 Disable Xbox axis deadzone handling by default Fixes https://github.com/libsdl-org/SDL/issues/5227
Sam Lantinga 1a50334c 2022-01-14T15:04:26 Fixed Xbox One trigger axis zero point
Sam Lantinga 16f5b9e3 2022-01-05T11:07:52 Filter jitter on Xbox One controllers when using raw input reports
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 907943a2 2021-08-12T17:51:08 Added support for the Xbox One S Controller with 5.x series firmware
Ozkan Sezer 7aec0b90 2021-08-13T01:56:56 SDL_hidapi_xboxone.c: fix bogus 'uninitialized' warning from clang. The last 'size == 50' check is always true anyway.
Sam Lantinga 6eb4ebb5 2021-08-12T15:49:33 Simplified the HIDAPI Xbox One controller initialization
Sam Lantinga 584b89ab 2021-08-12T08:17:10 Added support for the color LED on the Xbox Elite Series 2 controller
Sam Lantinga 64882b24 2021-08-12T08:17:08 Added support for the Xbox One Elite 2 Controller with 5.x series firmware
Sam Lantinga 6af6950d 2021-07-30T18:23:42 Added support for the Victrix Gambit Tournament Controller
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
Sam Lantinga afd100f0 2021-06-18T17:37:46 Added support for the PowerA Fusion Pro 2 and the PDP Xbox Series X Afterglow and Blue controllers
Sam Lantinga 5427f486 2021-02-11T17:28:07 Added support for trigger rumble for all Microsoft Xbox One controllers
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 85235985 2021-02-02T11:53:31 Fixed detecting the paddles on the Xbox Elite Series 1 controller
Sam Lantinga e2f46ed8 2021-01-14T23:49:20 Always lock the HIDAPI device when closing, in case rumble is pending
Sam Lantinga a5dba7d3 2021-01-08T09:54:52 Fixed Xbox One Series X share button incorrectly triggering on newer firmware
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga e65e4fd3 2020-12-14T09:48:51 Fixed detecting the guide button on Xbox One S controllers over Bluetooth on Linux
Sam Lantinga 09909d02 2020-12-03T19:44:47 Fixed handling of BACK button on newer Xbox One S controllers
Sam Lantinga 54e5136b 2020-12-03T18:17:04 Refactored Xbox One Bluetooth protocol and verified Xbox One S, Xbox Series X, and Xbox One Elite Series 2 controllers
Sam Lantinga 517be808 2020-11-25T16:05:19 Implemented battery status for Bluetooth Xbox One controllers Also switched the rumble loop count to 0xEB (one hour) to match Windows driver
Sam Lantinga 159d1b3d 2020-11-25T01:35:45 Don't set the serial number after the controller is opened We'll use the USB value instead so it's available as soon as it's opened.
Sam Lantinga 7d92b14f 2020-11-25T01:18:18 Simplified Xbox One controller initialization state, and don't query for the serial number.
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 ffb4d960 2020-11-19T19:09:34 Disabled Xbox protocol debugging
Sam Lantinga 45f14375 2020-11-18T20:34:12 Experimenting with requesting the serial number on an Xbox One controller
Sam Lantinga 963d8b3f 2020-11-18T20:34:10 Fixed bits in the initial Xbox One protocol ack
Sam Lantinga cd51a51f 2020-11-18T20:34:08 Updated with a better understanding of the Xbox One controller protocol
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 5c34c973 2020-11-13T19:40:25 Clarify that we're using button indices, not using gamepad button names
Sam Lantinga 5b0d4329 2020-11-12T07:53:03 Implemented trigger rumble in the HIDAPI Xbox One driver
Sam Lantinga 320a7587 2020-11-11T19:26:59 Fixed compiler warnings
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga e12457d8 2020-11-10T12:26:30 Added support for the Xbox Series X controller to the HIDAPI driver
Sam Lantinga c3dea231 2020-11-09T22:39:33 Added support for reading the paddles on a Xbox Elite Series 2 controller in Bluetooth mode
Sam Lantinga 009b62f1 2020-11-07T02:22:15 Be explicit about mapping the new game controller paddle buttons
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.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga b90b5927 2020-04-17T21:30:58 Added support for the Razer Atrox Arcade Stick
Sam Lantinga dbcda0b2 2020-04-17T21:30:56 Added support for the Razer Wolverine Ultimate
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 879f137a 2020-03-13T19:00:24 Added support for the older Xbox One S Bluetooth controller report format
Sam Lantinga 9fdc6cf3 2020-03-10T18:34:33 Removed Xbox HIDAPI debug code
Sam Lantinga 281d05a6 2020-03-04T09:42:10 Fixed handling the guide button with both V1 and V2 of the Xbox One Bluetooth wireless protocols
Sam Lantinga 756d2073 2020-03-02T09:26:12 Updated the HIDAPI Xbox One driver with support for Bluetooth Xbox One controllers
Sam Lantinga 20d67446 2020-02-27T09:33:32 Xbox One controller rumble doesn't need synchronization if you use a packet counter of 0
Sam Lantinga 81256207 2020-02-07T11:02:34 Update for bug 4923 - Calling SDL_GameControllerRumble() often takes 8 ms meyraud705 Dualshock4 on bluetooth need 78 bytes for the rumble data while SDL_HIDAPI_RumbleRequest can only hold 64 bytes. 'volatile' is not meant for thread synchronization. The list of rumble request could grow infinitely if user call SDL_JoystickRumble too much. The documentation says "Each call to this function cancels any previous rumble effect", so overwriting pending request seem like a good idea.
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 c9f672fd 2020-01-23T22:24:24 Fixed compiler warnings
Sam Lantinga 443bce74 2020-01-22T11:28:35 Added support for the paddles on the Xbox One Elite Series 1 controller
Sam Lantinga 25c88ea9 2020-01-20T13:53:40 The Xbox One 0x01 initialization packet is an ack packet
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 c6817a2c 2020-01-16T15:32:41 Added support for the paddles on the Xbox One Elite Series 2 controller
Sam Lantinga 4e1cc124 2020-01-16T15:32:39 Improved Xbox One controller initialization
Sam Lantinga 669729a8 2020-01-15T22:18:31 Improved Xbox One controller initialization sequence This sequence works across Microsoft, PowerA, PDP, and HORI controllers. The newer Microsoft XBox firmware requires synchronizing the rumble sequence number, when SDL sees it after the initial connect The Razer Wildcat controller requires waiting for init responses before continuing the initialization sequence. The PDP Battlefield 1 controller takes over a second to be ready for initialization, and if initialization is attempted before then, it will fail.
Sam Lantinga d2cda502 2020-01-12T17:22:24 Send the full Xbox One controller sequence for Microsoft controllers This switches Bluetooth controllers back into USB report mode for the latest Xbox One S and Xbox One Elite Series 2 firmware
Sam Lantinga 5d28c315 2020-01-09T14:53:34 Only initialize Xbox One controllers once they're ready for initialization (or if they are silent until init) This fixes the Hyperkin Duke Xbox One controller showing the Xbox startup animation every time an SDL application launches
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 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 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 c2b6d6f9 2019-12-13T16:12:37 Enable the LED on PowerA Xbox One controllers
Sam Lantinga 8b50dcb2 2019-12-11T17:46:54 Use the controller product string instead of hard-coding controller names
Sam Lantinga 82d2c357 2019-12-09T16:52:11 Fixed rumble after Xbox controller initialization When we initialize the controller it has an internal rumble sequence number, and if our rumble sequence number doesn't match that, rumble won't happen. To fix that we cycle through the range of sequence numbers, and at some point we'll match up with the controller's sequence number and it'll roll forward until it matches our next rumble sequence number.
Sam Lantinga 3d34750c 2019-12-09T13:54:05 The PowerA Mini controller blocks while writing feature reports, so don't try to use the HIDAPI driver for it on Linux
Sam Lantinga 2fd3f756 2019-11-28T11:44:17 Fixed trying to use the HIDAPI driver for the original Xbox One S Bluetooth controller
Sam Lantinga 4a776138 2019-11-27T18:26:57 Added the full Xbox One Elite Series 2 controller initialization sequence, to start input reports after switching out of Bluetooth mode.
Sam Lantinga 8e153922 2019-11-22T17:46:30 This packet didn't end up being needed to initialize input for the Xbox One Elite Series 2 controller