Commit graph

221 commits

Author SHA1 Message Date
Sam Lantinga
f35ede7281 Generalized the idea of joystick driver priority
Joystick drivers are sorted by priority in the driver list, and higher priority drivers report whether they are handling a device when lower priority drivers want to add it to their device list.

This has been handled ad-hoc with the Windows and HIDAPI drivers, but this formalizes the idea and makes sure that GameInput has the highest priority of the Windows drivers.
2024-02-17 16:06:07 -08:00
Sam Lantinga
f66fe7e221 Replaced SDL_GetJoystickCaps() with joystick properties
Fixes https://github.com/libsdl-org/SDL/issues/8927
2024-01-27 15:11:52 -08:00
Ningyuan Li
d6ebbc2fa4 mayflash adapter PS4 support 2024-01-24 19:25:35 -08:00
Anonymous Maarten
31d133db40
Define SDL_PLATFORM_* macros instead of underscored ones (#8875) 2024-01-24 01:40:51 +00:00
Sam Lantinga
a2665f54c8 Updated the atomic API for SDL 3.0 naming conventions
Fixes https://github.com/libsdl-org/SDL/issues/7388
2024-01-18 04:41:34 -08:00
Sam Lantinga
d3daba791a Don't try to send the PS third-party feature request to the Logitech G815 keyboard
Fixes https://github.com/libsdl-org/SDL/issues/8373
2024-01-06 08:29:01 -08:00
Sam Lantinga
5b3ee51c6c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
Sam Lantinga
1f1ee6f77c Use the original manufacturer and product strings for the joystick CRC
This allows the most information possible for the CRC string, which is used to differentiate controllers with the same VID/PID.

Fixes https://github.com/libsdl-org/SDL/issues/8724
2023-12-20 19:22:37 -08:00
Sam Lantinga
c981a597dc Added Steam Input API support for game controllers
Added support for getting the real controller info, as well as the function SDL_GetGamepadSteamHandle() to get the Steam Input API handle, from the virtual gamepads provided by Steam.

Also added an event SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED which is triggered when a controller's API handle changes, e.g. the controllers were reassigned slots in the Steam UI.
2023-12-20 10:40:28 -08:00
Max Maisel
c1a7d0f96e Add steam deck detection and HIDAPI driver scaffold. 2023-12-12 12:51:37 -08:00
Dimitriy Ryazantcev
c790572674 Use existing XUSB driver software PID 0x02a1 instead of PID 0x02fe
0x02fe is actually PID of Xbox Wireless Adapter for Windows 10 (Model 1790) and creates confusion.

Here is USB descriptor dump: https://github.com/DJm00n/ControllersInfo/blob/master/xboxone/DescriptorDump_Adapter%20(Xbox%20Wireless%20Adapter%20for%20Windows).txt
2023-12-11 11:45:05 -08:00
Ryan C. Gordon
447b508a77
error: SDL's allocators now call SDL_OutOfMemory on error.
This means the allocator's caller doesn't need to use SDL_OutOfMemory directly
if the allocation fails.

This applies to the usual allocators: SDL_malloc, SDL_calloc, SDL_realloc
(all of these regardless of if the app supplied a custom allocator or we're
using system malloc() or an internal copy of dlmalloc under the hood),
SDL_aligned_alloc, SDL_small_alloc, SDL_strdup, SDL_asprintf, SDL_wcsdup...
probably others. If it returns something you can pass to SDL_free, it should
work.

The caller might still need to use SDL_OutOfMemory if something that wasn't
SDL allocated the memory: operator new in C++ code, Objective-C's alloc
message, win32 GlobalAlloc, etc.

Fixes #8642.
2023-11-30 00:14:27 -05:00
Sam Lantinga
f0e47f8ee0 Added support for the NACON Revolution 5 Pro controller 2023-11-27 12:10:00 -08:00
Sylvain
d8600f717e Pointer as bool (libsdl-org#7214) 2023-11-09 14:18:36 -08:00
Sam Lantinga
f52b330ed8 Added support for the HP HyperX Clutch Gladiate controller 2023-10-25 09:00:26 -07:00
Sam Lantinga
38afd48daf Added a single source of SDL object IDs
This ensures that we don't accidentally interpret an ID from one system as an ID in another system.
Audio device IDs are not covered here, since they have a unique numbering system.
2023-10-23 10:49:37 -07:00
Cameron Gutman
435e7ce663 Check for device disconnection in HIDAPI_JoystickOpen()
HIDAPI joystick drivers may call HIDAPI_JoystickDisconnected() in their
UpdateDevice() function during HIDAPI_JoystickOpen(). If they do this
today, the opened joystick will end up partially initialized (no name,
path, mapping GUID, etc.) because HIDAPI_GetDeviceByIndex() will no
longer be able to find the SDL_HIDAPI_Device for the removed joystick.

Worse still, joystick->hwdata->device becomes a dangling freed pointer
the next time HIDAPI_UpdateDeviceList() is called. This leads to a UAF
when the application or SDL calls SDL_JoystickClose() on this joystick.

Fix all this by checking if the device no longer has any associated
joysticks after calling UpdateDevice() and failing the open call if so.
2023-10-17 21:54:09 -05:00
Sam Lantinga
0f80d47bbd Fixed thread-safety warning 2023-08-25 08:21:54 -07:00
Sam Lantinga
b271e92c6e Added the ability to specify a gamepad type in the mapping
Also renamed most cases of SDL_GAMEPAD_TYPE_UNKNOWN to SDL_GAMEPAD_TYPE_STANDARD, and SDL_GetGamepadType() will return SDL_GAMEPAD_TYPE_UNKNOWN only if the gamepad is invalid.
2023-07-17 12:59:56 -07:00
Sam Lantinga
57cfd1e106 Removed SDL_GAMEPAD_TYPE_VIRTUAL, SDL_GAMEPAD_TYPE_AMAZON_LUNA, SDL_GAMEPAD_TYPE_GOOGLE_STADIA, and SDL_GAMEPAD_TYPE_NVIDIA_SHIELD
Removing SDL_GAMEPAD_TYPE_VIRTUAL allows a virtual controller to emulate another gamepad type. The other controller types can be treated as generic controllers by applications without special glyph or functionality treatment.
2023-07-16 04:32:12 -07:00
Sam Lantinga
73927b0948 Removed unused function 2023-06-14 15:16:21 -07:00
Sam Lantinga
cdfc0c5a33 Added support for the PowerA Fusion Pro Wireless Controller in Bluetooth mode
This controller shows up with a VID/PID of 0, but has full functionality over Bluetooth
2023-06-13 22:20:58 -07:00
Sam Lantinga
2042e9c4e3 Only update the serial number if it hasn't already been set
This fixes the serial number for Nintendo Switch Pro, which is queried from the hardware in device initialization, and was later clobbered by the USB string which isn't correct.
2023-06-09 17:34:12 -07:00
Sam Lantinga
32d015a6a0 Fixed PS3 controller initialization over Bluetooth
Now that we have hidapi that knows whether the controller is connected via Bluetooth or USB, this is much easier to fix.
2023-06-08 10:46:56 -07:00
Sam Lantinga
2a08bf6118 Use the bus in the HIDAPI joystick guid now that it's available 2023-05-26 08:19:04 -07:00
Sam Lantinga
af45ae7296 Update the SDL HIDAPI API to match upstream hidapi 0.14.0 2023-05-26 08:19:04 -07:00
Sam Lantinga
b252ecec6d Fixed crash if trying to dump a packet larger than USB_PACKET_LENGTH 2023-05-26 08:19:04 -07:00
Sam Lantinga
ddbdd73258 Updated source to match SDL function prototype style 2023-05-23 11:29:41 -07:00
Sam Lantinga
2e6c48dcb4 Added support for the GameSir-G7 Controller for Xbox 2023-05-11 17:44:56 -07:00
Sam Lantinga
a4b4dff4a2 Added support for the Astro C40 in Xbox 360 mode 2023-04-27 17:10:44 -07:00
Sam Lantinga
acadb6f873 More defensive coding against dangling device pointers 2023-04-06 11:33:27 -07:00
Sam Lantinga
e13b74ccf0 Fixed crash if joystick->hwdata != NULL && device->driver == NULL
This should never happen, but we're seeing it in the wild, so make sure that we can never call into a NULL device driver.
2023-04-05 11:24:27 -07:00
Anonymous Maarten
b6ae281e97 Use #ifdef/#ifndef instead of #if defined/#if \!defined 2023-03-30 21:35:01 +00:00
Sam Lantinga
85ee1498a5 Fixed Visual Studio warning 4245 2023-03-30 14:02:06 -07:00
Sam Lantinga
655a07bdd8 Don't probe for PlayStation controllers when we already know the controller type
Fixes https://github.com/libsdl-org/SDL/issues/7556
2023-03-30 07:36:40 -07:00
Sam Lantinga
926db1bd54 Removed a duplicate delay accidentally added during code refactor 2023-03-09 16:12:49 -08:00
Sylvain
c963f02571 More fix warnings about static function and prototype 2023-03-08 16:14:09 +01:00
Sam Lantinga
da134a3039 Fixed locking up the Logitech F310 with the PlayStation controller detection 2023-02-28 08:36:31 -08:00
Sam Lantinga
ece8a7bb8e Hold the joystick lock while opening the HID device on non-Android platforms
On Windows the main thread can be enumerating DirectInput devices while the Windows.Gaming.Input thread is calling back with a new controller available, and in this case HIDAPI_IsDevicePresent() returned false since the controller initialization hadn't completed yet, creating a duplicate controller.

Fixes https://github.com/libsdl-org/SDL/issues/7304
2023-02-16 09:50:04 -08:00
Sam Lantinga
d1c72bb0bc Dynamically update the serial number if it isn't available at first
This happens for Xbox One controllers using newer firmware connected over NDIS
2023-02-08 14:16:17 -08:00
Sam Lantinga
5fded632d6 Added support for the Turtle Beach REACT-R and Recon Xbox controllers 2023-02-06 20:14:12 -08:00
Sam Lantinga
22bafe8729 Removed debug code accidentally committed 2023-02-06 11:23:53 -08:00
Sam Lantinga
f8b41919da Fixed warning running a command queue without any vertex operations 2023-02-06 11:22:00 -08:00
Sam Lantinga
fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga
e85839cd56 Fixed line wrapping for HID packet dump 2023-01-03 15:12:47 -08:00
Sam Lantinga
dacdb1c310 Added support for the ThrustMaster eSwap PRO Controller Xbox 2023-01-03 15:12:18 -08:00
Sam Lantinga
ab2d007982 More gamepad renaming 2022-12-27 11:31:54 -08:00
Sam Lantinga
659abc721a SDL API renaming: SDL_gamecontroller.h
SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.

Fixes https://github.com/libsdl-org/SDL/issues/6885
2022-12-27 09:47:24 -08:00
Sam Lantinga
fc478c1bc0 SDL API renaming: SDL_joystick.h
Fixes https://github.com/libsdl-org/SDL/issues/6881
2022-12-27 05:50:46 -08:00
Sam Lantinga
63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00