Commit Graph

2554 Commits

Author SHA1 Message Date
Sam Lantinga
eebe7558d5 Fixed the menu controller button state on recent Apple platforms
The OS reports the button state as of macOS 11.0, iOS 14.0, and tvOS 14.0, so use that instead of the deprecated pause handler.

(cherry picked from commit 1146ea484a)
2026-04-24 11:38:13 -07:00
Sam Lantinga
b00d32c10a Don't do name blacklisting if there's no name
(cherry picked from commit c124da4367)
2026-04-24 07:34:54 -07:00
Nintorch
563b8cb51c Include OS detection in Emscripten joystick GUID
This PR modifies the Emscripten joystick backend to detect the user's OS and store its ID in the GUID, because different OSes might need different mappings for the same controllers.
I'm not sure if different browsers on the same OS can also have different mappings, but if they can, browser detection can be added to the GUID too if needed.

This PR also makes the GUID use `SDL_HARDWARE_BUS_USB` instead of `SDL_HARDWARE_BUS_UNKNOWN`, similarly to how Android and MFI backends always use `SDL_HARDWARE_BUS_BLUETOOTH` and GameInput, XInput, and RawInput backends always use `SDL_HARDWARE_BUS_USB`.

(cherry picked from commit 60a59fa557)
2026-04-21 10:35:52 -07:00
Nintorch
9cdad39b52 Add trigger rumble support to Emscripten joysticks
This PR adds trigger rumble support to the Emscripten joystick backend.

