Commit Graph

553 Commits

Author SHA1 Message Date
Sam Lantinga
a199cb89ad Updated the Android Xbox One Wireless Controller mapping for the latest Xbox controller firmware update 2020-02-05 09:29:46 -08:00
Sam Lantinga
dc1d3c2974 Catch both PS3 and PS4 motion controls and don't treat them as a game controller 2020-02-04 18:36:23 -08:00
Sam Lantinga
1d1a35ef64 Fixed Visual Studio build 2020-02-04 16:05:39 -08:00
Sam Lantinga
1bd120266f Added SDL_hidapi_rumble.c to the macOS, iOS and tvOS builds 2020-02-04 15:42:49 -08:00
David Ludwig
65fd633694 FIX for SDL-4927: CFRetain+CFRelease a game controller's IOKit object
This fixes a crash whereby SDL could crash on macOS/Darwin, if and when a
USB game controller gets unplugged.  SDL was not retaining a reference
to the controller's OS/IOKit-provided 'device object', and was capable
of trying to use it, after a device was hot-unplugged.
2020-01-30 18:03:34 -05:00
Sam Lantinga
02108cf7e5 Added missing files from previous commit 2020-02-04 15:27:25 -08:00
Sam Lantinga
1684606fdf Fixed long delay on main thread caused by blocking rumble writes in HIDAPI drivers
There is now a thread that handles all HIDAPI rumble requests and a lock that guarantees that we're not reading and writing the device at the same time.
2020-02-04 15:26:56 -08:00
Sam Lantinga
6efebf1768 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests. 2020-02-04 12:48:53 -08:00
Sjoerd Simons
976eee77cc Correct joystick hat indexes on linux
The index and indices were swapped; Which is fine as long as there are
no gaps in the ABS_HAT* event availability but otherwise things do get confused.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
2020-02-04 07:23:44 -08:00
Sam Lantinga
212609b3f2 Map the right pad on the Steam Controller to the right stick in the game controller API 2020-01-31 14:09:23 -08:00
Sam Lantinga
39a498c940 Build the hidapi framework and weak link it on Mac OS X 2020-01-31 13:09:20 -08:00
Sam Lantinga
91121ee4bb Weak link the hidapi framework on iOS and tvOS 2020-01-31 10:45:04 -08:00
Sam Lantinga
0641711e9f Added missing file from previous commit 2020-01-29 20:09:59 -08:00
Sam Lantinga
355f0b54ec Added support for the Steam Controller on mobile devices 2020-01-29 20:09:11 -08:00
Sam Lantinga
c9c89783cb Miscellaneous pending fixes 2020-01-29 20:09:08 -08:00
Sam Lantinga
43b377b077 Fixed wired PS4 controller support on Android 2020-01-28 17:11:17 -08:00
Ryan C. Gordon
059de38c2c darwin: Don't pass NULL device refs to IOHIDDeviceGetValue().
Possibly fixes Bugzilla #4961.
2020-01-27 15:44:48 -05:00
Sam Lantinga
7ea3f5b464 Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble
meyraud705

