|
d6910106
|
2023-09-24T17:17:49
|
|
Check for NULL before dereferencing newly allocated memory
Fixes https://github.com/libsdl-org/SDL/issues/8289
(cherry picked from commit 70a1bc69739016884a22abe6bf86f8a5deba29ef)
(cherry picked from commit 27f2df2292cceab64ff25f94efca5ec8bc5f1478)
|
|
739d3ec1
|
2023-08-10T15:05:29
|
|
Fix out of bound read of 'has_hat' array
(cherry picked from commit 94b3f78c440bfd52182848adf39db71325861e9c)
(cherry picked from commit f348370e1b3416f70e3fd1e5668a385b661b4a48)
|
|
a614d8f8
|
2023-07-08T18:18:22
|
|
Fixed mapping BTN_TR2 to right trigger
(cherry picked from commit ea60da5b94ed8ec69aad69ca46e81567ab99ed2a)
(cherry picked from commit 4b1dd54a56236a41e647f129c6018c78499975b3)
|
|
3f6c4ec6
|
2023-06-13T16:49:33
|
|
Cleanup for previous change, fixing typos, etc.
(cherry picked from commit 883b0f4071687f2e5c8329963f97504e9679394b)
|
|
fc72f12e
|
2023-06-13T16:40:30
|
|
Added automatic mapping support for Xbox controllers on the 6.x Linux kernels
This automatically adds support for the share button and paddles when present.
(cherry picked from commit db1d4d3d76f5e21b2547463710b513fe0ebd7fad)
|
|
681f67d3
|
2023-06-14T00:25:50
|
|
fixed build after commit d2372c853843def01b7adb9872cbb89b0d6079ec.
|
|
d2372c85
|
2023-06-13T10:06:36
|
|
Added automatic mapping for Xbox Elite paddles using the xpadneo driver
We can't actually tell yet whether a controller has paddles, so this code isn't effective, but I'll file an upstream issue and see if we can get that resolved.
(cherry picked from commit b0677f476fa43f4a113b04a959228fd38f95d740)
|
|
7db23f4e
|
2023-06-13T10:05:19
|
|
Fixed joystick vendor detection in Linux automatic gamepad mapping
(cherry picked from commit 071d1e29dd4f80605932f320aa2e05fda383944c)
|
|
36ff6327
|
2023-06-09T13:24:21
|
|
linux: Improve gamepad mapping heuristic to accept Android conventions
This heuristic for gamepads without a more specific mapping already
tried two incompatible conventions for handling triggers: the Linux
Gamepad Specification uses hat switch 2 for the triggers (for whatever
reason), but the de facto standard set by the drivers for older Xbox
and Playstation controllers represents each trigger as the Z-axis of
the nearest analog stick.
Android documentation encourages Bluetooth gamepad manufacturers to use
a third incompatible convention where the left and right triggers are
represented as the brake and gas pedals of a driving simulator
controller. The Android convention also changes the representation of
the right stick: instead of using X and Y rotation as a second pair
of axes, Android uses Z position as a second horizontal axis, and
Z rotation as a second vertical axis.
Try to cope gracefully with all of these. This will hopefully resolve
the issue described in #5406 (when using unpatched kernels).
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cf1dc66e2cfc7a65374c5fea681dd31c50363a2c)
|
|
26a38a0b
|
2023-06-09T13:06:30
|
|
linux: Reduce magic numbers when mapping gamepad axes
The bitfield `mapped` has two different sets of meanings, depending
whether we're setting up the triggers or the d-pad. Represent them
as symbolic constants rather than opaque integers.
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c4d49fadd4500cb522b2a98e5a42d024c566d8bf)
|
|
1402d135
|
2023-03-18T20:34:38
|
|
video/blit: fix -Wimplicit-fallthrough warnings
(cherry picked from commit f7961b7c9ad598b031cd033f19e93c6d882e8e41)
|
|
0d763800
|
2023-03-09T15:10:00
|
|
Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!)
(cherry picked from commit c6443d86c92e962683a1efe5f123a144988875b5)
|
|
0479df53
|
2023-01-09T09:48:21
|
|
Updated copyright for 2023
|
|
d59caffe
|
2022-12-13T14:03:40
|
|
Added support for clang thread-safety analysis
The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code.
Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change.
This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock.
To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
|
|
d0bbfdbf
|
2022-12-01T16:07:03
|
|
Clang-Tidy fixes (#6725)
(cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
|
|
b8d85c69
|
2022-11-30T12:51:59
|
|
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
(cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
|
|
fb0ce375
|
2022-11-27T17:38:43
|
|
Cleanup add brace (#6545)
* Add braces after if conditions
* More add braces after if conditions
* Add braces after while() conditions
* Fix compilation because of macro being modified
* Add braces to for loop
* Add braces after if/goto
* Move comments up
* Remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements after merge
* Fix inconsistent patterns are xxx == NULL vs !xxx
* More "{}" for "if() break;" and "if() continue;"
* More "{}" after if() short statement
* More "{}" after "if () return;" statement
* More fix inconsistent patterns are xxx == NULL vs !xxx
* Revert some modificaion on SDL_RLEaccel.c
* SDL_RLEaccel: no short statement
* Cleanup 'if' where the bracket is in a new line
* Cleanup 'while' where the bracket is in a new line
* Cleanup 'for' where the bracket is in a new line
* Cleanup 'else' where the bracket is in a new line
(cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
|
|
c70e6759
|
2022-11-03T12:37:54
|
|
Wait a bit for devices to initialize before trying to enumerate and open them.
This works around udev event nodes arriving before hidraw nodes and the controller being opened twice - once using the Linux driver and once by the HIDAPI driver.
This also fixes a kernel panic on Steam Link hardware due to trying to open the hidraw device node too early.
A delay of 10 ms seems to be a good value, tested on Steam Link hardware.
|
|
e8cb4da7
|
2022-08-26T12:28:33
|
|
Add utility function to detect if SDL is inside a sandbox
Refactor the previous sandbox check in a standalone function that also
includes Snap support.
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
|
|
bac8df4a
|
2022-08-28T17:55:49
|
|
Fixed memory leak when out of memory
|
|
ffbad361
|
2022-08-28T16:21:05
|
|
Use the correct type for the device_instance
|
|
277b033e
|
2022-08-22T19:28:21
|
|
Refactor joystick GUID creation
|
|
c1e08739
|
2022-08-22T16:46:55
|
|
Added the CRC of the joystick name to the GUID
This will make it possible to have mappings for different controllers
that have the same VID/PID. This happens frequently with some generic
controller boards that have been reused in many products.
Fixes https://github.com/libsdl-org/SDL/issues/6004
|
|
f7b774a7
|
2022-05-18T17:59:17
|
|
Fixed build error on Linux if HAVE_INOTIFY isn't defined
Fixes https://github.com/libsdl-org/SDL/issues/5682
|
|
db9e14e5
|
2022-01-31T13:55:37
|
|
disabled linux joystick debugging outputs and reverted unnecessary comment edit
|
|
f7a19f9e
|
2022-01-14T13:14:42
|
|
relaxed the digital hat deadzone slightly, and fixed typo in DEBUG_GAMEPAD_MAPPING define
|
|
3696e23d
|
2022-01-14T10:45:16
|
|
added hints SDL_HINT_LINUX_DIGITAL_HATS and SDL_HINT_LINUX_HAT_DEADZONES to control the new Linux hat handling; added define DEBUG_GAMEPAD_MAPPINGS to log messages when generating default gamepad mapings for Linux joysticks
|
|
0b8e796e
|
2022-01-12T22:00:46
|
|
added hueristic to differentiate digital vs analog 'hat' input axes and expose the latter as regular axes; added automatic deadzones to hat outputs, in case analog axes are still mapped to digital hats; updated automatic gamepad control mapping to more completely follow the spec
|
|
e551384a
|
2022-04-26T14:54:14
|
|
Added functions to get the platform dependent name for a joystick or game controller
|
|
57927a24
|
2022-04-18T12:57:28
|
|
Don't call scandir() inside of scandir()
This works around a crash in address sanitizer
|
|
99ae6395
|
2022-04-12T10:04:05
|
|
Initialise scandir argument
'scandir' does not initialise 'entries' on error
|
|
7ea1b69d
|
2022-04-05T21:00:07
|
|
Sort controllers by the js* index on Linux
Also fixed the initial scan to directly scan devices instead of using
udev so they can be sorted, as intended.
Fixes https://github.com/libsdl-org/SDL/issues/4688
|
|
eb660e86
|
2022-04-05T19:43:42
|
|
Cache the fact that a device didn't look like a joystick
Fixes https://github.com/libsdl-org/SDL/issues/5211
|
|
120c76c8
|
2022-01-03T09:40:00
|
|
Updated copyright for 2022
|
|
40d80862
|
2021-11-15T20:17:14
|
|
SDL_classic_joysticks defaults off
|
|
afccabb8
|
2021-11-11T12:12:05
|
|
joystick: Add capability flags for rumble and trigger rumble
When API limitations force us to guess, we favor a false positive (reporting
support when it doesn't exist) compared to a false negative.
|
|
1ccfbf96
|
2021-11-11T11:13:08
|
|
joystick: Convert HasLED() into a generic GetCapabilities() function
|
|
ebed961c
|
2021-11-11T09:51:39
|
|
Fixed build with older Linux kernel headers
|
|
828a0a4a
|
2021-11-11T07:13:29
|
|
Fixed mapping for PS4 controller when using the classic Joystick
interface on Linux
|
|
dc9de1e2
|
2021-11-11T07:03:30
|
|
Get the correct USB VID/PID information for /dev/input/js* devices
|
|
bd92a95f
|
2021-11-11T06:30:36
|
|
Cleanup for the /dev/js* support (thanks @meyraud705)
|
|
1c78b080
|
2021-11-10T20:02:25
|
|
Added support for /dev/input/js* on Linux
Added the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to control whether /dev/input/js* or /dev/input/event* are used as joystick devices
Added the hint SDL_HINT_JOYSTICK_DEVICE to allow the user to specify devices t
hat will be opened in addition to the normal joystick detection
Fixes https://github.com/libsdl-org/SDL/issues/1314
Fixes https://github.com/libsdl-org/SDL/issues/1727
Fixes https://github.com/libsdl-org/SDL/issues/1981
Closes https://github.com/libsdl-org/SDL/pull/4727
|
|
65a50b24
|
2021-11-10T16:15:22
|
|
Re-enable udev joystick enumeration by default
|
|
b8c00bf9
|
2021-11-07T13:11:29
|
|
Allow opening joysticks that are read-only on Linux
Fixes https://github.com/libsdl-org/SDL/issues/4713
|
|
345c161f
|
2021-09-22T09:06:45
|
|
Fixed some accidental uses of external C runtime functions
|
|
bf97c5a2
|
2021-09-08T14:47:40
|
|
Make sure SDL file descriptors don't leak into child processes
|
|
130b6beb
|
2021-08-24T17:01:34
|
|
Manually scan for Linux joysticks before udev scan runs
This allows us to have joysticks sorted by insert time at startup, fixing https://github.com/libsdl-org/SDL/issues/4688
|
|
cbccf5bb
|
2021-08-24T17:01:06
|
|
Use SDL_GetHint() instead of SDL_getenv() for Linux joystick hints
|
|
e9179314
|
2021-08-11T21:27:42
|
|
joystick/linux: fix memleaks; streamline joylist item removal
|
|
ba8bc143
|
2021-07-26T12:09:33
|
|
Sort joystick entries in /dev/input
This fixes https://github.com/libsdl-org/SDL/issues/4430
|
|
cc19b13b
|
2021-07-24T19:21:29
|
|
Fixed missing return statement
|
|
5ae0dd4b
|
2021-07-24T17:44:35
|
|
joystick: Split out Linux opening code for reuse by querying code.
This prevents an assertion whem LINUX_JoystickGetGamepadMapping tried to
open the stick temporarily and messed with global state by doing so. Now
the global state is only set in LINUX_JoystickOpen, but the common code
is shared by both interfaces.
Fixes #4198.
|
|
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
|
|
de4ba6eb
|
2021-05-27T12:41:41
|
|
Ignore the device version for Atari vcs controllers
At least on bluetooth the guid user the version reported by the
bluetooth device. Which for Atari vcs controllers is the firmware
version. However the mapping will stay the same regardless of firmware
version, so ignore the version entirely to avoid needing a new mapping
entry for each firmware version.
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
|
|
499d31e9
|
2021-04-13T17:00:24
|
|
Cleanup Linux joystick code
|
|
b04136e7
|
2021-04-13T16:29:48
|
|
Fixed Xbox controller when using the default Linux gamepad mapping
Tested with the Xbox Series X controller and the xow driver
|
|
1542300a
|
2021-03-24T22:37:08
|
|
joystick: linux: Avoid checking for gamepad mapping each frame
The information whether a specific joystick can be used as a gamepad is
not going to change every frame, so we can cache the result into a
variable.
This dramatically reduces the performance impact of SDL2 on small
embedded devices, since the code path that is now avoided was quite
heavy.
Fixes #4229.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
|
|
8d43f45a
|
2021-02-16T14:13:30
|
|
Don't use udev for joystick enumeration if running in a container
If we are running in a container, like Flatpak[1] or pressure-vessel[2],
it's likely that we are using user namespaces,
therefore udev event notification via netlink won't work reliably.
Use their filesystem API to detect them and automatically fallback to
the inotify-based enumeration.
[1] <https://flatpak.org/>
[2]
<https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
|
|
9130f7c3
|
2021-01-02T10:25:38
|
|
Updated copyright for 2021
|
|
8795ca70
|
2020-12-14T09:15:47
|
|
Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085
I added some printf to verify the math being done. Of the three joysticks I have, it works correctly for at least two, and seems to work correctly for the third. I say "seems to" because, for the third joystick, the values never go through the AxisCorrect function, and thus never hit my printf statements, even though they did in the version I wrote my patch against. I'm not sure what's going on there, but it at least seems to be working correctly in as much as I can tell.
I note this result in particular, for an SNES Gamepad (min=0, max=255):
Joystick value 0 becomes -32768
Joystick value 127 becomes 0
Joystick value 255 becomes 32767
Without the code that forces a zero point, the 127 input value would become -129, so I think you see why I added that code to turn it into zero. However, I think Kai Krakow has a point about how SDL shouldn't assume that there should be a center.
Obviously in the majority of cases there actually should be a center, and the code that turns that 127 into an actual 0 is creating only a 0.2% error over 0.4% of this joystick's range. However, what if there is an axis that is some kind of special control, like a 4-position switch, and, for whatever reason, the joystick reports it as an axis with 4 possible values, 0 to 3? In that case, mutilating the two center values to the same value is much more of an error and and turns that 4-position switch into a 3-position switch. If any joystick does this with a 2-position switch, then this code would render that control entirely useless as it would report the same value with the switch in either position. Obviously the code could require that there be at least N possible values, to guess whether something is a proper axis or just some kind of switch, but the choice of N would be arbitrary and that's ugly.
I guess the real problem here is that my gamepad is just kind of broken. It should be reporting a range of -1 to +1 since that's what it actually does. Also, as Kai Krakow points out, it's probably not SDL's place to fix broken hardware. I'll add that, if SDL does fix broken hardware, it should probably actually know that it's broken rather than be merely guessing that it is.
So, to the extent that SDL is able to do stuff like this, perhaps it's something better left for the user to configure in some kind of config file.
|
|
b6e63625
|
2020-12-13T15:32:24
|
|
fix bug #5395: handle old systems where inotify_init1 is not available
|
|
db0a2025
|
2020-12-12T23:48:02
|
|
Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085
It occurred to me that my simple patch that comments out a few lines of code does not correctly remove the dead zone since the calculation presumably assumes the dead zone has been cut out of the range. Then, while looking into how to make it output the correct range of values, I realized SDL wasn't returning the correct range of values to begin with.
This line of code was already present:
printf("Values = { %d, %d, %d, %d, %d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat);
For my joystick this yeilds:
Values = { 0, -127, 127, 0, 15 }
Then this code calculates the coefficients:
In SDL1:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
if ( t != 0 ) {
joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
} else {
joystick->hwdata->abs_correct[i].coef[2] = 0;
}
In SDL2:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) + 2 * absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) - 4 * absinfo.flat);
if (t != 0) {
joystick->hwdata->abs_correct[i].coef[2] = (1 << 28) / t;
} else {
joystick->hwdata->abs_correct[i].coef[2] = 0;
}
Neither calculates the correct coefficients for the code in the AxisCorrect function.
In SDL1:
if ( value > correct->coef[0] ) {
if ( value < correct->coef[1] ) {
return 0;
}
value -= correct->coef[1];
} else {
value -= correct->coef[0];
}
value *= correct->coef[2];
value >>= 14;
In SDL2:
value *= 2;
if (value > correct->coef[0]) {
if (value < correct->coef[1]) {
return 0;
}
value -= correct->coef[1];
} else {
value -= correct->coef[0];
}
In SDL1, the calculated coefficients are coef[0]=15, coef[1]=-15 and coef[2]=5534751. So with a full-scale input of 127, it calculates an output value of 37835, which is considerably out of range.
In SDL2, the calculated coefficients are coef[0]=30, coef[1]=-30, and coef[2]=1383687. So with a full-scale input of 127, it calculates the same output value of 37835.
I tested it with the 3 joysticks I have, and it produces out-of-range values for all of them.
Anyway, since dead zones are garbage, I just deleted all of that junk and wrote some code that takes the absinfo.minimum and absinfo.maximum values and uses them to scale the axis range to -32767 through +32767.
I also made it detect when a range doesn't have an integer center point, e.g. the center of -128 to + 127 is -0.5. In such cases, if either value to the side of the center is provided, it zeros it, but it otherwise doesn't implement any kind of dead zone. This seemed important with my gamepad which provides only the values of 0, 127, and 255, since without this hack it would never be centered.
Also, the previous minimum output value was -32768, but as that creates an output range that has no true center, I changed the minimum value to -32767.
I tested it with the 3 joystick devices I have and it seems to create correct values for all of them.
|
|
0ccb3afd
|
2020-12-12T22:33:11
|
|
Fixed polling values after SYN_DROPPED event
|
|
13a4caf1
|
2020-12-12T22:08:02
|
|
Fixed bug 4286 - Joystick subsystem causes "not responding" when app is in the background
Added a hint to control whether a separate thread should be used for joystick events.
This is off by default because dispatching messages in other threads appears to cause problems on some versions of Windows.
|
|
cb361896
|
2020-12-09T07:16:22
|
|
Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon
We should really stick this in SDL_internal.h or something so it's always available.
|
|
59f28b7f
|
2020-12-03T18:17:01
|
|
Fixed whitespace
|
|
c8c818d7
|
2020-11-23T21:14:37
|
|
Fixed bug 5360 - non-libudev joystick detection doesn't see controllers that were already connected
Simon McVittie
When watching for hotplug events we can poll the inotify fd, but we
still need to scan /dev/input once per process, otherwise we'll fail
to detect devices that were already connected.
|
|
8e2746cf
|
2020-11-23T21:10:48
|
|
joystick: Don't use udev in Flatpak or pressure-vessel container
Flatpak[1] and pressure-vessel[2] are known to use user namespaces,
therefore udev event notification via netlink won't work reliably.
Both frameworks provide a filesystem API that libraries can use to
detect them. Do that, and automatically fall back from udev-based
device discovery to the inotify-based fallback introduced in Bug #5337.
[1] <https://flatpak.org/>
[2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
e9869e07
|
2020-11-23T21:08:19
|
|
Fixed bug 5335 - enable joystick/haptic/evdev support by default on FreeBSD
Alex S
Evdev headers aren't actually included in the base system (well, it has a private copy), they are available through the devel/evdev-proto port instead. We also have devel/libinotify and devel/libudev-devd shims, I didn't verify whether they work with SDL.
|
|
eaa53a19
|
2020-11-23T22:16:07
|
|
joystick: On Linux, don't try to close an invalid inotify file descriptor.
|
|
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
|
|
c122e9b9
|
2020-11-12T14:11:50
|
|
linux/SDL_sysjoystick.c (MaybeRemoveDevice): remove SDL_USE_LIBUDEV guards
fixes bug #5349.
|
|
b0eba1c5
|
2020-11-11T19:15:32
|
|
joystick: Use inotify to detect joystick unplug if not using udev
This improves SDL's ability to detect joystick hotplug in a container
environment.
We cannot reliably receive events from udev in a container, because they
are delivered as netlink events, which are authenticated by their uid
being 0. However, in a user namespace created by an unprivileged user
(for example bubblewrap, as used by Flatpak and Steam's
pressure-vessel-wrap), the kernel does not allow us to map uid 0, and
the netlink events appear to be from the kernel's overflowuid (typically
65534/nobody), meaning libudev cannot distinguish between genuine uevents
from udevd and an attack by a malicious local user.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
fdd945f2
|
2020-11-11T19:14:52
|
|
joystick: Use a better heuristic to guess what is a joystick
Previously we only checked for at least one button or key and at least
the X and Y absolute axes, but this has both false positives and false
negatives.
Graphics tablets, trackpads and touchscreens all have buttons and
absolute X and Y axes, but we don't want to detect those as joysticks.
On normal Linux systems ordinary users do not have access to these
device nodes, but members of the 'input' group do.
Conversely, some game controllers only have digital buttons and no
analogue axes (the Nintendo Wiimote is an example), and some have axes
and no buttons (steering wheels or flight simulator rudders might not
have buttons).
Use the more elaborate heuristic factored out from SDL's udev code path
to handle these cases.
In an ideal world we could use exactly the same heuristic as udev's
input_id builtin, but that isn't under a suitable license for inclusion
in SDL, so we have to use a parallel implementation of something
vaguely similar.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
8db3171b
|
2020-11-11T19:14:34
|
|
udev: Factor out SDL_EVDEV_GuessDeviceClass
This works on capability bitfields that can either come from udev or
from ioctls, so it is equally applicable to both udev and non-udev
input device detection.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
13e7d1a9
|
2020-11-11T19:14:11
|
|
joystick: Allow libudev to be disabled at runtime
Device enumeration via libudev can fail in a container for two reasons:
* the netlink protocol between udevd and libudev is considered private,
so there is no API guarantee that the version of libudev in a container
will understand netlink messages from a dissimilar version of udevd
on the host system;
* the netlink protocol between udevd and libudev relies for security on
being able to check the uid of each message, but in a container with
a user namespace where host uid 0 is not mapped, the libudev client
cannot distinguish between messages from host uid 0 and messages from
a different, malicious user on the host
To make this easier to experiment with, always compile the fallback
code path even if libudev is disabled. libudev remains the default if
enabled at compile time, but the fallback code path can be forced.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|
1e2caac5
|
2020-11-11T18:57:37
|
|
Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
|
|
e555d453
|
2020-11-05T11:07:54
|
|
Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
|
|
c3ecf18c
|
2020-07-21T23:38:42
|
|
Linux: Add hint for disabling deadzones
|
|
0e98040d
|
2020-06-28T16:23:05
|
|
joystick: Linux joysticks now recover better from dropped events.
Fixes Bugzilla #4830.
|
|
9fa8d6d0
|
2020-06-08T17:07:55
|
|
Define constants not available on older kernels
|
|
ae9ff11b
|
2020-05-29T14:54:07
|
|
The zero happens at a higher level now
|
|
345b4d7e
|
2020-05-29T13:37:21
|
|
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.
|
|
83cddd2e
|
2020-04-30T11:57:29
|
|
Add SDL_JoystickSetLED.
Currently, this is only supported by the PS4 HIDAPI driver.
|
|
885b3f69
|
2020-03-23T14:10:25
|
|
Don't check the HIDAPI driver for the virtual device created by xow
|
|
c44473ba
|
2020-03-12T19:47:30
|
|
Unified code to standardize joystick names
|
|
6efebf17
|
2020-02-04T12:48:53
|
|
Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests.
|
|
976eee77
|
2020-02-04T07:23:44
|
|
Correct joystick hat indexes on linux
The index and indices were swapped; Which is fine as long as there are
no gaps in the ABS_HAT* event availability but otherwise things do get confused.
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
|
|
2ae41b9c
|
2020-01-23T12:53:43
|
|
Fixed mapping for both versions of the Xbox One Elite Series 2 controller firmware connecting over Bluetooth
|
|
6dc172d0
|
2020-01-23T12:53:39
|
|
Turn off rumble on drivers which don't respect the replay.length value
|
|
a8780c6a
|
2020-01-16T20:49:25
|
|
Updated copyright date for 2020
|
|
c14a59d9
|
2020-01-11T13:38:50
|
|
Worked around an issue where the kernel would lose the force feedback effect
|
|
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()
|
|
0f529160
|
2019-12-11T17:47:01
|
|
Added custom names for some controllers
|
|
2a161e7a
|
2019-12-10T11:30:56
|
|
Remove any duplicate manufacturer in the joystick name
|
|
55eb7621
|
2019-11-20T20:27:45
|
|
Use stat() to minimize input device opens when not using udev
Calling open() on input devices can generate device I/O which blocks
the main thread and causes dropped frames. Using stat() we can avoid
opening anything unless /dev/input has changed since we last polled.
We could have used something fancy like inotify, but it didn't seem
worth the added complexity for this uncommon non-udev case.
|
|
9da4bfc1
|
2019-10-22T10:57:07
|
|
Added support for the Power A Nintendo Switch Enhanced Wireless Controller
|
|
c10a8742
|
2019-07-31T10:20:37
|
|
Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePresent()
|
|
c172f36b
|
2019-07-31T11:14:48
|
|
joystick: Ensure HIDAPI is initialized before calling it
|
|
a4bfe2a4
|
2019-06-24T21:08:26
|
|
Allow hotplugging joysticks without udev
|