Commit Graph

3506 Commits

Author SHA1 Message Date
Sam Lantinga
6cb7f9e39a Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for Nintendo Switch Pro controllers using the HIDAPI driver 2020-11-19 19:09:40 -08:00
Sam Lantinga
9980766533 Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for the Nintendo Switch Pro controller on Linux 2020-11-19 19:09:38 -08:00
Sam Lantinga
7366693f3b Added support for a few more controllers on Linux 2020-11-19 19:09:36 -08:00
Sam Lantinga
ffb4d960b2 Disabled Xbox protocol debugging 2020-11-19 19:09:34 -08:00
Sam Lantinga
c9b097e659 Clarify the meaning of the rumble enable bits for the PS5 controller 2020-11-19 13:31:16 -08:00
Sam Lantinga
c85623d790 Re-enable haptic audio after rumble on PS5 controller
Also make sure we don't set any other state when we're not intending to, and added more interesting effects which are currently not exposed via API
2020-11-19 13:10:14 -08:00
Sam Lantinga
b0b76a61c7 Fixed rumble on PS5 controllers connected to Windows over Bluetooth 2020-11-19 07:12:53 -08:00
Sam Lantinga
8c3196da60 Fixed some compiler warnings 2020-11-18 21:33:11 -08:00
Sam Lantinga
45f1437549 Experimenting with requesting the serial number on an Xbox One controller 2020-11-18 20:34:12 -08:00
Sam Lantinga
963d8b3f40 Fixed bits in the initial Xbox One protocol ack 2020-11-18 20:34:10 -08:00
Sam Lantinga
cd51a51f00 Updated with a better understanding of the Xbox One controller protocol 2020-11-18 20:34:08 -08:00
Ryan C. Gordon
335cfa107b x11: Don't crash if a messagebox has a NULL title string.
Fixes Bugzilla #5253.
2020-11-18 11:24:08 -05:00
Sam Lantinga
51ea6a6d44 Don't send controller gyro and accelerometer updates if the values haven't changed.
This keeps SDL_PollEvent() from returning data continuously when polling controller state.
2020-11-17 22:09:52 -08:00
Sam Lantinga
463d84a860 Added support for the PS5 controller gyro and accelerometer 2020-11-17 10:56:56 -08:00
Sam Lantinga
fcb21aa883 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
2020-11-17 10:30:20 -08:00
Sam Lantinga
d140d88744 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial() 2020-11-16 17:36:47 -08:00
Ryan C. Gordon
55e59a4f33 crc32: Fixed include path. 2020-11-16 18:48:13 -05:00
Sam Lantinga
7bbea0bb94 Fixed build warning 2020-11-16 15:10:02 -08:00
Sam Lantinga
71e32f5e1b Added SDL_crc32() 2020-11-16 15:00:15 -08:00
Sam Lantinga
3d48fc05c3 Added notes about the pad lights on the PS5 controller 2020-11-16 13:21:02 -08:00
Sam Lantinga
4514ad573e Fixed updating LED state when starting application with Bluetooth PS5 controller connected 2020-11-16 13:07:11 -08:00
Sam Lantinga
a37e3ae218 Implemented PS5 effects over Bluetooth 2020-11-16 11:21:58 -08:00
Sam Lantinga
c6c116e847 Implemented setting the LED color on the PS5 controller 2020-11-16 10:51:13 -08:00
Sam Lantinga
aa7c3eae19 Fixed size of rumble packet 2020-11-16 09:16:01 -08:00
Sam Lantinga
f28c01a4fb Fixed rumble order on PS5 2020-11-16 09:11:15 -08:00
Sam Lantinga
eb94c19a63 SDL: fix iOS build 2020-11-16 08:09:15 -08:00
Sam Lantinga
8243bd1dc6 SDL: Plumb PS5 rumble to output report 2020-11-16 08:09:13 -08:00
Ozkan Sezer
c0f7325b85 SDL_PrivateJoystickForceRecentering: fix wrong loop counter usage.
The typo seems to have been added by commit c7782fd6142b
2020-11-15 17:10:15 +03:00
Sam Lantinga
5c34c973e6 Clarify that we're using button indices, not using gamepad button names 2020-11-13 19:40:25 -08:00
Sam Lantinga
9f51fad361 Added support for the touchpad on PS4 and PS5 controllers 2020-11-13 18:01:29 -08:00
Sam Lantinga
78422fa3c8 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth 2020-11-13 13:17:07 -08:00
Sam Lantinga
30371f2d4d Fixed doubled report ID for Bluetooth Classic devices on Linux 2020-11-13 13:17:04 -08:00
Sam Lantinga
8cd4f364db Mapped the touchpad click as SDL_CONTROLLER_BUTTON_MISC1 on the PS5 controller 2020-11-12 20:02:31 -08:00
Sam Lantinga
8e312a6a59 Fixed detecting Bluetooth XInput controllers on Windows 2020-11-12 15:56:33 -08:00
Sam Lantinga
8b29aaddbd Fixed warning when building on Windows 2020-11-12 14:34:11 -08:00
Sam Lantinga
e0018d0869 Fixed Windows build 2020-11-12 14:23:56 -08:00
Sam Lantinga
0500c04468 Fix SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL also applying to HIGH priorities
As the name suggests, the hint should only apply to SDL_THREAD_PRIORITY_TIME_CRITICAL

