Commit Graph

158 Commits

Author SHA1 Message Date
Sam Lantinga
9f51fad361 Added support for the touchpad on PS4 and PS5 controllers 2020-11-13 18:01:29 -08:00
Sam Lantinga
1e2caac58b Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers() 2020-11-11 18:57:37 -08:00
Sam Lantinga
e12457d8bf Added support for the Xbox Series X controller to the HIDAPI driver 2020-11-10 12:26:30 -08:00
Sam Lantinga
c3dea23120 Added support for reading the paddles on a Xbox Elite Series 2 controller in Bluetooth mode 2020-11-09 22:39:33 -08:00
Sam Lantinga
3a3aaac221 Added 4 auxiliary buttons to the game controller API
Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver
PS4 and PS5 controllers use AUX1 to represent the touchpad button
Nintendo Switch Pro controllers use AUX1 to represent the capture button
2020-11-06 11:30:52 -08:00
Sam Lantinga
4d79f9662f Added initial support for the Sony PS5 Controller 2020-11-05 15:02:54 -08:00
Sam Lantinga
e555d45331 Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
2020-11-05 11:07:54 -08:00
Ethan Lee
83cddd2ebc Add SDL_JoystickSetLED.
Currently, this is only supported by the PS4 HIDAPI driver.
2020-04-30 11:57:29 -04:00
Sam Lantinga
345b4d7e14 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification
Jan Bujak

I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL.

Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this:

https://www.kernel.org/doc/html/v4.15/input/gamepad.html

Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments.

Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.)

With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
2020-05-29 13:37:21 -07:00
Brendan Shanks
032fa681a8 Add Logitech G29 to steering wheel list 2020-04-24 14:03:30 -07:00
Sam Lantinga
1a1f1704a2 Don't include the iOS joystick driver if joysticks are disabled 2020-05-27 10:35:43 -07:00
Sam Lantinga
aba2792896 Added a Windows Gaming Input joystick driver
This driver supports the Razer Atrox Arcade Stick

Some of the quirks of this driver, inherent in Windows Gaming Input:
* There will never appear to be controllers connected at startup. You must support hot-plugging in order to see these controllers.
* You can't read the state of the guide button
* You can't get controller events in the background
2020-04-18 21:41:37 -07:00
Ryan C. Gordon
8c165adde7 joystick: Remove force_centering flag; we handle this on disconnect now. 2020-04-07 23:17:27 -04:00
Ryan C. Gordon
07f231eeae joystick: Make sure recentering events happen before disconnect events.
Fixes Bugzilla #5063.
2020-03-26 18:47:04 -04:00
Sam Lantinga
4dea340ca7 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows
Jimb Esser

Add new RawInput controller API, and improved correlation with XInput/WGI

Reorder joystick init so drivers can ask the others if they handle a device reliably
Do not poll disconnected XInput devices (major perf issue)
Fix various cases where incorrect correlation could happen
Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation
Correlate by axis motion as well as button presses
Fix failing to zero other trigger
Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init()
Add missing device to device names
Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices

Updated to SDL 2.0.13 code with the following notes:
New HID driver: xbox360w - no idea what that is, hopefully urelated
SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data.
SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem.
Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason.
Something changed in how devices get names, so getting generic names.
Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
2020-03-16 12:23:38 -07:00
David Ludwig
b2296506bc virtual joysticks: MSVC support part 1/2, make driver's .c file be uniquely named 2020-03-15 15:05:36 -04:00
David Ludwig
cc90875647 virtual joysticks: removed ball support (Bug 5028) 2020-03-15 13:25:49 -04:00
Sam Lantinga
2be75c6a61 Fixed bug 5028 - Virtual Joysticks (new joystick backend)
David Ludwig

I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver.  This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically.  A primary use case for this is to help enable developers to add touch-screen joysticks to their apps.

The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one.

Use of virtual joysticks goes as such:

1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual.  If successful, this returns the virtual-device's joystick-index.
2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual).
3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes.  Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent).


Here is a listing of the new, public APIs, at present and subject to change:

------------------------------------------------------------

/**
 * Attaches a new virtual joystick.
 * Returns the joystick's device index, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats);

/**
 * Detaches a virtual joystick
 * Returns 0 on success, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);

/**
 * Indicates whether or not a virtual-joystick is at a given device index.
 */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);

/**
 * Set values on an opened, virtual-joystick's controls.
 * Returns 0 on success, -1 on error.
 */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);

------------------------------------------------------------

Miscellaneous notes on the initial patch, which are also subject to change:

1. no test code is present in SDL, yet.  This should, perhaps, change.  Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official.  If tests are to be added, what kind of tests?  Automated?  Graphical?

