Commit graph

1572 commits

Author SHA1 Message Date
Sam Lantinga 0bc852ce53 Revert "Disable the RAWINPUT joystick driver by default"
Disabling RAWINPUT on Windows 10 causes these issues:
* All Xbox controllers are named "XInput Controller".
* Trigger rumble no longer works.
* "XInput Controllers" are now also listed as separate haptic devices
2022-10-17 17:43:06 -07:00
Sam Lantinga 333935ff3f Make sure we completely unlock joysticks when opening HIDAPI devices
Also lock the joysticks when adding and removing Android joysticks
2022-10-17 11:10:53 -07:00
Sam Lantinga 47ba997f06 Disable the RAWINPUT joystick driver by default
It's only needed to support more than 4 Xbox controllers, and adds significant complexity to the joystick processing, and we regularly get bugs from people who aren't using an SDL window who need to turn on SDL_HINT_JOYSTICK_THREAD.
2022-10-17 07:39:52 -07:00
Sam Lantinga 5025f24033 Don't use RAWINPUT joystick driver on Windows XP
Fixes https://github.com/libsdl-org/SDL/issues/6400
2022-10-17 07:35:00 -07:00
Sam Lantinga 70dfd6dd1a Added mapping for Xbox Series X controller
Fixes https://github.com/libsdl-org/SDL/issues/6296
2022-10-16 09:06:02 -07:00
Sam Lantinga e8fdb861ef Removed redundant masking when loading the IMU calibration 2022-10-15 10:02:39 -07:00
happyharryh a6573f94ab Fix bugs in IMU calibration loading for Nintendo Controllers 2022-10-15 10:01:22 -07:00
Sam Lantinga 5129a07707 Steam Controller support defaults off, as documented in SDL_hints.h 2022-10-14 14:35:52 -07:00
Sam Lantinga 6af17369ca Added mapping for Qanba Drone on Linux without HIDAPI 2022-10-14 10:36:24 -07:00
Sam Lantinga 93b7196763 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.
2022-10-14 10:32:03 -07:00
Sam Lantinga 120a957d07 Added support for the Qanba Drone Arcade Stick 2022-10-14 09:57:02 -07:00
Sam Lantinga fc73386f45 Fixed the mapping from raw joystick values to the expected [SDL_JOYSTICK_AXIS_MIN, SDL_JOYSTICK_AXIS_MAX] range. (thanks Tas!)
The original code mapped incorrectly from [min, max] to [-32768, 32512], the upper bound being SDL_JOYSTICK_AXIS_MAX - 255 instead of SDL_JOYSTICK_AXIS_MAX.
2022-10-12 21:44:50 -07:00
happyharryh 6f224e4d9f Made timestamp_us of sensor events increase monotonically for Nintendo controllers 2022-10-10 22:33:19 -07:00
Pierre Wendling 43a2b0b1e5 N3DS: Use macro to correct axis.
Using `(value * SDL max) / 3DS max` allows for marginally better
accuracy compared to `value * (SDL max / 3DS max)`.
2022-10-10 08:50:59 -07:00
Pierre Wendling cb1972b3ba N3DS: ZL and ZR should be considered as triggers.
Previously they were considered as clicking stick.
2022-10-10 08:50:59 -07:00
Pierre Wendling 86a8714fea N3DS: Refactor joystick module to avoid globals. 2022-10-10 08:50:59 -07:00
Pierre Wendling 392f3882d0 N3DS: Use SDL_Sensor instead of Joystick sensors. 2022-10-10 08:50:59 -07:00
Pierre Wendling 266014faa7 N3DS: Use SDL_Touch instead of the Joystick touch. 2022-10-10 08:50:59 -07:00
Pierre Wendling 03bbbcd85e N3DS: Use CreateJoystickGUIDForName. 2022-10-10 08:50:59 -07:00
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Sam Lantinga efdb390caa Disable the HIDAPI Wii driver by default as it doesn't work with the dolphinbar 2022-10-09 09:11:33 -07:00
Sam Lantinga 33050fea39 Only open HID devices that might have a HIDAPI driver available
This prevents an OS prompt for every connected device when running on Android
2022-10-07 11:29:49 -07:00
Sam Lantinga fc720321b3 Fix rare deadlock when opening a HID controller on Android
Fixes https://github.com/libsdl-org/SDL/issues/6347
2022-10-06 18:23:07 -07:00
Sam Lantinga 689409fd97 Fixed the start button on the Nimbus+ controller on tvOS
Also updated mappings for Nintendo Switch controllers on tvOS, to reflect the lack of guide/menu button availability
2022-10-06 17:34:24 -07:00
Sam Lantinga ddc3de602e Added mapping for PS5 controller over Bluetooth on Android 12
Tested on Pixel 3a
2022-10-05 16:24:05 -07:00
Sam Lantinga 81afb3e303 Need to swap endianness when extracting the CRC from game controller mappings 2022-10-05 16:18:42 -07:00
Sam Lantinga 3607f8316f Find out if a controller is wireless using WGI (thanks @DJm00n!)
Confirmed using an Xbox Series X controller over USB and Bluetooth

