Commit Graph

7073 Commits

Author SHA1 Message Date
Sam Lantinga
87bb0f5bcb Don't mute the console input if we can't read the keyboard
This makes sure you can hit Ctrl-C if you don't have permission to access the raw keyboard device.

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

(cherry picked from commit ce9e1bd32485ae8a024d8147e3aa3a36f0cb0a19)
2023-11-08 03:29:39 -08:00
Sam Lantinga
7e11bd1ac1 Removed useless branch test
Fixes https://github.com/libsdl-org/SDL/issues/8286

(cherry picked from commit e5ccc80aba60f4132823d71ea6952c87f2392d06)
2023-11-08 01:35:57 -08:00
Sam Lantinga
af7fe2cf9b Actually we need to enumerate the 8BitDo Xbox SKUs
At the point we're calling SDL_IsJoystickXboxSeriesX(), we don't know for sure that the controller is an Xbox controller.

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

(cherry picked from commit 15bc12165ab56e6fbf93b8f3d18f2a0bb5854d8c)
2023-11-08 00:43:43 -08:00
Sam Lantinga
524ccf033f Assume all 8BitDo Xbox controllers have a share button
Fixes https://github.com/libsdl-org/SDL/issues/8174

(cherry picked from commit 8049af3355975c25bc5ac29ac518893d776a769b)
2023-11-08 00:36:27 -08:00
Sam Lantinga
b1807797a3 Make sure joysticks are locked when adding and removing them
Fixes https://github.com/libsdl-org/SDL/issues/8146

(cherry picked from commit ed1e0c1530e7902d6562f8e8cab2aa38e829a834)
2023-11-08 00:18:13 -08:00
Sam Lantinga
b07e5d38a2 Added missing calls to SDL_InvalidParamError("surface")
(cherry picked from commit 04e98d2236c02cbb10d0b88e1782b4dd4bf9d44a)
2023-11-07 21:58:39 -08:00
Sam Lantinga
624905a7f1 Destroy the window surface if we've created it for the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/8011
2023-11-07 21:47:07 -08:00
Sam Lantinga
4ace02df5f Added a mapping for the Atari VCS controller connected over Bluetooth (thanks @WizzardSK!)
Fixes https://github.com/libsdl-org/SDL/issues/7116

(cherry picked from commit 28e623c504558c0e438011207bcee254003b0f81)
2023-11-07 18:09:00 -08:00
Sam Lantinga
70adacf08a Make sure we include the null terminator in XLookupStringAsUTF8()
Fixes https://github.com/libsdl-org/SDL/issues/6728

(cherry picked from commit 4106697774ff533b2eeb223f87103fa464fc598a)
2023-11-07 16:25:12 -08:00
Ivan Mogilko
7526a87ff2 Handle subsystem dependencies recursively
Existing code is erroneous, because it adds or removes dependency's ref count based on number of InitSubSystem/QuitSubSystem calls, while ref count diff should depend on number of inited or quit dependents.
Recursive approach seems to be simplest solution that guarantees proper ref count.
2023-11-07 08:40:15 -08:00
Sam Lantinga
171e306dbf Enable the 5th player LED on the DualSense controller
Fixes https://github.com/libsdl-org/SDL/issues/5152

(cherry picked from commit 22016b4eae50fab0698ff3a33672f57283f1cccd)
2023-11-06 20:15:39 -08:00
Sam Lantinga
d6c725d522 Removed misleading comment
Fixes https://github.com/libsdl-org/SDL/issues/5069

(cherry picked from commit 66cf30c2de4f12c1b99b8d51ea5d77b62b373907)
2023-11-06 19:34:03 -08:00
Sam Lantinga
0c85173d5b Fixed connecting and disconnecting real-joysticks closing virtual joysticks in Emscripten (thanks David!)
Emscripten was using its own, private integer in order to allocate
new SDL_JoystickIDs.  SDL keeps a similar integer for allocating
joystick-ids, one which is shared across multiple joystick backends.

SDL 2.0.13 introduces a new joystick-backend, a Virtual joystick
backend, which allows for software-driven joysticks, and which is
designed to sit alongside joystick-backends that provide access to
physical joysticks.

