src/joystick/hidapi


Log

Author Commit Date CI Message
Sam Lantinga 3b0cd441 2022-12-17T06:51:02 Fixed compiler warning ``` ./src/joystick/SDL_joystick.c:105:12: warning: no previous extern declaration for non-static variable 'SDL_joystick_lock' [-Wmissing-variable-declarations] SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ ^ ./src/joystick/SDL_joystick.c:105:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ ^ ``` 1 warning generated.
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 802b5ef7 2022-12-12T10:54:29 Added support for the STRIKEPAD PS4 Grip Add-on to the HIDAPI driver (cherry picked from commit 618340bf990512247ed29a1beb38606e371d60e8)
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 6e40c7a9 2022-11-30T17:03:29 Added support for the Logitech Cordless Precision PS3 controller
Sam Lantinga 4504c10f 2022-11-30T16:37:20 Re-enabled support for third party PS3 controllers
Sam Lantinga 9e997cc7 2022-11-30T15:39:10 Fixed Victrix FS Pro V2 controller hang on reboot
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+
Sam Lantinga a937b5c4 2022-11-28T13:47:30 Add 8BitDo to the list of Xbox 360 third party vendors Allows detection of the 8BitDo Ultimate Wired Controller
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 509939b1 2022-11-18T18:20:53 Disable the third party PS3 HIDAPI driver by default, the L3/R3 buttons are unknown
Ryan C. Gordon 389ffab7 2022-11-16T12:53:48 Code style fixes, etc. Reference PR #6345.
ulatekh ec58a817 2022-10-05T19:26:09 Fixes made in response to running a static code analyzer under MS Windows. Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs. SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision. SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer. SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used. SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range. SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it. SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691). SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen. SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL. SDL_pixels.c: Looks like the switch is genuinely missing a break! SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons. SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
Sam Lantinga 0dfc829a 2022-11-10T19:16:53 Added simple BLE Steam Controller support on all platforms This is still disabled by default via the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM
Sam Lantinga 2e3b4f3f 2022-11-08T07:50:51 Don't send rumble to the Amazon Luna controller on macOS Sending rumble to the Amazon Luna controller on macOS gets there, but IOHIDDeviceSetReport() blocks for a long time and eventually fails. This appears to be a bug in the macOS Bluetooth stack, ref rdar://99265496
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 38af459d 2022-11-06T01:15:19 Fixed potential clobbering of packets of different types using SDL_HIDAPI_SendRumble()
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 c70e6759 2022-11-03T12:37:54 Wait a bit for devices to initialize before trying to enumerate and open them. This works around udev event nodes arriving before hidraw nodes and the controller being opened twice - once using the Linux driver and once by the HIDAPI driver. This also fixes a kernel panic on Steam Link hardware due to trying to open the hidraw device node too early. A delay of 10 ms seems to be a good value, tested on Steam Link hardware.
Sam Lantinga b75d3187 2022-10-31T13:33:53 Sometimes the HID open doesn't succeed immediately after being notified about the device Tested on Steam Link hardware with the Nintendo Switch Pro controller, which will occasionally take 2 attempts to open.
Sam Lantinga c74ea994 2022-10-25T13:11:41 Added support for the Razer Raiju Tournament Edition controller in Bluetooth mode
Sam Lantinga 72f6e216 2022-10-25T12:25:57 Disabled debug logging
Sam Lantinga da478d1f 2022-10-25T10:30:56 Fixed build
Sam Lantinga a6018ae5 2022-10-25T10:23:51 Added support for the NVIDIA SHIELD controller v1.03 to the HIDAPI driver
Sam Lantinga f4d1f5ed 2022-10-23T16:35:36 SDL-HIDPS4: fix PS4 Slim controller over BT - it sends the same input report as the it does over USB, but with a larger packet size CR: saml
Sam Lantinga 333935ff 2022-10-17T11:10:53 Make sure we completely unlock joysticks when opening HIDAPI devices Also lock the joysticks when adding and removing Android joysticks
Sam Lantinga e8fdb861 2022-10-15T10:02:39 Removed redundant masking when loading the IMU calibration
happyharryh a6573f94 2022-10-16T00:23:25 Fix bugs in IMU calibration loading for Nintendo Controllers
Sam Lantinga 5129a077 2022-10-14T14:35:52 Steam Controller support defaults off, as documented in SDL_hints.h
Sam Lantinga 93b71967 2022-10-14T10:32:03 Only update the battery level if we're on Bluetooth Fixes battery level dropping to empty with the Qanba Drone Arcade Stick. It looks like we might also be able to skip the check for all third party controllers, but I think this is the right thing to do for Sony controllers as well.
happyharryh 6f224e4d 2022-10-11T10:44:20 Made timestamp_us of sensor events increase monotonically for Nintendo controllers
Sam Lantinga efdb390c 2022-10-09T09:11:33 Disable the HIDAPI Wii driver by default as it doesn't work with the dolphinbar
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 fc720321 2022-10-06T18:23:07 Fix rare deadlock when opening a HID controller on Android Fixes https://github.com/libsdl-org/SDL/issues/6347
Sam Lantinga bd6afc23 2022-10-02T10:15:39 Fixed sensor axes in vertical mode
Sam Lantinga b4c25f57 2022-10-02T09:51:05 Remapped the side button and trigger as paddles for the mini-gamepad mode of the Joy-Cons This is the only case where the mapping differs between right and left Joy-Cons in mini-gamepad mode. The left Joy-Con will have the left paddles and the right Joy-Con will have the right paddles. This facilitates co-op gameplay with individual actions while still using the normal mini-gamepad mode. The paddles are used for this because conceptually they are more awkward to hit than the normal controls and they are in roughly the correct hand position.
Sam Lantinga 37dfa262 2022-10-02T09:36:50 Added paddle mapping for combined Joy-Cons
Happy Harry 6c8bf3af 2022-10-03T00:19:34 Add vertical mode for Nintendo Joy-Con (#6303) * Added support for vertical mode for Joy-Con controllers * Added the hint SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS for switching to this mode * Added support for SL/SR buttons in combined/vertical mode and L/ZL/R/ZR buttons in mini-gamepad mode
Sam Lantinga 0672dc8d 2022-10-02T08:48:38 Fixed combined Joy-Cons after https://github.com/libsdl-org/SDL/commit/aa2e2f4843567cfe4e6f2f4ffa3f0b74dd98f1ba (thanks @happyharryh!)
Sam Lantinga 18eb319a 2022-09-27T12:34:03 Added sensor timestamp for Nintendo Switch controllers
Sam Lantinga 5e3a4030 2022-09-27T11:36:01 Added sensor timestamp for Steam Controllers
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 db075ff3 2022-09-26T22:45:01 Removed unused variable
Sam Lantinga 2ccdd066 2022-09-26T22:32:57 Handle DS4 dongle controller connection and disconnection We also drop Bluetooth packets that fail the CRC check, as recommended by Sony
Sam Lantinga 18046b9a 2022-09-26T20:53:50 Fixed crash with a NULL serial number
Sam Lantinga 67fa6a93 2022-09-26T20:49:26 Don't wait a long time for zombie Bluetooth controllers If a Nintendo Switch Pro controller is turned off, it will leave the controller connected in Windows, but not responding to reports. Don't wait a really long time trying to get information from a controller in this state.
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 2cc91761 2022-09-26T18:52:26 Removed debug logging
Sam Lantinga 2c98c8af 2022-09-26T18:39:18 Use better default values for Switch controller calibration
Sam Lantinga a205c5e2 2022-09-26T18:18:16 Use separate extents for simple and advanced reports
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 56b91ea7 2022-09-23T15:27:40 Fixed feature detection for the Razer Raiju Tournament Edition controller
Sam Lantinga c2ae2ccc 2022-09-23T09:10:51 Added feature support for the Razer Raiju to the HIDAPI driver
Sam Lantinga 51fefd1c 2022-09-23T02:39:35 Added support for third party PS3 controllers to the HIDAPI driver
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 1d34a524 2022-09-23T00:38:23 Fixed shadowed variable warning
Sam Lantinga 010d3e64 2022-09-23T00:36:46 Fixed function prototype mismatch
Sam Lantinga b7940c29 2022-09-23T00:15:40 Allow HIDAPI controllers to override the default joystick type
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)
Amir 7f415ce5 2022-09-12T20:09:00 android: fix some compiler warnings
Sam Lantinga d93f9a77 2022-09-07T12:33:43 The new Wii Remote shares the same VID/PID as the Wii U Pro controller
Sam Lantinga 87f8b6ff 2022-09-07T01:21:01 Don't mess with the state of the Motion Plus extension on Linux
Sam Lantinga c28da489 2022-09-07T00:52:40 Fixed build
Sam Lantinga 638452ec 2022-09-07T00:44:13 Assert that continuous reporting is enabled, so input timeout is a reliable way of detecting Bluetooth connection problems.
Sam Lantinga 8dfe0e4b 2022-09-07T00:41:29 Removed checks not needed for the Wii U Pro Controller
Sam Lantinga 4018f35e 2022-09-07T00:00:27 Added left and right sensors for Nintendo Joy-Con and Wii controllers
Sam Lantinga 30f55a5d 2022-09-06T23:33:55 Added initial support for the Wii Motion Plus extension This adds a gyro sensor to the Wii controller, and is enabled in standalone and nunchuk mode
Sam Lantinga d1fea10c 2022-09-05T16:08:15 Added support for the accelerometer in the Wii Remote
Sam Lantinga a61b823d 2022-09-05T14:31:25 Added support for the Wii Remote with the Classic Controller Pro extension Also changed event order to: buttons, triggers, axes, for consistency with other drivers
Ozkan Sezer 612a86eb 2022-09-05T20:47:00 HIDAPI_DriverPS3_UpdateEffects: kill bad use of & operator on effects[]
Sam Lantinga b00e1b1b 2022-09-05T10:01:28 Added support for a ShanWan PS2 -> PS3 USB converter to the HIDAPI driver
Sam Lantinga 5770e87c 2022-09-02T13:57:59 Fixed regression handling touchpad input with PS5 controllers using the original shipping firmware
Sam Lantinga 253f6a91 2022-09-02T11:49:06 Variable renaming for consistency
Sam Lantinga 5002624e 2022-09-02T11:41:19 Fixed crash when extension controllers are hotplugged
Sam Lantinga 7df571ff 2022-09-02T11:37:16 HIDAPI_DumpPacket() takes a const memory pointer
Sam Lantinga b6d23d21 2022-09-02T11:21:51 Fixed interactions with the Linux Wiimote driver
Ozkan Sezer 0c984360 2022-09-02T20:02:56 SDL_hidapi_wii.c: fix a -Wshadow warning
Sam Lantinga b6b3fb00 2022-09-02T09:59:32 This was intended to be Uint8
Ozkan Sezer 5be157b3 2022-09-02T19:33:40 SDL_hidapi_wii.c: fix -Wpointer-sign warnings
Sam Lantinga 54356f41 2022-09-02T09:03:44 Wii: fixed trigger axis reporting for the Wii U Pro Controller
Sam Lantinga a35642fa 2022-09-02T08:58:21 Wii: don't bother reading the extension type for the Wii U Pro controller, we already know what it is