Fixes https://github.com/libsdl-org/SDL/issues/6322
2022-10-03 11:02:23 -07:00
Sam Lantinga bd6afc2317 Fixed sensor axes in vertical mode 2022-10-02 10:15:39 -07:00
Sam Lantinga b4c25f5714 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.
2022-10-02 09:51:05 -07:00
Sam Lantinga f58a6506a1 Added paddle mapping for combined Joy-Cons 2022-10-02 09:50:27 -07:00
Sam Lantinga 37dfa2629b Added paddle mapping for combined Joy-Cons 2022-10-02 09:36:50 -07:00
Happy Harry 6c8bf3af4c
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
2022-10-02 09:19:34 -07:00
Sam Lantinga 0672dc8d8f Fixed combined Joy-Cons after aa2e2f4843 (thanks @happyharryh!) 2022-10-02 08:50:11 -07:00
Sam Lantinga 7becbd7d42 Add joystick locking for controller notifications on iOS/tvOS
Fixes https://github.com/libsdl-org/SDL/issues/6288
2022-09-27 12:58:16 -07:00
Sam Lantinga 18eb319adc Added sensor timestamp for Nintendo Switch controllers 2022-09-27 12:34:03 -07:00
Sam Lantinga 5e3a40309e Added sensor timestamp for Steam Controllers 2022-09-27 11:36:01 -07:00
Sam Lantinga 2c518747b9 Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver 2022-09-27 09:56:49 -07:00
Sam Lantinga 1e1be0b954 Updated logic to match between PS4/PS5/Switch controllers 2022-09-26 23:00:58 -07:00
Sam Lantinga 8c40a6b0c7 Drop PS5 Bluetooth reports that fail CRC check 2022-09-26 22:47:21 -07:00
Sam Lantinga db075ff3ba Removed unused variable 2022-09-26 22:45:01 -07:00
Sam Lantinga 2ccdd0667a Handle DS4 dongle controller connection and disconnection
We also drop Bluetooth packets that fail the CRC check, as recommended by Sony
2022-09-26 22:34:33 -07:00
Sam Lantinga 18046b9aa3 Fixed crash with a NULL serial number 2022-09-26 20:53:50 -07:00
Sam Lantinga 67fa6a935f 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.
2022-09-26 20:49:26 -07:00
Sam Lantinga 67db8a9103 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.
2022-09-26 20:43:46 -07:00
Sam Lantinga 2cc9176137 Removed debug logging 2022-09-26 18:52:26 -07:00
Sam Lantinga 2c98c8af01 Use better default values for Switch controller calibration 2022-09-26 18:39:47 -07:00
Sam Lantinga a205c5e26c Use separate extents for simple and advanced reports 2022-09-26 18:39:47 -07:00
Sam Lantinga b7fddb4c0e Minor tweaks 2022-09-26 14:39:51 -07:00
Sam Lantinga 39adcc0a6b 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.
2022-09-26 14:20:34 -07:00
Sam Lantinga 17d7d03adf Added detection of the joystick type for third party PS4 and PS5 controllers 2022-09-26 08:12:35 -07:00
Sam Lantinga 8d2cb1555e Added an entry for the ZEROPLUS P4 Wired Gamepad 2022-09-23 16:56:24 -07:00
Sam Lantinga cb063db64f Moved XInputPS4 controllers into the PS4 controller section 2022-09-23 16:52:37 -07:00
Sam Lantinga 5b3b7e6e7c Separated PS4/PS5 effects support into individual capabilities 2022-09-23 16:46:36 -07:00
Sam Lantinga 33619aa2e9 Added support for the ZEROPLUS P4 Wired Gamepad to the HIDAPI driver 2022-09-23 16:38:15 -07:00
Sam Lantinga e888c99fa6 Fixed the entry for the Nacon PS4 Compact Controller 2022-09-23 16:26:41 -07:00
Sam Lantinga 4ea64fee9f Fixed manufacturer/product name deduplication for the Razer Raiju Tournament Edition controller 2022-09-23 15:29:00 -07:00
Sam Lantinga 56b91ea720 Fixed feature detection for the Razer Raiju Tournament Edition controller 2022-09-23 15:29:00 -07:00
Sam Lantinga 34f928abb7 Generate the correct name for ASTRO Gaming controllers
Manufacturer "ASTRO Gaming" and product "ASTRO C40" turns into "ASTRO C40"
2022-09-23 09:26:18 -07:00
Sam Lantinga 6ddef7c234 Generate the correct name for Qanba and Mad Catz controllers 2022-09-23 09:20:27 -07:00
Sam Lantinga c2ae2ccc32 Added feature support for the Razer Raiju to the HIDAPI driver 2022-09-23 09:11:12 -07:00
Sam Lantinga 51fefd1c35 Added support for third party PS3 controllers to the HIDAPI driver 2022-09-23 02:39:35 -07:00
Sam Lantinga 5b4c10fc7b 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
2022-09-23 02:36:53 -07:00
Sam Lantinga 1d34a5249d Fixed shadowed variable warning 2022-09-23 00:38:23 -07:00
Sam Lantinga 010d3e6442 Fixed function prototype mismatch 2022-09-23 00:36:46 -07:00
Sam Lantinga b7940c29cc Allow HIDAPI controllers to override the default joystick type 2022-09-23 00:15:40 -07:00
Sam Lantinga 899a1e7cba Skip PS4/PS5 probe message if we already know it's a supported controller 2022-09-22 23:54:26 -07:00
Sam Lantinga fa2063fb44 Improved detection of third party PS4 and PS5 controllers 2022-09-22 23:42:25 -07:00
Sam Lantinga aa2e2f4843 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.
2022-09-22 18:27:38 -07:00
Sam Lantinga 2857e3c748 Added an entry for the Mad Catz FightStick TE 2+ PS3 2022-09-22 15:53:32 -07:00
Sam Lantinga 6812f1b5d7 Fixed the entry for the HORI Fighting Commander 4 in PS4 mode 2022-09-22 15:16:34 -07:00
Sam Lantinga 6cbdc66650 Fixed use of uninitialized 'size' variable (thanks @ozkan!) 2022-09-22 09:05:06 -07:00
Sam Lantinga 0c4594ac72 Improved PS4 and PS5 third-party controller feature detection 2022-09-22 06:45:46 -07:00
Ivan Epifanov 08a331847b Vita: fix controls on PSTV with opened IME 2022-09-20 11:03:34 -07:00
Sam Lantinga 2e9f5b5989 Added support for the HORI Fighting Commander OCTA (Xbox Series X and PS versions) 2022-09-16 15:41:35 -07:00
Sam Lantinga 5892ed4373 Fixed Xcode warnings on macOS 2022-09-16 09:44:39 -07:00
Sam Lantinga eb046958da Fixed build warning 2022-09-16 08:19:45 -07:00
Sam Lantinga 4f1b408a72 Fixed button mapping for PS5 controllers 2022-09-12 18:19:02 -07:00
Amir 7f415ce587 android: fix some compiler warnings 2022-09-12 10:06:08 -07:00
Sam Lantinga a3900a751e Lock joysticks when removing a controller on the WGI thread 2022-09-08 13:59:25 -07:00
Sam Lantinga 12413ab31f Lock joysticks while attaching a virtual one 2022-09-08 13:33:21 -07:00
Ozkan Sezer 787cd580ee silence unused function warning for SDL_endswith() on non-linux. 2022-09-08 23:00:04 +03:00
Sam Lantinga 4071573241 Don't try to second guess DS4Windows, let it remap things as expected.
DS4Windows can create both emulated Xbox and emulated PS4 controllers, and we don't know which the user has it doing, so don't try to second guess it, just let it do it's thing. Users should follow the remapping software recommendations on when to enable/disable it for various situations.

