Commit Graph

12725 Commits

Author SHA1 Message Date
Sam Lantinga 808d83dd67 Allow specifying APP_PLATFORM and APP_ABI on the command line 2023-06-21 13:49:09 -07:00
Sam Lantinga 214d5daa3c Removed 100 ms hitch when querying third party Nintendo Switch controllers that don't respond to request for info
Also take advantage of the fact that we know whether the device is connected over Bluetooth now.
2023-06-21 12:14:50 -07:00
Sam Lantinga 3694dabe7c Use default sensor calibration if we can't read it from the Nintendo Switch controller
Fixes https://github.com/libsdl-org/SDL/issues/7830
2023-06-21 10:28:45 -07:00
Sam Lantinga 6306ee9f42 List the available haptic devices in testhaptic 2023-06-20 09:33:59 -07:00
Sam Lantinga 8cf5dc9963 Build on Android targeting the arm64-v8a architecture by default
This speeds up iteration time and covers most customer devices
2023-06-20 09:18:19 -07:00
Sam Lantinga 5f3213eb0e Added support for gamepad sensor fusion with the Razer Kishi 2023-06-20 08:41:15 -07:00
Simon McVittie 91198baed4 ibus: Handle error when getting the D-Bus machine ID
It is possible for retrieving the machine ID to fail, either because
dbus was installed incorrectly (machine ID absent or corrupt), or in
32-bit builds, because stat() on the machine ID fails with EOVERFLOW
if it has an out-of-range timestamp or inode number.

dbus has historically treated this as a faulty installation, raising
a warning which by default causes the process to crash. Unfortunately,
dbus_get_local_machine_id() never had a way to report errors, so it has
no alternative for that (bad) error handling.

In dbus >= 1.12.0, we can use dbus_try_get_local_machine_id() to get
the same information, but with the ability to cope gracefully with
errors. ibus won't work in this situation, but that's better than
crashing.

Mitigates: https://github.com/ValveSoftware/steam-for-linux/issues/9605
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-20 06:46:33 -07:00
Sam Lantinga 3ddbeab88f Moved Android sensor event handling to a separate thread
This makes it so you can interact with sensors on multiple threads, as long as only one thread initializes and cleans up the sensor subsystem.

This also has the benefit that sensor data is available as soon as possible.
2023-06-20 01:17:44 -07:00
Sam Lantinga 329e1b8b6a Update the sensors before the joysticks so the gamepad code gets fresh sensor readings 2023-06-19 19:42:01 -07:00
Sam Lantinga 1a9c04e9f1 Don't try to update the gamepad fusion sensors manually, instead rely on the normal update flow 2023-06-19 19:41:20 -07:00
Sam Lantinga 20ea35138f Use a separate sensor watching function for gamepad events to avoid reliance on system sensor events and prevent a potential deadlock 2023-06-19 16:17:34 -07:00
Sam Lantinga 70e43c150e Added support for blitting SDL_PIXELFORMAT_INDEX1LSB
Fixes https://github.com/libsdl-org/SDL/issues/7844

(cherry picked from commit a3d4fd71c3)
2023-06-19 08:38:07 -07:00
Sam Lantinga c6ee9780df Fixed DualSense controllers not being picked up by the HIDAPI driver
The hidraw device may take additional time to get the correct permissions for us to open it. In my tests on Steam Deck hardware, this ranges between 5-8ms.
2023-06-18 12:19:54 -07:00
Sam Lantinga 4e81b4e8de Added SDL_HINT_VIDEO_X11_SCALING_FACTOR to allow overriding the content scale on X11 (thanks Andres!) 2023-06-18 12:19:43 -07:00
Sam Lantinga 210c135f74 Implement SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED for X11
To match the focus stealing prevention logic from windows/osx.

I didn't implement SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN as there is no
standard mechanism for us to do so. In most cases marking a window as OverrideRedirect
will cause to not acquire focus when mapped. And in steam we are doing that when
appropriate.

I still left a note in X11_ShowWindow() regarding this behaviour.
2023-06-18 12:19:38 -07:00
Sam Lantinga 9351bf6dd1 Add handling for SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED and SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN on macOS
- Cocoa_ShowWindow will order a window that is not being activated below the key window (if one exists) then set visible