2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX.  When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions).

3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8.

4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER.  This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above).

5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate.

6. the initial patch is based off of SDL 2.0.12

7. the virtual joystick subsystem is disabled by default.  It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1



Questions, comments, suggestions, or bug reports very welcome!
2020-03-13 19:08:45 -07:00
Sam Lantinga
6318765d54 Handle entirely duplicated joystick product names, as well as vendor and product names that start with the name of the vendor, but with different case (e.g. 8bitdo 8BitDo) 2020-03-13 13:05:43 -07:00
Sam Lantinga
de2001eeee Fixed binding the D-PAD on the 8BitDo M30 controller 2020-03-13 13:05:40 -07:00
Sam Lantinga
c44473ba73 Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
Cameron Gutman
4e0fb110c8 Clear the old player index slot when moving to a new one 2020-03-07 19:21:21 -08:00
Cameron Gutman
165ccaa85b Fix incorrect player index when assigning a joystick the same index twice
Prior to this fix, we would hit the existing_instance >= 0 case and move the joystick
again to a different index than the one requested by the caller. It also breaks the assumption
that a SDL_JoystickID is only present in SDL_joystick_players at one location.
2020-03-07 17:20:04 -08:00
Sam Lantinga
07000bfc33 Fixed bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application
Jake Breen

I have tracked it down to a call on
hid_device_info() -> HidD_GetManufacturerString (Line 499 in src\hidapi\windows\hid.c)
2020-03-02 17:31:58 -08:00
Sam Lantinga
3b3ae4d14d Possible fix for bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application
Jake Breen

When I run SDL_INIT with SDL_INIT_JOYSTICK it stalls for about 10 seconds (last report was 10,615ms), but only if I'm currently playing audio. (Like in Spotify for example.)

querying something related to device access (last dll loaded)
'BabbysFirst64.exe' (Win32): Loaded 'C:\Windows\SysWOW64\deviceaccess.dll'.

I use a USB DAC because my mobo's audio out is pretty not great. And I've noticed unplugging it seems to solve the issue. I haven't noticed any other issues that are caused by my DAC.

My DAC is the Sound BlasterX G1 https://us.creative.com/p/gaming-headsets/sound-blasterx-g1
Vid = 041E
PID = 3249

My system specs:
- Windows 10 Pro
- Ryzen 2700x
- 16GB Ram
- Nvidia 2070 RTX

Additional USB devices plugged in:
- Valve Index
- Xbox One Elite Controller
2020-03-02 15:06:47 -08:00
Sam Lantinga
8d14636326 Fixed support for third party Xbox 360 wireless controller dongle 2020-02-19 08:26:00 -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
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
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -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
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
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
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
52b6ab2196 Added support for the SteelSeries Stratus Duo 2019-12-16 17:11:23 -08:00
Sam Lantinga
4d4e5584ea Fixed binding D-pad on NES30 controller 2019-12-12 19:07:26 -08:00
Sam Lantinga
0352814a8a Added general remapping of controller manufacturer 2019-12-13 16:07:25 -08:00
Sam Lantinga
0f52916027 Added custom names for some controllers 2019-12-11 17:47:01 -08:00
Sam Lantinga
8342fa7c7e Fixed controller mapping issues caused by PS3 gyro jitter 2019-12-05 13:48:08 -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
Sam Lantinga
733f25252a Fixed build 2019-11-22 14:09:24 -08:00
Sam Lantinga
b5aff9d7c3 Added SDL_GameControllerTypeForIndex() and SDL_GameControllerGetType() to return the type of controller attached. 2019-11-22 13:12:12 -08:00
Sylvain Becker
b7ab3b3984 Fixed bug 4838 - Use after free in SDL_JoystickUpdate (Thanks!) 2019-10-23 08:50:57 +02:00
Sam Lantinga
e6ac16ef2f Added support for third party Nintendo Switch controllers that don't support the full protocol 2019-10-17 16:59:05 -07:00
Sam Lantinga
a06d8cd0d4 Merged latest changes from Steam into controller_type.h 2019-07-17 16:47:17 -07:00
Sam Lantinga
be6cda9f95 Rolling back GameCube HIDAPI support
It causes the HIDAPI devices to always be opened on enumeration, which causes crashes in the Windows drivers when multiple applications are reading and writing at the same time. We can revisit this after 2.0.10 release.
2019-06-19 15:54:21 -07:00
Zack Middleton
b23cce282e Fix GameCube controller power level being reset to unknown
HIDAPI_DriverGameCube_OpenJoystick() set power level to wired and then
it was set to unknown in SDL_JoystickOpen().
2019-06-19 06:43:04 -07:00
Sam Lantinga
9261e473d6 Potential fix for a crash we're seeing on Android that should in theory never happen. 2019-06-07 09:00:24 -07:00
Sam Lantinga
9a8d5215c6 Handle potentially calling SDL_JoystickUpdate() and SDL_JoystickQuit() at the same time. 2019-03-27 08:17:05 -07:00
Ethan Lee
c528615626 hidapi: Add support for Wii U/Switch USB GameCube controller adapter.
Note that a single USB device is responsible for all 4 joysticks, so a large
rewrite of the DeviceDriver functions was necessary to allow a single device to
produce multiple joysticks.
2019-03-12 20:27:54 -04:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sam Lantinga
6ed76ae18f Fixed the ROCCAT Tyon mouse showing up as a joystick on Windows 2018-12-05 14:46:03 -08:00
Sam Lantinga
b73703b9c6 Fixed bug 4391 - hid_enumerate() sometimes causes game to freeze for a few seconds
Daniel Gibson