Fixes https://github.com/libsdl-org/SDL/issues/6167
2022-09-08 11:50:56 -07:00
Sam Lantinga a0f169603d Fixed the CRC in the mappings for PS2, PSP, and Vita controllers 2022-09-08 09:53:51 -07:00
Sam Lantinga 0ad8d9d292 SDL_IsXInputDevice() shouldn't return true if XInput isn't enabled 2022-09-07 15:31:24 -07:00
Sam Lantinga d93f9a778b The new Wii Remote shares the same VID/PID as the Wii U Pro controller 2022-09-07 12:33:43 -07:00
Sam Lantinga f398d8a424 Note that the Logitech Extreme 3D is a flight stick 2022-09-07 11:53:13 -07:00
Sam Lantinga 0a05b281f2 Make sure we hold the joystick lock when updating the device state while opening it 2022-09-07 11:51:51 -07:00
Sam Lantinga d4e0d27c1c Added Wii Remote controller mappings for Linux 2022-09-07 02:02:04 -07:00
Sam Lantinga 42cf6d6c56 Don't treat the Wii extension controls as a separate game controller on Linux 2022-09-07 01:41:11 -07:00
Sam Lantinga 87f8b6ff0f Don't mess with the state of the Motion Plus extension on Linux 2022-09-07 01:21:01 -07:00
Sam Lantinga c28da4892a Fixed build 2022-09-07 00:52:40 -07:00
Sam Lantinga 638452ecf7 Assert that continuous reporting is enabled, so input timeout is a reliable way of detecting Bluetooth connection problems. 2022-09-07 00:44:13 -07:00
Sam Lantinga 8dfe0e4beb Removed checks not needed for the Wii U Pro Controller 2022-09-07 00:41:29 -07:00
Sam Lantinga 4018f35ef2 Added left and right sensors for Nintendo Joy-Con and Wii controllers 2022-09-07 00:00:27 -07:00
Sam Lantinga 30f55a5d59 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
2022-09-06 23:33:55 -07:00
Sam Lantinga d1fea10c0f Added support for the accelerometer in the Wii Remote 2022-09-05 16:08:15 -07:00
Sam Lantinga a61b823da8 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
2022-09-05 14:32:45 -07:00
Ozkan Sezer 612a86ebad HIDAPI_DriverPS3_UpdateEffects: kill bad use of & operator on effects[] 2022-09-05 20:47:00 +03:00
Sam Lantinga b00e1b1b62 Added support for a ShanWan PS2 -> PS3 USB converter to the HIDAPI driver 2022-09-05 10:01:51 -07:00
Sam Lantinga 1b4e08b89e Added an entry for the Hori Fighting Stick mini 4 kai
This is a PS3/PS4 arcade stick which becomes an Xbox 360 controller on PC
2022-09-02 17:04:53 -07:00
Sam Lantinga 47f2373dc1 Added locking for Android joystick events 2022-09-02 16:52:55 -07:00
Sam Lantinga e8f6b7503a Added mappings for the ASUS ROG Kunai 3 Gamepad 2022-09-02 15:06:13 -07:00
Sam Lantinga 5770e87cb2 Fixed regression handling touchpad input with PS5 controllers using the original shipping firmware 2022-09-02 13:57:59 -07:00
Sam Lantinga 253f6a913d Variable renaming for consistency 2022-09-02 11:49:06 -07:00
Sam Lantinga 5002624e8a Fixed crash when extension controllers are hotplugged 2022-09-02 11:41:19 -07:00
Sam Lantinga 7df571ffc6 HIDAPI_DumpPacket() takes a const memory pointer 2022-09-02 11:37:16 -07:00
Sam Lantinga b6d23d21db Fixed interactions with the Linux Wiimote driver 2022-09-02 11:21:51 -07:00
Ozkan Sezer 0c984360d1 SDL_hidapi_wii.c: fix a -Wshadow warning 2022-09-02 20:02:56 +03:00
Sam Lantinga b6b3fb0023 This was intended to be Uint8 2022-09-02 09:59:32 -07:00
Ozkan Sezer 5be157b3a2 SDL_hidapi_wii.c: fix -Wpointer-sign warnings 2022-09-02 19:33:40 +03:00
Sam Lantinga 54356f41a9 Wii: fixed trigger axis reporting for the Wii U Pro Controller 2022-09-02 09:03:44 -07:00
Sam Lantinga a35642fa3e Wii: don't bother reading the extension type for the Wii U Pro controller, we already know what it is 2022-09-02 08:58:52 -07:00
Sam Lantinga c3ecb9d099 Wii: re-request the status if we get a communication error 2022-09-02 08:58:52 -07:00
Ozkan Sezer 0c24b46e9f SDL_hidapi_wii.c: fix build in c89 mode. 2022-09-02 18:55:00 +03:00
Sam Lantinga 9874fc4e6a Reconnect as a different controller if the Wii extension hardware changes 2022-09-02 08:47:15 -07:00
Sam Lantinga 5f3cb54972 Updated Wii support with @tellowkrinkle's changes in 2f288e9d5b 2022-09-02 08:28:28 -07:00
Sam Lantinga 785d784a93 Set the output value for ParseExtensionResponse() in all return cases 2022-09-01 22:30:05 -07:00
Sam Lantinga 046aaa2d21 Use auto calibration for the Wii Nunchuk thumbstick axis values 2022-09-01 21:37:26 -07:00
Sam Lantinga 8381e008ea Handle hotplugging of Wii controller extensions 2022-09-01 21:13:16 -07:00
Sam Lantinga 396411c090 Added mapping for the Wii Nunchuk extension 2022-09-01 20:27:34 -07:00
Sam Lantinga e19b36d871 Initial support for the Wii Remote with Nunchuk extension 2022-09-01 19:29:20 -07:00
Sam Lantinga c887cb02af Added the hint SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED to control whether the player LED should be lit on the Nintendo Wii controllers
Also fixed the Y axes on the Wii U Pro controller, and various formatting cleanup
2022-09-01 16:30:55 -07:00
Ozkan Sezer 0ffaf5b871 SDL_hidapi_wii.c: fix build in c89 mode and builds using watcom compiler 2022-09-02 02:04:20 +03:00
Sam Lantinga c72e14e8f4 Added initial support for Wii controllers (thanks @tellowkrinkle!) 2022-09-01 15:29:41 -07:00
Sam Lantinga 7708bf0f8a Try matching game controller mappings on CRC and version and fall back to no CRC and no version, in that order.
We do exact match when adding mappings, but loose matching everywhere else we look up a mapping for a GUID.
2022-09-01 08:18:58 -07:00
Sam Lantinga 7861f924ea Removed debug print statements 2022-08-31 13:34:43 -07:00
Sam Lantinga 62f2379e4c Try up to 20 times to read the controller type
It takes a while for Joy-Cons to initialize when plugged in via the Nintendo Joy-Con Charging Grip.
2022-08-31 13:24:23 -07:00
Sam Lantinga e5f161bda4 Restored accidentally removed code to guess XInput device 2022-08-30 19:12:22 -07:00
Ozkan Sezer 973a677a2d SDL_xinputjoystick.c: commented out GuessXInputDevice()
Not used since commit 277b033e78.
2022-08-31 02:32:28 +03:00
Shawn Hoffman 42d09a8f42 wgi: refcount the delegate objects 2022-08-30 15:01:31 -07:00
Shawn Hoffman ca915b1884 WGI_JoystickUpdate: bounds-check array sizes 2022-08-30 14:59:38 -07:00
Sam Lantinga cdaafcec0d The Kinvoca Joy-Cons are handled by the Joy-Con driver, not the Switch Pro driver. 2022-08-30 14:56:11 -07:00
Sam Lantinga b2c3237b75 Added support for the Kinvoca Joy-Cons
These report their VID/PID as a Nintendo Switch Pro controller, but they are actually left/right Joy-Cons. We'll fix up the joystick GUID so applications can handle them appropriately.
2022-08-30 14:14:38 -07:00
Sam Lantinga 92d3fc4883 Fixed deadlock when shutting down the Windows joystick system 2022-08-30 12:59:02 -07:00
Sam Lantinga 0e4baf1c4e Don't crash if SDL functions are passed a closed joystick or gamecontroller 2022-08-30 12:39:23 -07:00
Sam Lantinga 675d90c708 Revert "wgi: refcount the delegate objects"
This reverts commit ff233fe306.

