Commit Graph

103 Commits

Author SHA1 Message Date
Sam Lantinga
b936a4c360 Added support for the XiaoMi Game Controller 2016-12-09 04:57:54 -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
Sam Lantinga
1b08f0c179 Added the guide button for the NVIDIA Shield Controller 2016-12-07 11:41:20 -08:00
Sam Lantinga
acabb5d5fd Added support for XBox One controllers on Mac OS X, using the driver at: https://github.com/360Controller/360Controller/releases 2016-12-06 14:22:28 -07:00
Sam Lantinga
264138cceb Added support for the Hori Fighting Commander 4 2016-12-03 08:39:21 -08:00
Sam Lantinga
e7efcfbaa4 Added Linux mapping for the DragonRise Inc. Generic USB Joystick 2016-12-03 00:40:13 -08:00
Sam Lantinga
26f05ecb4d Fixed missing prototypes on Android, patch from Sylvain 2016-12-02 02:25:12 -08:00
Sam Lantinga
a738a6fb49 Added Linux controller mapping for the Nostromo n45 Dual Analog Gamepad 2016-12-01 07:31:08 -08:00
Sam Lantinga
cb8748b719 Fixed the controller mappings for the OUYA controller 2016-11-30 12:58:03 -08:00
Sam Lantinga
5fcf2577fb Added PS4 controller entries for the new Sony HID driver
https://git.kernel.org/cgit/linux/kernel/git/jikos/hid.git/log/?h=for-4.10/sony
2016-11-30 12:34:50 -08:00
Sam Lantinga
663afa911f Added support for the DS4 USB Wireless Adaptor 2016-11-30 12:25:19 -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
d834c08ac7 Add the controller mappings to the linked list in order 2016-11-29 22:02:37 -08:00
Sam Lantinga
dd5d85a4e7 Added an API to iterate over game controller mappings 2016-11-29 06:36:57 -08: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
2f6ba615ee Guess the USB VID/PID of XInput devices 2016-11-24 12:24:22 -08:00
Sam Lantinga
e9983c7b0f We are comparing 16-bit values 2016-11-24 11:53:23 -08:00
Sam Lantinga
5232b8e952 Fixed XBox One S controller mapping for firmware revision 3.1.1221.0, including back and guide buttons 2016-11-23 06:54:19 -08:00
Sam Lantinga
aa03b9d7af The XBox One S controller sends keys outside the standard joystick button range 2016-11-22 22:14:28 -08:00
Sam Lantinga
6558ecdbf6 Added mapping for XBox One S controller firmware version 3.1.1221.0 2016-11-22 04:42:07 -08:00
Sam Lantinga
3615633571 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Philipp Wiesemann
eb9cc03068 Fixed two memory leaks if added game controller mapping has lower priority.
Found by buildbot.
2016-11-19 23:27:37 +01:00
Philipp Wiesemann
97aa577589 Fixed empty parameter list in signatures of internal functions. 2016-11-16 22:08:51 +01:00
Sam Lantinga
57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
23c01c1890 Fixed bug 3079 - Allow non destructive SDL_GameControllerAddMappingsFromFile
x414e54

It is a bit of a pain to update the library or rely on whatever version the user has on their computer for default mappings.

So providing an easily updatable text file via SDL_GameControllerAddMappingsFromFile is still currently the most viable way. However using this replaces all mappings provided by the SDL_HINT_GAMECONTROLLERCONFIG environment variable which may have come from the user's custom Steam mapping.

There should be an easy way for games to supply extra game controller mappings to fill in the differences between SDL versions without it clobbering the SDL_HINT_GAMECONTROLLERCONFIG environment variable.

Internally the mappings could use a priority system and if the priority is lower then it will not overwrite the mappings.

For now it just assumes SDL_HINT_GAMECONTROLLERCONFIG is the highest priority, the default hardcoded are the lowest and anything set via the API is medium.
2016-11-11 13:29:23 -08:00
Sam Lantinga
160e719449 Fixed whitespace and added code to support older game controller GUIDs 2016-11-11 04:35:06 -08:00
Sam Lantinga
b6542ab237 Fixed whitespace 2016-11-11 04:30:09 -08:00
Sam Lantinga
47418f2d5a Updated Windows game controller support 2016-11-11 03:35:37 -08:00
Sam Lantinga
801a9eaf64 Updated Mac OS X game controller support 2016-11-11 04:06:00 -07:00
Sam Lantinga
0cc6207c68 Added Linux entries for the Logitech Dual Action game controller 2016-11-10 18:53:29 -08:00
Sam Lantinga
ac74e16cde Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller. 2016-11-10 17:19:34 -08:00
Sam Lantinga
acae3ebf74 Added mapping for the PS3 controller in Bluetooth mode 2016-11-02 02:50:27 -07:00
Sam Lantinga
ae8ca7c54d Fixed bug 3444 - Android-TV: no more handling of back button on remote
ny00

Unfortunately, simply checking the return codes of "onNativePadDown/Up" as previously done has its own issue:

If an SDL joystick is connected *and* opened, then a proper KeyEvent, say with keycode KEYCODE_BUTTON_1, should lead to an SDL joystick button event as expected.

If, however, the joystick was *not* opened, then "onNativePadDown/Up" will return a negative value, so before the commit from bug 3426, you could unexpectedly get a keyboard event. (In practice, you'll just get a log message, since KEYCODE_BUTTON_1 has no mapping to a proper SDL_ScanCode value, but it's still an problem).

What should still be done, though, is checking the key code itself. We do have the KeyEvent.isGamepadButton method, but according my test, it returns "true" exactly (and only) for the KEYCODE_BUTTON* values, and not for KEYCODE_DPAD* or any other key code.