(cherry picked from commit 651136ac7a)
2026-04-21 07:46:16 -07:00
atiradonet
7ca97d0791 joystick: Add VIRPIL Controls flight stick and throttle device IDs. (#15418)
VIRPIL Controls (VID 0x3344) flight sticks are misclassified as
gamepads by SDL's axis-count heuristic because they report exactly
6 axes, matching SDL_GAMEPAD_AXIS_COUNT. Adding them to the
appropriate device lists ensures correct classification.

Tested on Linux (Fedora 43, kernel 6.19) with:
- R-VPC Stick MT-50CM3 (PID 0x4391) -> SDL_JOYSTICK_TYPE_FLIGHT_STICK
- L-VPC Stick MT-50CM3 (PID 0x8390) -> SDL_JOYSTICK_TYPE_FLIGHT_STICK
- VPC VMAX Prime Throttle (PID 0x0196) -> SDL_JOYSTICK_TYPE_THROTTLE

(cherry picked from commit 3b89c7b537)
2026-04-20 09:04:42 -07:00
Ozkan Sezer
7f3071a207 SDL_hidapi_zuiki.c: silence bogus -Warray-bounds warnings from gcc-4.9
(cherry picked from commit f61a22e10f)
2026-04-07 06:47:02 +03:00
Sam Lantinga
a883e69d7b Use the correct index for PS2 controllers
Closes https://github.com/libsdl-org/SDL/pull/15294

(cherry picked from commit 41c3a91079)
2026-04-03 16:08:55 -07:00
Sanjay Govind
8d7f469fb5 Add support for GIP guitars via gameinput (#15301)
(cherry picked from commit 7f86f9107d)
2026-04-03 16:03:17 -07:00
foxtacles
18463ccb8f (emscripten) Add null checks for gamepad in vendor/product/xinput helpers (#15313)
navigator.getGamepads() can return null for a slot if the gamepad
disconnects between the gamepadconnected event and the proxied
MAIN_THREAD_EM_ASM_INT call. This causes a TypeError when accessing
gamepad.id. Add null guards matching the pattern already used in
EMSCRIPTEN_JoystickOpen and EMSCRIPTEN_JoystickRumble.

(cherry picked from commit 59602fb473)
2026-04-03 15:08:37 -07:00
Christian Semmler
5be888591c emscripten: Fix navigator.getGamepads crash in worker threads
The three EM_JS functions (SDL_GetEmscriptenJoystickVendor,
SDL_GetEmscriptenJoystickProduct, SDL_IsEmscriptenJoystickXInput)
call navigator.getGamepads() which is only available on the main
browser thread. With PROXY_TO_PTHREAD, the joystick callbacks are
dispatched to a worker where the Gamepad API is not available,
causing a TypeError.

Convert these from EM_JS to static functions using
MAIN_THREAD_EM_ASM_INT, which proxies the JavaScript execution to
the main browser thread. This matches the pattern already used by
other navigator.getGamepads() calls in the same file.

(cherry picked from commit be8643f739)
2026-04-02 19:37:33 -07:00
Sanjay Govind
b264c19c83 Update to GameInput V3 (#15302)
(cherry picked from commit c58a61fdd4)
2026-04-02 17:10:59 -07:00
Janne Virtala
212f7539cb SDL_PrivateJoystickForceRecentering(): fix infinite loop
(cherry picked from commit b5ef75249f)
2026-04-02 09:28:15 -07:00
Steel
0bf2065922 Add support for PXN VD6 Wheelbase
(cherry picked from commit 32cf5fe93d)
2026-03-16 10:51:30 -07:00
Rachel Blackman
8ba903c859 Add second-gen Backbone One to recognized controllers.
(cherry picked from commit ba00e772a7)
2026-03-13 15:40:29 -07:00
Sam Lantinga
6248eeec09 Disable system gesture state for all GCControllers
Technically we only want to do this for controllers that are opened, but we don't have a way to match up controllers using other APIs with individual GCControllers.

(cherry picked from commit 11adfd2008)
2026-03-12 08:43:19 -07:00
Nintorch
ffd2696516 Fallback for non-gamepad controllers in GameInput
This PR makes the GameInput joystick backend ignore non-gamepad controllers if DirectInput or XInput backends are enabled. This is done to prevent possible bugs and/or regressions.

(cherry picked from commit 419dcfe747)
2026-03-10 11:06:37 -07:00
Nintorch
66020c2ed7 Small GameInput joystick backend improvements
This PR includes small improvements to the GameInput joystick backend:
- Device subtypes
- Compatibility with DirectInput joystick mappings (if the controller is not a gamepad, i.e. `GAMEINPUT_InternalIsGamepad()` returns `false`)
- Fallback to DirectInput/XInput for currently unsupported devices (force feedback ones and the ones that are neither gamepads nor controllers, I'm not sure if that's possible, but maybe racing wheels and other device subtypes would count?)

(cherry picked from commit 0138843eb7)
2026-03-09 11:12:30 -07:00
Sanjay Govind
36ed4b75d1 support batteries on 3rd party controllers
(cherry picked from commit e610b85d1c)
2026-03-08 11:40:56 -07:00
Sanjay Govind
b08f7924a4 Add support for whammy and tilt on PS4/5 guitars
PS4/5 controllers put device specific data into a specific region in the report, so we have to extract it separately.

No known guitars use the right stick on the guitar, so to keep things working similarly to PS3, i have opted to map whammy and tilt the same way as the PS3 rb guitars.

(cherry picked from commit 94f17d6c61)
2026-03-08 11:36:17 -07:00
Sanjay Govind
1ee158cd31 fix off by one with tilt on ps3 guitars (#15144)
(cherry picked from commit 34378609bb)
2026-03-02 09:45:54 -08:00
zuiki_inn
6d93ffe923 Add ZUIKI EVOTOP controller support with gyroscope and accelerometer sensor capabilities. (#15034)
(cherry picked from commit 29ca920fdf)
2026-02-25 20:24:50 -08:00
Sam Lantinga
aa9de89232 Added battery status for newer FlyDigi controllers
(cherry picked from commit 49a8b4229b)
2026-02-24 20:50:11 -08:00
Sanjay Govind
645b8e7f6d Support accelerometers on 3rd party ps3 controllers (#15109)
(cherry picked from commit 0c859452ef)
2026-02-24 19:00:11 -08:00
Sanjay Govind
17532fd62e Set joystick_type for known ps3/wii instruments (#15111)
(cherry picked from commit a7ccd48957)
2026-02-24 17:30:07 -08:00
Sanjay Govind
2214522b69 deal with controllers that don't have report ids
(cherry picked from commit 1419bcb6cb)
2026-02-24 15:19:49 -08:00
Sanjay Govind
b3adee0720 Fix up controller types for various playstation and wii instruments (#15104)
(cherry picked from commit 0e4008441f)
2026-02-24 13:36:08 -08:00
Sam Lantinga
00c85a0b9e Added support for the Flydigi Vader 5 Pro in Xbox 360 mode
(cherry picked from commit 2385dc6297)
2026-02-24 10:20:29 -08:00
Vicki Pfau
399b2b18ce Support SL/SR on Switch 2 controllers, but only in mini-controller mode
It doesn't really make sense to support these in combined mode since they're usually occluded.

(cherry picked from commit 8a1684fbbc)
2026-02-24 06:53:41 -08:00
Ryan C. Gordon
7cc9955ae1 emscripten: Move some EM_ASM blocks to MAIN_THREAD_EM_ASM.
These blocks reference the `navigator` global, which is not available in
background threads.

(cherry picked from commit c728e2f044)
2026-02-20 10:28:12 -05:00
Sam Lantinga
3b4cf41c92 Fixed HIDAPI PS5 Bluetooth report format
(cherry picked from commit 129627068f)
2026-02-17 08:57:28 -08:00
Sam Lantinga
9f0ebbef46 Steam Controller report 0x45 is used for BLE mode
(cherry picked from commit 0b1c592fda)
2026-02-12 15:46:19 -08:00
Sam Lantinga
6707df6d88 Updated Steam Controller packet handling
(cherry picked from commit 84c21cf970)
2026-02-12 14:34:52 -08:00
Sam Lantinga
b467276f4a Fixed initializing the PowerA Fusion Pro 4 on Steam Link hardware
(cherry picked from commit 2b484a1ccb)
2026-02-11 16:54:42 -08:00
Sam Lantinga
17eb20505c Fix the 8BitDo Ultimate 2D Wireless Controller showing up multiple times
This controller has 3 interfaces, one for the Xbox gamepad protocol, and two HID interfaces. We should only handle the Xbox interface in the Xbox driver.

(cherry picked from commit 9f8c70713a)
2026-02-09 13:29:47 -08:00
Vicki Pfau
2b72332b81 Fix Switch and Switch 2 player LED patterns
The patterns we were using don't match the official patterns, which fill up as
many lights as players instead of just using the nth player LED. Above 4,
there are some special patterns, as documented on Nintendo's Singaporean site:
https://www.nintendo.com/sg/support/qa/detail/33822

(cherry picked from commit 017d950b6b)
2026-02-07 07:37:51 -08:00
Vicki Pfau
45086459d2 Add and use libusb_set_auto_detach_kernel_driver for the Switch 2 driver
(cherry picked from commit e1b8ad0380)
2026-02-05 14:59:10 -08:00
Sam Lantinga
38b9c9117d Fixed warning: no previous prototype for function 'SDL_PrivateIsGamepadPlatformMatch'
(cherry picked from commit cd14bf3d00)
2026-02-04 14:41:27 -08:00
Nintorch
94f6f8d3c3 Add share button mapping to Xbox Series X controller on Android
(cherry picked from commit 997a168e00)
2026-02-03 11:33:44 -08:00
Sam Lantinga
a2653b857c Fixed the GameCube Controller Adapter showing up twice on macOS
(cherry picked from commit b5206909a7)
2026-02-02 15:56:06 -08:00
Sam Lantinga
00fc74e6af Fixed handling GameCube adapters in PC mode on Linux and macOS
On Windows there is a separate HIDAPI device for each slot. On Linux and macOS, there is a single HIDAPI device and the slot is included in the report.

(cherry picked from commit cdffbdfeaf)
2026-02-02 15:56:05 -08:00
Cameron Gutman
3cf15dc222 gamepad: Accept older 'Mac OS X' mappings on macOS
(cherry picked from commit e3c9ec7b67)
2026-01-30 18:12:54 -06:00
Henrique Jorge Barateli
38b5ad824d Fixed PS2 joystick analog sticks not enabled
(cherry picked from commit 8fa8c331a5)
2026-01-30 12:17:39 -08:00
Eddy Jansson
ff2a43bfbf Fix typos in comments.
(cherry picked from commit 23fec649c2)
2026-01-30 07:25:35 -08:00
Sam Lantinga
1ec73bac92 Fixed typo
(cherry picked from commit 58c30a4451)
2026-01-28 13:43:40 -08:00
Sam Lantinga
e1294f3b48 Fixed the 8BitDo Ultimate 2 Wireless for PC controller showing up twice on macOS
(cherry picked from commit 0f10f81b3b)
2026-01-28 13:39:37 -08:00
Sam Lantinga
3bde3e2406 Fixed the 8BitDo Ultimate 2 Wireless controller showing up twice on macOS
Fixes https://github.com/libsdl-org/SDL/issues/14902

(cherry picked from commit 3aa3a357fc)
2026-01-27 14:41:36 -08:00
Sam Lantinga
5c002ba0b9 Fixed the NVIDIA SHIELD Controller showing up twice on macOS
Fixes https://github.com/libsdl-org/SDL/issues/14911

(cherry picked from commit 1fe6bf4982)
2026-01-27 13:53:06 -08:00
Sam Lantinga
05fdfa1572 Fixed hang sending output reports to the NVIDIA SHIELD Controller on macOS
(cherry picked from commit 72343b9ee2)
2026-01-27 13:53:06 -08:00
Sam Lantinga
d4da5df088 Fixed unaligned access in NVIDIA SHIELD Controller driver
Also refactored the LOAD16() and LOAD32() macros into SDL_hidapijoystick_c.h

(cherry picked from commit cae2a28f5b)
2026-01-27 13:53:06 -08:00
Sam Lantinga
6fef8fd0dc Fixed Steam Controller battery state
(cherry picked from commit dd53ecbce8)
2026-01-27 09:53:17 -08:00