This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
2022-08-30 12:09:57 -07:00
Sam Lantinga 40bd4feedc Revamped joystick locking
This makes the joystick locking more robust by holding the lock while updating joysticks.

The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().

It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.

Fixes https://github.com/libsdl-org/SDL/issues/6063
2022-08-30 11:42:13 -07:00
Shawn Hoffman ff233fe306 wgi: refcount the delegate objects
assert if calls become unbalanced.
2022-08-30 10:48:10 -07:00
Sam Lantinga 2f08bf2313 Added the share button to the Linux mapping for the third party Nintendo Switch Pro controllers 2022-08-29 22:15:35 -07:00
Sam Lantinga b2ac758f61 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver 2022-08-29 17:33:00 -07:00
Ludovico de Nittis e8cb4da71f Add utility function to detect if SDL is inside a sandbox
Refactor the previous sandbox check in a standalone function that also
includes Snap support.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Sam Lantinga 1153aaae0d Fixed compiling with USB_GET_DEVICEINFO on DragonFly BSD
Although the ioctl() currently fails on this platform...
2022-08-29 00:15:56 -07:00
Sam Lantinga 57cbec1095 Added controller mappings for Xbox 360, PS4, and PS5 controllers on OpenBSD
Removed the axis flipping hack for Xbox controllers which would actually apply to any controller with a full 16-bit range.