Even though my game (dhewm3) doesn't use SDL_INIT_JOYSTICK, SDL_PumpEvent() calls SDL_JoystickUpdate() which ends up calling hid_enumerate() every three seconds, and sometimes on my Win7 box hid_enumerate() takes about 5 seconds, which causes the whole game to freeze for that time.
2018-11-19 21:17:00 -08:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Sam Lantinga
14329256cb Generalized the XInput user index into a player index 2018-10-25 16:53:14 -07:00
Sam Lantinga
545febcf21 Fixed initializing XInput user index 2018-10-25 13:22:34 -07:00
Sam Lantinga
9987ca69f3 Added SDL_JoystickGetXInputUserIndex() 2018-10-25 12:54:42 -07:00
Ryan C. Gordon
b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Sam Lantinga
6b3f11e2a3 Fixed code style 2018-08-20 21:18:56 -07:00
Ryan C. Gordon
67a48ad13a haiku: Patched to compile with new joystick interfaces. 2018-08-10 15:04:08 -04:00
Ryan C. Gordon
67764070f0 bsd: Update joystick code for new interfaces.
(this is an untested push to see if buildbot likes it.)
2018-08-10 14:42:40 -04:00
Ryan C. Gordon
b692c35237 emscripten: Patched to compile with new joystick interfaces. 2018-08-10 14:32:30 -04:00
Sam Lantinga
888bf1af69 Worked around bug with Sony PS Now PS3 controller where DirectInput polling will continue to return success after the controller is unplugged.
The code is now reliant on SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() being called correctly when devices are added or removed on Windows
2018-08-09 16:03:50 -07:00
Sam Lantinga
f35e97ba8a Fixed Windows build 2018-08-09 16:03:29 -07:00
Sam Lantinga
d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Ozkan Sezer
5454765a22 replace bool stuff in controller_type.h with SDL_bool.
remove bool<->SDL_bool dance in SDL_joystick.c:SDL_IsJoystickSteamController()
after the controller_type.h change.
2018-09-28 17:01:24 +03:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
59a2d12cc3 Fixed creating an Android game controller mapping for HIDAPI devices on initialization 2018-09-17 11:35:22 -07:00
Sam Lantinga
8e062f6925 Generalized the handling of instantaneous guide button presses so there's a minimum of 100 ms between guide button press and release.
This happens with at least the following controllers: All Apple MFI controllers, ASUS Gamepad, XiaoMi Bluetooth Controller
2018-03-19 14:42:51 -07:00
Sam Lantinga
9e651b6915 Try to dynamically create a default Android game controller mapping based on the buttons and axes on the controller.
Include the controller USB VID/PID in the GUID where possible, as we do on other platforms.
2018-03-06 14:51:50 -08:00
Sam Lantinga
e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
b647bd0692 The event filter and event watch functions are now thread-safe 2017-10-10 17:41:41 -07:00
Sam Lantinga
d90fce3c9e Exposed the joystick locking functions for multi-threaded access to the joystick API 2017-10-10 11:10:15 -07:00
Sam Lantinga
5ab5c9b767 Avoid duplicate joystick axis events 2017-09-22 08:56:09 -07:00
Sam Lantinga
eaab6098eb Only apply the jitter filter to prevent unexpected motion on axes that haven't been touched. 2017-09-21 10:29:17 -07:00
Sam Lantinga
de91b1248f Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks
Patches contributed by Ozkan Sezer
2017-08-14 06:28:21 -07:00
Sam Lantinga
059d9e4627 Fixed bug 2950 - wrong axes values are set on joystick initialization
Edward Rudd

Device: Logitech Rumble Gamepad F510 in Xinput mode.

Upon opening the joystick the values of the axes are queried via PollAllValues are not actually set on the device all the time.

