Commit graph

116 commits

Author SHA1 Message Date
Sam Lantinga
6e62d312ea Fixed default Android D-PAD mapping so the back button is treated as B 2017-12-16 10:40:47 -08:00
Sam Lantinga
42b997becf Fixed building on non-Android platforms 2017-11-01 10:07:04 -07:00
Sam Lantinga
7565396bf0 Added controller mapping for Android TV remotes
Also fixed the back button on the remote exiting the application
2017-11-01 10:06:58 -07:00
Sam Lantinga
6387f21f85 Exposed the joystick locking functions for multi-threaded access to the joystick API 2017-10-10 11:10:15 -07:00
Sam Lantinga
35811c4c2f Fixed crash in SDL_IsGameController() on Windows if called when a controller is being removed 2017-10-09 11:45:15 -07:00
Sam Lantinga
1e46b7fc9a Added stubs for simple Steam Controller support 2017-09-22 08:30:52 -07:00
Sam Lantinga
520aaf19a4 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
67823aa306 Fixed bug 3744 - missing SDLCALL in several functions
Ozkan Sezer

The attached patch adds missing SDLCALL to several functions, so that
they properly match the headers as intended.
2017-08-13 21:06:52 -07:00
Sam Lantinga
2a8d4de4af Added check for XBOX in addition to Xbox and X-Box 2017-08-13 20:39:00 -07:00
Sam Lantinga
b3ecc4942c Fixed compiler warnings on Visual Studio 2013 2017-08-12 00:04:46 -07:00
Sam Lantinga
3c8dc5ab15 Added a private hint for Steam to bypass the controller filtering for the Steam virtual gamepad 2017-08-09 12:38:20 -07:00
Sam Lantinga
a0941b37eb Fixed Linux build 2017-08-09 12:11:59 -07:00
Sam Lantinga
b044a3bba8 Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
Ryan C. Gordon
82d0a04881 Fix some more compiler warnings on armcc. 2017-03-03 16:38:17 -05:00
Philipp Wiesemann
f8d3d73cc9 Fixed comments. 2017-01-14 21:36:06 +01:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Philipp Wiesemann
1a24600b5f Fixed crash if allocating memory for game controller failed. 2016-12-28 20:10:48 +01:00
Sam Lantinga
df32741ff4 Fixed comment style 2016-12-27 02:04:38 -08:00
Sam Lantinga
c6e0424049 Split controller axes into positive and negative sides so each can be bound independently.
Using this a D-Pad can be mapped to a thumbstick and vice versa.
Also added support for inverted axes, improving trigger binding support
2016-12-27 01:39:07 -08:00
Sam Lantinga
7d8c7416d1 Fixed bug 3517 - Compiler warnings with gcc -Wstrict-prototypes
felix

Compiling even a simple SDL2 'hello world' program with gcc -Wstrict-prototypes (GCC 6.2.1) results in warnings like:

/usr/include/SDL2/SDL_gamecontroller.h:143:1: attention : function declaration isn't a prototype [-Wstrict-prototypes]
 extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings();
 ^~~~~~

It seems there is a missing 'void' between the parentheses.
2016-12-26 02:12:21 -08:00
Sam Lantinga
5ea622c38f 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
6ece64092f 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
428b0082bf Add the controller mappings to the linked list in order 2016-11-29 22:02:37 -08:00
Sam Lantinga
a31f3d2c25 Added an API to iterate over game controller mappings 2016-11-29 06:36:57 -08:00
Philipp Wiesemann
0fac39e6db Fixed two memory leaks if added game controller mapping has lower priority.
Found by buildbot.
2016-11-19 23:27:37 +01:00
Sam Lantinga
dae32409e9 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
c3a90c043d 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
58670bda06 Fixed whitespace and added code to support older game controller GUIDs 2016-11-11 04:35:06 -08:00
Sam Lantinga
6fcf21b827 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
d14ce58e75 Fixed bug 3438 - SDL_GameControllerEventWatcher: Log on event with value >= k_nMaxReverseEntries 2016-10-07 18:24:34 -07:00
Sam Lantinga
c680df8746 Fixed recentering triggers when the application doesn't have focus 2016-10-07 16:13:37 -07:00
Sam Lantinga
0438241313 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
Sam Lantinga
fd8e31b7aa 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
Sam Lantinga
f98a06ec45 Added SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved()
Updated the removal code to iterate over all joystick add messages instead of just the first one.
2016-08-26 12:18:08 -07:00
Sam Lantinga
b97a48ebad commit 1170112da3776fdb06425f62d57b63144c33dc51
Author: James Zipperer <james.zipperer@synapse.com>
Date:   Sun Aug 21 01:19:19 2016 -0700

    bugfix for controller / joystick add / remove being in the event queue at the same time