Fixes https://github.com/libsdl-org/SDL/issues/6143
2022-08-28 23:18:40 -07:00
Sam Lantinga 0b8b321f9e Allow the product version to be different when trying to find a controller mapping
This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
2022-08-28 23:01:30 -07:00
Sam Lantinga 761b9d1e49 Use the HID usage for the button as the button number 2022-08-28 22:33:17 -07:00
Sam Lantinga a9d3935a84 Improved code to get the name and guid for joysticks on OpenBSD and NetBSD
Also dynamically allocate joysticks to reduce static memory usage
2022-08-28 18:20:54 -07:00
Sam Lantinga 32700294e2 Don't crash if SDL_CreateJoystickGUID() is passed a NULL name 2022-08-28 18:20:54 -07:00
Sam Lantinga bac8df4abd Fixed memory leak when out of memory 2022-08-28 18:20:54 -07:00
Sam Lantinga ffbad3617c Use the correct type for the device_instance 2022-08-28 18:20:54 -07:00
Sam Lantinga 4a800ae149 Created a consolidated define enabling BSD gameport joystick support 2022-08-28 18:20:54 -07:00
Sam Lantinga 42f90c6292 Removed unused path variable 2022-08-28 18:20:54 -07:00
Cameron Gutman b7c1fbf9f0 WGI: Fix a couple of reference leaks 2022-08-28 17:38:02 -05:00
Sam Lantinga 0db1813049 Applied OpenBSD patch
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/devel/sdl2/patches/patch-src_joystick_bsd_SDL_bsdjoystick_c?rev=1.5&content-type=text/plain&hideattic=1
2022-08-28 07:27:01 -07:00
Sam Lantinga 3cbfd75d0f Re-added the CRC to the joystick guid
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.

Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.

sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.

Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
2022-08-27 19:00:31 -07:00
Sam Lantinga b188a916ff Fixed uhid device name for non-OpenBSD platforms 2022-08-27 09:46:28 -07:00
Brad Smith 3f93ec470a Add support for OpenBSD's ujoy(4) 2022-08-27 09:45:08 -07:00
Sam Lantinga 9a01eac57d Temporarily disable joystick GUID CRCs 2022-08-26 13:45:05 -07:00
Sam Lantinga f6c2c22d38 Don't try to use the charging port for the PowerA wireless controller as an input device 2022-08-25 22:25:25 -07:00
Sam Lantinga f1aa843415 Don't report rumble capability for Nintendo Online controllers 2022-08-25 21:51:43 -07:00
Sam Lantinga babaa7d2bd Fixed PS3 accelerometer values on little endian systems 2022-08-24 16:10:47 -07:00
Julio C. Rocha 05983fb8ee Add Mayflash PC043 adapter 2022-08-24 15:34:46 -07:00
Sam Lantinga e7332cd814 Fixed zero CRC matching in the controller mapping database 2022-08-24 15:28:56 -07:00
Sam Lantinga 970344719a Fixed the Nintendo Switch Pro mappings on iOS/tvOS 2022-08-24 09:39:01 -07:00
Sam Lantinga 1fc7f68118 Document that it's not possible to use the HIDAPI driver for PS3 controllers on Windows 2022-08-24 06:38:36 -07:00
Sam Lantinga 645b0f6abf Enable HIDAPI PS3 support by default on macOS 2022-08-24 01:30:29 -07:00
Sam Lantinga 3d62ebdbf6 Fixed HIDAPI PS3 support on macOS 2022-08-24 00:34:30 -07:00
Sam Lantinga aaee6e242c Added missing file 2022-08-23 22:56:48 -07:00
Sam Lantinga b6f96b69aa Initial HIDAPI driver support for the PS3 controller 2022-08-23 22:45:37 -07:00
Sam Lantinga b6a3d76225 Look up mappings by GUID in two passes: first with CRC, second without 2022-08-23 07:24:21 -07:00
Sam Lantinga 277b033e78 Refactor joystick GUID creation 2022-08-22 19:44:14 -07:00
Sam Lantinga c1e0873940 Added the CRC of the joystick name to the GUID
This will make it possible to have mappings for different controllers
that have the same VID/PID. This happens frequently with some generic
controller boards that have been reused in many products.