The Emscripten and the Virtual backends were, at times, getting
allocated the same SDL_JoystickIDs, if and when both backends were used
simultaneously.  This could happen if, for example, an application
was using a virtual joystick in order to drive a touch-screen
based joystick, while also supporting physical joysticks through the
Emscripten backend.

When two joysticks end up with the same SDL_JoystickID, conflicts
can occur.  For example, disconnecting a physical joystick with
the same SDL_JoystickID as a virtual one, can lead to the virtual
joystick being closed, inadvertently.

This fix makes the Emscripten backend use SDL's cross-joystick-backend
integer counter, which is shared among joystick backends, for allocating
new SDL_JoystickIDs, rather than a private, Emscripten-specific
counter.

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

(cherry picked from commit 07cb7c10a15b95387431bcb3a1ae77cfd432707b)
2023-11-06 17:13:16 -08:00
Ryan C. Gordon
065d80716b
hidapi: Avoid memcpy'ing to NULL.
(This fix was originally from @themightyoarfish on GitHub. Thanks!)

Fixes #8428.
Reference PR #8431.

(cherry picked from commit c6d9fb1ad71462bc844c6ca41e2ac7fe7cec3883)
2023-11-06 13:50:49 -05:00
Ryan C. Gordon
9d7feaaf9e
coreaudio: If paused, clear any pending stream data.
This makes sure stuff that was still pending for conversion/resampling doesn't
pop in later when the device is unpaused again.

Fixes #8485.
2023-11-06 09:57:00 -05:00
Sam Lantinga
d5896f9010 Fixed memory leak in XInput code
Fixes https://github.com/libsdl-org/SDL/issues/3597

(cherry picked from commit 3e4d7e48b0a87b2c1df26ad62c8152ba6c064024)
2023-11-06 00:40:48 -08:00
Sam Lantinga
64a7e75dd3 Only save ibus_addr_file after we've successfully read an address from it.
Fixes https://github.com/libsdl-org/SDL/issues/3359

(cherry picked from commit bc3d9e99f381072820d29e75e6cc28fe40572c42)
2023-11-05 22:13:34 -08:00
Ozkan Sezer
93e51dd33e fix a possible memory leak in SDL_vasprintf()
(cherry picked from commit 1a83bf2399c29f3028477225067bf6a106068f08)
2023-11-05 20:02:20 +03:00
Sam Lantinga
e8f4045d0b Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!)
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE

Fixes https://github.com/libsdl-org/SDL/issues/2797
2023-11-04 22:24:55 -07:00
Sam Lantinga
aa129c9257 Fixed potential uninitialized memory access (thanks Mathieu!)
GetRawInputDeviceList() can return a different number of devices than was allocated.

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

(cherry picked from commit b9784feb2467dbb4cdc2474aa78098cd4f0b1630)
2023-11-04 21:12:15 -07:00
Sam Lantinga
20ecd2afcb Check to make sure the Windows joystick device has buttons and axes
This reverts commit e5a15f94e2f1a8fbbffb25ea9932cda9679a68fd.

It turns out removing this check allows mice like the ROG PUGIO II to show up as game controllers. We need to find a different way to differentiate between gaming mice and pedals.

Since these mice show up as controllers, and potentially causing games to use them instead of real controllers, we'll go ahead revert this change for now.

Reopens https://github.com/libsdl-org/SDL/issues/8227

(cherry picked from commit ad0af488837e44cbea0f0eab3b2f73b50a74bff4)
2023-11-02 08:43:11 -07:00
Frank Praznik
60e8ff16dc wayland: Sanity check pointers and protocols before confining
(cherry picked from commit 875e45e70b4086ca8cdff405231fc616f06cda7e)
2023-10-29 14:28:58 -04:00
Frank Praznik
19c3e125ba wayland: Check the relative pointer handle before destroying
If the relative protocol is unsupported, this will always be null and the destroy function won't be called.

(cherry picked from commit 0e87b71d08c75af8c4b02808038825d3b16bf854)
2023-10-29 14:28:19 -04:00
Sam Lantinga
832afa81a1 Fixed making the EGL context current when resuming on Android
Make sure that we don't have the context cached as current on the current thread.

