Commit graph

7004 commits

Author SHA1 Message Date
Sam Lantinga 657c346556 Apply DPI scale to mouse coordinates in SDL_WarpMouseInWindow()
Fixes https://github.com/libsdl-org/SDL/issues/7855
2023-06-21 08:44:19 -07:00
Sam Lantinga ceece918e4 Updated to version 2.29.0 for development 2023-06-20 11:50:19 -07:00
Sam Lantinga ffa78e6bea Updated to version 2.28.0 for release 2023-06-20 11:00:20 -07:00
Simon McVittie 4ce5c3a694 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.

(cherry picked from commit 91198baed40d5709020c3001e9234f4580df696a)

Mitigates: https://github.com/ValveSoftware/steam-for-linux/issues/9605
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-20 09:45:25 -07:00
Sam Lantinga a3d4fd71c3 Added support for blitting SDL_PIXELFORMAT_INDEX1LSB
Fixes https://github.com/libsdl-org/SDL/issues/7844
2023-06-19 08:36:30 -07:00
Sam Lantinga d97423ebab 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.

(cherry picked from commit c6ee9780df4286f66c38f3fa9732daa9afe0a8a3)
2023-06-18 12:22:06 -07:00
Sam Lantinga 333a03f1ec We don't know in advance whether a device is connected over Bluetooth in SDL2 2023-06-17 13:15:07 -07:00
Sam Lantinga 5b8fc907df 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.

(cherry picked from commit f168f9c81326ad374aade49d1dc46f245b20d07a)
2023-06-17 13:07:03 -07:00
Eric Wasylishen 76392f4fe1 Handle DPI scaling in SDL_GetWindowSurface
Fixes DPI awareness of testdrawchessboard (previously, the surface was
being created in points instead of pixels, resulting in the demo app
only drawing in a corner of the screen on High-DPI displays)