Switch hidapi and xinput also need to check for overflow, attached a patch for them.
2020-01-26 12:48:35 -08:00
Sam Lantinga
adb53d0b1f Fixed disabling the Xbox 360 wireless HIDAPI driver 2020-01-26 10:32:39 -08:00
Sam Lantinga
c9f672fde4 Fixed compiler warnings 2020-01-23 22:24:24 -08:00
Sam Lantinga
2ae41b9c61 Fixed mapping for both versions of the Xbox One Elite Series 2 controller firmware connecting over Bluetooth 2020-01-23 12:53:43 -08:00
Sam Lantinga
48240ac88e Added mapping for the Xbox One controller connected via the wireless dongle using xow 2020-01-23 12:53:41 -08:00
Sam Lantinga
6dc172d093 Turn off rumble on drivers which don't respect the replay.length value 2020-01-23 12:53:39 -08:00
Sam Lantinga
443bce741b Added support for the paddles on the Xbox One Elite Series 1 controller 2020-01-22 11:28:35 -08:00
Sam Lantinga
25c88ea903 The Xbox One 0x01 initialization packet is an ack packet 2020-01-20 13:53:40 -08:00
Sam Lantinga
9c3d1602ab Refactored code so SDL_GetJoystickGameControllerType() is called less during controller detection 2020-01-19 11:43:36 -08:00
Sam Lantinga
ff06801106 Added missing file from previous commit 2020-01-18 11:21:42 -08:00
Sam Lantinga
43aa1fa9e7 Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android 2020-01-18 11:21:14 -08:00
Sam Lantinga
27035425e0 There are multiple bindings for XBox One controller model 1708, depending on firmware revision 2020-01-17 11:09:57 -08:00
Sam Lantinga
bde1a371d1 Added support for the NACON GC-400ES 2020-01-17 11:07:19 -08:00
Sam Lantinga
4e682461cc Reattach the kernel driver after closing USB controllers 2020-01-17 10:43:14 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
c6817a2c19 Added support for the paddles on the Xbox One Elite Series 2 controller 2020-01-16 15:32:41 -08:00
Sam Lantinga
4e1cc124d2 Improved Xbox One controller initialization 2020-01-16 15:32:39 -08:00
Sam Lantinga
669729a8a0 Improved Xbox One controller initialization sequence
This sequence works across Microsoft, PowerA, PDP, and HORI controllers.
The newer Microsoft XBox firmware requires synchronizing the rumble sequence number, when SDL sees it after the initial connect
The Razer Wildcat controller requires waiting for init responses before continuing the initialization sequence.
The PDP Battlefield 1 controller takes over a second to be ready for initialization, and if initialization is attempted before then, it will fail.
2020-01-15 22:18:31 -08:00
Sam Lantinga
3448600526 Added support for the HORI Fighting Commander 2020-01-15 22:18:29 -08:00
Sam Lantinga
6705e27c9f Added D-PAD bindings for the Linux Steam Controller 2020-01-13 22:05:58 -08:00
Sam Lantinga
cb800d1c27 Fixed compiler warning 2020-01-13 22:05:56 -08:00
Sam Lantinga
7775f7cedf Fixed deadlock in HIDAPI joystick system 2020-01-13 22:05:54 -08:00
Sam Lantinga
3a796d6a58 Free the joystick player index when the joystick is removed 2020-01-13 15:35:54 -08:00
Sam Lantinga
d2cda502cc Send the full Xbox One controller sequence for Microsoft controllers
This switches Bluetooth controllers back into USB report mode for the latest Xbox One S and Xbox One Elite Series 2 firmware
2020-01-12 17:22:24 -08:00
Sam Lantinga
c14a59d999 Worked around an issue where the kernel would lose the force feedback effect 2020-01-11 13:38:50 -08:00
Sam Lantinga
d33b122f4f The Xbox One S Bluetooth controller with older firmware uses b16 as the guide button. The same controller with newer firmware uses b12 as the guide button. Map both buttons so both firmware revisions will work with the same mapping. 2020-01-11 04:34:28 -08:00
Sam Lantinga
5d28c31548 Only initialize Xbox One controllers once they're ready for initialization (or if they are silent until init)
This fixes the Hyperkin Duke Xbox One controller showing the Xbox startup animation every time an SDL application launches
2020-01-09 14:53:34 -08:00
Sam Lantinga
47abe4e3b3 Fixed crash when unplugging a HIDAPI controller 2020-01-09 14:53:30 -08:00
Sam Lantinga
f34795d05f Added support for the updated Hyperkin Duke Xbox One controller 2020-01-08 18:55:53 -08:00
Sam Lantinga
a56aaea139 Fixed handling the 8BitDo M30 in Nintendo Switch mode 2020-01-07 16:47:56 -08:00
Sam Lantinga
f4375e86f9 Added support for the 8BitDo M30 GamePad 2020-01-07 18:43:40 -08:00
Sam Lantinga
eb3d39bc8b Added support for the 8Bitdo FC30 Pro 2020-01-06 12:18:51 -08:00
Sam Lantinga
d9c4be0648 Added support for the Hyperkin Duke controller 2020-01-01 08:13:40 -08:00
Sam Lantinga
4c9628a002 Fixed GameCube controller axis and trigger ranges and X and B button being swapped 2019-12-30 17:56:56 -08:00
Sam Lantinga
8b0660b25a Fixed bug 4918 - SDL failed to build due to error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex with MSVC x64 on Windows
LinGao

We build SDL with Visual studio 2017 compiler on Windows Server 2016, but it failed to build due to error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex with MSVC x64 on Windows on latest default branch. And we found that it can be first reproduced on 0fff06175109 changeset. Could you please help have a look about this issue? Thanks in advance!

Steps to Reproduce:
1.hg clone https://hg.libsdl.org/SDL D:\SDL\src
2.Open a VS 2017 x64 command prompt as admin and browse to D:\SDL
3.msbuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17134.0 VisualC\SDL.sln /t:Rebuild

