|
3bf7994f
|
2021-09-27T14:38:12
|
|
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).
Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.
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.
|
|
abc12a83
|
2021-11-11T15:58:44
|
|
Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs"
This reverts commit 66a08aa3914a98667f212e79b4f0b9453203d656.
This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
|
|
fe09a493
|
2021-11-11T15:53:11
|
|
joystick: Add APIs to query rumble support
|
|
66a08aa3
|
2021-09-27T14:38:12
|
|
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.
|
|
9fdb0645
|
2021-08-04T11:33:28
|
|
Added support for the Joy-Con Charging Grip when SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS is enabled
|
|
65ff00ec
|
2021-07-29T14:18:54
|
|
Query the rate for the correct sensor (thanks @meyraud705)
|
|
a186a503
|
2021-07-29T06:43:39
|
|
Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.
|
|
ce8261dd
|
2021-07-29T06:36:20
|
|
Only pump events once per frame and process all currently pending events
If you continually poll for events it's possible that new events can come in while you're still processing the last one, delaying rendering. This is more likely with high update rate sensors.
|
|
94b7a876
|
2021-07-24T09:10:18
|
|
Added SDL_GameControllerType enumerations for the Amazon Luna and Google Stadia controllers
Fixes bug https://github.com/libsdl-org/SDL/issues/4019
|
|
d135c076
|
2021-07-08T13:22:41
|
|
Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers
See testgamecontroller.c for an example of a custom PS5 trigger effect
|
|
646ddfb7
|
2021-05-15T00:22:50
|
|
minor watcom build fixes.
|
|
c94283d4
|
2021-01-13T11:01:54
|
|
testgamecontroller: log which controller the event came from
|
|
9130f7c3
|
2021-01-02T10:25:38
|
|
Updated copyright for 2021
|
|
390b2cf0
|
2020-12-22T20:53:27
|
|
Enable PS5 enhanced functionality for testgamecontroller
|
|
058a0ab4
|
2020-12-22T14:38:32
|
|
Set the pad lights on the PS5 controller corresponding to the player index
Also allow setting the player index from testgamecontroller using the number keys
|
|
3c68051e
|
2020-12-04T15:47:28
|
|
Allow background input when testing game controllers
|
|
04f0fd13
|
2020-11-27T18:57:42
|
|
Remember to close the game controller when we're done with it
|
|
012471e9
|
2020-11-27T18:57:38
|
|
Open and test all connected controllers
|
|
24cc0012
|
2020-11-25T16:05:15
|
|
Some controllers don't always reset their triggers to zero when they are released (e.g. Xbox One S in Bluetooth mode), so only trigger rumble if the trigger is pulled halfway or more.
|
|
e16afa79
|
2020-11-24T16:38:49
|
|
Automatically switch to testing a new controller when it's plugged in
|
|
04b45b55
|
2020-11-23T14:28:30
|
|
Allow testing a specific controller
|
|
75721b19
|
2020-11-21T18:01:23
|
|
Allow testing effects on PS4 controllers
Note, this will switch the controller into advanced report mode which breaks DirectInput on Windows
|
|
fcb21aa8
|
2020-11-17T10:30:20
|
|
Added API for sensors on game controllers
Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers
Also fixed an issue with the accelerometer on iOS having inverted axes
|
|
d140d887
|
2020-11-16T17:36:47
|
|
Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial()
|
|
fe4da420
|
2020-11-16T10:39:44
|
|
Improve LED color calculation, don't set LED unless left thumbstick is moved
|
|
9f51fad3
|
2020-11-13T18:01:29
|
|
Added support for the touchpad on PS4 and PS5 controllers
|
|
e749c126
|
2020-11-12T07:53:01
|
|
Fixed overflow in trigger rumble calculation
|
|
1e2caac5
|
2020-11-11T18:57:37
|
|
Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
|
|
009b62f1
|
2020-11-07T02:22:15
|
|
Be explicit about mapping the new game controller paddle buttons
|
|
5a92edee
|
2020-11-06T15:54:18
|
|
Don't try to map the accelerometer as a game controller
|
|
59a644fb
|
2020-11-06T14:44:26
|
|
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
|
|
3a3aaac2
|
2020-11-06T11:30:52
|
|
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
|
|
e555d453
|
2020-11-05T11:07:54
|
|
Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
|
|
aba27928
|
2020-04-18T21:41:37
|
|
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
|
|
3d942ccc
|
2020-04-08T09:02:02
|
|
Removed debug code
|
|
09f55263
|
2020-04-08T09:00:10
|
|
Fixed memory leak and removed debug code from Windows sensor implementation
|
|
2be75c6a
|
2020-03-13T19:08:45
|
|
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!
|
|
dd0ebfdf
|
2020-02-07T11:45:32
|
|
Use the triggers to test rumble for more fine grained vibration feedback
|
|
a8780c6a
|
2020-01-16T20:49:25
|
|
Updated copyright date for 2020
|
|
46e1377d
|
2019-12-20T20:12:03
|
|
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()
|
|
b5aff9d7
|
2019-11-22T13:12:12
|
|
Added SDL_GameControllerTypeForIndex() and SDL_GameControllerGetType() to return the type of controller attached.
|
|
32bb8b4b
|
2019-09-10T10:03:20
|
|
test: replace some exit()s with returns.
|
|
5e13087b
|
2019-01-04T22:01:14
|
|
Updated copyright for 2019
|
|
d2042e1e
|
2018-08-09T16:00:17
|
|
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
|
|
e3cc5b2c
|
2018-01-03T10:03:25
|
|
Updated copyright for 2018
|
|
45b774e3
|
2017-01-01T18:33:28
|
|
Updated copyright for 2017
|
|
c2b90f2d
|
2016-12-28T20:11:29
|
|
Fixed compiling of testgamecontroller program with C++.
|
|
6d7da088
|
2016-12-27T01:39:07
|
|
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
|
|
70aa2a57
|
2016-12-09T04:17:10
|
|
Only print out the controller mappings if we're not going to test a controller
|
|
dd5d85a4
|
2016-11-29T06:36:57
|
|
Added an API to iterate over game controller mappings
|
|
c406f649
|
2016-11-10T18:53:50
|
|
Added USB VID/PID information to the SDL test programs
|
|
c490b54e
|
2016-10-13T04:01:25
|
|
Fixed black screen on Steam Link
|
|
929b965c
|
2016-09-21T23:06:38
|
|
Fixed compiling of three test programs with C++.
|
|
6a9a8b68
|
2016-05-05T22:05:21
|
|
Fixed memory leak in game controller test program.
|
|
42065e78
|
2016-01-02T10:10:34
|
|
Updated copyright to 2016
|
|
11d98995
|
2015-11-25T21:39:28
|
|
Replaced tabs with spaces in test programs.
|
|
e6ad29ae
|
2015-11-14T12:35:45
|
|
Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
|
|
2bf6f1bc
|
2015-09-20T23:08:36
|
|
Added initial support for MFi game controllers on iOS.
|
|
0e45984f
|
2015-06-21T17:33:46
|
|
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().
|
|
2c4a6ea0
|
2015-05-26T06:27:46
|
|
Updated the copyright year to 2015
|
|
4f00dda9
|
2015-05-21T21:27:53
|
|
Removed redundant NULL check in test program.
|
|
2c4ad51d
|
2015-05-18T21:21:14
|
|
Added missing loop cancel for Emscripten in test programs.
|
|
b72938c8
|
2015-04-20T12:22:44
|
|
Windows: Always set the system timer resolution to 1ms by default.
An existing hint lets apps that don't need the timer resolution changed avoid
this, to save battery, etc, but this fixes several problems in timing, audio
callbacks not firing fast enough, etc.
Fixes Bugzilla #2944.
|
|
fe6c797c
|
2015-04-10T23:30:31
|
|
Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
|
|
d1932834
|
2015-02-12T21:40:53
|
|
Fixed test programs for joystick not exiting on events after first disconnect.
Exit was broken since the main loop extraction needed for Emscripten support
because the former local but now global variables were not reset correctly.
|
|
b88ca1b4
|
2015-02-10T16:28:56
|
|
the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here.
Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture.
More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
|
|
b48e54aa
|
2015-01-26T22:00:29
|
|
Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation
Jonas Kulla
The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c.
I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
|
|
97e87667
|
2014-12-25T21:42:56
|
|
Fixed compile errors in example programs.
|
|
fe40a172
|
2014-12-18T00:19:52
|
|
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!)
|
|
70438be2
|
2014-12-03T10:55:23
|
|
WinRT: fixed bug whereby SDL would override an app's default orientation
WinRT apps can set a default, preferred orientation via a .appxmanifest file.
SDL was overriding this on app startup, and making the app use all possible
orientations (landscape and portrait).
Thanks to Eric Wing for the heads up on this!
|
|
9c398852
|
2014-11-22T22:20:40
|
|
Corrected header file documentation comment.
|
|
24c86b55
|
2014-09-11T19:24:42
|
|
[X11] Reconcile logical keyboard state with physical state on FocusIn
since the window system doesn't do it for us like other platforms.
This prevents sticky keys and missed keys when going in and out
of focus, for example Alt would appear to stick if switching away
from an SDL app with Alt-Tab and had to be pressed again.
CR: Sam
|
|
a0cdcb0a
|
2014-08-20T22:44:15
|
|
Fixed warnings about unused functions in test program.
|
|
3dcb451f
|
2014-04-09T21:29:19
|
|
Added a README file regarding WinRT support
To note, this file is currently formatted with CRLF line endings, rather than
LF, to allow the file to be viewed with Notepad.
|
|
229b438d
|
2014-03-29T12:27:27
|
|
Fixed assertion loading button.bmp in testgamecontroller
|
|
2d92a372
|
2014-02-10T11:29:48
|
|
Make controllermap, etc, work on platforms with hardcoded window sizes.
This makes sure everything renders correctly, even if, say, an Android device
gives you a certain "window" size no matter what you ask for.
|
|
b17fd9a1
|
2014-02-10T01:41:58
|
|
Replace testgamecontroller visualization mode with something more useful.
|
|
58edac3e
|
2014-02-02T00:53:27
|
|
Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
|
|
112f60a4
|
2013-12-23T15:55:08
|
|
Changed testgamecontroller to wait for controllers to be reattached, the way testjoystick does.
|
|
95ec90aa
|
2013-12-02T19:35:04
|
|
Adds controllermap utility to test suite.
|
|
f848adff
|
2013-11-29T10:06:08
|
|
Improve Android pause/resume behavior.
|
|
540cb538
|
2013-08-28T00:07:02
|
|
Fixed testgamecontroller output to make sense.
|
|
65728477
|
2013-08-14T23:30:10
|
|
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
|
|
dad42067
|
2013-08-12T11:13:50
|
|
Fixes #2022, do not resume on Android when surfaceChanged
If the app is in landscape mode and the user presses the power button, a pause
is followed immediately by a surfaceChanged event because the lock screen
is shown in portrait mode. This triggers a "false" resume.
So, we just pause and resume following the onWindowFocusChanged events.
Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before
blocking the event pump.
|
|
1ad936eb
|
2013-08-11T19:56:43
|
|
Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow()
Rainer Deyke
I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.
|