*_CreateWindowFramebuffer()/*_UpdateWindowFramebuffer(): are updated
to use SDL_GetWindowSizeInPixels instead of SDL_GetWindowSize() or
window->w/window->h.

Most of the _CreateWindowFramebuffer backends are untested except
for Windows.

Fixes #7047

(cherry picked from commit 67c91353e01f6f2c0cc80c17eeddbad6def7cb01)
2023-06-14 17:23:54 -07:00
Sam Lantinga 3a5abee512 Removed unused function
(cherry picked from commit 73927b09480fd5d664f7077a70a8b6df318cdd2d)
2023-06-14 15:16:44 -07:00
Sam Lantinga e7ee375f22 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.

(cherry picked from commit 0c16f4faf00eb573d051cac7d60ed8dd22e5596a)
2023-06-14 15:15:27 -07:00
Sam Lantinga 4aec54988c Allow switching licensed Nintendo Switch Pro controllers into gyro input mode
(cherry picked from commit 8c95bd814bf1cf0ea1f12aa724938176a7dfd780)
2023-06-14 15:13:11 -07:00
Sam Lantinga 271e03f0d7 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

(cherry picked from commit cdfc0c5a3314e4e0cd5152feddd8950c7eb797f1)
2023-06-14 15:12:56 -07:00
Sam Lantinga d4f9be4416 Updated to version 2.27.1 for release candidate 2023-06-13 19:44:26 -07:00
Sam Lantinga 1f5b21ead5 Removed more Linux Xbox mappings in favor of the automatic mapping
This fixes the Xbox Series X share button on Linux 5.x kernels.

(cherry picked from commit 0f4b15e16b7f07a46db6dc8e651f8c1849d658c5)
2023-06-13 17:06:24 -07:00
Sam Lantinga 35c7884929 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.

(cherry picked from commit 9567989eb3ce9c858f0fe76806c5ccad69da89ba)
2023-06-13 17:06:21 -07:00
Sam Lantinga 3f6c4ec6d0 Cleanup for previous change, fixing typos, etc.
(cherry picked from commit 883b0f4071687f2e5c8329963f97504e9679394b)
2023-06-13 17:04:54 -07:00
Sam Lantinga fc72f12e7f 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)
2023-06-13 17:04:17 -07:00
Ozkan Sezer 681f67d353 fixed build after commit d2372c8538. 2023-06-14 00:25:50 +03:00
Sam Lantinga d2372c8538 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)
2023-06-13 10:12:07 -07:00
Sam Lantinga 7db23f4ef1 Fixed joystick vendor detection in Linux automatic gamepad mapping
(cherry picked from commit 071d1e29dd4f80605932f320aa2e05fda383944c)
2023-06-13 10:11:55 -07:00
Simon McVittie 36ff6327b0 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)
2023-06-13 05:46:01 -07:00
Simon McVittie 26a38a0b20 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)
2023-06-13 05:45:43 -07:00
Sam Lantinga b3e1fd97b8 Fixed enumerating Steam Controllers on iOS
(cherry picked from commit dec0dbff13d4091035209016eb2d0dd82c9aba58)
2023-06-13 05:44:34 -07:00
Sam Lantinga c77aaa5d99 Fixed n3ds build
(cherry picked from commit d95dbe78bb7a5087ecfb8d301417b1108d868738)
2023-06-12 15:41:09 -07:00
Sam Lantinga e4e0a12901 Reduce the chance of destroying the joystick mutex while it's in use
Fixes https://github.com/libsdl-org/SDL/issues/7811

(cherry picked from commit 6390165fd4c193631d6780758a4aeec0d02b90eb)
2023-06-12 15:31:16 -07:00
Ryan C. Gordon 2afb49ba9a cocoa: Warp mouse to center of window before enabling relative mouse.
This prevents the case where the mouse might be at the edge of the
window when enabling relative mode, which confuses macOS, at it
might believe the user is attempting to resize the window.

Fixes #6994.
2023-06-11 12:47:26 -04:00
Ozkan Sezer 154ad6faa9 SDL_dynapi.c: minor cosmetics. 2023-06-10 20:50:10 +03:00
Sam Lantinga 2aa8525ecb Fixed build 2023-06-10 09:29:09 -07:00
Sam Lantinga 36033e3832 Make it clear that you can't mix 2D rendering and the window surface API
Also added functions to query and destroy the window surface so you can switch between modes if you want.

See https://github.com/pygame-community/pygame-ce/issues/2190 for more details.
2023-06-10 08:54:36 -07:00
Sam Lantinga 320f3fffbe Fixed querying device info on the MOBAPAD M073
The query packet needs to contain valid rumble data in order to be accepted by the controller.

Fixes https://github.com/libsdl-org/SDL/issues/7788

(cherry picked from commit 5490873daa12a57ff4b36090f25f04530323c6e4)
2023-06-09 18:43:14 -07:00
Sam Lantinga 30b4d90f1c Only update the serial number if it hasn't already been set
This fixes the serial number for Nintendo Switch Pro, which is queried from the hardware in device initialization, and was later clobbered by the USB string which isn't correct.

(cherry picked from commit 2042e9c4e3cba6ffa9c34abac14828e31365f98b)
2023-06-09 17:36:06 -07:00
Sam Lantinga 1cdd6dc829 Fixed reading input from the Razer Atrox Arcade Stick using Windows Gaming Input
(cherry picked from commit 172cfca51332a845abf9c141ae56aa121fe4ada5)
2023-06-09 14:36:12 -07:00
Ozkan Sezer f5b3247aae further mouse relative motion fix for os/2 (thanks Andrey Vasilkin) 2023-06-08 03:40:32 +03:00
Ryan C. Gordon aa536217b3
x11: check if window size/position has changed during SDL_ShowWindow.
Fixes #4216.

(cherry picked from commit 49b5cfa6c5cb9bb8cecce508e12fa7f8e0cc302f)
2023-06-07 15:46:59 -04:00
Ozkan Sezer b1324fbc9f fixed os/2 mouse relative motion not working (thanks Andrey Vasilkin,)
for issue reported at https://github.com/bitwiseworks/SDL2-os2/issues/5
2023-06-05 11:50:50 +03:00
Sam Lantinga 4700fbcbdf Don't bother re-encoding Latin1 characters in the ASCII range
(cherry picked from commit 6150b5b3cbde0e592c4ffe822f66aa5f9c90c3d9)
2023-06-04 05:40:07 -07:00
Eddy Jansson 2660da6f5c Always allocate zt in output of SDL_iconv_string()
Before this, the function could not be used on buffers,
as it would not account for the zero-termination unless
it was included in the input.

(cherry picked from commit 5f5abb680523e1adedd3fca2a8e252db01fc1c52)
2023-06-04 05:17:15 -07:00
Sam Lantinga 7c86d96e86 Fixed SDL_iconv_string() truncation when handling SDL_ICONV_E2BIG
(cherry picked from commit c369b900199f905c51edb372bd7780f67a544a8c)
2023-06-04 05:14:44 -07:00
Ozkan Sezer a1dea11d32 fix MSVC build error. 2023-06-04 14:29:10 +03:00
Sam Lantinga bfef7c302c Only convert the result of XLookupString() if it's not already UTF-8
Fixes https://github.com/libsdl-org/SDL/issues/7766

(cherry picked from commit 491ae20d963cff397b5980b31d142d576e74becb)
2023-06-04 02:54:21 -07:00
Sam Lantinga dc94cca8dd Fixed typo in cherry-pick (thanks @HadesD!) 2023-06-03 11:57:08 -07:00
Sam Lantinga 97fe777ab4 Steam uses a different VID/PID for the Steam Virtual Gamepad on Windows
(cherry picked from commit 6815e75cafee8e7caaacf1f428b6539c8bbc7f7d)
2023-06-03 11:40:58 -07:00
Sam Lantinga f1bad83a21 Revert "Fixed detection of the Steam Virtual Gamepad on macOS"
This reverts commit 7aa28ce279.

Steam has been updated to send a version of 1 to avoid conflicts with controllers that report a version of 0.
2023-06-03 11:36:38 -07:00
Sam Lantinga 7aa28ce279 Fixed detection of the Steam Virtual Gamepad on macOS
(cherry picked from commit 5fcd70578bdde3eaaa51aa4ab6c24ed08bd49db3)
2023-06-02 18:39:22 -07:00
Sam Lantinga c89a460672 Fixed build if SDL_JOYSTICK_RAWINPUT_MATCHING isn't enabled
(cherry picked from commit 7c55845c804e2272df8bc111dea5d3e9d11670a0)
2023-06-02 11:20:55 -07:00
Sam Lantinga e3bfacde3e Don't use raw input while Remote Desktop is active
Raw input will not send game controller events while Remote Desktop is active, so dynamically switch between XInput and raw input when Remote Desktop state changes.

Fixes https://github.com/libsdl-org/SDL/issues/7759

(cherry picked from commit 767507fcf6f4607edb413acb53a6c029863701ed)
2023-06-02 11:19:44 -07:00
Sam Lantinga 9c05098ed9 Fixed WGI immediately being correlated with raw input devices with no input
The at rest match state is 0x0000008800000000, not 0

(cherry picked from commit e8b5b4881c8eb31bb7de5adef3479305a73fb0bf)
2023-06-02 09:39:57 -07:00
Alibek Omarov 68e3e99087 wayland: reset orientation bitmask before reading values from hint on QtWayland
Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
2023-06-02 07:41:08 -07:00
Ryan C. Gordon 379a6f4dab
x11: Attempt to wait for SDL_MaximizeWindow to complete before returning.
Fixes #7070.
2023-05-30 17:04:31 -04:00
Ryan C. Gordon d275851dfb
windows: Don't allow non-resizable windows to be maximized.
Fixes #6346.
2023-05-29 14:47:53 -04:00
Sam Lantinga 5007b96363 Fixed build warning 2023-05-28 19:23:56 -07:00
Sam Lantinga b2e88ecfeb Disable SDL_JOYSTICK_RAWINPUT_XINPUT
Apparently when using the Xbox One Wireless Adapter, using XInput at the same time as raw input will cause the controller to turn off immediately after connecting. This appears to be a bug in the Windows 11 driver stack, but since WGI provides all the extended functionality we need, this can be turned off for now.

Fixes https://github.com/libsdl-org/SDL/issues/3468
2023-05-28 18:41:21 -07:00
Anonymous Maarten d6cd450624 windows: SDL_Delay expects a 32-bit integer 2023-05-27 02:34:41 +02:00
Anonymous Maarten e875775940 windows: SDL_immdevice needs SDL_timer.h include 2023-05-27 02:10:18 +02:00
Ryan C. Gordon 48e71ae87b
wasapi: Deal with HDMI or DisplayPort-based audio devices.
They can vanish for UP TO EIGHT SECONDS...!

This is for devices that connect to HDMI/DisplayPort/etc, where it
presumably has to wait for a display to get up and running before it
can play audio through it, so one can see the audio device fail when
changing display modes, or the system returning from sleep. Since this
can be triggered by a game changing video resolutions at startup (either
before or after opening the audio device!), it's important to deal with.

In normal conditions, it shouldn't take this long to open or recover an
audio device, but this is better than unexpectedly losing the device
in this situation.

Fixes #7044.
Fixes #5571.
2023-05-26 19:15:28 -04:00
Sam Lantinga 7308325559 Added support for printing wide strings using "%ls" syntax
(cherry picked from commit 128ca7016018178c0c3231db7db2005dbf234068)
2023-05-26 14:59:30 -07:00
Anonymous Maarten c68976360d Fix -Wunused-function warning when configuring with -DSDL_X11_XINPUT2=OFF 2023-05-26 15:28:58 -04:00
Ryan C. Gordon a535cc62a0
video: Only specify some GL context attributes if not the explicit default.
Just in case it upsets some OpenGL drivers unnecessarily.

Fixes #7730.

(cherry picked from commit d4bc393efebdd45a95430397df106b69b1c26df3)
2023-05-25 10:10:03 -04:00
Sam Lantinga 3f1fd5abff Updated source to match SDL function prototype style 2023-05-23 10:59:03 -07:00
Frank Praznik 891c89eeb8 Fix unused variable warnings 2023-05-23 11:15:48 -04:00
Frank Praznik e2b8d96529 wayland: Validate surfaces and window data before sending touch events
Ensure that incoming touch events originate from valid surfaces owned by SDL and have proper window data before forwarding them to the touch subsystem, or the window focus pointer that is sent with the event may not be a pointer to an SDL window.
2023-05-23 10:31:28 -04:00
Sam Lantinga 78a92b4f9d Fixed duplicate Joy-Con controllers on macOS
If both Apple and HIDAPI drivers see the controller, HIDAPI will be preferred.

Fixes https://github.com/libsdl-org/SDL/issues/7479

(cherry picked from commit 61ef4efdfae7e384b0d24b1b171a9ee6203a3f0d)
2023-05-22 14:52:05 -07:00
Sam Lantinga 7b2b99a996 Fixed handling the Saitek P3600, which doesn't use the Xbox 360 controller protocol
(cherry picked from commit cf0abf99118f1ea5ba423ce62950e5840db2c649)
2023-05-22 12:42:05 -07:00
Sam Lantinga a2f4783e75 Don't map the top keyboard row to numbers when using the one-handed DVORAK layouts (thanks @tormol!)
Fixes https://github.com/libsdl-org/SDL/pull/5127
2023-05-22 11:30:42 -07:00
Caleb Cornett 2001a891c4 Fix Xbox link error from IsRectEmpty
(cherry picked from commit 376a3cd100a3d59e887496c75a1ac49ab4a2d8ec)
2023-05-21 19:11:25 -07:00
M. P. Halpin 1ee9a437f9 Stop beep when running iOS apps on ARM-based Macs
(cherry picked from commit bbf38bbbc334bc0ee90d3eec228a968d8fc1689e)
2023-05-20 11:21:13 -07:00
Sam Lantinga 69644346ac Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
Fixes https://github.com/libsdl-org/SDL/issues/7160
2023-05-20 11:09:36 -07:00
Sam Lantinga 00b87f1ded Make sure the sentinel is at the end of the current event pump cycle
If we're waiting, it's possible to not get any events, then add the sentinel, then pump again and then add another sentinel. We want to make sure we only have one sentinel and that it's at the end of the currently pumped events.

Testing:
* Verified test case in https://github.com/libsdl-org/SDL/issues/6539
* Verified test case in https://github.com/libsdl-org/SDL/issues/5350

Fixes https://github.com/libsdl-org/SDL/issues/6539
2023-05-20 10:27:48 -07:00
Sam Lantinga beca41480d Undo name change for the controller list
(cherry picked from commit f60622c5103e37f221aa8252acfa9073cfbafbc7)
2023-05-19 14:27:06 -07:00
Sam Lantinga 43b12fd9bc Moved the controller list out so it can be included elsewhere
(cherry picked from commit 24007b00b2a5e9d09d953db79a24dd51b78e598b)
2023-05-19 14:23:57 -07:00
Sam Lantinga e8ec8ba1d4 Added support for the Astro C40 in Xbox 360 mode
(cherry picked from commit a4b4dff4a2998699757f12d29fdd4c632db884fe)
2023-05-19 14:23:57 -07:00
Ozkan Sezer 92a487f2e4 style fixes for SDL_PROC macros. 2023-05-19 14:10:02 +03:00
Ryan C. Gordon df9d0fb332
power: On Linux, compare status strings as case-insensitive.
In case something reports "Device" when we expected "device", etc.

Reference Issue #6835.
2023-05-18 13:26:55 -04:00
Ryan C. Gordon 4a0b9522b6
audio: Load .WAV files with format->blockalign==0.
In theory this is illegal, but legit wavefiles in the field do it, and
it's easy to bump it to 1 for general purposes.

Formats with more specific alignment requirements already check for them
separately.

Fixes #7714.

(cherry picked from commit 2e646c7141b3009628abda2a964ba5f9d1702e1a)
2023-05-17 20:09:28 -04:00
Ryan C. Gordon 32999798e0
dynapi: Accept a comma-separated list of libraries to attempt to load.
First one to load and have the necessary symbol is the one we accept,
if any. Once we accept one, we won't try loading others.

Fixes #7613.
2023-05-17 20:03:17 -04:00
valid-ptr 424bc4bcf7 SDL emscripten port: preventDefault should not be called on mousedown. Otherwise mouseup will not be fired outside iframe in Chrome-based browsers 2023-05-17 12:30:32 -07:00
Ryan C. Gordon 0eea92c8fc
blit: Add a case for 8-bit blits that sdl12-compat exposed.
sdl12-compat can get into a state where a color-keyed surface is
marked for blending, but wants to blend with full alpha (which
is the same as _not_ blending), so rather than fail to find a
blitter in that case, it just selects the colorkey blitter.

Reference https://github.com/libsdl-org/sdl12-compat/issues/233
2023-05-16 14:38:44 -04:00
Sam Lantinga d42c303b24 Check to make sure the Windows joystick device has buttons and axes
This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10

(cherry picked from commit 642504bc5993a6acd4d9c1d4c1314c6b1cf6e4e1)
2023-05-15 21:44:20 -07:00
Ryan C. Gordon 86786ed544 coreaudio: Flush/stop the AudioQueue before disposing of it.
Otherwise, a CoreAudio thread lingers forever, and coreaudiod eats CPU
until the SDL process terminates.

Fixes #7689.
2023-05-08 14:25:01 -04:00
Sam Lantinga de93728674 Removed redundant __powerpc__ check
(cherry picked from commit b6df25c33497388f16a4ed2af896ef14277c8865)
2023-05-06 08:44:48 -07:00
Jeremy Rand 5e74365e55 SDL_blit_N.c: Move ppc64le swizzle outside of loop
An in-place swizzle mutation was erroneously inside of a loop, which
caused each consecutive 4-pixel vector to alternate between correct and
incorrect endianness.

The bug was introduced in 715e070d29.

Thanks to RobbieAB for reporting the bug.

Fixes https://github.com/libsdl-org/SDL/issues/3428

(cherry picked from commit 9142292f4ad6d9bc8a2bc7c874e2fde54befeb9b)
2023-05-06 08:39:59 -07:00
Loc(Elliot) 3e64fec9f4 Fix bug memory acess
Bitmap is not initialized before use, that cause segmentation fault on function use it. Fix by allocate memory before use.
2023-05-04 07:01:25 -07:00
Sam Lantinga f72213c4ac By default, OpenBSD uses Linux controller mappings
Fixes https://github.com/libsdl-org/SDL/issues/7609

(cherry picked from commit 255c3b7c82968def667da860cbda01f267b4edf1)
2023-04-29 17:10:46 -07:00
Frank Praznik 132b88749c wayland: Destroy proxy wrappers and callbacks before event queues
Destroy any proxy wrappers and callbacks before the associated event queues to silence libwayland warnings about destroying the queues while proxies are still attached.
2023-04-27 13:08:59 -04:00
Linus Probert 8b39eb9b1f wayland: Fixes a memory leak wheere primary selection isn't freed
(cherry picked from commit 43f65a6ef08a502485c6107b255a9b22c890acd5)
2023-04-24 12:00:16 -07:00
Ozkan Sezer 0f2322acfc hidapi/mac: replace sprintf uses with snprintf.
Reference issues:
-  https://github.com/libusb/hidapi/pull/509
-  https://github.com/libusb/hidapi/pull/511

(cherry picked from commit ae9119c36bdcf2214d83c6d35c436d22b5fd03cb)
2023-04-24 10:46:49 -07:00
Ozkan Sezer 5f344c17c2 hidapi/mac: import mainstream commit c1b9d2ad
c1b9d2ad98
Properly handle the close of run loop on macOS
(https://github.com/libusb/hidapi/pull/522)
- as per documentation `kCFRunLoopRunStopped` should be handled once the runloop is closed via `CFRunLoopStop`;
- if it is not handled - a race condition/crash may happen on the latest macOS when a device gets disconnected while being open;

(cherry picked from commit 62d1a2c836c6176a6c76d54229eafa7d011bb9fb)
2023-04-24 10:46:49 -07:00
Mingjie Shen a688ecd6fa
Check return value of SDL_malloc()
(cherry picked from commit a4604cb0d616db97921a2674a63b45f3fdfb81bc)
2023-04-23 12:28:54 -04:00
Sam Lantinga 120bc77e91 Report PS3 accelerometer values in m/s2 instead of Gs
(cherry picked from commit 0467301baf57389d96fafbe169fb07f4c10169bc)
2023-04-19 13:12:38 -07:00
Sam Lantinga 7ec9a4385a More defensive coding against dangling device pointers
(cherry picked from commit acadb6f873acaa0de094ad10a88f877d540ce0ec)
2023-04-06 13:21:44 -07:00
Sam Lantinga cb0cf14155 The latest Armor-X Pro firmware update fixes the sign on the Z axis of the sensors
(cherry picked from commit 558bbbb07ae0afa0108c1560915351cfa13442b7)
2023-04-06 09:55:39 -07:00
Cyril Dubet 7914234b26 Fix key code names for ISO keyboard layouts
(cherry picked from commit 60dcaff7eb25a01c9c87a5fed335b29a5625b95b)
2023-04-05 17:03:42 -07:00
Sam Lantinga f6363fde9a Fixed crash if joystick->hwdata != NULL && device->driver == NULL
This should never happen, but we're seeing it in the wild, so make sure that we can never call into a NULL device driver.

(cherry picked from commit e13b74ccf0b20a20bd4baf1617bdc4f84c13feb7)
2023-04-05 11:24:55 -07:00
Ozkan Sezer f633915443 fix build after commit 22685556e5. 2023-04-05 02:10:56 +03:00
Sam Lantinga 57043825ba Fixed crash if dbus can't be initialized
(cherry picked from commit cf2c6fa58dea02edb870cff7090fd69f3dfbd081)
2023-04-04 12:35:30 -07:00
Sam Lantinga 22685556e5 Don't probe for PlayStation controllers when we already know the controller type
Fixes https://github.com/libsdl-org/SDL/issues/7556

(cherry picked from commit 655a07bdd88d6bd19fe97c3abd39a2e2eef252ec)
2023-04-04 12:35:20 -07:00
Sam Lantinga f444eac557 Fixed analog triggers on the DualSense controller
(cherry picked from commit a67d41050164e447048fa55179cc31b23be9d9b7)
2023-04-04 12:35:20 -07:00
Jerome Duval eb0d214c17 Haiku: use a BLooper for events.
only create a BApplication when it doesn't already exist.
2023-03-30 10:20:11 -07:00
Frank Praznik 55f74c3285 x11: Don't allow the changing of certain scancodes
The X11 driver uses scancodes derived from keysyms to map the scancodes for extended keys to the physical keyboard, however, this can be incorrect when using certain XKB options (e.g. caps:swapescape), which changes the keysyms emitted by certain keys, but does not imply that their scancodes or positions should be altered. Mark selected scancodes as being non-remappable so that their scancodes aren't changed by toggling XKB mapping options.
2023-03-30 11:20:28 -04:00
Sam Lantinga c2ee45f5ff The Xinmotek Controller is used in multiple products with different mappings
The mapping included here is for the Ultimate Atari Fight Stick

(cherry picked from commit f1099f8e70a1284c2ee3031f2ea0cfc84f22110c)
2023-03-28 15:16:07 -07:00
Sam Lantinga 0bf63175ab Fixed gyro values for the Armor-X Pro controller
(cherry picked from commit 8df7b4d8539338121b1e34e29f331b28f1f4ff05)
2023-03-28 14:44:59 -07:00
Sam Lantinga d043c8535b Fixed the accelerometer and gyro axes for the Armor-X Pro controller
(cherry picked from commit 37517557ae076cd94acd9ca3b739e1f32c150a43)
2023-03-28 12:29:33 -07:00
Anonymous Maarten 85fecbb10b video: fix warnings about unused variables when building without duff's loop
(cherry picked from commit 0c3777d5661dd0bf60ba3db634f79c2121371092)
2023-03-28 10:21:36 -07:00
Anonymous Maarten 1402d13556 video/blit: fix -Wimplicit-fallthrough warnings
(cherry picked from commit f7961b7c9ad598b031cd033f19e93c6d882e8e41)
2023-03-28 10:21:35 -07:00
Sylvain 16c9bad786 Safety fix: clear "_this->wakeup_window" when destroying the window
(cherry picked from commit c838ccf0e3a330ebbcf433698b8f5370c6fa80d6)
2023-03-28 08:29:24 -07:00
Sylvain 6574e5eb57 Safety fix: clear "_this->current_glwin" when destroying the window
(cherry picked from commit 0c048d98af449f1bc540e256c90eb792f1effff4)
2023-03-28 08:29:23 -07:00
Sylvain 4fa21ee5ed
Fixed bug #7515 - Window still grabbed after destroying 2023-03-28 09:43:34 +02:00
Sam Lantinga 8bfbda1eab Fixed the accelerometer sensitivity for the Armor-X Pro controller
(cherry picked from commit 8029a767eef4147c07cde965bd5a2d2e11e237ee)
2023-03-27 14:33:59 -07:00
Sam Lantinga 93c289b475 Increased precision for PS4 sensor data conversion
(cherry picked from commit 3340864786314d77e04a0dd2bf1ebffbc43bfc31)
2023-03-27 14:33:56 -07:00
Pierre Wendling ed5a343d25 SDL_hidapi_steam.c: Fix compilation under c2x.
When N2935 is implemented, the enum breaks compilation. Use a #define of
the SDL booleans instead.

(cherry picked from commit 975039ce0d3587c42e11f2922240957fc8f74166)
2023-03-27 09:02:46 -07:00
Anonymous Maarten cd64e0b6e3 SDL_blit_copy: Don't call potentially FPU using SDL_memcpy in SDL_memcpyMMX 2023-03-27 06:13:28 +00:00
Anonymous Maarten d1dc195208 Implement _intel_fast_(memcpy|memset)
The classic Intel compiler generates calls to these functions when
building the SDL library with SDL_LIBC=OFF.
2023-03-27 06:13:28 +00:00
Anonymous Maarten 5aa76de35f cpuinfo: use __cpuidex instead of __cpuid
The classic Intel Compiler does not clear the ecx register prior
to executing the cpuid opcode.
2023-03-27 06:13:28 +00:00
Frank Praznik c0824cd49a events: Increase the size of the name buffer when logging events
Event names have grown in length and are occasionally truncated when being logged (e.g. SDL_EVENT_WINDOW_PIXEL_SIZE_CHA). Increase the event name buffer size to handle the longer names.

(cherry picked from commit 203a2a76fc0af2094de84d75dbf959c7db73fe72)
2023-03-26 22:01:17 -07:00
Bartłomiej Dach b970dd1beb Android: Fix mismatching JNI method signature
Another regression from commit dca3fd8307,
which was a backport of commit de3909a190f6e1a3f11776ce42927f99b0381675
from SDL3 to SDL2. This time the regression is much less apparent,
however, due to two reasons:

- It only appears when the SDL project is ran on an actual device
  due to magic stringage.

- More importantly, the regression was partially hidden due to
  the nature of de3909a190f6e1a3f11776ce42927f99b0381675.

  The commit which was backported added a single `I` to the JNI method
  signature in `SDL_android.c`, representing the added `int axis_mask`
  parameter. The parameter was added to both SDL2 and SDL3.

  However, notably, that `I` was added *after* commit
  fcafe40948fe308cc9552df5a3d625ee2725de5a, which removed the
  `int nballs` parameter from the joystick API, but only from the SDL3
  branch.

  Therefore, in totality, what should really have been a merge conflict,
  was obscured by the fact that the SDL3 branch ended up having
  a net-identical JNI signature to the SDL2 branch, due to having
  one bool param removed and one added - while, in fact, the SDL2 branch
  needed one bool param added and none removed.
2023-03-25 15:08:33 -07:00
Sylvain 2dddaa7dc9 backport x11/sdl2 fixes
4b1378f

X11: fix size/position (test video_setWindowCenteredOnDisplay)

this fix x11 backend to correctly pass video_setWindowCenteredOnDisplay()

    get border values early (eg status bar)
    wait for size/position change to get valid values

d4d26e0

testautomation_video: if SDL_SetWindowSize/Position isn't honored, we should check there is an event
x11: send the events if various occasions
2023-03-25 10:27:17 +01:00
Sam Lantinga b57a6a1adf Added gamepad mapping for Flydigi Vader 2 with the latest firmware (6.0.4.9)
(cherry picked from commit ed0937598e0a637a1033c90a1b31886537bb288c)
2023-03-18 11:36:50 -07:00
Ivan Mogilko d78072fcd4 Fixed SDL_RenderSetVSync does not update flags if simulated vsync is on
This lets the user to correctly detect current vsync state by reading SDL_RendererInfo.
Also fixes SetVSync's return value check (it may be positive for error too).
2023-03-17 14:55:04 -07:00
Ryan C. Gordon 446e0943da wasapi: Force WIN_CoInitialize duing device open.
Otherwise this won't work if you open a device on a background thread.

Fixes #7478.
2023-03-17 08:44:19 -07:00
Sylvain 23bce27b26 Change SDL_BLENDMODE_MUL for gl renderers
Add FIXME for PSP and DirectFB
2023-03-16 20:27:09 +01:00
Sylvain c078dfcf6b Refresh generation of SDL_blit_auto.c after simplifying sdlgenblit.pl 2023-03-16 20:27:09 +01:00
Sylvain 18c4db678b Simplify SDL_BLENDMODE_MUL in sdlgenblit.pl 2023-03-16 20:27:09 +01:00
Sylvain 7d26ba754a Simplify SDL_BLENDMODE_MUL 2023-03-16 20:27:09 +01:00
Sylvain bd70ce7f94 Refresh generation of SDL_blit_auto.c 2023-03-16 20:27:09 +01:00
Sam Lantinga 57ae9f466d Ignore the PS4 packet CRC if it's not being set correctly
This fixes handling the 8BitDo SN30 Pro with the 2.00 firmware in PS4 mode

Fixes https://github.com/libsdl-org/SDL/issues/7270

(cherry picked from commit 3951cae4a56fddcb42ce4141a6518c97fa9125cd)
2023-03-13 20:00:19 -07:00
Rudolf Polzer dca3fd8307 Android: indicate gamepaddb entries where axis order changed.
Axis order was changed in 6f1f586086a18ab32ddccc05e4616aac02774a1b to improve
default mappings.

(cherry picked from commit de3909a190f6e1a3f11776ce42927f99b0381675)
2023-03-11 13:01:50 -08:00
Sam Lantinga ab1670386f Added support for the trigger buttons on the Victrix Pro FS for PS5
(cherry picked from commit 8d7e61ea42364c256b76e7f6f2b6d6f90742bcb7)
2023-03-10 15:46:22 -08:00
Sam Lantinga 76e9d64b36 Removed space between sizeof and parentheses 2023-03-10 08:13:51 -08:00
Sam Lantinga e9f9cb29fc Fixed build warning on Android
(cherry picked from commit 2af6f4a3e4f0a82ccbb7ce142c914b5aa5df2000)
2023-03-10 08:12:28 -08:00
Qrox ef347776c2 Uses integer arithmetics in SDL_ResampleAudio
- Avoids precision loss caused by large floating point numbers.
- Adds unit test to test the signal-to-noise ratio and maximum error of resampler.
- Code cleanup

(cherry-picked from commit 20e17559e545c5d3cfe86c1c4772365e70090779)
2023-03-10 18:37:00 +03:00
Sam Lantinga 71dc7169d9 Added header for SDL_Delay() 2023-03-09 17:18:40 -08:00
Sam Lantinga 1e6ffc6294 Removed a duplicate delay accidentally added during code refactor
(cherry picked from commit 926db1bd544364a9e4ab61e60bcfbe75e05adf56)
2023-03-09 16:13:19 -08:00
Sam Lantinga 3f00fa16c6 Wait for the GCController framework to see IOKit devices
It occasionally takes a few millseconds for the GCController framework to handle the device notification and set up the device

Fixes the duplicate controller issue in https://github.com/libsdl-org/SDL/issues/6686

(cherry picked from commit 645823fc901c98b688512d3b3e70cc8922e8140c)
2023-03-09 16:13:19 -08:00
Sam Lantinga 0d76380042 Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!)
(cherry picked from commit c6443d86c92e962683a1efe5f123a144988875b5)
2023-03-09 15:23:59 -08:00
Sam Lantinga 46d143376a If the client rect is empty, use the last known window size
This happens on Windows 11 with fullscreen desktop windows when the desktop is brought up with the Windows+D shortcut.

Fixes https://github.com/libsdl-org/SDL/issues/7419

(cherry picked from commit 2ca727aec6f5f264620f80999beb5ef77eefec4a)
2023-03-09 10:39:43 -08:00
Deve 1c2f825230 Fixed incorrect modifier keys handling on macOS
(cherry-picked from commit 45a58b7882a253db29b1b1393bc2a1fe030d5955)
2023-03-09 20:28:51 +03:00
Frank Praznik 8f7427c158 tests: Always set valid dimensions for the fullscreen mode 2023-03-08 19:46:37 -05:00
Frank Praznik 6a999d16fa wayland: Always use a scale factor of 1 for exclusive fullscreen emulation 2023-03-08 19:46:37 -05:00
Lokathor cfd6b34b8f Make mappings for "Retrolink SNES Controller" with SDL_GAMECONTROLLER_USE_BUTTON_LABELS both on and off
I've only tested this on windows, but I went ahead and made the same changes for linux and mac because I assumed it's the same there and that we'd want to keep the three platforms in sync.

(cherry picked from commit b8bc4a234b93efa7a28c7fd7d524d905d9b76e6d)
2023-03-08 16:44:30 -08:00
Ozkan Sezer a70964aaf4 fix SDL_FindFreePlayerIndex so it can really return -1. 2023-03-08 20:00:50 +03:00
Sam Lantinga 35c13196f0 Fixed uninitialized variable 2023-03-08 08:40:38 -08:00
Sam Lantinga f5c0760c6b Disassociate the SDLOpenGLContext from the view before deleting it
If we don't do this, the view will be blanked even if another context is current and rendering from that context won't be visible.

Fixes https://github.com/libsdl-org/SDL/issues/4986
2023-03-08 01:15:21 -08:00
Sam Lantinga 63e6c19b7d Use SDL_GL_DeleteContext instead of Cocoa_GL_DeleteContext for context cleanup
That will make the current context NULL before deleting the context.
2023-03-08 01:13:00 -08:00
Sam Lantinga 1bd9ebf533 If we're not the current fullscreen window and we don't want to be fullscreen, don't touch the current video mode
Fixes an assertion in qemu on macOS, which creates multiple hidden windows:
2023-03-07 09:56:55.304 qemu-system-i386[9931:2984587] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'NSWindowStyleMaskFullScreen cleared on a window outside of a full screen transition. Called from (
	0   AppKit                              0x00000001968f77ac __25-[NSWindow setStyleMask:]_block_invoke + 140
	1   AppKit                              0x00000001968f76cc NSPerformVisuallyAtomicChange + 108
	2   AppKit                              0x00000001968f7580 -[NSWindow setStyleMask:] + 188
	3   libSDL2-2.0.0.dylib                 0x0000000106531328 Cocoa_SetWindowFullscreen + 568
	4   libSDL2-2.0.0.dylib                 0x0000000106501700 SDL_UpdateFullscreenMode + 1316
	5   libSDL2-2.0.0.dylib                 0x0000000106504270 SDL_SetWindowFullscreen_REAL + 328
	6   libSDL2-2.0.0.dylib                 0x000000010650117c SDL_FinishWindowCreation + 100
	7   libSDL2-2.0.0.dylib                 0x0000000106500998 SDL_CreateWindow_REAL + 1812
	8   libSDL2-2.0.0.dylib                 0x00000001063efd54 SDL_CreateWindow + 76
	9   qemu-system-i386                    0x00000001050aa600 sdl2_window_create + 192
	10  qemu-system-i386                    0x00000001050a9fa0 sdl2_2d_switch + 196
	11  qemu-system-i386                    0x0000000104e9c784 displaychangelistener_display_console + 524
	12  qemu-system-i386                    0x0000000104e9e36c register_displaychangelistener + 264
	13  qemu-system-i386                    0x00000001050ab6d0 sdl2_display_init + 304
	14  qemu-system-i386                    0x000000010505c870 qemu_init + 13380
2023-03-07 10:10:43 -08:00
Sam Lantinga e0e79419b6 Fixed which window we check flags for when updating fullscreen mode 2023-03-07 10:08:55 -08:00
Sam Lantinga 8fc10ac95c Added mapping for the Xbox Elite Core controller connected via Bluetooth on Android
(cherry picked from commit d08338ddc5bb3cae1e4ce06201a2cd3c53215aa0)
2023-03-06 15:37:52 -08:00
divVerent 91ad208d18 Fix Xbox One gamepad axis assignment on SDL_JOYSTICK_ANDROID API (#7405)
(cherry picked from commit 6f1f586086a18ab32ddccc05e4616aac02774a1b)
2023-03-06 15:37:41 -08:00
Michal Suchanek 96a2a6b945 evdev_kbd: Use current keymap
keymap can change over time, caching the keymap causes wrong keys
returned when user changes keymap during runtime

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2023-03-03 14:30:02 -08:00
Ozkan Sezer fd4bb4154b dynapi: replace uses of deprecated SDL_assert_state and SDL_assert_data 2023-03-03 03:01:02 +03:00