2016-08-26 11:16:44 -07:00
Ethan Lee
be57775a6c Allow mappings to be added before GameControllerInit 2016-03-07 08:22:55 -05:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
c27d95571f Added broad support for wireless XBox 360 controllers on Linux 2015-12-09 12:11:40 -08:00
Ryan C. Gordon
03cb578e6e Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
--HG--
extra : amend_source : 110a5505509ddb9ecafed75abd89602986a99696
2015-11-14 12:35:45 -05:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Sam Lantinga
1cbf83b0c0 Added generic xinput fallback for XBox compatible controllers on Linux 2015-05-13 22:37:26 -07:00
Ryan C. Gordon
de88474dda Initial merge of Emscripten port!
With this commit, you can compile SDL2 with Emscripten
( http://emscripten.org/ ), and make your SDL-based C/C++ program
into a web app.

This port was due to the efforts of several people, including: Charlie Birks,
Sathyanarayanan Gunasekaran, Jukka Jylänki, Alon Zakai, Edward Rudd,
Bruce Mitchener, and Martin Gerhardy. (Thanks, everyone!)

--HG--
extra : rebase_source : 97af74c8a5121e926ebe89f123536b5dd6681695
2014-12-18 00:19:52 -05:00
Philipp Wiesemann
76173b195e Added handling of NULL as input for SDL_GameControllerAddMapping(). 2014-10-26 23:28:45 +01:00
Philipp Wiesemann
bbbe3edca1 Fixed SDL_GameControllerMappingForGUID() crashing if no more memory available.
The return value of SDL_malloc() was not checked and NULL therefore not handled.
NULL returned by SDL_GameControllerMapping()/SDL_GameControllerMappingForGUID()
now either means "no mapping" (as before) or "no memory" (just crashed before).
2014-10-26 23:22:53 +01:00
Philipp Wiesemann
8869fe78be Added handling of NULL as input for SDL_GameControllerMapping().
For consistency with the similar functions getting SDL_GameController as input.
Also NULL is no SDL_GameController and therefore can not have a mapping anyway.
2014-10-26 17:53:16 +01:00
Philipp Wiesemann
81958288cc Removed two wrong documentation comments from gamecontroller source.
No replacement because correct documentation is already in SDL_gamecontroller.h.
2014-10-26 17:46:11 +01:00
Philipp Wiesemann
788b558bc8 Fixed wording in SDL_GameControllerAddMappingsFromRW() error message. 2014-10-26 17:44:00 +01:00
Sam Lantinga
9d42bf534d Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Sam Lantinga
9cdeec59f3 Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
--HG--
rename : src/audio/directsound/directx.h => src/core/windows/SDL_directx.h
rename : src/haptic/windows/SDL_syshaptic.c => src/haptic/windows/SDL_windowshaptic.c
rename : src/haptic/windows/SDL_syshaptic_c.h => src/haptic/windows/SDL_windowshaptic_c.h
rename : src/joystick/windows/SDL_dxjoystick.c => src/joystick/windows/SDL_dinputjoystick.c
rename : src/joystick/windows/SDL_dxjoystick_c.h => src/joystick/windows/SDL_dinputjoystick_c.h
rename : src/joystick/windows/SDL_dxjoystick_c.h => src/joystick/windows/SDL_windowsjoystick_c.h
2014-07-03 15:39:55 -07:00
Sam Lantinga
dc434901da Fixed bug 2553 - Add support to all XInput devices
This adds support for all XInput devices, exposed through the SDL joystick API.
The button and axis reporting for XInput devices has been changed to match DirectInput and other platforms.
The game controller xinput mapping has been updated so this change is seamless.
There is a new hint, SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING, for any applications that have hardcoded the old xinput button and axis set. This hint will be removed in SDL 2.1.
2014-06-24 13:31:25 -07:00