(cherry picked from commit 8b6da3c7017935932357a0decee84dc6167ace17)
2023-10-26 17:09:13 -07:00
Sam Lantinga
1db0bd3fc0 Added support for the HP HyperX Clutch Gladiate controller
(cherry picked from commit f52b330ed84c477a94094302aa6a3baaca87019d)
2023-10-25 09:01:46 -07:00
Ryan C. Gordon
cba6090398
n3ds: Check that audio thread name starts with "SDLAudioP"
The string has a number after it, so a basic SDL_strcmp() will never match.

Reference PR #8346.
2023-10-24 23:58:00 -04:00
Sam Lantinga
4194a902e8 Added support for "%[]" sscanf syntax
Fixes https://github.com/libsdl-org/SDL/issues/8423

(cherry picked from commit 39a961ba41430788774f1b8c0e6d63f7308116e7)
2023-10-24 17:32:23 -07:00
ds-sloth
3823ba1ded n3ds systhread - use 80kb thread stack size as default, remove hard cap 2023-10-24 16:42:44 -07:00
ds-sloth
301ee21f33 n3ds systhread - prefer to put audio thread on system core 2023-10-24 16:42:44 -07:00
ds-sloth
6623c87d0b SDL_n3dsaudio.c - don't risk leaving current_priority uninitialized 2023-10-24 16:42:44 -07:00
ds-sloth
070f57820f SDL_n3dsaudio.h: use triple buffering 2023-10-24 16:42:44 -07:00
ds-sloth
62266dbd4f SDL_n3dsaudio.c: separate mixer locks from audio device locks 2023-10-24 16:42:44 -07:00
Sam Lantinga
d47c286b12 SDL_IsJoystickProductWheel() returns SDL_TRUE for Asetek wheelbases (thanks @IOBYTE!)
(cherry picked from commit e07f6c0a17fbf60eca96152036b2494d0cfafecd)
2023-10-23 10:44:30 -07:00
Sam Lantinga
259009a7ea Add missing error reporting in Android_JNI_FileOpen()
Fixes https://github.com/libsdl-org/SDL/issues/8427

(cherry picked from commit a844d909426153985136433f28ee5621affce97e)
2023-10-23 08:28:37 -07:00
Sam Lantinga
e3e41b69a1 Revert "Check to make sure the Windows joystick device has buttons and axes"
This reverts commit 642504bc5993a6acd4d9c1d4c1314c6b1cf6e4e1.

We have SDL_HINT_JOYSTICK_ROG_CHAKRAM to ignore or allow the ROG Chakram X mouse to be used as a joystick.

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

(cherry picked from commit e5a15f94e2f1a8fbbffb25ea9932cda9679a68fd)
2023-10-22 09:24:23 -07:00
Ozkan Sezer
44d8721087 Allow building against old Linux kernels. 2023-10-19 11:14:20 +03:00
Cameron Gutman
4aab2342e9 Check for device disconnection in HIDAPI_JoystickOpen()
HIDAPI joystick drivers may call HIDAPI_JoystickDisconnected() in their
UpdateDevice() function during HIDAPI_JoystickOpen(). If they do this
today, the opened joystick will end up partially initialized (no name,
path, mapping GUID, etc.) because HIDAPI_GetDeviceByIndex() will no
longer be able to find the SDL_HIDAPI_Device for the removed joystick.

Worse still, joystick->hwdata->device becomes a dangling freed pointer
the next time HIDAPI_UpdateDeviceList() is called. This leads to a UAF
when the application or SDL calls SDL_JoystickClose() on this joystick.

Fix all this by checking if the device no longer has any associated
joysticks after calling UpdateDevice() and failing the open call if so.

(cherry picked from commit 435e7ce663b7e568086c5dc0fb1bb889e41a3ed1)
2023-10-17 22:18:52 -05:00
Sylvain
df6db90dd4 Fix sdltest_randomAsciiStringWithMaximumLength() where it requests a string a size 0
seen with: ./testautomation --seed MILAFAP2AKVP3V4G --filter sdltest_randomAsciiStringWithMaximumLength
2023-10-13 20:23:01 +02:00
Ryan C. Gordon
d8b34b0993
pulseaudio: Stop the threaded mainloop before destroying the context.
Otherwise, we might trigger an assertion in libpulse.

