Commit Graph

13361 Commits (2e7d2b94ebf614b9711c76ce9bafe9e814b54ee4)

Author SHA1 Message Date
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
Sam Lantinga 23e007d3b7 Fixed third party Nintendo Switch Pro Controller resetting when being sent an unsupported command to set the Home LED
Tested with the PowerA Fusion Pro Wireless Controller in Bluetooth mode
2023-06-14 00:02:32 -07:00
Sam Lantinga 8c95bd814b Allow switching licensed Nintendo Switch Pro controllers into gyro input mode 2023-06-13 22:40:51 -07:00
Sam Lantinga cdfc0c5a33 Added support for the PowerA Fusion Pro Wireless Controller in Bluetooth mode
This controller shows up with a VID/PID of 0, but has full functionality over Bluetooth
2023-06-13 22:20:58 -07:00
Sam Lantinga 0f4b15e16b Removed more Linux Xbox mappings in favor of the automatic mapping
This fixes the Xbox Series X share button on Linux 5.x kernels.
2023-06-13 16:53:10 -07:00
Sam Lantinga 883b0f4071 Cleanup for previous change, fixing typos, etc. 2023-06-13 16:49:33 -07:00
Sam Lantinga 9567989eb3 Use the automatic mapping instead of a hardcoded one for Xbox controllers on Linux
This is much more robust and able to dynamically create a mapping for Xbox One S, Xbox Series X, and Xbox Elite 2 controllers.
2023-06-13 16:41:52 -07:00
Sam Lantinga db1d4d3d76 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.
2023-06-13 16:40:30 -07:00
Sylvain 0f24956b0a testautomation_hints.c: free hint memory 2023-06-13 23:12:01 +02:00
Sylvain 2c3717881f testautomation_events.c: initialize "timestamp" to solve "conditional jump or move depends on uninitialised value" 2023-06-13 23:03:32 +02:00
Simon McVittie 56ba7f2ff0 testevdev: Add details of X-Box One Elite 2 via USB
Thanks to iacore for capturing these.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-13 10:33:13 -07:00
Simon McVittie 74484511eb testevdev: Provide a pointer to more information about adding test-cases
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-13 10:33:13 -07:00
Sam Lantinga bc5d074818 Added SDL_nextafter() and SDL_nextafterf() 2023-06-13 10:32:21 -07:00
Sam Lantinga b0677f476f 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.
2023-06-13 10:06:36 -07:00
Sam Lantinga 071d1e29dd Fixed joystick vendor detection in Linux automatic gamepad mapping 2023-06-13 10:05:19 -07:00