Fixes https://github.com/libsdl-org/SDL/issues/6004
2022-08-22 18:22:35 -07:00
Sam Lantinga b2819e43a7 Send SDL_CONTROLLERDEVICEREMOVED for all joysticks because we don't know after the fact whether it was a game controller.
Fixes https://github.com/libsdl-org/SDL/issues/2092
2022-08-22 13:10:57 -07:00
Sam Lantinga 5a3adbfdb2 Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED to control whether the player LED is set on Xbox 360 controllers 2022-08-19 11:11:25 -07:00
Sam Lantinga 52b6899a6b Added hints for more fine grained control over HIDAPI Xbox controller support 2022-08-19 11:11:23 -07:00
Sam Lantinga 9670d2bb9e Make sure we hold the joystick lock when disconnecting a HIDAPI joystick
This prevents crashes when calling SDL joystick API functions from a different thread while disconnection is happening.

See https://github.com/libsdl-org/SDL/issues/6063 for a more thorough review of joystick locking.
2022-08-15 17:28:50 -07:00
Mathieu Eyraud c6c688ab01 Add SDL_JOYBATTERYUPDATED event to SDL_JoystickEventState() 2022-08-14 07:00:12 -07:00
Your Name cfbeb438c1 fix a bug if XINPUTGETBATTERYINFORMATION is nullptr 2022-08-12 10:07:35 -04:00
Sam Lantinga bf925b9ecd Fixed build 2022-08-11 14:41:48 -07:00
Sam Lantinga 24f97dd700 Added an SDL error to SDL_GameControllerMapping* functions 2022-08-11 14:39:49 -07:00
Sam Lantinga 879af7b5c8 Fixed mapping for paired Joy-Con controllers on iOS 2022-08-10 14:01:23 -07:00
Sam Lantinga e49321cec5 Fixed double-free in combined HIDAPI controller code 2022-08-10 08:21:15 -07:00
Sam Lantinga 9ff498e78e Make HIDAPI_JoystickOpen() more robust against internal logic errors
Fixes https://github.com/libsdl-org/SDL/issues/6030
2022-08-10 06:00:30 -07:00
Sam Lantinga 8e782876bb Fixed spamming the controller with reset IMU commands when they are failing 2022-08-09 21:30:11 -07:00
Sam Lantinga eab27b9049 Make sure Switch controller initialization is synchronous and start the input timeout then 2022-08-09 17:59:44 -07:00
Sam Lantinga 1db7d33dc4 Recover from Bluetooth devices temporarily out of range 2022-08-09 17:04:26 -07:00
Sam Lantinga 6d012b2a5d Better fix for rescanning devices after read failure 2022-08-09 16:54:11 -07:00
Sam Lantinga 483a010f0c Fixed accidentally deadlocking the rumble thread with combined Joy-Cons
Also added more accurate check for sensor data. At least one axis will always have acceleration because of gravity.
2022-08-09 15:39:39 -07:00
Sam Lantinga 5d63a3d435 Re-enumerate devices if a read fails
This allows combined Joy-Con devices to immediately separate if one of them is disconnected
2022-08-09 14:06:49 -07:00
Sam Lantinga da50f1bd3e Bluetooth devices can recover from over a second of dropped reports 2022-08-09 14:05:43 -07:00
Sam Lantinga 824f2d4650 Added a second hint SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED to control the Home button LED on Nintendo Joy-Con controllers separately from Nintendo Switch Pro controllers 2022-08-09 13:41:58 -07:00
Sam Lantinga 8aa6922fec Fixed detecting Bluetooth disconnection on Nintendo Switch controllers 2022-08-09 13:26:10 -07:00
Sam Lantinga 201484ff6f Don't duplicate the serial number twice if a child doesn't set one 2022-08-09 09:03:28 -07:00
Sam Lantinga d90c0d41cc Include the child serial numbers in the serial number for a HIDAPI combined device 2022-08-09 09:00:56 -07:00
Sam Lantinga 55882e43c4 Fixed invalid read when SDL_GameControllerSetPlayerIndex() is passed a negative player_index 2022-08-09 00:19:02 -07:00
Sam Lantinga df537a7c0e SDL_GameControllerSetPlayerIndex(gamecontroller, -1) means turn off the player LED if possible 2022-08-09 00:18:19 -07:00
Sam Lantinga 5545be8530 The player LED index wraps for PS5 controllers, like it does for other controller types 2022-08-08 23:44:50 -07:00
Sam Lantinga 593d20d9cc Removed debug logging 2022-08-08 20:11:43 -07:00
Sam Lantinga 6204ae5002 Restart the IMU if the controller stops sending gyro/accel data 2022-08-08 20:10:12 -07:00
Sam Lantinga d58bec72a0 Fixed Joy-Con gyro axes in mini-gamepad mode 2022-08-08 17:19:33 -07:00
Shawn Hoffman 5aa438e80a WGI: fix interop with applications that have their own WGI code
QI for Added/Removed events need to handle IAgileObject
2022-08-08 15:53:57 -07:00