Reference Issue #8348.

(cherry picked from commit 10fab3a39e2bd163cc45147b6afd517501801002)
2023-10-13 09:36:06 -04:00
Ryan C. Gordon
2849ca404e
x11: Properly check for XInput2 support before using it.
This specifically fixes a crash in X11_WarpMouseInternal if XInput2 was
missing at runtime, but also cleans up a few other existing checks.

Fixes #8378.

(cherry picked from commit 82f54af6177f3d50be1db42a528027ada6ea0a20)
2023-10-11 01:09:46 -04:00
Ozkan Sezer
b7a0ef6bdf artsaudio: revert bad arts_init return code check from commit ce5da5d. 2023-10-10 10:40:20 +03:00
Frank Praznik
e8c915dacc wayland: Try to skip the Wayland driver if not connecting to or in a Wayland session
When initializing the Wayland driver, check if the application is being started in, or trying to connect to, a Wayland session and skip to another driver if not. If neither WAYLAND_DISPLAY nor XDG_SESSION_TYPE are set, try to start anyway, and if the Wayland library is missing or no Wayland sessions are started, initialization will fail later in the process as it previously did.

This fixes the case where a Wayland session is running on a different VT, but an application wishes to run via KMSDRM on the current VT.

(cherry picked from commit 836927edf8da93ca2d3c8dddf7653113da65ce65)
2023-10-09 12:49:15 -04:00
KWottrich
25b0081367 Backport #7697 to SDL 2
Backport fixes from #8349

Include changes from #8357
2023-10-08 16:37:23 -07:00
Frank Praznik
1d8dbb2896 wayland: Unref the libdecor window when hiding
Hiding the decorations while not unreferencing the frame was a workaround for an internal libdecor use-after-free bug that was fixed some time ago. Revert to unreferencing the window when hiding to ensure that it is properly destroyed.

Reverts dd2e318
2023-10-05 20:26:06 +02:00
Anonymous Maarten
43c57e3239 triangle: don't read destination pixel when you're going to discard it anyways 2023-10-05 13:46:28 +02:00
Anonymous Maarten
2d5c05a69c blit_slow: don't read destination pixel when you're going to discard it anyways
(cherry picked from commit 4cd0c13823551cce279c9ff3d284c41c28deb3d8)
2023-10-04 19:42:46 -07:00
Frank Praznik
f9dc49c21c Fix automated tests using the dummy video driver
Manual backport of b8d9125
2023-09-30 11:21:10 -04:00
Anonymous Maarten
71b7790be8 snd_pcm_plugin_flush was removed in QNX 7.1 and later
Co-authored-by: elahav <elahav@users.noreply.github.com>
2023-09-30 16:48:51 +02:00
Anonymous Maarten
a263cc2369 Allow the use of posix_spawn() instead of vfork/execlp()
Backport of #7041

Co-authored-by: elahav <elahav@users.noreply.github.com>
2023-09-30 16:48:51 +02:00
Simon McVittie
6b5eadb10f SDLTest_CompareSurfaces: Decode pixels correctly on big-endian platforms
Previously, if acting on a surface with less than 32 bits per pixel,
this code was placing the pixel value from the surface in the first
few bytes of the Uint32 to be decoded, and unrelated data from a
subsequent pixel in the remaining bytes.

Because SDL_GetRGBA takes the bits to be decoded from the
least-significant bits of the given value, ignoring the higher-order
bits if any, this happened to be correct on little-endian platforms,
where the first few bytes store the least-significant bits of an
integer.

However, it was incorrect on big-endian, where the first few bytes are
the most-significant bits of an integer.

The previous implementation also assumed that unaligned access to a
32-bit quantity is possible, which is not the case on all CPUs (but
happens to be true on x86).

These issues were not discovered until now because
SDLTest_CompareSurfaces() is only used in testautomation, which until
recently was not being run routinely at build-time, because it contained
other assumptions that can fail in an autobuilder or CI environment.

Resolves: https://github.com/libsdl-org/SDL/issues/8315
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d95d2d7051e23271db7cec43134582834fb3ac8b)
2023-09-29 06:56:50 -07:00