- Cocoa_RaiseWindow calls -[NSWindow orderFront:] without changing the key window
2023-06-18 12:19:22 -07:00
Sam Lantinga f168f9c813 Added support for the GameSir G4 Pro
We can't read device info or IMU calibration from this controller, and it has no gyro or accelerometer, but is otherwise perfectly functional.
2023-06-17 12:42:55 -07:00
Sam Lantinga b770644411 Fixed building on older kernel headers 2023-06-17 09:46:46 -07:00
Sam Lantinga b98494a101 Fixed building on older kernel headers 2023-06-17 09:39:50 -07:00
Sam Lantinga 9fe384b696 Fixed display orientation function names for SDL 3.0 convention 2023-06-17 09:28:27 -07:00
Sam Lantinga d91e96e7f5 Use SDL_HINT_GAMECONTROLLER_SENSOR_FUSION as a list of controllers to enable sensor fusion
There are too many wraparound style controllers out there to enumerate them all, so instead make this a user option in applications that support it.
2023-06-17 08:59:52 -07:00
Sam Lantinga 610c31c7b7 Generalized the sensor coordinate transform for wraparound gamepads 2023-06-17 08:28:37 -07:00
Sam Lantinga 9eb5eab0ad Use the correct orientation transformation based on whether the device is naturally landscape or portrait 2023-06-17 08:04:34 -07:00
Sam Lantinga e6d1ba2a17 Added the concept of display natural orientation
Also renamed SDL_GetDisplayOrientation() SDL_GetDisplayCurrentOrientation()

The natural orientation of the primary display is the frame of reference for accelerometer and gyro sensor readings.
2023-06-17 07:42:16 -07:00
Sam Lantinga 8de6ce7e92 Rotate the sensor axes to match gamepad orientation when using the device sensors for game controllers 2023-06-16 17:48:34 -07:00
Sam Lantinga a9c86e518a Added the Razer Edge controller to the list of wraparound controllers 2023-06-16 17:48:18 -07:00
Sam Lantinga c207cd3f56 Added the Razer Junglecat to the wraparound controller list 2023-06-16 16:04:12 -07:00
Ozkan Sezer e4f53e6b21 testevdev.c: comment out two unused data to fix build. 2023-06-17 01:01:10 +03:00
Sam Lantinga 42e4639a5e For gamepads that don't have their own sensors, try to use the system sensors.
This allows using the gyro and accelerometer in handheld devices in conjunction with built-in or wraparound controllers.
2023-06-16 14:44:59 -07:00
Simon McVittie d584592822 linux: If the kernel specifically tells us the device type, trust it
If a device is positively identified as an accelerometer, pointing stick
or clickpad, then we don't need to second-guess it.

