135 Commits

Author SHA1 Message Date
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
18eb319adc Added sensor timestamp for Nintendo Switch controllers 2022-09-27 12:34:03 -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
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
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
4018f35ef2 Added left and right sensors for Nintendo Joy-Con and Wii controllers 2022-09-07 00:00:27 -07:00
Sam Lantinga
396411c090 Added mapping for the Wii Nunchuk extension 2022-09-01 20:27:34 -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
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
f1aa843415 Don't report rumble capability for Nintendo Online controllers 2022-08-25 21:51:43 -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
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
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
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
df537a7c0e SDL_GameControllerSetPlayerIndex(gamecontroller, -1) means turn off the player LED if possible 2022-08-09 00:18:19 -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
Sam Lantinga
878259722f Added SDL_GameControllerType enumeration for Nintendo Switch Joy-Con controllers 2022-08-08 08:22:20 -07:00
Sam Lantinga
52bf5b1de9 Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED to control whether the player LED is set on Nintendo Switch controllers 2022-08-06 10:34:19 -07:00
Sam Lantinga
4a9ceb7be9 The HORIPAD S uses the Xbox 360 protocol on all platforms and shows up as multiple styles of controller, depending on what model you have. 2022-08-04 11:33:36 -07:00
Sam Lantinga
28c01955bc Fixed button mapping for the HORIPAD S
This controller actually comes in at least two flavors: a GameCube controller and an arcade pad, neither of which should have the face buttons remapped.
2022-08-04 10:46:37 -07:00
Sam Lantinga
43b90484c9 Retry a little longer when writing to the Nintendo Joy-Con Charging Grip 2022-08-04 00:40:38 -07:00
Sam Lantinga
dfd2c574d7 Removed unused variable 2022-08-03 22:27:43 -07:00
Sam Lantinga
c84dea0943 Fixed detecting the controller type of controllers over USB 2022-08-03 22:12:21 -07:00
Sam Lantinga
ba297f12cd Use the Nintendo controller type to determine whether to always use button labels 2022-08-03 21:46:01 -07:00
Sam Lantinga
946f4777f6 Don't set Bluetooth controllers to wired power level 2022-08-03 21:33:38 -07:00
Sam Lantinga
57c3b2c950 Don't rely on the device VID/PID to get the Nintendo controller type
The Nintendo Online Sega Genesis controller reports the SNES VID/PID over Bluetooth. This is a more robust way of handling future controllers as well, so let's go with this instead.

Also use full reports over Bluetooth, and don't report gyro for Nintendo Online classic controllers.
2022-08-03 21:31:12 -07:00
Sam Lantinga
b6aadb16b9 Added k_eSwitchDeviceInfoControllerType_N64 to ESwitchDeviceInfoControllerType 2022-08-03 20:38:33 -07:00
Sam Lantinga
bdfb32de3c Added some additional Nintendo controller types to ESwitchDeviceInfoControllerType 2022-08-03 20:30:58 -07:00
Sam Lantinga
5d50fa52df Fixed timeout opening the Nintendo Joy-Con Charging Grip
Sometimes opening the right Joy-Con takes a little longer for some reason
2022-08-03 19:39:36 -07:00
Sam Lantinga
29cdb2c9c9 Added support for the Nintendo Switch Joy-Con Charging Grip 2022-08-03 18:01:10 -07:00
Sam Lantinga
a8120104ad The Nintendo Online classic controllers and Joy-Cons shouldn't show up as Switch Pro controllers 2022-08-03 13:53:49 -07:00
Sam Lantinga
bcdef4aaf9 Added separate hints for Nintendo Online classic controllers and Joy-Cons
This allows them to be enabled/disabled separately from Switch Pro HIDAPI support
2022-08-03 13:07:47 -07:00
Mathieu Eyraud
59a104b803 Do not pass NULL to memcpy
ReadJoyConControllerType calls WriteSubcommandSync with pbuf=NULL
2022-08-02 06:38:51 -07:00
Sam Lantinga
875b737c64 Added support for the Nintendo Online NES Controllers to the HIDAPI driver 2022-07-28 21:40:01 -07:00
Sam Lantinga
2fa2f9ff77 Greatly improved Nintendo Joy-Con support using the HIDAPI driver
* Added support for mini-gamepad mode for Joy-Con controllers, matching the mapping for hid-nintendo on Linux and iOS 16
* Added the ability to merge left and right Joy-Con controllers into a single Pro-style controller
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_COMBINE_JOY_CONS to control this merging functionality
* Removed the hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
2022-07-28 19:22:27 -07:00
Sam Lantinga
def60ce6fe Fixed the name of the HIDAPI Joy-Con controller for consistency with other drivers 2022-07-27 19:20:42 -07:00