This can easily be seen in the testjoystick or testgamecontroller test programs,as the testjoystick shows all axes in the center until one 'tickles' the triggers., and the testgamecontroller will show the triggers as 'on' until on 'tickles' the triggers.

Upon further research the culprit is the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint. In the default value events are ignored until there is an active window, Thus in cases where the joystick system is initialized and controllers opened before the initial window is created & focuses, the initial values will be incorrect.

Here is my current workaround in the game I'm working on porting..

SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_GameController* gamepad = SDL_GameControllerOpen(index);
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
2017-08-12 17:41:59 -07:00
Sam Lantinga
c49fa37c5b Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
Sam Lantinga
1eb92f6342 Implemented Linux joystick blacklist
Based on https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py

This fixes a few devices that are not actually joysticks showing up as such in SDL
2017-04-06 06:30:43 -07:00
Sam Lantinga
763e138903 Added an API to get the joystick instance ID before opening the device: SDL_JoystickGetDeviceInstanceID() 2017-03-09 16:09:16 -08:00
Sam Lantinga
be28d7c88c Added support for the Saitek Pro Flight X-56 Rhino 2017-01-31 12:30:55 -08:00
Sam Lantinga
6717a3d38d Added support for the HOTAS Warthog throttle 2017-01-31 12:23:29 -08:00
Sam Lantinga
a156b0d994 Added the HOTAS Warthog as a flight stick 2017-01-31 10:20:09 -08:00
Sam Lantinga
95ab9dc73c Added Thrustmaster Wheel FFB entry to the list of wheels 2017-01-27 06:05:50 -08:00
Sam Lantinga
3c90a52aa7 Added an API to get the type of a connected joystick 2017-01-27 05:59:58 -08:00
Sam Lantinga
8fa0b0889d Added support for the 8Bitdo Zero GamePad 2017-01-20 08:13:23 -08:00
Sam Lantinga
4938c5054e Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value.
This is useful for controller mapping programs to determine an axis' zero state
2017-01-04 10:28:07 -08:00
Sam Lantinga
99e10ef506 Assume D-pad or thumbstick style axes are centered at 0 2017-01-04 07:06:48 -08:00
Sam Lantinga
d2a01b6e53 Added the NEXT SNES Controller to the list of zero-centered joysticks 2017-01-04 06:19:56 -08:00
Sam Lantinga
c7780497dc Increased joystick jitter tolerance for PS3 controllers 2017-01-04 05:56:47 -08:00
Sam Lantinga
082132a70c Fixed binding the D-pad on some Super NES style controllers
Fixed a case where partial trigger pull could be bound to another button

There is a fundamental problem not resolved by this commit:

Some controllers have axes (triggers, pedals, etc.) that don't start at zero, but we're guaranteed that if we get a value that it's correct. For these controllers, the current code works, where we take the first value we get and use that as the zero point and generate axis motion starting from that point on.

Other controllers have digital axes (D-pad) that assume a zero starting point, and the first value we get is the min or max axis value when the D-pad is moved. For these controllers, the current code thinks that the zero point is the axis value after the D-pad motion and this doesn't work.

My hypothesis is that the first class of devices is more common and that we should solve for that, and add an exception to SDL_JoystickAxesCenteredAtZero() as needed for the second class of devices.
2017-01-03 23:39:28 -08:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
ca019dada5 Fixed issue where the throttle and other axes on racing wheels don't start at zero and show up as immediate input when the wheel is turned for the first time. Wait until they are actually moved before generating input from them. 2016-12-22 17:33:45 -08:00
Sam Lantinga
b4ea63ec2c Fixed crash if there are multiple joysticks closed during the joystick update loop 2016-12-14 06:25:09 -08:00
Sam Lantinga
3b18c796ed Fixed bug 3512 - Memory leak of SDL_Joystick axes_zero array
Benjamin Harris

Found with valgrind and confirmed in the 2.0.5 source code.
One-line fix in SDL_JoystickClose?
2016-12-09 01:29:52 -08:00
Sam Lantinga
a525017139 Protect the game controller API the same way the joystick API is protected from multi-threaded access 2016-12-08 10:13:45 -08:00
Philipp Wiesemann
a7655d77d1 Fixed warning about storing an unused value.
Found by buildbot.
2016-11-30 23:31:23 +01:00
Sam Lantinga
5220759f03 Made it safe to update joysticks from multiple threads, fixes crash in Steam 2016-11-29 05:04:42 -08:00
Sam Lantinga
e9983c7b0f We are comparing 16-bit values 2016-11-24 11:53:23 -08:00
Sam Lantinga
b6542ab237 Fixed whitespace 2016-11-11 04:30:09 -08:00