Actual result:
 Creating library D:\SDL\src\VisualC\x64\Release\SDL2.lib and object D:\SDL\src\VisualC\x64\Release\SDL2.exp
SDL_joystick.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex [D:\SDL\src\VisualC\SDL\SDL.vcxproj]
D:\SDL\src\VisualC\x64\Release\SDL2.dll : fatal error LNK1120: 1 unresolved externals [D:\SDL\src\VisualC\SDL\SDL.vcxproj]
Done Building Project "D:\SDL\src\VisualC\SDL\SDL.vcxproj" (Rebuild target(s)) -- FAILED.
2019-12-30 13:18:57 -08:00
Sam Lantinga
a9482a1d60 Added support for the Nintendo GameCube adapter, tested on Steam Link hardware 2019-12-30 09:44:32 -08:00
Zack Middleton
f0cee3edec Fix shutting down HIDAPI device with multiple joysticks
Using Wii U GameCube USB adapter with multiple controllers attached and
restarting SDL input in a game results in extra joysticks with NULL name.

HIDAPI_CleanupDeviceDriver() shut down joysticks by iterating through
device->num_joysticks but each HIDAPI_JoystickDisconnected() decreases
device->num_joysticks and shifts joysticks array down. Resulting in only
half of controllers being shutdown. It worked with only 1 controller
attached though.

Disconnect HIDAPI device joystick 0 until there are none left.
2019-12-22 13:15:11 -08:00
Sam Lantinga
d000a592ab Fixed windows build 2019-12-21 22:33:21 -08:00
Sam Lantinga
f3a547d00a Added support for the Hori Dragon Quest Slime Controller 2019-12-20 21:40:28 -08:00
Sam Lantinga
46e1377d49 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks.
Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()
2019-12-20 20:12:03 -08:00
Sam Lantinga
6b76787209 Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers 2019-12-19 21:45:44 -08:00
Sam Lantinga
1db56619de Fixed rare infinite rumble in HIDAPI controller driver 2019-12-19 18:03:28 -08:00
Sam Lantinga
25bd5070f5 Fixed GameCube rumble 2019-12-19 18:00:08 -08:00
Sam Lantinga
202c966a44 Added support for the Nintendo GameCube Controller, using the Mayflash GameCube adapter. 2019-12-19 16:14:22 -08:00
Sam Lantinga
2481ab9340 Fixed compiler warning 2019-12-19 15:58:16 -08:00
Sam Lantinga
20daf54fd8 Added new HIDAPI driver files to the Xcode projects 2019-12-19 15:18:50 -08:00
Sam Lantinga
fead0b24e1 Added missing files from previous commits 2019-12-19 15:02:12 -08:00
Sam Lantinga
e22e77dadc Added an untested driver for the Nintendo GameCube adapter, based on code contributed by Ethan Lee 2019-12-19 15:01:35 -08:00
Sam Lantinga
15d30298cf Added support for wireless Xbox 360 controllers using the HIDAPI driver 2019-12-19 15:01:32 -08:00
Sam Lantinga
e7f7e3f40f Refactored HIDAPI controller code to support dongles and hubs that dynamically attach controllers 2019-12-19 15:01:30 -08:00
Sam Lantinga
52b6ab2196 Added support for the SteelSeries Stratus Duo 2019-12-16 17:11:23 -08:00
Sam Lantinga
a7ae9175c3 Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble
meyraud705

On a Dualshock 4 controller using hidapi driver, calling SDL_JoystickRumble with a duration too long (SDL_HAPTIC_INFINITY for example) causes the rumble to stop immediately.