Here is a possible solution:
- Do check the return codes of "onNativePadDown/Up" as previously done.
- In addition, in "Android_OnPadDown/Up" from src/joystick/android/SDL_sysjoystick.c, 0 should *always* be returned in case the key code can be translated to an SDL_joystick button; Even if no matching joystick can be found.
2016-10-17 22:09:22 -07:00
Philipp Wiesemann
c0578f9293 Linux: Removed not needed platform info from entry in controller database. 2016-10-16 22:46:56 +02:00
Sam Lantinga
3f167a5a7f Added support for the PS4 Slim controller, model CUH-ZCT2U 2016-10-13 02:19:23 -07:00
Sam Lantinga
27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga
89abbbfe9e Fixed bug 3438 - SDL_GameControllerEventWatcher: Log on event with value >= k_nMaxReverseEntries 2016-10-07 18:24:34 -07:00
Sam Lantinga
24df68ea33 Fixed bug 2833 - Access Violation on SDL_PollEvent after init, delay and quit of joystick subsystem
Jan Klass

Not sure if this is limited to the joystick subsystem,
but I created a minimal program for reproducibility,
which is attached.

The issue occurs with my gamepad Razer Onza (an xbox-style gamepad) plugged in.
On initialization, the gamepad is being recognized.
After quitting the subsystem, the poll will receive the joystick added event,
which it instantly handles itself, calling SDL_SYS_JoystickDetect again,
which this time calls IDirectInput8_EnumDevices with dinput = NULL (after it was released on quit).
This seems to lead to an access violation within said function, which I have no source for.
2016-10-07 16:32:58 -07:00
Sam Lantinga
8bc5c57d2e Fixed recentering triggers when the application doesn't have focus 2016-10-07 16:13:37 -07:00
Sam Lantinga
72164985b0 Fixed bug 2823 - Release events for triggers receive wrong centered value
Ryochan7

I have been using SDL 2 for a little project that I have been developing for a while. My project is called antimicro and it takes gamepad input and then translates gamepad events into keyboard and mouse events. SDL is used to read the input from an XInput gamepad and it works great for the most part. However, there is one glaring problem that I have encountered.

When a device is unplugged and SDL sends the centered value release events for all axes, buttons, and hats, SDL does not use the proper centered value for the triggers. It pushes an SDL_JOYAXISMOTION event onto the queue with a value of 0 for all axes. That value is converted to around 16,000 for a Game Controller. That value is incorrect for triggers and, in my program, that causes any bindings that are assigned to the triggers to get activated. With most profiles, that will typically mean that a mouse right click and left click will be activated before the device is finally seen as removed and then those bindings are released by antimicro.
2016-10-07 16:04:15 -07:00
David Ludwig
3c8a26984d WinRT: build fix in joystick code 2016-10-01 18:10:50 -04:00
Sam Lantinga
7b34f47e19 Fixed windows build 2016-10-01 14:50:22 -07:00
Sam Lantinga
fa0f417631 Fixed build warnings and errors 2016-10-01 14:48:18 -07:00
Sam Lantinga
64180d2261 Fixed bug 3138 - c_dfDIJoystick2 already defined in dinput8.lib
Machiel van Hooren

In SDL_dxjoystick.c line 349 there is a constant c_dfDIJoystick2.
However, this constant is aparently also defined in dinput8.lib.

I encountered a linking error when statically linking to SDL:
SDL2_static.lib(SDL_dxjoystick.obj) : error LNK2005: _c_dfDIJoystick2 already defined in dinput8.lib
My application is also linking to dinput8.lib because we rolled our own joystick input and are not using the joystick functionality from SDL.
2016-10-01 14:05:35 -07:00
Sam Lantinga
c2e2565144 Fixed bug 3424 - SDL_GameController: Increase k_nMaxReverseEntries
ny00

On Android, the keycodes KEYCODE_BUTTON_1..16 (actual values 188-203) are translated to SDL_Joystick buttons no. 20-35. These are currently ignored in SDL_gamecontroller.c.

The attached patch fixes this, by increasing k_nMaxReverseEntries from 20 to another arbitrary bound of 48.

Side-note: Maybe some log should be emitted in case of going over any such bound?
2016-10-01 13:02:20 -07:00
Jonathan Dowland
461336a23e Add gamecontrollerdb lines for SFC30 controller in various modes
SFC30 controller: http://www.8bitdo.com/sfc30/

The SFC30 controller can present itself in a variety of modes and it offers up
different names in each. This patch captures data for three modes (one USB and
two Bluetooth) on three platforms (Mac OS X, Windows, Linux).

However, USB mode on Linux and Windows is missing as the button events did not
make it through to SDL's controllermap tool on Fedora 24/Linux 4.5.5 nor Steam
Big Picture mode on Windows. The two Bluetooth modes were indistinguishable on
Windows. Two modes on OS X were indistinguishable.

There exists a similar controller called the SNES30 (And some others) that are
very likely identical except for the name, but I have not verified this yet so
haven't synthesized lines for those controllers until I can.
2016-07-01 16:47:27 +01:00
Alex Szpakowski
a96b6f2104 Added a new hint SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION.
When set to "1", the orientation of the Apple TV remote affects the axes of the corresponding SDL joystick. It is "0" (disabled) by default.
2016-09-17 01:31:07 -03:00
Sam Lantinga
925859aaa6 Fixed accidental call to SDL_PrivateJoystickHat() 2016-09-13 18:43:55 -07:00
Alex Szpakowski
f050576665 Initial Apple TV / tvOS support.
The Apple TV remote is currently exposed as a joystick with its touch surface treated as two axes. Key presses are also generated when its buttons and touch surface are used.

A new hint has been added to help deal with deciding whether to background the app when the remote's menu button is pressed: SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS.
2016-09-13 22:18:06 -03:00