The resulting priorities for my current distro result in these values:

     | High         | Time Critical
Hint |--------------|-----------------
 0   |  P=10 N=-10  | P=5   N=-15
 1   |  P=10 N=-10  | P=-21 N=0
2020-11-12 07:53:05 -08:00
Sam Lantinga
5b0d432942 Implemented trigger rumble in the HIDAPI Xbox One driver 2020-11-12 07:53:03 -08:00
Ozkan Sezer
c122e9b9ce linux/SDL_sysjoystick.c (MaybeRemoveDevice): remove SDL_USE_LIBUDEV guards
fixes bug #5349.
2020-11-12 14:11:50 +03:00
Sam Lantinga
83b653d55d Fixed build warning 2020-11-11 20:09:56 -08:00
Sam Lantinga
76bd6cd2d9 Fixed bug 5326 - Logitech Extreme 3D joystick is listed as gamepad in linux section of SDL_gamecontrollerdb.h
Spooky

For some reason the Logitech Extreme 3D joystick was added to SDL_gamecontrollerdb.h  in the linux section only.

This breaks the joystick in linux as it is not a gamepad.  I am unable to correctly use or map the Logitech Exteme 3D joystick in games that use SDL2 in linux.

Please remove Logitech Extreme 3D from SDL_gamecontrollerdb.h  Linux section.  It is a joystick not a gamepad.
2020-11-11 19:45:56 -08:00
Sam Lantinga
3160c7d66f Fixed bug 5327 - When direct input fails to load, but a controlller is plugged in through another api, an access violation happens.
Bart van der Werf

When directinput fails to load, but a controlller is plugged in, an access violation happens.
This is due to IEventHandler_CRawGameControllerVtbl_InvokeAdded calling SDL_DINPUT_JoystickPresent which does not check if dinput is assigned signalling initialization of directinput.
2020-11-11 19:43:02 -08:00
Sam Lantinga
502cfe314a Fixed bug 5332 - WGI: Fix wrong level of indirection and implicit truncating cast.
Joel Linn

This fixes two types of MSVC compiler warnings.

- One parameter in the function signatures of two WGI event handlers had one level of indirection too much (and did not match Windows SDK headers). The indirection was cast away so it still worked.
- size_t was implicitly cast to UINT32 for a number of (constant) string lengths.
2020-11-11 19:39:46 -08:00
Sam Lantinga
1822f97e5f Fixed bug 5346 - Add FreeBSD evdev KBIO keyboard input driver
wahil1976

This patch adds the KBIO text input driver for FreeBSD, which allows text input to fully work without text spilling out into the console. It also supports accented input, AltGr keys and Alt Lock combinations.

Tested with US accent keys layout and various AltGr layouts.
2020-11-11 19:37:47 -08:00
Sam Lantinga
320a7587d7 Fixed compiler warnings 2020-11-11 19:26:59 -08:00
Simon McVittie
b0eba1c55d 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>
2020-11-11 19:15:32 -08:00
Simon McVittie
aae53d5972 evdev: Detect whether input devices are accelerometers
Anything with X, Y and Z axes but no buttons is probably an
accelerometer (this is the assumption made in udev).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:15:09 -08:00
Simon McVittie
fdd945f2af 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>
2020-11-11 19:14:52 -08:00
Simon McVittie
8db3171b98 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>
2020-11-11 19:14:34 -08:00
Simon McVittie
13e7d1a958 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>
2020-11-11 19:14:11 -08:00