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
Sam Lantinga
ada55c690d
Fixed Joy-Con type detection for the Nintendo Joy-Con Charging Grip
2022-08-08 15:38:19 -07:00
Sam Lantinga
47ebf0087a
Fixed shadow variable warning
2022-08-08 08:36:17 -07:00
Francisco Javier Trujillo Mata
0a307628e6
Fix wrong mapping in some ps2 controller keys
2022-08-08 08:32:11 -07:00
Sam Lantinga
8f05b4f833
Fixed iOS/tvOS build
2022-08-08 08:26:21 -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
4f19421ed8
Fixed build
2022-08-07 20:17:40 -07:00
Sam Lantinga
29265d0738
Use SDL_GetStringBoolean() to parse the hint value
2022-08-07 18:49:30 -07:00
Sam Lantinga
198d62d813
joystick: remove unused Xbox Controller Keyboard VID/PID.
...
0x045e, 0x0b02 - is actually virtual keyboard that is generated by XboxGip drivers for Xbox One Controllers.
Closes https://github.com/libsdl-org/SDL/pull/5121
2022-08-06 23:53:18 -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
f810dede16
Fixed comment so script processing works correctly
2022-08-06 09:50:13 -07:00
Francisco Javier Trujillo Mata
3da131c1c6
Check if port if closed and open it again
2022-08-05 17:44:59 -07:00
Sam Lantinga
d6a8b43cf7
Added support for the HORIPAD FPS for Nintendo Switch
2022-08-05 10:37:38 -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
40b7143180
Fixed button mapping for the HORIPAD S controller
...
This controller looks like a GameCube controller, is actually a Nintendo Switch controller, and shows up as an XInput device on Windows with the buttons already in the correct location.
2022-08-04 10:26:10 -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
a2b4f4406f
The Nintendo Wii Remote Pro Controller respects the SDL_GAMECONTROLLER_USE_BUTTON_LABELS hint
2022-08-03 22:27:42 -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
ea7fbf7947
Update in-flight SDL_CONTROLLERDEVICEADDED messages when a device is removed
...
This fixes the application trying to open the wrong device index when a device is removed and another has just been added
2022-08-03 19:39:37 -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
6e1ee1d4a5
sort the controller names
2022-08-03 13:51:25 -07:00
Sam Lantinga
8ab9dc8b2b
Fixed crash if Joy-Cons are disabled while a combined Joy-Cons controller is open
2022-08-03 13:18:00 -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
Mathieu Eyraud
42b2320756
Fix memory leak of children for combined JoyCon
2022-08-02 06:33:18 -07:00