This happens because of integer overflow on line 301 of SDL_hidapi_ps4.c
(https://hg.libsdl.org/SDL/file/a3077169ad23/src/joystick/hidapi/SDL_hidapi_ps4.c#l301), which sets expiration time in the past.
2019-12-16 10:20:03 -08:00
Sam Lantinga
4d4e5584ea Fixed binding D-pad on NES30 controller 2019-12-12 19:07:26 -08:00
Sam Lantinga
9f8009f2e1 Added mappings for the Razer Serval on Windows and Mac OSX 2019-12-13 16:12:41 -08:00
Sam Lantinga
cf9af481e0 Added support for the 8Bitdo NES30 GamePad in wired mode 2019-12-13 16:12:39 -08:00
Sam Lantinga
c2b6d6f9ed Enable the LED on PowerA Xbox One controllers 2019-12-13 16:12:37 -08:00
Sam Lantinga
511df4a53f Added support for the BDA XB1 Spectra Pro 2019-12-13 16:12:35 -08:00
Sam Lantinga
55f8eabfae Identified the BDA XB1 Classic Controller 2019-12-13 16:12:33 -08:00
Sam Lantinga
0352814a8a Added general remapping of controller manufacturer 2019-12-13 16:07:25 -08:00
Sam Lantinga
b51d7f35aa Added support for the HORI PAD A 2019-12-13 16:07:22 -08:00
Sam Lantinga
23c39a2e44 Strip trailing whitespace on controller manufacturer identification 2019-12-12 19:14:37 -08:00
Sam Lantinga
1ac7eabaca Fixed comment typo 2019-12-12 14:25:02 -08:00
Sam Lantinga
a613fc7cc2 Added names for official Microsoft controllers, since they don't have descriptive product names 2019-12-11 19:24:40 -08:00
Sam Lantinga
0f52916027 Added custom names for some controllers 2019-12-11 17:47:01 -08:00
Sam Lantinga
e029fdbb38 Shorten "Performance Designed Products" to "PDP" 2019-12-11 17:46:59 -08:00
Sam Lantinga
325a2efb3d Added support for the full line of PDP Xbox 360 and Xbox One controllers 2019-12-11 17:46:57 -08:00
Sam Lantinga
8b50dcb21b Use the controller product string instead of hard-coding controller names 2019-12-11 17:46:54 -08:00
Sam Lantinga
89401b21e9 Added support for the Razer Raion Fightpad for PS4 2019-12-10 13:09:52 -08:00
Sam Lantinga
a21f6b7a91 Add the manufacturer to the joystick name on Mac OS X, for consistency with other drivers 2019-12-10 11:46:22 -08:00
Sam Lantinga
2a161e7add Remove any duplicate manufacturer in the joystick name 2019-12-10 11:30:56 -08:00
Sam Lantinga
3469481ef6 Don't include the manufacturer if it's already included in the product string 2019-12-10 10:00:49 -08:00
Sam Lantinga
bb37a1ebf5 Fixed the name of the Razer RAION Fightpad 2019-12-10 09:38:10 -08:00
Sam Lantinga
82d2c357c3 Fixed rumble after Xbox controller initialization
When we initialize the controller it has an internal rumble sequence number, and if our rumble sequence number doesn't match that, rumble won't happen. To fix that we cycle through the range of sequence numbers, and at some point we'll match up with the controller's sequence number and it'll roll forward until it matches our next rumble sequence number.
2019-12-09 16:52:11 -08:00
Sam Lantinga
3d34750ced The PowerA Mini controller blocks while writing feature reports, so don't try to use the HIDAPI driver for it on Linux 2019-12-09 13:54:05 -08:00
Sam Lantinga
3626506369 Added some missing Xbox controller names 2019-12-09 13:54:03 -08:00
Sam Lantinga
135a90539b Fixed the Apple TV remote menu button on tvOS 13.2 (thanks Romain Tisserand) 2019-12-06 13:48:13 -08:00
Sam Lantinga
7a51ad6a50 Fixed the game controller menu button on tvOS 13.2 (thanks Romain Tisserand) 2019-12-06 13:48:10 -08:00
Sam Lantinga
8342fa7c7e Fixed controller mapping issues caused by PS3 gyro jitter 2019-12-05 13:48:08 -08:00
Sam Lantinga
6d00166813 Get full axis range for PS3 controller triggers on Linux 2019-12-05 13:18:53 -08:00
Cameron Gutman
55eb76218d Use stat() to minimize input device opens when not using udev
Calling open() on input devices can generate device I/O which blocks
the main thread and causes dropped frames. Using stat() we can avoid
opening anything unless /dev/input has changed since we last polled.

We could have used something fancy like inotify, but it didn't seem
worth the added complexity for this uncommon non-udev case.
2019-11-20 20:27:45 -08:00
Sam Lantinga
b98808f639 Updated DPAD binding for 8Bitdo Zero controller 2019-11-28 14:23:24 -08:00
Sam Lantinga
2fd3f756d2 Fixed trying to use the HIDAPI driver for the original Xbox One S Bluetooth controller 2019-11-28 11:44:17 -08:00
Sam Lantinga
8aaf945b2f Fixed mapping controllers that have axes that start at -32768 and then snap to 0 at the first input report 2019-11-28 11:44:15 -08:00