src/joystick/hidapi/SDL_hidapi_ps5.c


Log

Author Commit Date CI Message
Sam Lantinga cc4973ea 2023-09-18T12:55:43 Fixed sensor timestamp units for third-party PS5 controllers (cherry picked from commit a72dfa6a5fe8d8901175db852de8686b83487522) (cherry picked from commit 37dee79b74723b7021ccaa946e31872f0539df4a)
Sam Lantinga 8114bd91 2023-09-18T12:19:18 Fixed error: array subscript 2 is above array bounds of ‘const Uint8[2]’ Smart compilers don't like dereferencing off the end of arrays (cherry picked from commit f6756047a4190d9c82222e4ec378bdb14a72f8d7) (cherry picked from commit 62e7049a4f6eedc75d7ffb9cffc435f491f1577c)
Sam Lantinga 495fca15 2023-09-18T11:50:56 Fixed sensor timestamp calculation for third-party PS5 controllers (cherry picked from commit 7059a55ccca04b75145c3d23a317fbe1eb77039e) (cherry picked from commit fff3c2573a46b685f73646dc01937a88c35b3be6)
Sam Lantinga 874f6fea 2023-08-24T11:37:50 Fixed the report format for the Razer Wolverine V2 Pro (cherry picked from commit 69aec8c915b5cddae2bb6171d7d5404f4d779db3) (cherry picked from commit 6ff48dddcb34736a3550ba94f8ef3f3ce3e79de5)
Sam Lantinga fb57ba76 2023-07-17T17:08:17 Fixed LED pending check failing when the controller timestamp is very large In this case we know the controller has been on for a while and the Bluetooth connection LED cycle is complete. Also fixed the timestamp being zero the first time it is checked (cherry picked from commit bd4f155bbbdc4be34505535e4bd936ae12671925) (cherry picked from commit f7dc8c0eaa66cf33dcacb31cc3d09dee197bacbe)
Sam Lantinga 63a98d0d 2023-07-17T16:45:31 Don't send k_EPS5FeatureReportIdCapabilities to Sony PS5 controllers This report is for third party controllers only. (cherry picked from commit 16dd5f0da4ee950e9f998a757dcb4789463e67e2) (cherry picked from commit bb036ef5441f6e0374eed6a02adb9dc66273c629)
Sam Lantinga 78f11e05 2023-07-17T16:42:58 Don't tickle Bluetooth PS5 controllers in simple mode with an effects packet That will put the PS5 controller into enhanced mode, which breaks DirectInput games (cherry picked from commit 2fef0be2f646ae048e239aa6694e632081c85238) (cherry picked from commit 910dad505af1684d1a6ebce3a8a371830fd3e50b)
Sam Lantinga f444eac5 2023-03-30T07:25:49 Fixed analog triggers on the DualSense controller (cherry picked from commit a67d41050164e447048fa55179cc31b23be9d9b7)
Sam Lantinga ab167038 2023-03-10T15:28:22 Added support for the trigger buttons on the Victrix Pro FS for PS5 (cherry picked from commit 8d7e61ea42364c256b76e7f6f2b6d6f90742bcb7)
Sam Lantinga 0d763800 2023-03-09T15:10:00 Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!) (cherry picked from commit c6443d86c92e962683a1efe5f123a144988875b5)
Sam Lantinga c0fb0924 2023-02-28T08:36:31 Fixed locking up the Logitech F310 with the PlayStation controller detection (cherry picked from commit da134a30396e12786c14fe8d1190ab05c67d9dba)
Sam Lantinga abe8dbbf 2023-02-20T15:14:20 Added support for the Razer Wolverine V2 controllers (cherry picked from commit 4994654d4f2d5c96a0faa972ebbb6c653f939d56)
Sylvain 17515f4a 2023-02-04T15:51:37 Backport simplify flags PR #7220
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Sam Lantinga d59caffe 2022-12-13T14:03:40 Added support for clang thread-safety analysis The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code. Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change. This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock. To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
Sam Lantinga fc689a6c 2022-12-07T16:06:17 Fixed build
Sam Lantinga b4d54790 2022-12-07T14:53:33 Use the correct name for the DualSense controllers (cherry picked from commit 9a6bcca6b8db999217f157dab8c44bf27b0a8eb4)
Sam Lantinga 4ee36a94 2022-12-07T14:25:53 Added support for the DualSense Edge paddles (cherry picked from commit 9339085593dc20b1f003f26b3c40615cf04504b0)
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)
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 38af459d 2022-11-06T01:15:19 Fixed potential clobbering of packets of different types using SDL_HIDAPI_SendRumble()
Sam Lantinga 33050fea 2022-10-07T11:29:49 Only open HID devices that might have a HIDAPI driver available This prevents an OS prompt for every connected device when running on Android
Sam Lantinga 2c518747 2022-09-27T09:56:02 Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver
Sam Lantinga 1e1be0b9 2022-09-26T23:00:58 Updated logic to match between PS4/PS5/Switch controllers
Sam Lantinga 8c40a6b0 2022-09-26T22:47:21 Drop PS5 Bluetooth reports that fail CRC check
Sam Lantinga 67db8a91 2022-09-26T20:41:51 Wait for input before reconnecting a Bluetooth device On Windows, the Bluetooth device can remain in a connected state if the controller just shut down. It won't return any errors, but it also won't generate any input reports in this state, so wait until we know for sure that the Bluetooth controller is sending data before letting the application know it's available.
Sam Lantinga b7fddb4c 2022-09-26T14:39:51 Minor tweaks
Sam Lantinga 39adcc0a 2022-09-26T14:20:34 Prefer USB input over Bluetooth for PS5/PS5/Switch controllers Nintendo Switch controllers will automatically turn off Bluetooth when connected over USB, but this takes care of that a little more quickly. PS4 and PS5 controllers will happily send reports over both Bluetooth and USB, so we'll prefer USB if connected and switch back to Bluetooth if USB is disconnected.
Sam Lantinga 17d7d03a 2022-09-26T08:12:35 Added detection of the joystick type for third party PS4 and PS5 controllers
Sam Lantinga 5b3b7e6e 2022-09-23T16:46:36 Separated PS4/PS5 effects support into individual capabilities
Sam Lantinga 5b4c10fc 2022-09-23T02:36:53 Return true from IsSupportedDevice if it's a device that we _might_ support This forces an update of the device list so we have the correct state when we check to see whether a device is being handled by HIDAPI
Sam Lantinga 899a1e7c 2022-09-22T23:54:26 Skip PS4/PS5 probe message if we already know it's a supported 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 6cbdc666 2022-09-22T09:05:06 Fixed use of uninitialized 'size' variable (thanks @ozkan!)
Sam Lantinga 0c4594ac 2022-09-22T06:45:46 Improved PS4 and PS5 third-party controller feature detection
Sam Lantinga 2e9f5b59 2022-09-16T15:41:35 Added support for the HORI Fighting Commander OCTA (Xbox Series X and PS versions)
Sam Lantinga 5770e87c 2022-09-02T13:57:59 Fixed regression handling touchpad input with PS5 controllers using the original shipping firmware
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 b2ac758f 2022-08-29T17:33:00 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver
Sam Lantinga 52b6899a 2022-08-19T11:11:23 Added hints for more fine grained control over HIDAPI Xbox controller support
Sam Lantinga 5545be85 2022-08-08T23:44:50 The player LED index wraps for PS5 controllers, like it does for other controller types
Sam Lantinga b0e827fb 2022-06-17T07:55:33 Enable improved rumble emulation on DualSense(tm) Wireless Controllers with firmware version 2.24 and newer
Sam Lantinga 68544be4 2022-06-10T11:31:59 Added support for the Nintendo Online controllers
Sam Lantinga 9202df04 2022-06-09T18:11:34 Implemented SDL_GameControllerGetFirmwareVersion() for HIDAPI PS5 controllers
Sam Lantinga 2ca08378 2022-04-22T14:21:41 SDL: sometimes the PS5 controller doesn't report having to power even when connected over USB. Possibly related to being completely charged? Either way we already know that it's USB or BT so let's use the driver's knowledge instead.
Cameron Gutman 2c04df8d 2022-03-30T18:33:38 joystick: Fix rumble issues on PS5 HIDAPI controllers We were returning the report size from HIDAPI_DriverPS5_RumbleJoystick() rather than 0 upon success, causing SDL_JoystickRumble() (and callers) to think that rumbling failed. This didn't cause major problems until 1868c5b, when it started preventing rumble state from being persisted in the joystick core, even though it was successfully sent to the hardware. This led to all sorts of strangeness, including broken rumble duration and attempts to stop rumble being discarded.
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
Ozkan Sezer 6ad0fb84 2021-11-13T17:55:10 SDL_hidapi_ps4.c, SDL_hidapi_ps5.c: use SDL_zeroa()
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 a186a503 2021-07-29T06:43:39 Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.
Sam Lantinga 384d86b5 2021-07-23T23:48:23 Fixed compile warnings with Visual Studio
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 333c8e75 2021-05-17T11:54:05 The PS5 driver supports Joystick LED
Cameron Gutman 6e97170e 2021-01-08T21:16:06 Use PS4 rumble hint as the default for the PS5 rumble hint Existing SDL applications may not know about the need to set a specific hint to enable rumble on PS5 controllers, even though they may already set the equivalent SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE hint for PS4 controller rumble support. Rather than requiring those developers update their apps, let's use the SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE value as an indication of the behavior they are expected for all PlayStation controllers.
Sam Lantinga e2f46ed8 2021-01-14T23:49:20 Always lock the HIDAPI device when closing, in case rumble is pending
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 0684572c 2020-12-29T12:13:10 Added a hint to control whether the player LEDs should be lit to indicate which player is associated with a PS5 controller.
Sam Lantinga 0ed4d929 2020-12-23T04:53:23 Fixed setting player LEDs for PS5 controllers over Bluetooth
Sam Lantinga 6341bb35 2020-12-22T21:51:59 Fixed controller disconnect detection for PS4 and PS5 controllers over Bluetooth
Sam Lantinga a30adae5 2020-12-22T20:58:32 Make it possible to turn on PS4 rumble effects at runtime using the hint
Sam Lantinga c93947a2 2020-12-22T20:12:03 Make it possible to turn on PS5 rumble effects at runtime using the hint
Sam Lantinga 058a0ab4 2020-12-22T14:38:32 Set the pad lights on the PS5 controller corresponding to the player index Also allow setting the player index from testgamecontroller using the number keys
Sam Lantinga 6a57072e 2020-12-22T14:10:08 Only add the touchpad and sensors to the PS5 controller if effects are enabled
Sam Lantinga 4ec776c3 2020-12-22T13:29:23 Don't switch the PS5 controller out of DirectInput mode by default
Sam Lantinga 80e5c689 2020-12-13T01:20:38 Fixed the PS5 controller not disconnecting when powered off
Sam Lantinga e3966e25 2020-11-30T13:04:30 Use the correct internal API for updating the battery level for PS5 controllers
Sam Lantinga f4ed07de 2020-11-30T13:02:34 We don't know whether the PS5 controller is Bluetooth or not when we open it
Sam Lantinga e44bf8a0 2020-11-23T21:18:37 Fixed bug 5359 - Incorrect sensor data from DualShock4 multiply gyro values by sensitivity When the hardware calibration fails, values read from sensors need to be multiplied by default sensitivity (16 for gyro, 1 for accelerometer).
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 870841c4 2020-11-21T11:59:01 Reset the LED state after Bluetooth connection has completed on the PS5 controller
Sam Lantinga 549010f2 2020-11-20T13:24:49 It takes 2 packets to stop audio haptics and start emulated rumble on the PS5 controller
Sam Lantinga c9b097e6 2020-11-19T13:31:16 Clarify the meaning of the rumble enable bits for the PS5 controller
Sam Lantinga c85623d7 2020-11-19T13:10:14 Re-enable haptic audio after rumble on PS5 controller Also make sure we don't set any other state when we're not intending to, and added more interesting effects which are currently not exposed via API
Sam Lantinga 8c3196da 2020-11-18T21:33:11 Fixed some compiler warnings
Sam Lantinga 463d84a8 2020-11-17T10:56:56 Added support for the PS5 controller gyro and accelerometer
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 d140d887 2020-11-16T17:36:47 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial()
Sam Lantinga 71e32f5e 2020-11-16T15:00:15 Added SDL_crc32()
Sam Lantinga 3d48fc05 2020-11-16T13:21:02 Added notes about the pad lights on the PS5 controller
Sam Lantinga 4514ad57 2020-11-16T13:07:11 Fixed updating LED state when starting application with Bluetooth PS5 controller connected
Sam Lantinga a37e3ae2 2020-11-16T11:21:58 Implemented PS5 effects over Bluetooth
Sam Lantinga c6c116e8 2020-11-16T10:51:13 Implemented setting the LED color on the PS5 controller
Sam Lantinga aa7c3eae 2020-11-16T09:16:01 Fixed size of rumble packet
Sam Lantinga f28c01a4 2020-11-16T09:11:15 Fixed rumble order on PS5
Sam Lantinga eb94c19a 2020-11-16T08:09:15 SDL: fix iOS build
Sam Lantinga 8243bd1d 2020-11-16T08:09:13 SDL: Plumb PS5 rumble to output report
Sam Lantinga 9f51fad3 2020-11-13T18:01:29 Added support for the touchpad on PS4 and PS5 controllers
Sam Lantinga 78422fa3 2020-11-13T13:17:07 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth
Sam Lantinga 320a7587 2020-11-11T19:26:59 Fixed compiler warnings
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 a22beef4 2020-11-05T17:03:28 Moved the PS5 controller driver to a separate file, as the advanced feature protocol is very different from that of the PS4