Commit Graph

40 Commits

Author SHA1 Message Date
Misa 66a08aa391 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-11 07:23:25 -08:00
Sam Lantinga 3d74707830 Run the renderer so Steam can find the main window 2021-08-03 09:25:13 -07:00
Sam Lantinga 8726f500ef Allow quitting controllermap if there are no controllers attached 2021-08-03 01:10:48 -07:00
Sam Lantinga 8b87b438b4 Don't try to map the touchpad button, since we don't have any art for that at the moment. 2021-03-26 13:01:06 -07:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga ff4bc1389c Fixed mapping controllers after adding the touchpad button 2020-11-23 14:28:16 -08:00
Sam Lantinga 009b62f1c2 Be explicit about mapping the new game controller paddle buttons 2020-11-07 02:22:15 -08:00
Sam Lantinga 5a92edee03 Don't try to map the accelerometer as a game controller 2020-11-06 15:54:18 -08:00
Sam Lantinga 59a644fb01 iOS should use the same size window for the controller tests as other platforms
Otherwise the position of the button and axis elements won't be correct
2020-11-06 14:44:26 -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 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
Sam Lantinga de2001eeee Fixed binding the D-PAD on the 8BitDo M30 controller 2020-03-13 13:05:40 -07:00
Sam Lantinga 25061816bf Fixed compile warning 2020-03-02 10:58:08 -08:00
Sam Lantinga 0a7fe18fe6 On Mac OSX there are spurious hat events at program start, so skip these 2020-01-17 11:06:02 -08:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 8ce894a316 Ignore axis jitter when mapping controllers 2019-12-05 13:18:56 -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 c8896e4681 Turned on controllermap debug output by default 2019-11-21 10:09:26 -08:00
Ozkan Sezer 32bb8b4b40 test: replace some exit()s with returns. 2019-09-10 10:03:20 +03:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Philipp Wiesemann 20c846ebe7 Fixed warning about implicit conversion in controllermap program. 2017-03-04 23:05:47 +01:00
Sam Lantinga a395a90759 Fixed mapping the PG-9021 which, on Linux, emits a button partway through the trigger press along with axis motion all along the pull 2017-01-20 16:40:11 -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 1ddff75c70 Some controllers have trouble getting out to 20000 2017-01-04 05:09:02 -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
Philipp Wiesemann de79828b9f Fixed warning about unused variable in controllermap program. 2016-12-28 20:11:12 +01:00
Sam Lantinga 21cb42d79b Make sure we go all the way back (within the XBox controller dead zone) to prevent accidentally binding axes inverted 2016-12-27 09:51:58 -08:00
Sam Lantinga 6d7da0887d 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
Philipp Wiesemann 0a3f9d0cfb Fixed warning about unused variable in controllermap program. 2016-12-16 22:58:16 +01:00
Sam Lantinga 0c5e7a1067 Fixed handling joysticks that send multiple events for a single control, e.g. both a button and axis event for a trigger.
Tested with the 8Bitdo NES30 Pro on Linux
2016-12-15 14:27:22 -08:00
Sam Lantinga c406f649b3 Added USB VID/PID information to the SDL test programs 2016-11-10 18:53:50 -08:00
Philipp Wiesemann 826508b6ee Removed unused constants in controllermap program. 2016-10-15 20:01:30 +02:00
Sam Lantinga cb7b823cc1 Fixed black screen on Steam Link 2016-10-13 02:09:37 -07:00
Philipp Wiesemann 929b965c62 Fixed compiling of three test programs with C++. 2016-09-21 23:06:38 +02:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga 7b680a2ab7 Fixed mapping third party XBox controllers that have the trigger axis all the way in until they are pulled and get updated values. 2015-12-18 18:49:23 -08:00
Philipp Wiesemann 11d98995da Replaced tabs with spaces in test programs. 2015-11-25 21:39:28 +01:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00