In practice this does not change the result for any device in our
test data, so add some artificial records that exercise this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 08:54:41 -07:00
Simon McVittie 0d5aa70e62 linux: Pass evdev properties when guessing device type
In newer kernels, devices that can be positively identified as a
particular device type (for example accelerometers) get a property
bit set. Plumb this information through into the function, but don't
use it for anything just yet.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 08:54:41 -07:00
Simon McVittie a4ce721d7a testevdev: Allow device properties to be fully populated
The props array was too small for the highest property bits to be set,
although in practice this didn't matter since only the lower-order bits
have a meaning. Make it consistent with all the others.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 08:54:41 -07:00
Simon McVittie fa0ca3d41e linux: Distinguish between "device with keys" and a full keyboard
udev distinguishes between ID_INPUT_KEY, a device with any keyboard keys
at all (including for example USB numeric keypads, Bluetooth headsets
with volume control buttons, and some game controllers; and
ID_INPUT_KEYBOARD, a reasonably fully-featured keyboard that you could
use for general-purpose text entry. If we do the same here, then it's
useful input to our heuristics for identifying devices: for example,
a device with ID_INPUT_KEY could reasonably be a gamepad, but a device
with ID_INPUT_KEYBOARD certainly isn't.

Resolves: https://github.com/libsdl-org/SDL/issues/7827
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 08:49:31 -07:00
Simon McVittie 9b7a9ca666 testevdev: Add some more laptop built-in devices
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 07:27:48 -07:00
Simon McVittie 00b6db68de testevdev: Add some EVIOCGNAME and USB name strings to test data
We don't currently use these for anything, but we might start using
them as input to our heuristics as part of #7697.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 07:27:48 -07:00
Simon McVittie 3772d6cc99 testevdev: Add raw HID report descriptors where available
We don't currently use these in our device-classification heuristic,
but it could be a useful input in future.

Thanks to Sam Lantinga, Ben Fradella, kevenwyld and schlegp for
providing some of these.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 07:27:48 -07:00
Simon McVittie 2b7556fea2 testevdev: Correct typo in bus type for Xbox Series S|X via Bluetooth
All Bluetooth devices are bus type 0x0005.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 07:27:48 -07:00
Simon McVittie c13e511844 testevdev: Try to correct Wii devices guessed from kernel source
The comments here disagreed with the actual bytes. According to
https://elixir.bootlin.com/linux/v6.3.7/source/drivers/hid/hid-wiimote-modules.c,
the Balance Board reports BTN_A and ABS_HAT0X, HAT0Y, HAT1X and HAT1Y.
This means the comments here were correct, but the .abs bits shown
were in the wrong byte.

Matching the Wii U Pro Controller against the same kernel source, it
appears to be correct: it's the same representation as a PS3 gamepad,
except that it lacks the Z and RZ axes for analogue triggers.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 06:38:12 -07:00
Simon McVittie ffdafcd880 testevdev: Verify most Wii devices against real hardware
Some of the test data previously seen here was guessed from kernel
source code, and not all of it was correct. The following devices have
now been verified against `evemu-describe` output with Linux 6.3
(thanks to Jeremy Whiting for collecting this):

- basic Wiimote
    - buttons
    - 3-axis accelerometer
    - infra-red sensor for Sensor Bar location (precise aim)
- Motion Plus accessory (3-axis gyroscope)
- Nunchuck accessory (joystick, 2 buttons, second 3-axis accelerometer)
- Classic Controller accessory (a complete traditional gamepad)

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-16 06:38:12 -07:00
SDL Wiki Bot 739f78302b Sync SDL3 wiki -> header 2023-06-16 12:22:18 +00:00
Anonymous Maarten 26df689935 docs: expand CMake documentation + add minimal CMake project for reporting issues 2023-06-16 14:21:38 +02:00
Sylvain 378e33bb2c Android: potential ANR during onKeyDown/Up
SDLActivity may call onNativeKeyDown, while application is quitting
2023-06-16 10:17:01 +02:00
Sam Lantinga e72935a445 Check for modff in addition to modf 2023-06-15 16:43:35 -07:00
Sam Lantinga dab4f296b8 Cleanup spacing 2023-06-15 16:43:22 -07:00
Simon McVittie 16b57d2ff1 testevdev: Add details of another driving simulator controller
Thanks to Ben Fradella.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-15 12:21:36 -07:00
Simon McVittie 2b00751206 testevdev: Expand test data for X-Box One Elite 2
This slightly newer device than the one from #7814 is functionally
equivalent when connected via USB. When connected via Bluetooth, it has
a different button mapping.

Thanks to Sam Lantinga.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-15 08:16:28 -07:00
Mathieu Eyraud 62ed6f453f Use SDL_strdup instead of strdup 2023-06-15 06:31:19 -07:00
Sam Lantinga 73927b0948 Removed unused function 2023-06-14 15:16:21 -07:00
Sam Lantinga 2e465ae31b Revert "Added SDL_nextafter() and SDL_nextafterf()"
This reverts commit bc5d074818.

It's not clear that we need these yet, so I'm going to remove them for now.
2023-06-14 11:05:10 -07:00
Sam Lantinga 0c16f4faf0 Fixed third-party Nintendo Switch Pro controllers shutting down when we try to set the home LED.
This fixes the PDP Afterglow Wireless Deluxe Controller.
2023-06-14 10:15:06 -07:00