Compare commits

..

391 Commits

Author SHA1 Message Date
Frank Praznik
c9b993f7b6 wayland: Prevent the window from errantly growing when scale to display is used
Some compositors will send a configure event immediately after a scale event, however, this event can contain the old logical size, and should be ignored, or the window will incorrectly change size when moved between displays with differing scale factors.

Store the last requested logical size as the last configure size when resizing a floating window due to a scale change, so a configure event immediately following with the old size will be ignored.

(cherry picked from commit 18219d5b53)
(cherry picked from commit 58c9c0ba7b)
2026-03-12 10:25:04 -04:00
Anonymous Maarten
17c70ee0aa cmake: cannot detect deprecated apple-clang link options (they are not fatal)
So skip these

(cherry picked from commit 5f151f4532)
2026-02-03 20:57:47 +01:00
Brad Smith
6d7bceb41d cmake: Fix header detection with CheckUSBHID
Make use of check_include_files to be able to also include
stdint.h when checking for the headers. Fixes detection of
usbhid.h on OpenBSD.

/usr/include/usbhid.h:40:2: error: unknown type name 'uint32_t'
   40 |         uint32_t _usage_page;
      |         ^

(cherry picked from commit 410a35fbee)
2026-01-28 07:45:40 -08:00
Frank Praznik
49955b3732 events: Raise keyboard keys before sending the focus lost message
Otherwise, the key raises may end up being ignored.

(cherry picked from commit e62d6a95b9)
2026-01-15 15:03:30 -05:00
Anonymous Maarten
3d03699d2b cmake: rpi videocore needs brcmegl as well
(cherry picked from commit cd31381185)
2026-01-14 18:17:52 +01:00
Frank Praznik
c12b2e41cb joystick/win32: Fix function return type mismatch
Fixes #14804

(cherry picked from commit 55acc0b829)
2026-01-11 10:57:58 -05:00
Anonymous Maarten
bba304c0b4 cmake: add SDL_FULL_VERSION target property containing full SDL version
(cherry picked from commit d73e74f9bf)
2026-01-06 04:05:20 +01:00
Sam Lantinga
814deb9438 Updated to version 3.2.31 for development 2025-12-31 17:54:27 -08:00
Sam Lantinga
f5e5f65889 Ignore the tray template when checking for the SDL revision 2025-12-31 17:10:09 -08:00
Sam Lantinga
65da64b0eb Print the SDL- strings that were found if validation failed 2025-12-31 17:00:35 -08:00
Sam Lantinga
3588d09b1c Updated to version 3.2.30 for release 2025-12-31 16:33:51 -08:00
Sam Lantinga
5afbd85755 gpu renderer: fixed memory leak when resizing the backbuffer
Fixes https://github.com/libsdl-org/SDL/issues/14734

(cherry picked from commit 9698e20399)
2025-12-31 08:02:35 -08:00
Frank Praznik
6034cf5cd8 gpu: Use the window event watcher list for Vulkan and D3D12
Events won't be delivered to the regular event watcher list callbacks if a client event filter discards events. Use the special window event watcher list to watch for resizes in the GPU renderers, as events are delivered to this list before a client can potentially discard them.

(cherry picked from commit cb4f33b644)
2025-12-31 07:52:03 -08:00
Ryan C. Gordon
cfc41248be timer: Use the emscripten-specific code on Emscripten, even with threading.
Fixes #14640.

(cherry picked from commit 4d8f84f161)
2025-12-31 07:52:03 -08:00
Simon McVittie
d1d0a50751 wayland: If GTK is disabled, try to avoid libdecor's GTK plugin
As described in the previous commit, loading GTK while setuid or setgid
would result in the process exiting. This is equally true if it's loaded
indirectly, for a libdecor plugin.

libdecor doesn't currently have any API by which it can be asked to
avoid specific plugins, but its GTK plugin declines to initialize if it
detects a non-main thread (because GTK documents that it must only be
used from the main thread), resulting in libdecor falling back to the
lower-priority Cairo plugin. We can make use of this by intentionally
initializing libdecor on another thread if we have been asked to avoid
GTK. This is a bit of a hack, but at worst it should be harmless.

Resolves: https://github.com/libsdl-org/sdl2-compat/issues/564
Signed-off-by: Simon McVittie <smcv@debian.org>
(cherry picked from commit 370e9407b5)
2025-12-30 17:13:51 -08:00
Simon McVittie
aeca6a77cf unix: If setuid or setgid, don't use GTK
GTK explicitly doesn't support being used setuid or setgid, and if SDL
loads and initializes GTK, GTK will exit the process if it
detects a setgid executable. This is incompatible with the historical
practice of making game executables setgid in order to write out a
shared high-score table on multi-user systems (which is security theatre
at best, because typical game runtime libraries are not hardened against
an untrusted caller, but making it regress would be a user-observable
regression in sdl2-compat).

Helps: https://github.com/libsdl-org/sdl2-compat/issues/564
Signed-off-by: Simon McVittie <smcv@debian.org>
(cherry picked from commit b6f4e10bf9)
2025-12-30 17:13:51 -08:00
Simon McVittie
a45a2368a7 unix: Add internal function SDL_CanUseGtk()
Necessary for a backport of #14712 to the 3.2.x branch. In the 3.4.x
branch this was factored out from tray-icon code, but 3.2.x doesn't have
that functionality.

Helps: https://github.com/libsdl-org/sdl2-compat/issues/564
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-12-30 17:13:51 -08:00
Simon McVittie
888104f5ad Document SDL's policy on setuid/setgid executables
Stated briefly, the policy is: don't.

Resolves: https://github.com/libsdl-org/SDL/issues/14717
Signed-off-by: Simon McVittie <smcv@debian.org>
(cherry picked from commit 76352f2931)
2025-12-28 10:16:44 -08:00
Ozkan Sezer
ec1d66d4f6 Revert "GPU: Add bounds validation for slot bindings and uniform data pushes. (#14692)"
This reverts commit 4b0a1df21f.
(Was cherry picked from commit bd29d60d3c)
2025-12-25 02:10:02 +03:00
Edgar San Martin, Jr.
4b0a1df21f GPU: Add bounds validation for slot bindings and uniform data pushes. (#14692)
(cherry picked from commit bd29d60d3c)
2025-12-23 08:36:56 -08:00
Frank Praznik
bfe3abdc26 wayland: Use the implicit grab serial when clearing the clipboard
Some compositors won't clear the selection without a valid serial.

(cherry picked from commit 9094395b13)
2025-12-22 13:32:13 -05:00
Sam Lantinga
9b1843c8da Allow the offscreen and dummy drivers to be used as fallback
(cherry picked from commit efc33633e3)
2025-12-21 16:18:21 -08:00
Frank Praznik
12d8540800 video: Unload GL/Vulkan when shutting down the video subsystem
If GL/Vulkan was loaded manually via a SDL_X_LoadLibrary() call instead of via window flags or through the GPU or renderer system, and there is no matching SDL_X_UnloadLibrary() call, the library instance won't be automatically unloaded while shutting down the video system, as the refcount won't go to zero, which can cause problems with some backends, and leaves a leaked DLL/SO handle when the global video object is destroyed.

Ensure that the libraries are unloaded after destroying the windows, but before shutting down the video backend, to prevent a leak and possible driver errors when shutting down the video backend.

(cherry picked from commit 37fca1fdcf)
2025-12-21 12:45:10 -05:00
Kaleb Reid
15f1a26656 Fix building joystick for OpenBSD
(cherry picked from commit 341f60555f)
2025-12-21 07:59:13 -08:00
Ryan C. Gordon
cb81c21f62 egl: Better attempt at retrying surface creation w/o EGL_EXT_present_opaque.
Fixes #13094.

(cherry picked from commit 808a3f573f)
2025-12-20 12:11:54 -06:00
eafton
c3cb21a498 Fix for #13094
(cherry picked from commit 98eaa05a9f)
2025-12-20 12:11:54 -06:00
Frank Praznik
cd4aa78d9a wayland: Update the HDR data on placeholder displays
Update the HDR data on a placeholder display if it hasn't been finalized and added yet, or the HDR data on the added display will be incorrect.

(cherry picked from commit 235f417616)
2025-12-17 15:13:52 -05:00
Frank Praznik
1f216da1e6 x11: Don't poll the map state when the window was unmapped and borders are toggled
An event flush while a window is being hidden may try to toggle the window borders. Don't poll the mapping state when toggling borders if the window is in the process of being hidden, or the window may already be unmapped, and the wait loop will hang forever.

(cherry picked from commit 78d008fcd2)
2025-12-16 11:46:47 -05:00
Edgar J San Martin
99cbedd662 Fix SDL_EnumerateDirectory(/) failing on POSIX and Windows.
(cherry picked from commit 09a2283b53)
2025-12-15 17:01:56 -08:00
Jakub Wasilewski
e8fbb7e820 GPU: Metal: Rebind storage buffers when changing the pipeline moves them.
(cherry picked from commit 73c9f25867)
2025-12-15 11:45:58 -08:00
Sam Lantinga
7f84afa68b Pass the window along with evdev touch events
Fixes https://github.com/libsdl-org/SDL/issues/14644

(cherry picked from commit 518c98ea01)
2025-12-15 08:29:45 -08:00
Fredrik Foss-Indrehus
51786880f4 cmake: add reftable ref storage support to GetGitRevisionDescription
The script assumed Git's traditional loose refs or packed-refs format.
When cloning with extensions.refstorage=reftable, neither .git/refs/*
nor .git/packed-refs exist, causing cmake configuration to fail.

Fall back to git rev-parse when file-based ref lookup fails.

(cherry picked from commit bdb72bb3f0)
2025-12-11 16:14:34 -08:00
Arnoldo Adonaí Barón Robles
e0050c3a9f GPU: Fix crash on Android upon returning from the background
(cherry picked from commit e5731f9bac)
2025-12-10 18:10:08 -08:00
Ozkan Sezer
0ca7052345 stb_image.h: apply patches from mainstream PRs 1839, 1862 and 1863.
Patches authored by @NBickford-NV to fix mainstream issues 1838, 1860,
1861.

(cherry picked from commit 9c6c2387b9)
(cherry picked from commit c7133a6720)
2025-12-10 21:05:20 +03:00
Ryan C. Gordon
bcdb3eddcc WhatsNew.txt: Moved some missing entries over to the release-3.2.x branch.
Fixes #14622.
2025-12-08 11:08:04 -05:00
Qiu Qiang
057634d069 Fix loop variable bug in V4L2 camera format enumeration
(cherry picked from commit 19988c5faa)
2025-12-07 14:12:03 -08:00
LuncyBloont
eb5eb4a33d Fix crash in UploadToTexture() on DX12.
(cherry picked from commit ab67be7e5a)
2025-12-05 11:47:02 -08:00
Eddy Jansson
df145a9649 log: Fix unlikely out-of-bounds issue.
In the unlikely case that the overflow check should fail,
the else clause would switch to the truncated stack message
without updating the len variable. This would contain the
return value from vsnprintf(), meaning it could point beyond
the buffer.

The subsequent code which trims NL and CR from the buffer,
would then read -- and possibly write -- out-of-bounds.

To fix this, we split the two joint conditions into separate
if-clauses, and adjust the len variable in the case where we
know the message buffer was truncated.

(cherry picked from commit 2cb9a4fcc1)
2025-12-04 13:20:34 -08:00
cosmonaut
b8618dd405 GPU: Remove erroneous buffer usage flag from defrag process
(cherry picked from commit aae2f74ae6)
2025-12-03 15:03:53 -08:00
Simon McVittie
ddb497e815 testver: Assert that SDL_GetRevision() starts with SDL-
https://github.com/libsdl-org/SDL/issues/14575

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 65ef4df6d4)
2025-12-03 08:51:53 -08:00
Simon McVittie
6a42180dbf build-scripts: Include SDL- prefix in SDL_REVISION when built from tarball
https://github.com/libsdl-org/SDL/issues/14575

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cc681ffeda)
2025-12-03 08:51:52 -08:00
Anonymous Maarten
223a3dc461 release: verify SDL_REVISION contains SDL-
(cherry picked from commit 3313cb9c4b)
2025-12-03 08:51:52 -08:00
Toast
13373ef501 Added Keychron V5 System Control to the controller blacklist
(cherry picked from commit 1dea7c801b)
2025-12-03 07:15:22 -08:00
Sam Lantinga
a7de0d9a3e Updated to version 3.2.29 for development 2025-12-02 13:02:25 -08:00
Sam Lantinga
7f3ae3d574 Updated to version 3.2.28 for release 2025-12-02 07:47:05 -08:00
Cameron Gutman
80f82acdf8 quit: don't call signal() if we're using sigaction()
At best, this is a no-op.

At worst, it might:
 - Clobber a signal handler someone registered after us
 - Overwrite the signal mask or flags
 - Cause unregistration to fail (sigaction() isn't guaranteed to return the exact pointer passed to signal())

(cherry picked from commit 6d99204a82)
2025-12-01 19:47:32 -06:00
Sam Lantinga
78146bb14c Correct the sensor axis ordering with the Linux Nintendo driver
Fixes https://github.com/libsdl-org/SDL/issues/14552

(cherry picked from commit 5e9163592f)
2025-11-30 11:37:34 -08:00
Amelia Clarke
c61f97dbce events: fix SDL_PeepEvents() returning 0 on error
Signed-off-by: Amelia Clarke <selene@perilune.dev>
(cherry picked from commit defd7895da)
2025-11-28 07:42:09 -08:00
Anonymous Maarten
c823f837c0 ci: bump macos-13 to macos-14
macos-13 image is getting retired in December 2025

(backported from commit 7a26bee6ee)
2025-11-26 17:25:50 +03:00
Anonymous Maarten
f8252fcc91 JNI_Unload must return the JNI version needed by the native library
(cherry picked from commit eda8d1d842)
2025-11-26 14:05:37 +01:00
Ryan C. Gordon
98ed8b98b1 blit: Check MSVC's _M_ARM64 define in addition to __aarch64__.
Reference Issue #14519.

(cherry picked from commit 4e79d2ad64)
2025-11-25 14:41:57 -08:00
Ryan C. Gordon
5f5a73a8f6 blit: Check MSVC's _M_ARM64 define in addition to __aarch64__.
Reference Issue #14519.

(cherry picked from commit 7f0d0d0046)
2025-11-25 14:41:49 -08:00
Ryan C. Gordon
50be2a7e56 blit: Change ifdefs on NEON functions that use an aarch64-specific opcode.
Fixes #14519.

(cherry picked from commit 15f98b2a61)
2025-11-25 14:41:07 -08:00
Ethan Lee
4fdbac7207 video: Explicitly call DestroyWindowTexture when destroying a window.
This prevents some recursion issues with hashtables, as described in #14499.
2025-11-24 01:25:38 -05:00
Sam Lantinga
8199076878 vulkan gpu: set the sample count for depth prepass
Fixes https://github.com/libsdl-org/SDL/issues/14500

(cherry picked from commit 1fc093491a)
2025-11-22 07:54:21 -08:00
Susko3
c49de41ef3 Fix WM_SYSKEYDOWN not being trapped by IME message handling
This would cause Alt + <something> not being trapped if handled by the system IME.

(cherry picked from commit 2ef005afe5)
2025-11-19 13:40:19 -08:00
Sam Lantinga
ad5681c45b Fixed crash in the vulkan renderer when the window is minimized
There's more work to do here in other cases where we can't recreate the swap chain, but this fixes the common minimize case.

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

(cherry picked from commit 0ae3d7b0b0)
2025-11-14 12:35:42 -08:00
Sam Lantinga
daf76f1ff6 Restored the original OpenBSD Xbox 360 controller mapping
(cherry picked from commit 90242312fe)
2025-11-14 07:20:17 -08:00
Sam Lantinga
cdff4b2bb5 Completed removing predefined Xbox 360 mappings for Linux
Also removed them for OpenBSD, since it's not clear which ones, if any, are needed.

(cherry picked from commit b305534edc)
2025-11-14 07:20:17 -08:00
Dave Wickham
d3a1a97db8 Re-add deleted gamepad mappings to the OpenBSD-specific section
(cherry picked from commit f6c3af9c8c)
2025-11-14 07:20:16 -08:00
Dave Wickham
962464629d Remove special-case Xbox 360 wireless controller mappings
Fixes https://github.com/libsdl-org/SDL/issues/14324

(cherry picked from commit 0c4c4cfd16)
2025-11-14 07:20:16 -08:00
Sam Lantinga
3291c2e560 Check for wine_get_version() to detect Wine/Proton
If this application is being run under Wine but Steam doesn't know that, Steam won't set STEAM_COMPAT_PROTON. So we'll use wine_get_version() to detect that we're running under Wine instead.

(cherry picked from commit e2e8f86076)
2025-11-12 22:30:48 -08:00
Sam Lantinga
b797a84b5d Don't check SteamVirtualGamepadInfo when running as Wine
Wine will ignore the Steam Virtual Gamepad if it looks like it has the original (blocked) controller VID/PID.

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

(cherry picked from commit 493bc621e4)
2025-11-12 22:30:48 -08:00
Marcin Serwin
45b0460019 Don't divide by zero in slow blitter
Other blitters seem to handle zero width/height destinations correctly.

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
(cherry picked from commit 53ee410d7a)
2025-11-09 07:26:37 -08:00
Chris Genova
5d0919855e D3D12 GPU: Prevent reading out of bounds when uploading textures.
When the upload needs realignment, a new buffer is created to do the
upload, and the source data is copied to the new buffer. This commit
fixes the issue where the memcopy can read off the end of the source
buffer since it is reading based on destination pitch instead of source
pitch.

(cherry picked from commit 6a01d6e7d3)
2025-11-07 17:50:25 -08:00
Sam Lantinga
6d2d283954 Fixed blitting bitmaps with a non-zero x offset
Also added basic testautomation coverage of bitmap blits

Fixes https://github.com/libsdl-org/sdl2-compat/issues/546

(cherry picked from commit a2ed1a4197)
2025-11-06 22:49:17 -08:00
Frank Praznik
49db06b604 x11: Only correct placement for border offset on the initial window mapping
Correcting it when it is subsequently hidden and re-mapped will cause the position to be double offset by the size of the borders.

(cherry picked from commit a71b2f0a93)
2025-11-06 19:35:51 -05:00
yuanhecai
85012b6074 loongarch: add SDL_FillSurfaceRect4LSX opt
(cherry picked from commit dc5b136930)
2025-11-06 07:29:51 -08:00
yuanhecai
14271c72f3 loongarch: add Blit8888to8888PixelAlphaSwizzleLSX opt
(cherry picked from commit 0b1eb4c841)
2025-11-06 07:29:50 -08:00
Sam Lantinga
d73922e407 Validate SPI read command in the Nintendo Switch HIDAPI driver
(cherry picked from commit c94da8977d)
2025-11-05 17:35:02 -08:00
Sam Lantinga
c8d23a5f01 Fixed unaligned access in the Nintendo Switch HIDAPI driver
(cherry picked from commit 9a1745f2c8)
2025-11-05 17:08:50 -08:00
Yevgen Abramov
4d8c8cdeda Fix V4L2 frame rate numerator comparison in SDL3 camera
Signed-off-by: Yevgen Abramov <eabramov84@gmail.com>
(cherry picked from commit b09b557fc6)
2025-11-05 10:56:25 -08:00
Anonymous Maarten
148d8c4995 release: don't download pre-release dependencies + strict version parsing
(cherry picked from commit 0da649eb72)
2025-11-04 18:00:48 +01:00
Sam Lantinga
4ae517e24e Removed redundant wait at shutdown in the ALSA audio driver
(cherry picked from commit 97e2951875)
2025-11-02 18:30:35 -08:00
Sam Lantinga
1fd4703907 Save a copy of the D3D12 semantic string
Fixes https://github.com/libsdl-org/SDL/issues/14383

(cherry picked from commit 4db63e323e)
2025-11-02 18:11:23 -08:00
Anonymous Maarten
024221d448 release: sync scripts with main branch
[ci skip]
2025-11-03 00:11:55 +01:00
Sam Lantinga
bfe046b60f Clamp the audio drain delay to 100 ms
Fixes https://github.com/libsdl-org/SDL/issues/9829

(cherry picked from commit 0882623092)
2025-11-02 11:16:13 -08:00
Sam Lantinga
1bfa90cb1f Fixed the paddle mapping for Steam Controllers
Fixes https://github.com/libsdl-org/SDL/issues/14380

(cherry picked from commit 3336aa95f1)
2025-11-02 10:07:42 -08:00
bleeqer
0c2e3308a5 Fix NULL pointer dereference in SDL_GlobStorageDirectory
(cherry picked from commit fc6f97f162)
2025-11-02 08:56:14 -08:00
Sam Lantinga
11fc77b704 Fixed the right touchpad calculation for the BLE Steam Controller
Fixes https://github.com/libsdl-org/SDL/issues/14368

(cherry picked from commit eb87a36940)
2025-11-02 08:31:59 -08:00
Arkadiusz Hiler
28af0d58c6 pulseaudio: Match channel map to SDL's chosen order
pa_channel_map_init_auto() with PA_CHANNEL_MAP_WAVEEX does the wrong
thing as it just takes the lest significant bits of
WAVEFORMATEXTENSIBLE's dwChannelMask in order. This doesn't match SDL's
chosen channel ordering.

The implementation here mirrors what we do for PipeWire.

(cherry picked from commit 0d2f081d41)
2025-10-30 13:33:46 -07:00
Sam Lantinga
bca544448f Updated to version 3.2.27 for development 2025-10-30 10:18:08 -07:00
Sam Lantinga
badbf8da4e Added some missing changes from main for the Android release build 2025-10-30 09:52:18 -07:00
Sam Lantinga
b140291cd0 Updated to version 3.2.26 for release 2025-10-30 09:10:42 -07:00
Sam Lantinga
70b12c1b1b Check to see if joysticks are actually initialized in SDL_UpdateJoysticks()
Fixes https://github.com/libsdl-org/SDL/issues/14362

(cherry picked from commit c21b7f8cb8)
2025-10-30 08:54:53 -07:00
Simon McVittie
2bbd74b4b6 wayland: Fix compile with libdecor 0.2 and SDL_WAYLAND_LIBDECOR_SHARED=OFF
libdecor 0.3, which changes the signature of libdecor_new and
libdecor_decorate to use a const pointer to the interface struct, has
not yet been released. In the latest release, libdecor 0.2.4, the
interface struct is a mutable pointer.

This doesn't affect typical upstream builds with
SDL_WAYLAND_LIBDECOR_SHARED=ON, in which case we're casting a pointer
returned by dlsym(); but Linux distributions that want tighter control
over dependencies often prefer to link them in the normal way, in which
case the build will fail if the signature doesn't match.

Fixes: 33834360 "wayland: Fix libdecor incompatible pointer types"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8b64dd67d2)
2025-10-30 07:14:49 -07:00
Sam Lantinga
add176e538 Make sure we don't allocate a TLS ID clobbering an application defined one
Fixes https://github.com/libsdl-org/SDL/issues/14359

(cherry picked from commit d9ca0457b5)
2025-10-29 14:06:11 -07:00
Sam Lantinga
86384afbcf Fixed the right shoulder button on the 8BitDo Pro 3
(cherry picked from commit cecf4b0d4e)
2025-10-28 14:55:36 -07:00
Sam Lantinga
328f833d51 Added a Linux mapping for the 8BitDo Pro 3
(cherry picked from commit 78f9cb44c3)
2025-10-28 14:14:00 -07:00
Frank Praznik
a002a6313e wayland: Fix libdecor incompatible pointer types
(cherry picked from commit 3383436068)
2025-10-28 13:43:46 -04:00
Sam Lantinga
4fc5405f16 Fixed trying to grab the mouse when losing keyboard focus
Fixes https://github.com/libsdl-org/SDL/issues/14350

(cherry picked from commit 2d14a237dc)
2025-10-28 08:20:17 -07:00
Albin Johansson
16d9f7316f Use cast operators in headers to avoid warnings
This avoids compiler warnings when consuming the
headers from C++.

(cherry picked from commit 7381a2b072)
2025-10-25 20:11:48 -07:00
Sam Lantinga
95977f41b7 Perform full rectangle intersection for empty rects
If we don't do that, we leave the x and y values uninitialized.

Fixes https://github.com/libsdl-org/sdl12-compat/issues/365

(cherry picked from commit ffd0ca4391)
2025-10-25 13:50:32 -07:00
DONGGEUN YOO
3302162ede Fix uninitialized length in X11_GetClipboardData causing test failures (#14322)
(cherry picked from commit 093fbfd867)
2025-10-25 07:42:24 -07:00
Sam Lantinga
29f857fed6 Removed SDL_FILE from source code
(cherry picked from commit a402af506c)
2025-10-22 11:11:31 -07:00
Sam Lantinga
492ed877ea Removed __FILE__ from source code
(cherry picked from commit f79ede100b)
2025-10-22 10:49:31 -07:00
Sam Lantinga
b1959ecf23 Be more selective when blacklisting controller touchpads
On Android, the PS4 controller is called "Wireless Controller Touchpad"
Fixes https://github.com/libsdl-org/SDL/issues/14294

(cherry picked from commit 999f782ad3)
2025-10-22 10:45:34 -07:00
Anonymous Maarten
928454cbfe cmake: fix typo
INTERFACE_COMPILE_COMPILE_OPTIONS -> INTERFACE_COMPILE_OPTIONS

(cherry picked from commit c5b0187fc9)
2025-10-22 19:01:17 +02:00
Katelyn Gadd
36b306a36c If VULKAN_Submit fails during VULKAN_INTERNAL_CreateTexture, destroy the texture and return NULL
(cherry picked from commit 9479ac039c)
2025-10-20 16:24:32 -07:00
Sylvain
92570af7d3 Fixed bug #14233 - Android fix Android_WaitActiveAndLockActivity() to make sure Android_Paused state is refreshed
(cherry picked from commit e4c60c05bf)
2025-10-19 07:44:15 -07:00
Peter0x44
5a9050aea3 Make D3D math functions static inline to reduce likelihood of linking conflicts
Convert SDL_d3dmath.c functions to static inline in SDL_d3dmath.h to make
it less likely to conflict when static linking SDL. raylib's SDL backend
does not work with a "normal" upstream binary static link. It has these
errors:

/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixIdentity':
SDL/src/render/SDL_d3dmath.c:35: multiple definition of `MatrixIdentity'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18470): first defined here
/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixMultiply':
SDL/src/render/SDL_d3dmath.c:44: multiple definition of `MatrixMultiply'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18540): first defined here
collect2: error: ld returned 1 exit status

It works if these functions aren't emitted, (i.e.
!SDL_VIDEO_RENDER_D3D(11|12|GPU|VULKAN)

Or, if SDL is not linked static. Which I know is preferred anyway.

In raylib's case, it doesn't use this code anyway so it's not a problem
to build it yourself with them disabled. But it's a minor hassle to be
incompatible with static linking libraries from upstream.

I can't see any good reason for these functions to not be static inline
already, so I just put them in the header and deleted the .c.

Raylib's conflicting case is a library with a public function exposed to
users. But SDL's case is not.

- Moved all matrix functions from SDL_d3dmath.c to SDL_d3dmath.h as static inline
- Removed SDL_d3dmath.c from all project files (Visual Studio and Xcode)
- Functions affected: MatrixIdentity, MatrixMultiply, MatrixScaling,
  MatrixTranslation, MatrixRotationX, MatrixRotationY, MatrixRotationZ

(cherry picked from commit 705ced8cf5)
2025-10-14 16:58:04 -07:00
Oleksandr Manenko
3d9f4c3328 Fix thread safety attributes for TryLock functions
Changed SDL_TRY_ACQUIRE and SDL_TRY_ACQUIRE_SHARED success value
from 0 to true for functions that now return bool instead of int.
This fixes false positives/negatives in Clang's thread safety analysis.

(cherry picked from commit 901173aee6)
2025-10-14 12:47:58 -07:00
Sam Lantinga
04ceb2d4a0 Only pass UIPress from game controllers and remotes if the're not open
Fixes https://github.com/libsdl-org/SDL/issues/14080

(cherry picked from commit f844f3e10b)
2025-10-14 12:44:23 -07:00
Sam Lantinga
e6987e2452 Fixed emulated touch on Android
This also fixes laser pointer input on Meta Quest headsets

(cherry picked from commit 712ce16469)
2025-10-14 08:40:58 -07:00
Sam Lantinga
4cd6df1997 Added the 8BitDo Ultimate 2C Wireless Controller to the Xbox controller list
Fixes https://github.com/libsdl-org/SDL/issues/14127

(cherry picked from commit 98944ecd0c)
2025-10-13 18:48:05 -07:00
Evan Hemsley
9163913305 GPU: Correctly recycle D3D12 descriptor heaps (#14234)
(cherry picked from commit 20206b8e66)
2025-10-13 13:00:38 -07:00
cosmonaut
b3f4ba0725 GPU: Validate that buffer size is at least 4 bytes
(cherry picked from commit b067dfa345)
2025-10-13 11:07:22 -07:00
Brenton Bostick
354bda8dde fill-in missing DeleteLocalRef calls
(cherry picked from commit e584d2a8a9)
2025-10-13 09:28:44 -07:00
Sam Lantinga
8ccbfdf368 Added support for the ZENAIM ARCADE CONTROLLER
(cherry picked from commit 831ec4dc6c)
2025-10-13 08:56:34 -07:00
DominusExult
19b646849c Adding dSYMs (DWARF debug symbols) to the xcFramework.
Needed to generate debug symbols for both release and debug builds and explicitly set the format so all arches actually generate the dSYMs.
This allows distributing an SDL3 app to the AppStore without the need to generate the dSYMs via script when using either the xcFramework or embedding the SDL3 Xcode project.
Fixes #13573

(cherry picked from commit 98c03c644a)
2025-10-13 08:35:25 -07:00
Sam Lantinga
48a83d69cc Corrected texture colors on PS2 (thanks @Trinth!)
Fixes https://github.com/libsdl-org/SDL/issues/12395

(cherry picked from commit 1ed093ad8b)
2025-10-12 09:21:49 -07:00
Gustaf Alhäll
ec682cc794 Fix SDL_SetRelativeMouseMode failing with software framebuffer on Haiku
(cherry picked from commit 2c63bc7315)
2025-10-11 09:03:01 -07:00
SDL Wiki Bot
d2d655b41f Sync SDL3 wiki -> header
[ci skip]

(cherry picked from commit add18e52c8)
2025-10-09 12:23:30 -07:00
Sam Lantinga
d6021b7d89 Only call clipboard callbacks with mime types they expect
Also clarified that returning NULL from a callback sends zero length data to the receiver, which should be able to handle that.

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

(cherry picked from commit 23e3cbec20)
2025-10-09 12:23:30 -07:00
Sam Lantinga
8dcb6db823 Only return current clipboard data under X11
Fixes https://github.com/libsdl-org/SDL/issues/10192

(cherry picked from commit 9cf7cdf23a)
2025-10-09 12:23:30 -07:00
Sam Lantinga
d0cfcf10bb Fixed crash getting clipboard data processing clipboard events on X11
SDL_PumpEvents() was freeing the temporary memory in the clipboard event, so if the application was iterating over the mime types in the event and retrieving the clipboard data, it would crash after the first entry.

(cherry picked from commit 3c0a6c32d4)
2025-10-09 12:23:30 -07:00
Edu Garcia
dd791f6838 Fix SDL GPU D3D12 Descriptor Heap leak
When descriptor leaks overflow, the D3D12 SDL GPU renderer fetches more from the pool, but never returns them, which eventually causes an "out of memory" crash.

(cherry picked from commit c74b406a4c)
2025-10-09 08:45:42 -07:00
Sylvain
988714beb9 Fixed bug #14173 - Android / SDL_Renderer Vulkan : going background / foreground produces a black screen.
need to recreate the swap chain + send SDL_EVENT_RENDER_DEVICE_RESET event

(cherry picked from commit 2a96997e90)
2025-10-09 08:41:00 -07:00
Sam Lantinga
78756540cb Recreate the Vulkan GPU swap chain when resuming on Android
Fixes https://github.com/libsdl-org/SDL/issues/12957

(cherry picked from commit 2a92a3c9c5)
2025-10-08 21:09:34 -07:00
Sam Lantinga
205b5c9f44 Ignore invalid width/height in setOrientationBis()
(cherry picked from commit 6f4993ddee)
2025-10-08 20:15:33 -07:00
Sam Lantinga
bca30aafed Ignore VK_SUBOPTIMAL_KHR on the Android platform
This is returned whenever the device has been rotated, and can be safely ignored.

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

(cherry picked from commit 00ffddece8)
2025-10-08 20:04:13 -07:00
Sam Lantinga
840d5c16d2 Temporarily disabled texture binding validation
There are some advanced use cases that trip over this, so temporarily disabling the validation pending further review.

Reference: https://github.com/libsdl-org/SDL/issues/13871
(cherry picked from commit a2a60f75c7)
2025-10-08 19:53:05 -07:00
Sam Lantinga
25b9a686b0 Added the Wooting 60HE keyboard to the controller blacklist
(cherry picked from commit d4b684311e)
2025-10-08 16:06:41 -07:00
Sam Lantinga
54c2f2c3f7 Only call WIN_RoUninitialize() if WIN_RoInitialize() succeeded
Fixes https://github.com/libsdl-org/SDL/issues/14178

(cherry picked from commit 7914bdb7ea)
2025-10-08 13:16:16 -07:00
Sylvain
b9cf5f08db Fixed bug #13306 - workaround for android issue "java.lang.NullPointerException android.view.View.onResolvePointerIcon"
(cherry picked from commit 10885f4b7e)
2025-10-08 08:05:36 -07:00
Ozkan Sezer
c7a36fa3c9 ci: bump cross-platform-actions.
(cherry picked from commit 97c1df66a8)
2025-10-07 14:28:04 +03:00
Sam Lantinga
73ca5f53e7 Don't treat the Moonlander MK1 Keyboard as a controller
Fixes http://github.com/mgba-emu/mgba/issues/3606

(cherry picked from commit 69791ccad0)
2025-10-06 16:52:36 -07:00
Sam Lantinga
2be2fb4918 Fixed build 2025-10-04 10:28:57 -04:00
Anonymous Maarten
fec1dd4a8b release: don't cache ndk + verify arm64 alignment
(cherry picked from commit f4039d0132)
2025-10-03 23:55:13 +02:00
Sam Lantinga
2a3a8f736c Fixed destination coordinates when using scale with the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/14051

(cherry picked from commit d333044462)
2025-10-03 13:58:57 -07:00
Anonymous Maarten
d3aff13aa3 cmake: use correct suffix in PkgConfigHelper
(cherry picked from commit 0bbfbf5b37)
2025-10-03 21:03:50 +02:00
Nintorch
54fb312a2c Add blacklist words for gamepad names
(cherry picked from commit 6e6dc500b5)
2025-10-03 09:45:31 -07:00
nmlgc
20aa0ad1c5 testautomation: Test SDL_snprintf() for doubles >LLONG_MAX and <ULLONG_MAX
The uclibc version of SDL_snprintf() is currently limited to values
<ULLONG_MAX due to the `unsigned long long` cast in SDL_PrintFloat(),
but it makes sense to at least ensure that it does support the full
unsigned 64-bit range. This also covers the one defined case where a
32-bit MSVC build can't assume that _ftoul2_legacy() == _ftol2().

(cherry picked from commit 8824eace93)
2025-10-03 07:22:59 -07:00
nmlgc
ff667d35f2 SDL_mslibc: Implement _ftoul2_legacy()
cl.exe versions ≥v19.41 call this builtin for double → uint64_t
conversions on x86. SDL currently needs such conversions in:

* MainCallbackRateHintChanged()
* SDL_PrintFloat()
* WIN_ApplyWindowProgress()

This seems enough to justify implementing this function rather than
trying to work around it, as it was done in sdl12-compat:

	https://github.com/libsdl-org/sdl12-compat/issues/352

This implementation was taken from ReactOS:

	https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f637e6b809adb5e0ae420ef4f80c73b19172a2e7

Passes the stdlib testautomation, and also matches the behavior of
Microsoft's 64-bit libc for the currently implementation-defined case
of calling SDL_PrintFloat() with values >SDL_MAX_UINT64.

(cherry picked from commit f39e49a3dd)
2025-10-03 07:22:59 -07:00
nmlgc
ff9599fb7e build: Fix typo in SDL_uclibc target name for 32-bit Windows
(cherry picked from commit 7916af9910)
2025-10-03 07:22:59 -07:00
mccakit
0448f20394 replace script with flags
(cherry picked from commit f6e711c377)
2025-10-02 16:01:17 -07:00
mccakit
db07924104 static release build fix
(cherry picked from commit 2e4bc73916)
2025-10-02 16:01:17 -07:00
mccakit
e60acdc477 android symbol export for release builds
(cherry picked from commit fe92d0a7bd)
2025-10-02 16:01:17 -07:00
Sam Lantinga
d69f658835 Make sure the current resolution is in the fullscreen mode list
Custom resolutions don't enumerate normally, but make sure the current resolution is in the mode list.

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

(cherry picked from commit b1c2dd8433)
2025-10-02 16:01:17 -07:00
Sam Lantinga
3eb9328d3e Updated to version 3.2.25 for development 2025-10-02 11:36:07 -07:00
Sam Lantinga
a8589a8422 Updated to version 3.2.24 for release 2025-10-02 10:52:32 -07:00
Simon McVittie
0bdaaf6c76 build: Prefix SDL- to revision from REVISION.txt
This makes it possible to get the version number of an unknown SDL binary
from `strings libSDL3.so.0 | grep SDL-`, like we could for SDL 2.

Resolves: https://github.com/libsdl-org/SDL/issues/14114
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 618b7b6c73)
2025-10-02 09:09:03 -07:00
Simon McVittie
390197d3aa build: Prefix version from git with SDL- rather than SDL3-
We can tell it's SDL 3 from the version number and git revision,
so there's no need to duplicate that in the prefix.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d5b79418f4)
2025-10-02 09:09:03 -07:00
Mathieu Eyraud
9fafba49dc Zero-initialize SDL_GPUDevice
(cherry picked from commit 86da08b0be)
2025-10-01 07:23:41 -07:00
Victor Ilyushchenko
5d47efe7fb Fix Metal 3D texture upload stride calculation
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
(cherry picked from commit a34d31322c)
2025-09-28 07:32:48 -07:00
Sam Lantinga
824234accc Fixed HIDAPI controller disconnect reading on multiple threads
If multiple threads are calling SDL_UpdateJoysticks(), then an overlapped read can be initiated on one thread (read_pending set to true) and GetOverlappedResult() called on another thread. This results in ERROR_OPERATION_ABORTED. This is harmless so we shouldn't return an error in this case, we'll just retry the read on the next call.

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

(cherry picked from commit b2188b325d)
2025-09-25 10:41:52 -07:00
Frank Praznik
6519158ae5 wayland: Ignore bogus libdecor content sizes if an unmapped window is suspended
If a client takes a long time to present the first frame after creating the window, a configure event to set the suspended state may arrive with libdecor increasing the content size by the decoration dimensions, which should be ignored.

(cherry picked from commit 9d5d7010de)
2025-09-24 10:36:04 -04:00
Frank Praznik
00718d60d2 x11: Use the pending size for the min/max limits if a resize is in flight
Otherwise, an outdated size may be used, reverting the requested resize operation.

(cherry picked from commit 45480f5fe5)
2025-09-24 10:36:04 -04:00
Sam Lantinga
18c2e179ee Use the real window position on macOS
On newer MacBooks, the fullscreen window might be placed below the camera notch, so use the actual window position

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

(cherry picked from commit 0a50058f7a)
2025-09-23 23:04:41 -07:00
Sam Lantinga
21ae008fc2 Use an empty bitmap for the blank cursor on macOS
Some macOS installations seem to have trouble decoding the GIF we were using

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

(cherry picked from commit 221d1f12ea)
2025-09-22 19:16:01 -07:00
Sam Lantinga
97a8bb44e6 The default swap interval on EGL is 1, according to the spec
Fixes https://github.com/libsdl-org/SDL/issues/14014

(cherry picked from commit 137b0b2bee)
2025-09-22 11:28:46 -07:00
Ryan C. Gordon
5d33fce898 wav: Patched to compile on Visual Studio.
(cherry picked from commit 09ee8876b3)
2025-09-22 08:14:33 -07:00
Ryan C. Gordon
bb5df96f69 wav: Clamp DATA chunk to size of file if possible.
Prevents a malicious file from malloc'ing multiple gigabytes.

Fixes #10052.

(cherry picked from commit 44e4deab7c)
2025-09-22 08:14:33 -07:00
Brenton Bostick
12b97944f3 fix: Extra parameter(s) for call to 'getCacheDir()'.
(cherry picked from commit 6590a5bc0b)
2025-09-22 07:25:19 -07:00
Brenton Bostick
0f17fbe1ca fix 'SDL_MessageBoxFlags' is not a valid JVM type.
(cherry picked from commit ed7d39b28c)
2025-09-22 07:05:05 -07:00
Sam Lantinga
c3480ca99c Use clearPrimaryClip() on Android 9 and newer
Fixes https://github.com/libsdl-org/SDL/issues/8355

(cherry picked from commit 34b09be6a5)
2025-09-21 23:30:57 -07:00
Sam Lantinga
936d94c2ee Fixed SDL_RunOnMainThread() on Android
If the application is waiting in SDL_WaitEvent(), we still need to run event loop maintenance in between calls to Android_PumpEvents().

Fixes the testautomation events_mainThreadCallbacks() test on Android.

(cherry picked from commit bae34c3e34)
2025-09-21 13:58:51 -07:00
Sam Lantinga
6cb55ebd46 Fixed a memory leak in fill_device_info_usage() (thanks @digant73)
Fixes https://github.com/libsdl-org/SDL/issues/13998

(cherry picked from commit 5503fe1c1b)
2025-09-20 09:05:52 -07:00
Andrei Sabalenka
482c5130eb wayland: fix typo in xdg_positioner_set_anchor_rect
(cherry picked from commit bb2b39b8ea)
2025-09-20 08:54:18 -07:00
Anonymous Maarten
066bcc5204 ci: disable ccache on macOS 13 job
(cherry picked from commit 566e7c2379)
2025-09-17 22:06:16 +02:00
ManifoldFR
21baa27bea gpu/vulkan : fix clear value indexing
(cherry picked from commit 8bc4e029bd)
2025-09-16 08:45:56 -07:00
Sora
93fd4a1c80 fix: use productCategory instead of vendorName for joy name for apple driver
(cherry picked from commit 964bedfdd9)
2025-09-15 11:52:21 -07:00
Ozkan Sezer
7135779599 SDL_endian.h: don't add _m_prefetch hack for clang-cl if available as a builtin
Fixes: https://github.com/libsdl-org/SDL/issues/13952 .

(cherry picked from commit 81f2f44843)
2025-09-15 20:10:28 +03:00
Eddy Jansson
62c151d044 wayland: Silence unused variable warning
'vd' and 'd' are only used if SDL_USE_LIBDBUS is set.

(cherry picked from commit 21c9f5304d)
2025-09-15 10:27:51 -04:00
Sam Lantinga
11d38fc23b Only use a transparent cursor on Windows when connected via RDP
VMware relies on the cursor being set to NULL to optimize relative mouse motion for games.

We should also revisit whether current RDP works better with a NULL cursor or a transparent cursor.

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

(cherry picked from commit dac6af4ba6)
2025-09-14 17:31:09 -07:00
Sam Lantinga
d027f0ae6e Remove Windows 32-bit ARM build from CI
This architecture is deprecated and is now failing with:
Windows SDK 10.0.22621.0 : 'C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um' not found or was incomplete

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

(cherry picked from commit cc3274b6f1)
2025-09-14 15:45:34 -07:00
Nintorch
44290c204e Fix HP Deluxe Webcam KQ246AA detected as joystick
(cherry picked from commit 556ee00fe3)
2025-09-14 15:40:40 -07:00
Sam Lantinga
0b69860af6 Fixed testprocess on 32-bit Windows
Previously the test would kill the child process while it was in the process of initializing (loading DLLs, etc) and this would cause the test to fail.

(cherry picked from commit 937b7e6aea)
2025-09-14 15:40:06 -07:00
Sam Lantinga
e7a1ae0ea5 Clarify why we ignore EINVAL when flushing a file descriptor
(cherry picked from commit a1d3fc1f50)
2025-09-14 15:39:53 -07:00
Sam Lantinga
7af36d6c40 Ignore errors flushing output on POSIX pipes
Fixes https://github.com/libsdl-org/SDL/issues/13116
Fixes https://github.com/libsdl-org/SDL/issues/13412

(cherry picked from commit e40d337a47)
2025-09-14 12:10:18 -07:00
Sam Lantinga
d1ae1163dd Wait briefly after enabling effects on DualSense controller
The rumble motors apparently take a short time to power up after enabling enhanced mode.

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

(cherry picked from commit 1aba421bd3)
2025-09-14 10:00:40 -07:00
Sam Lantinga
b2cf5729b4 Disable Windows.Gaming.Input by default
The functionality is already covered by XInput and DirectInput, and Microsoft is recommending GameInput going forward.

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

(cherry picked from commit 78a29d1670)
2025-09-14 08:52:43 -07:00
Sam Lantinga
11b8dd76db Fixed memory leak when using detached threads
Fixes https://github.com/libsdl-org/SDL/issues/13886

(cherry picked from commit ede86a1267)
2025-09-14 08:43:12 -07:00
Frank Praznik
56507a6122 x11: Use the SDL_WindowFlags type instead of Uint32
Uint32 can potentially truncate the flag value, as it is 64 bits in SDL3.

(cherry picked from commit 4561be89a5)
2025-09-13 15:45:43 -04:00
Evan Hemsley
8d4324cba2 GPU: Bump MAX_COLOR_TARGET_BINDINGS to 8 (#13937)
(cherry picked from commit fe314a1b8a)
2025-09-12 13:38:58 -07:00
Jaan Soulier
35408a2126 Fix reallocation of GPU renderer vertex buffer
(cherry picked from commit ed6a72a7fd)
2025-09-09 20:28:32 -07:00
Sam Lantinga
e5b9dfd181 Fixed setting SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER
(cherry picked from commit b7dba970e1)
2025-09-09 17:35:03 -07:00
eafton
e8a5d07e5e X11: Check for invalid opcodes in SHM error handler
(cherry picked from commit b59d6d49c3)
2025-09-09 10:59:58 -07:00
Luis Caceres
8c1daf0caf gpu/vulkan: Move dereference after null check
(cherry picked from commit 03d0c2ad74)
2025-09-08 09:50:09 -07:00
Sam Lantinga
ad2b211f75 Fixed pitch and chroma issues with the Vulkan planar YUV texture update functions
Fixes https://github.com/libsdl-org/SDL/issues/13734

(cherry picked from commit 466f93aee1)
2025-09-07 10:19:59 -07:00
Sam Lantinga
414ae344af Fixed rumble strength on DualSense Edge and Bluetooth connected controllers
Fixes https://github.com/libsdl-org/SDL/issues/13771

(cherry picked from commit 25d9096d41)
2025-09-06 11:53:55 -07:00
Adrian
71af2c020c Set preferredFrameRateRange in main callbacks CADisplayLink
(cherry picked from commit 01e6aceffc)
2025-09-06 10:13:44 -07:00
Aleksey Melekh
e755f50072 xbox: fix build
(cherry picked from commit 129c97f610)
2025-09-05 09:20:34 -07:00
Sam Lantinga
a0b8275e9c Fixed the perspective matrix calculation (thanks @KonkolyTamas!)
Fixes https://github.com/libsdl-org/SDL/issues/13867

(cherry picked from commit ea1a769322)
2025-09-04 06:07:28 -07:00
Cameron Cawley
ea362839b1 Remove unused PSP source files
(cherry picked from commit 42f571ea4b)
2025-09-03 15:20:00 -07:00
Sam Lantinga
e7dd5d841b Don't set SDL_SURFACE_LOCK_NEEDED until a surface is RLE encoded
Reference https://github.com/libsdl-org/sdl2-compat/issues/476

(cherry picked from commit 437d78499c)
2025-09-02 21:32:17 -07:00
Sam Lantinga
5594d03da0 Leave letterbox borders set to the frame clear color
Fixes https://github.com/libsdl-org/sdl2-compat/issues/483

(cherry picked from commit fbbc29159a)
2025-09-02 20:14:56 -07:00
Sam Lantinga
f2ae66b64f Set the texture scale and address mode when creating a texture
Fixes https://github.com/libsdl-org/sdl2-compat/issues/506

(cherry picked from commit ef19c72015)
2025-09-02 19:46:28 -07:00
Anonymous Maarten
393d99338f cmake: make SDL_CPU_xxx variable visible when using CMAKE_OSX_ARCHITECTURES
(cherry picked from commit ebb52973e1)
2025-09-02 23:00:10 +03:00
Ozkan Sezer
4d88280931 cmake: simd detection clean-up for Apple multi-arch configs.
(cherry picked from commit 83bb0f9105)
2025-09-02 22:35:32 +03:00
Anonymous Maarten
e8cc359b5e cmake: use 'TargetConditionals.h' on Apple for SIMD tests
(cherry picked from commit e15e2808f2)
2025-09-02 22:35:20 +03:00
Anonymous Maarten
3b4a198655 cmake: use APPLE in dep_option
expands to <nothing> on e.g. Windows, which will be interpreted as true by cmake_dependent_option.

(cherry picked from commit 1e7d3b51de)
2025-09-02 22:35:02 +03:00
Ethan Lee
03dd1520a3 gpu: VK_KHR_get_physical_device_properties2 can be optional
(cherry picked from commit 689049f8ec)
2025-09-02 09:53:59 -07:00
Sam Lantinga
a6fd74fa3b Fix crash when enumerating Steam Controllers
Closes https://github.com/libsdl-org/SDL/pull/13746
2025-09-02 08:42:16 -07:00
Sam Lantinga
03b36bac94 Updated to version 3.2.23 for development 2025-09-01 15:12:43 -07:00
Sam Lantinga
a96677bdf6 Updated to version 3.2.22 for release 2025-09-01 14:40:32 -07:00
Ryan C. Gordon
67f89d0a2b openslES: Patched to compile.
(whoops.)

(cherry picked from commit 7323104f97)
2025-09-01 11:10:33 -04:00
Ryan C. Gordon
f6de8877ec openslES: OpenSL ES on Android only supports two formats, limit to that.
(Three with the floating point extension, which we use.)

This is according to:

https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android

Previously, this would accept a request for Sint8 or Sint32 and disaster
would ensue.

Fixes #13779.

(cherry picked from commit 0b2a003a35)
2025-09-01 10:31:05 -04:00
Ozkan Sezer
7c189b1f17 cmake: revert commit 5d1bbd9 and change sse4.2 test
clang doesn't support -mcrc32 until version 14.0, therefore drop -mcrc32
use in sse 4.2 test, and change it to check _mm_cmpgt_epi64() instead of
_mm_crc32_u32(). without this, sse4.2 check was failing with clang <= 13

Fixes https://github.com/libsdl-org/SDL/pull/12223

(cherry picked from commit 875653658a)
2025-08-31 03:20:40 +03:00
Sam Lantinga
a7947080c0 Fixed warnings building with Visual Studio
(cherry picked from commit 7c8df4ea52)
2025-08-30 10:16:11 -07:00
Sam Lantinga
08c82a3781 Fixed build
(cherry picked from commit 3cf2350f21)
2025-08-30 10:15:48 -07:00
Jordan Saunders
589aea50c2 Fix two uninitialized variables
Found when running in valgrind looking at another issue.

- RenderPass' depth_stencil_target
    Tripped in SDL_BindGPUFragmentSamplers when not binding a DS target

- VulkanCommandBuffer's swapchainRequested
    Tripped in VULKAN_Submit for the end transition barrier when
    creating an image. The field is only reset when reused, not on first
    use

(cherry picked from commit 265236d952)
2025-08-30 06:05:43 -07:00
Ozkan Sezer
72acd7c9df CI: add OpenBSD workflow
(cherry picked from commit c0e5fd55d2)
2025-08-30 14:22:24 +03:00
Frank Praznik
1a70d1158e fs: Fix OpenBSD path retrieval
Set the path start pointer to point to a valid string.

(cherry picked from commit fdfde42db1)
2025-08-30 14:21:24 +03:00
Frank Praznik
ae915c6516 wayland: Add a sigtimedwait() implementation for OpenBSD
sigtimedwait() is an optional part of POSIX.1-2001, and OpenBSD doesn't implement it. Add a replacement implementation based on https://comp.unix.programmer.narkive.com/rEDH0sPT/sigtimedwait-implementation

(cherry picked from commit 1049426a76)
2025-08-30 14:21:00 +03:00
Xander
54d573332e Add SDL_SENSOR_COUNT to SDL_SensorType
(cherry picked from commit dc7a3a1219)
2025-08-29 07:31:25 -07:00
Matthew Zavislak
0204a69f6b Add elf alignment check for Android artifacts (#13818)
(cherry picked from commit 4f11feb708)
2025-08-28 16:31:25 -07:00
Susko3
b2689ff76a Avoid checking for HAVE_POSIX_SPAWN on Android
This makes the CMake build closer to SDL_build_config_android.h
as both will now use SDL_PROCESS_DUMMY.

(cherry picked from commit cd21bbe796)
2025-08-28 04:10:16 -07:00
Ozkan Sezer
611940fb80 cmake: fall back to -Wconversion if -Wfloat-conversion isn't available
... during checks for valid isinf/isinff/isnan/isnanf macros.

(cherry picked from commit 98bed62259)
2025-08-27 22:20:37 +03:00
Nintorch
16c0329a2a Add Emscripten joystick rumble support
Adds support for Emscripten (Web) joystick rumble support via EM_ASM_INT macros and HTML5's Gamepad API.

(cherry picked from commit 1fbed16cb0)
2025-08-25 12:59:15 -07:00
Nintorch
2743716132 Allow Android to ignore unnecessary joysticks
Previously, SDL_ShouldIgnoreJoystick wasn't being called for Android, and fingerprint sensors were recognized as joysticks.

(cherry picked from commit 1af7dfb0a7)
2025-08-25 11:23:34 -07:00
Colin Kinloch
a744eee993 testffmpeg: avutil queue family version check
The `AVVulkanDeviceQueueFamily` struct was introduced by libavutil
59.34.100

(cherry picked from commit 81920b5db7)
2025-08-25 11:10:31 -07:00
Evan Hemsley
0e24267eb5 gpu: D3D12 only requires feature level 11_0 with Resource Binding Tier 2. (#13782)
We previously thought this wasn't possible because constant buffer offsets and
partial updates were unavailable, but we were reading the wrong table - this is
only the case for D3D11...

https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro

... while 12 doesn't list this feature at all:

https://learn.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels

We double checked and Jesse Natalie confirmed that this feature is required for
D3D12 even for 11_0 drivers. (Thanks Jesse!)

Additionally, D3D12 requires that UAVs are accessible from all shader stages,
meaning Tier 2 is enough to support the number of UAVs we need. Tier 1 could be
a property to lower the requirements, but that can be done later.
2025-08-22 14:07:58 -07:00
Wilson Jallet
f4d6043aa4 GPU: Fix Vulkan indexing error for resolve attachment refs (#13768)
(cherry picked from commit 03b14f5211)
2025-08-19 12:13:23 -07:00
Petar Popovic
9fb9bd31a3 emscripten tests: fix warning: uninitialized variable
(cherry picked from commit 45feacf608)
2025-08-13 17:01:31 -07:00
ChaseKnowlden
c3828bb0a3 Keep MSVC Flags Consistent across CMake runs
(cherry picked from commit 10478c59db)
2025-08-12 19:39:44 -07:00
Sam Lantinga
40371f0907 Support the "ambient" value for SDL_HINT_AUDIO_CATEGORY
Fixes https://github.com/libsdl-org/SDL/issues/13732

(cherry picked from commit 4725213eef)
2025-08-12 09:54:43 -07:00
Sylvain
94f9434564 Fixed bug #13493: Assertion failure at SDL_AddTouch with Android API 28
Java touch id should be -1 because it's reserved for internal SDL
synthetic events.
It should also not be 0, because this is SDL invalid value.

(cherry picked from commit 970c0bfe96)
2025-08-12 09:44:04 -07:00
Chase Knowlden
bfaf247d30 Update NDK version to 28 (#13729)
* Update NDK version to 28 and add 16kb page size linker flags to x86_64

* Remove Android Linker Options

16kb page size is now the default since NDK r28c

* Update Android CI to use NDK 28

(cherry picked from commit 6e422e5ff2)
2025-08-12 07:46:27 -07:00
Beyley Cardellio
2287c43b59 GPU: Hold submit lock before waiting for device idle
(cherry picked from commit e699f3dca1)
2025-08-10 07:22:19 -07:00
Petar Popovic
15cc0f5f91 linux/SDL_syshaptic.c:SDL_SYS_HapticStopAll(): Fix return on error
(cherry picked from commit 43f3991398)
2025-08-09 09:28:02 -07:00
Anonymous Maarten
68e0108b1c release: build aarch64 libraries with 16kiB page size
[ci skip]

(cherry picked from commit 7017fbaa8e)
2025-08-09 05:23:43 +02:00
Mohamed Shazan
7b3796bc39 SDL_TriggerBreakpoint() will default to __debugbreak() on MinGW toolchain on windows
(cherry picked from commit f4c124e4bf)
2025-08-08 16:21:15 -07:00
Petar Popovic
b5bc6d2cc4 SDL_SendJoystickVirtualSensorDataInner(): Fix max_sensor_events increment
(cherry picked from commit d9c20cfd0a)
2025-08-08 12:52:03 -07:00
Petar Popovic
0d1d4ea1f9 SDL_SetRenderDrawBlendMode(): Remove redundant param check
(cherry picked from commit b63c32e790)
2025-08-08 14:06:27 -04:00
Pino Toscano
1a48f897f2 ime: fcitx: use SDL_GetExeName() in GetAppName()
Use the existing SDL_GetExeName(), available for all the UNIX
platforms, in the internal GetAppName(); this has few advantanges:
- SDL_GetExeName() (and SDL_GetAppID() that builds on top of it) are
  used in various places already; since it caches the executable name,
  this may remove one extra read of the application name
- SDL_GetExeName() has a non-dummy implementation in more OSes than
  GetAppName(), thus providing a small improvement for this IME

As drive-by change: since SDL_GetExeName() provides a constant string,
there is no more need to allocate a new string in GetAppName(), which
is used as constant string anyway. Hence, return a constant string in
GetAppName() too.

(cherry picked from commit 248bcf6b29)
2025-08-07 13:58:27 -07:00
Simon McVittie
2b42789de6 Fix some typos detected by Debian's lintian QA tool
I assume the demoninator is a typo, rather than an indication that
someone has been playing too much Doom :-)

Signed-off-by: Simon McVittie <smcv@collabora.com>

(cherry picked from commit d83503f80e)
2025-08-07 13:55:44 -07:00
Simon McVittie
b9c1da10ba hints: Rephrase documentation to improve grammar
"This thing allows to do something" is not really grammatically correct.
The closest rephrasing would be "allows one to do something" or "allows
the user to do something", but I think the passive voice reads more
naturally here.

Detected by Debian's lintian QA tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 40b941c826)
2025-08-07 13:55:44 -07:00
cosmonaut
56f5a76696 GPU: Fix uninitialized value in Vulkan command buffer structure
(cherry picked from commit fe6b2161bf)
2025-08-07 13:42:16 -07:00
Sam Lantinga
c7e8977e60 Revert "Support Google Play 16 KB Page Size Requirement (#13470)"
This reverts commit edef6e66e9

If you need to support the Google Play 16 kiB page size requirement, the recommendation is to use NDK r28c or newer, which automatically aligns binaries correctly.
2025-08-07 11:41:43 -07:00
Pino Toscano
e6ba3612db SDL_endian.h: extend Linux way for GNU libc
The currently used way to determine the endianness (i.e. include
<endian.h> and use the __BYTE_ORDER macro) is provided in general by
GNU libc. Thus, extend that to any platform/OS based on GNU libc.

(cherry picked from commit 561c99ee11)
2025-08-06 16:13:44 -07:00
Frank Praznik
5e77fb314c win32: Use the current flags to determine if NCCALCSIZE is required
SDL_GetWindowFlags() also ORs in pending flags, whereas the current state is needed here, particularly when creating/showing a window.

(cherry picked from commit cd0c660dea)
2025-08-05 18:49:41 -04:00
Frank Praznik
1a2841deb1 win32: Use STYLE_BORDERLESS when showing a pending fullscreen window
In addition to hiding the border on bordered windows that will immediately become fullscreen, The combination of flags used in STYLE_BORDERLESS_WINDOWED will still show the borders on borderless windows if the initial window size exactly matches the desktop, so STYLE_BORDERLESS must be used instead.

(cherry picked from commit 90a023007f)
2025-08-05 15:59:06 -04:00
Mathieu Eyraud
688637eca8 Fix condition for setting HDR properties
(cherry picked from commit a05aca51ec)
2025-08-05 09:26:12 -07:00
Frank Praznik
85d1d70ca1 cocoa: Wait for fullscreen spaces transitions to complete if switching to an exclusive mode
If attempting to switch to an exclusive mode while a fullscreen spaces transition is active, wait until the transition is complete before trying to apply the changes, or the window can wind up in a weird, broken state if a mode switch occurs while in a fullscreen space.

(cherry picked from commit f44a98729c)
2025-08-05 12:17:01 -04:00
Frank Praznik
09356c709a Revert "cocoa: Don't re-enter a fullscreen space if leaving to enter an exclusive mode"
This reverts commit 07b9e86d02.

It turns out that the problem is elsewhere, related to needing to block mode changes until spaces transitions are complete.
2025-08-04 23:51:47 -04:00
Frank Praznik
07b9e86d02 cocoa: Don't re-enter a fullscreen space if leaving to enter an exclusive mode
Doing so can leave the window in a weird, offset state.

(cherry picked from commit ee8f2861e7)
2025-08-04 22:16:22 -04:00
Sam Lantinga
8e46e5d8b4 Updated to version 3.2.21 for development 2025-08-04 11:54:34 -07:00
Sam Lantinga
96292a5b46 Updated to version 3.2.20 for release 2025-08-04 09:58:55 -07:00
Petar Popovic
ffa618c00b SDL_LoadWAV_IO(): On error, set *audio_buf to NULL and *audio_len to 0
(cherry picked from commit 23e08f7807)
2025-08-03 13:44:37 -04:00
Petar Popovic
291b9b3c82 SDL_enabled_assert(): Use NULL istead of 0 to explicity initialize the pointer members of SDL_AssertData
(cherry picked from commit faf3bd9991)
2025-08-03 13:36:14 -04:00
Frank Praznik
ec45117f0f x11: Filter mouse wheel events from "Master" devices
Discard wheel events from "Master" devices to avoid duplicates, as wheel events are stateless and can't be deduplicated.

(cherry picked from commit 51ce3f8c8d)
2025-08-02 18:57:44 -04:00
Frank Praznik
0d7aff9c56 GPU: Vulkan backend flags command buffer for cleanup when swapchain is requested
When skipping presentation due to the window being hidden, presentDataCount is not incremented on the command buffer, and subsequently the submitted command buffers will not be cleaned up as long as the window is hidden. This results in a lag spike when showing the window due to all previously submitted command buffers suddenly being cleaned up at once, and lag at shutdown due to an equivalent number of fences needing to be destroyed.

Instead of relying on presentDataCount to determine whether a command buffer should be cleaned up, use a flag, which is set under the appropriate circumstances.

(cherry picked from commit 42463569d5)
2025-08-02 09:24:21 -07:00
Petar Popovic
d31b239288 Fix double-free warning in src/hidapi/linux/hid.c
(cherry picked from commit ae5ce258cf)
2025-08-02 07:09:12 -07:00
capehill
b1cadf0e99 Fix SDL_BlitSurfaceScaled crash
SDL_BlitSurfaceScaled could crash when passed large coordinates, due
to final_dst.w or final_dst.h getting negative values.

(cherry picked from commit 1c5c3b1479)
2025-08-01 09:22:38 -07:00
Frank Praznik
c1f67585e6 wayland: Cleanup an outdated conditional and comment
There may have been a reason for not attaching a null buffer when destroying a popup at some point in the past, but that is unnecessary now, as is the comment about ShowWindow crashing, as ShowWindow assures that a null buffer is attached before (re)creating the window.

(cherry picked from commit 550d95e04f)
2025-08-01 10:40:32 -04:00
A1029384756
93988e28c0 wayland: reorder surface destruction to avoid premature blanking
(cherry picked from commit 9034375d2f)
2025-08-01 10:40:32 -04:00
Matthew Zavislak
edef6e66e9 Support Google Play 16 KB Page Size Requirement (#13470)
- See: https://developer.android.com/guide/practices/page-sizes#update-packaging
- Also, make min API uniform at 21 (from 16 and 23 in a few places)

(cherry picked from commit dc2c83c383)
2025-07-31 16:21:02 -07:00
Petar Popovic
e3f47809c4 Fix potential memory leak in SDL_render_gles2.c
(cherry picked from commit 09221820f6)
2025-07-31 16:19:10 -07:00
cosmonaut
f759e7ac59 GPU: Bail out of aquiring Vulkan swapchain if window is hidden
(cherry picked from commit c5edf4bd5b)
2025-07-31 16:03:19 -07:00
Frank Praznik
544eb2c5a9 wayland: Adjust popup adjoining check
The previous calculation could result in a window whose original position was positioned exactly corner-to-corner with the parent not being adjusted to be adjoining, and thus subject to spurious closure.

(cherry picked from commit b0cdb7143f)
2025-07-31 12:13:54 -04:00
Cheney Wang
30e3eba20a GPU: Fix wrong Vulkan swapchain size when retrying acquire
(cherry picked from commit d8ac51859e)
2025-07-30 15:35:23 -07:00
Wouter Wijsman
f0e85a2a9c psp: fix audio not playing
(cherry picked from commit 3d1a28ccf2)
2025-07-30 13:11:23 -07:00
Thaddeus Crews
106af5b46a Define relevant macros when LACKS_ERRNO_H is true
(cherry picked from commit 3195980b49)
2025-07-30 09:11:22 -07:00
Stefan Schlosser
522716ed90 SDL_getenv.c: fix dynamic loading of environ symbol on FreeBSD
The current implementation uses the returned address of the `dlsym` function
directly to load the `environ` symbol. But this function doesn't return the
address to the symbol itself, instead it returns the address to the location
where the actual address is stored, i.e. it's an additional indirection.
Consequently, the implementation fails to load and process the environment
variables successfully.

One example where this error shows up is in the `Dialog API`: in an `X11`
environment, the `zenity` driver requires access to the user's `DISPLAY` and
`XAUTHORITY` environment variables. Because these variables aren't transfered
to the `zenity` process, no dialogs are shown. This can be exercised in the
`test/testdialog.c` testprogram.

The fix changes the indirection level of the `dlsym` call from `char **` to
`char ***`, does a `NULL`-check in case the call failed, and returns the
dereferenced actual adress to the `environ` symbol.

(cherry picked from commit 10458f2cac)
2025-07-30 07:06:54 -07:00
Evan Hemsley
a65fbb0211 GPU: Fix incorrect block size when D3D12 uniform buffer is rotated (#13469)
(cherry picked from commit 07af4b237b)
2025-07-29 15:51:58 -07:00
Petar Popovic
46ec859bd1 Fix two use-after-free warnings
(cherry picked from commit f27dbb22f0)
2025-07-29 12:29:34 -07:00
Xen
2a7aa4eae4 Update SDL_clipboard.h
Typo fixes and a small addition to SDL_SetClipboardData about mime_type list usage clarity.

(cherry picked from commit b3ba1c159e)
2025-07-28 11:59:34 -07:00
Dan Andrus
c31ddf021e Check NSWindow::isVisible before sending SDL_WINDOWEVENT_RESTORED during Cocoa_WindowListener::windowDidResize
(cherry picked from commit 30f0aeb26a)
2025-07-28 14:47:45 -04:00
Shootfast
eaa2a8239f Fixed typo in SDL_scancode.h
The backslash/vertical line key is between the left shift and "Z" key on ISO keyboards

(cherry picked from commit 507ee033cc)
2025-07-27 19:58:45 -07:00
Brenton Bostick
d313ecb737 Fix warning on Android arm-v7
Building SDL for armeabi-v7a gives this warning:
```
SDL/src/audio/SDL_audiotypecvt.c:541:14: warning: '#pragma FENV_ACCESS' is not supported on this target - ignored [-Wignored-pragmas]
  541 | #pragma STDC FENV_ACCESS ON
```

(cherry picked from commit ed4de7aeed)
2025-07-27 08:16:21 -07:00
Petar Popovic
64b2af0340 SDL_gpu.c: Fixed deref-before-check warning
(cherry picked from commit 6a5af95364)
2025-07-26 12:08:57 -07:00
Anonymous Maarten
58d0702948 ci+n3ds: avoid apt-get package manager
- use Unix Makefiles (with parallelization) CMake generator
- use binutils strings binary from devkitpro

(cherry picked from commit e6d200e51c)
2025-07-26 16:06:36 +02:00
Sam Lantinga
707717e94b Reverted: Added Steam Virtual Gamepad support to the GameInput driver
This version of SDL doesn't support newer GameInput versions required for this feature.
2025-07-24 14:00:20 -07:00
Sam Lantinga
a140bba55a Fixed building with GameInput v1.0
(cherry picked from commit e5d57d8ad6)
2025-07-24 10:52:28 -07:00
Sam Lantinga
f4ddacacd0 Fixed building with GameInput v1.0
(cherry picked from commit 0ee0fe1572)
2025-07-24 10:43:05 -07:00
Sam Lantinga
ebba656bdb Added Steam Virtual Gamepad support to the GameInput driver
(cherry picked from commit 66dad9c21f)
2025-07-24 10:38:02 -07:00
Sam Lantinga
b78c61d67a Fixed double SDL_EVENT_GAMEPAD_ADDED for controllers with automatic gamepad mappings
(cherry picked from commit 6babade758)
2025-07-24 10:38:02 -07:00
L zard
4210aa61e1 build_config_windows: define HAVE_STDARG/STDDEF_H outside of
condition.
They are defined in both `#if HAVE_LIBC` and its `#else` anyway.
[sdl-ci-filter msvc-*]

(cherry picked from commit ea995b1694)
2025-07-21 14:45:19 -07:00
L zard
d8a345d924 build_config_windows: fix HAVE_VSSCANF defined regardless of MSVC version.
[sdl-ci-filter msvc-*]

(cherry picked from commit a977a11fa6)
2025-07-21 14:45:19 -07:00
Acclution
b8dc9767da GPU: Fix Vulkan compute uniform descriptor not being marked as set (#13389)
(cherry picked from commit 8bd29f7ca3)
2025-07-18 15:30:05 -07:00
BurntRanch
1ab01b9367 Clarify SDL_GPUVertexBufferDescription.pitch comment (#13381)
(cherry picked from commit ee6d8f78f4)
2025-07-17 08:55:04 -07:00
Sam Lantinga
ee371ff740 Fixed crash if a clipboard event was sent with video uninitialized
This can happen if you're using SDL on Android without using the video subsystem.

(cherry picked from commit 855d28e97a)
2025-07-17 08:48:00 -07:00
Evan Hemsley
ef58dd77ca GPU: Clean up properties in SDL_ReleaseGPUTexture (#13378) 2025-07-17 00:23:52 -07:00
Ryan C. Gordon
e6a7121904 audio: Binding an SDL_AudioStream will set missing formats.
It _must_ have the format set for the opposite side from the device (so
playback needs the src format set, and recording needs the dst format set),
since the stream gets mangled by the device thread if not. So if it has never
been set (stream created with NULL audiospec), just set it to match the device.
If the stream is just meant to buffer and not convert, this is desired
behavior, even if it didn't also fix a bug.

Binding the audio stream will always set the device side's format, as usual;
this does not need to be set by the caller at all.

Fixes #13363.

(cherry picked from commit f2ae6503c0)
2025-07-15 06:44:12 -04:00
Sam Lantinga
a6ed8ab59d Updated to version 3.2.19 for development 2025-07-14 11:44:22 -07:00
Sam Lantinga
bd40d0ded1 Removed the Mayflash GameCube adapter from the PS3 controller list
(cherry picked from commit 277f91c317)
2025-07-14 11:30:46 -07:00
Andon M. Coleman
68bfcb6c54 Allow 1 kHz sample rate for DualSense Edge over USB
DualSense Edge natively reports at 1 kHz for all connection types, but gyro sample rate was limited to 250 Hz for USB.

(cherry picked from commit a07cf3ecdc)
2025-07-14 10:02:46 -07:00
Josh Dowell
0d01efca52 windows: Fix crash when using a system that reports itself as Windows 17763 or newer, but is missing many of the newer dark mode window functions (Linux Mint Cinnamon w/ Proton 7.0.6)
(cherry picked from commit 0a50b798bf)
2025-07-13 20:10:26 -07:00
Kyle Sylvestre
0e65e04ce1 remove spoofed SDL_HelperWindow when SDL_VIDEO is off
(cherry picked from commit 0f061ff154)
2025-07-12 07:48:56 -07:00
Kyle Sylvestre
58d351fe98 check SDL_PLATFORM_WINDOWS instead of SDL_VIDEO_DRIVER_WINDOWS when using SDL_HelperWindow
(cherry picked from commit d42217ba26)
2025-07-12 07:48:56 -07:00
Kyle Sylvestre
9b71f18141 move SDL_HelperWindow outside of video
move to SDL_window.c to prevent relying on SDL_VIDEO

(cherry picked from commit a190e3b514)
2025-07-12 07:48:56 -07:00
Anonymous Maarten
554f08bac3 ci: build MSVC release binary on windows-2025 2025-07-12 01:25:08 +02:00
Sam Lantinga
913813a933 Updated to version 3.2.18 for release 2025-07-11 15:56:55 -07:00
Ryan C. Gordon
4e34c771e4 Revert "windows: Use wglSwapLayerBuffers if available."
This reverts commit b8ee44ca6a.

This is reverting a cherry-pick. It's probably too risky for a 3.2.x release,
but we'll let it marinate on main, for 3.4.0.
2025-07-11 18:25:14 -04:00
Ryan C. Gordon
9995174e68 gpu: Fixed uninitialized variable in SDL_AcquireGPUCommandBuffer().
Fixes #13191.

(cherry picked from commit 190afc0f4f)
2025-07-11 18:23:15 -04:00
Ryan C. Gordon
5a0197d430 wasapi: Force enumerated audio devices to report themselves as float32 format.
This is what they'll end up being when used through WASAPI in shared mode,
regardless of what the hardware actually expects.

Reference Issue #12914.

(cherry picked from commit a81cf566f4)
2025-07-11 18:23:01 -04:00
Sam Lantinga
4a55143e15 Fixed build
(cherry picked from commit 92e8224d32)
2025-07-11 14:12:27 -07:00
Sam Lantinga
87c9bc1b1f Fixed long delay when enumerating the Razer Huntsman keyboard
Fixes https://github.com/libsdl-org/SDL/issues/13236

(cherry picked from commit 0b2e389ee3)
2025-07-11 14:12:27 -07:00
Sam Lantinga
16a57b70f7 Set hwndTarget to NULL when unregistering raw input
Fixes https://github.com/libsdl-org/SDL/issues/13335

(cherry picked from commit 937e8d55a4)
2025-07-11 12:14:50 -07:00
Aleksey Sakovets
69564cd0b1 README-macos.md: replace old API calls
(cherry picked from commit 6386781351)
2025-07-11 12:08:58 -07:00
Ryan C. Gordon
da648b00e7 cocoa: Don't minimize fullscreen windows for a modal file dialog.
macOS sends a focus loss event when the dialog is created, which causes SDL
to try to minimize the window, which confuses the entire system. So in this
special case, don't do the minimization.

Fixes #13168.

(cherry picked from commit 9af93abd4f)
2025-07-11 15:06:10 -04:00
Sam Lantinga
5886d90308 Fixed long delay when enumerating the Razer Huntsman keyboard
Fixes https://github.com/libsdl-org/SDL/issues/13236

(cherry picked from commit f199aafaeb)
2025-07-11 11:56:06 -07:00
Ryan C. Gordon
e84df0cad1 x11: Avoid duplicate mouse events when using a pen device.
Fixes #12968.

(cherry picked from commit 72f4dd17be)
2025-07-11 14:31:07 -04:00
Frank Praznik
e482904111 Add support for non-constrained and non-grabbing popups
By default, popups are automatically constrained to be completely within display bounds, so as not to cut off information and result in an unusable menu, or unreadable tooltip. In some cases, however, this is not wanted, so a property to toggle this behavior is added.

There are also cases where the client may not want a popup menu to implicitly grab the keyboard focus, as is the default behavior, so popup menus now respect the focusable flag/property, as well as being able to toggle focus grabbing via SDL_SetWindowFocusable().

(cherry picked from commit b871ac0d97)
2025-07-11 14:26:51 -04:00
Ryan C. Gordon
b8ee44ca6a windows: Use wglSwapLayerBuffers if available.
It apparently works better (or can work better?) on multimonitor setups
than SwapBuffers.

This should be available back to Windows 95, but just in case, it falls
back to standard SwapBuffers if not available.

Fixes #13269.

(cherry picked from commit f286558bae)
2025-07-11 13:25:18 -04:00
Anonymous Maarten
4a4abe4240 cmake: remove /RTC1 from CXX flags when building with SDL_LIBC=OFF
(cherry picked from commit cfb8e591cb)
2025-07-11 10:00:22 -07:00
Wouter Wijsman
fe47f5cc30 PSP: Truncate thread name when passing to sceKernelCreateThread
(cherry picked from commit c64518f300)
2025-07-11 10:00:07 -07:00
Ryan C. Gordon
5b64be0810 docs: Documentation for SDL_Swap64 was reporting the wrong return type.
Fixes #13309.

(cherry picked from commit 530639aa4a)
2025-07-11 09:59:13 -07:00
Ryan C. Gordon
17656d051b cocoa: Don't use trick of briefly focusing the Dock on newer macOS releases.
On newer systems, the trick isn't necessary, and if you do it, if the user is
moving the mouse when launching the app, it'll show a hidden Dock.

Fixes #10340.

(cherry picked from commit 279dabfc96)
2025-07-10 15:54:25 -04:00
Ozkan Sezer
233fce456a fix ARM64 linkage with Visual Studio >= 17.14 when SDL_LIBC is disabled
Reference issue:  https://github.com/libsdl-org/SDL/issues/13254

(cherry picked from commit 2fb6abb9ad)
(cherry picked from commit fb0e03f262)
2025-07-09 01:32:00 +03:00
Frank Praznik
5290bb036c wayland: Ensure that the xdg_surface is always configured after creation
The spec states that xdg_surface must have seen an initial configure event before attaching a buffer, however, this was only being done when initially showing the window, and not after show->hide->show cycle.

Always wait for the initial configure event when (re)creating an xdg_surface as part of the show window sequence.

(cherry picked from commit ecdc6f2adb)
2025-07-05 12:10:28 -04:00
WillyJL
2bff72b4f6 SDL3 GPU: Fix -Wbool-conversion warnings
(cherry picked from commit 4eff36ef53)
2025-06-29 13:33:56 -04:00
Anonymous Maarten
08ebeaee5c cmake: Android always needs a native HIDAPI implementation
(cherry picked from commit 89eef1bd34)
2025-06-26 15:43:29 -07:00
Caleb Heuer
12b56f5447 Allow overriding SDL_FORK_MESSAGEBOX in build environment
(cherry picked from commit cd98b66114)
2025-06-26 10:49:48 -07:00
Frank Praznik
165b86e7b7 x11: Always update the borders on frame extent events
Always update the border sizes on frame extent events, or they can incorrectly still be zero if followed by a PropertyNotify event when leaving fullscreen.

Fixes sending the correct restored window size when leaving fullscreen in fvwm.

(cherry picked from commit 0ac1241b7a)
2025-06-26 11:53:32 -04:00
Sam Lantinga
608101a185 Update the viewport when logical presentation changes
Fixes https://github.com/libsdl-org/SDL/issues/13256

(cherry picked from commit 727b4924c8)
2025-06-25 09:59:13 -07:00
Paul Vick
554bee6aae Fix #13276: Crash in SDL_GetAudioDeviceChannelMap
(cherry picked from commit de6a23028a)
2025-06-25 09:59:07 -07:00
Rémi Verschelde
3e0ce51067 joystick: Fix MSVC errors C2099 with /fp:strict
(cherry picked from commit db3a35e9bc)
2025-06-24 07:32:26 -07:00
Ozkan Sezer
7261c43342 alsa: change an SDL_LogError into SDL_LogDebug.
it is informational only and seeing ERROR on the terminal was confusing

(cherry picked from commit af8bee2dd1)
2025-06-22 21:05:10 -07:00
Marcin Serwin
ad57c6ea37 test: Fix resource paths in testtray
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
(cherry picked from commit bbc674b9e7)
2025-06-22 21:03:55 -07:00
mitchellcairns
caecff650d Resolve bug for calibration Nintendo Switch Pro Controller (#13260)
Resolves a bug which prevents the stored calibration data from loading, only allowing loading of factory-installed calibration data

(cherry picked from commit 796961acec)
2025-06-22 21:00:01 -07:00
Mitch Cairns
f6300be4b2 Fixed Nintendo Switch thumbstick calibration
(cherry picked from commit 3a6f9e01f8)
2025-06-22 15:27:30 -07:00
Sam Lantinga
bde5687a3c Fixed Nintendo Switch Pro thumbstick calibration
Fixes https://github.com/libsdl-org/SDL/issues/13246

(cherry picked from commit 038a3806eb)
2025-06-21 19:57:04 -07:00
Sam Lantinga
0f3504f78d Updated testffmpeg for ffmpeg 7.1
(cherry picked from commit e6c2649afc)
2025-06-21 08:49:43 -07:00
Sam Lantinga
0aaa0321cc Fixed warning C5286: implicit conversion from enum type 'VkFilter' to enum type 'SDL_ScaleMode' 2025-06-21 07:41:20 -07:00
Josh Dowell
caaaf52583 win32: Invalidate window message mouse button flags when reading buttons from raw input or GameInput
SDL2 would set a high bit in the mouse button flags to indicate when raw input had been read from, without this, if you hold down a mouse button and left raw input mode (leaving relative mode) the button would remain partially stuck, and would require two clicks to start producing mouse down events again.
SDL3's raw input code was refactored to not use the mouse button flags, but forgot to invalidate the flags, causing this bug to manifest.

(cherry picked from commit 6aedc488d3)
2025-06-21 07:29:05 -07:00
Ozkan Sezer
56449f167d hidapi/libusb: disable C5287 warning in MSVC builds
A quick search implies that it is a bogus warning:
https://www.google.com/search?q=visual+studio+C5287

(cherry picked from commit 81e3066303)
2025-06-21 07:16:36 -07:00
Ryan C. Gordon
c7325228dc audio: Enumerating audio devices will skip zombie devices still in the hash.
(cherry picked from commit eb04219efe)
2025-06-20 14:49:32 -07:00
Sam Lantinga
079967afa5 Clarify that SDL_GetAudioStreamDevice() returns the logical device.
(cherry picked from commit c19ad189dc)
2025-06-20 14:01:32 -07:00
Lilian Gimenez
2ed55b614c Fix support for F21 to F24 scancodes on Linux
(cherry picked from commit e4e29b8601)
2025-06-20 09:07:27 -07:00
Frank Praznik
28721e3cd2 test: Fix a window parenting bug in testmodal
(cherry picked from commit 390fe65323)
2025-06-18 09:27:03 -04:00
Frank Praznik
9d9845d063 video: Explicitly disallow setting the parent of a window to itself
Doing so causes a cycle in the window hierarchy tree graph, which leads to infinite recursion when destroying the windows.

(cherry picked from commit ca9b7c8ea3)
2025-06-18 09:27:03 -04:00
ceski
a96dc76831 Read Switch controller gyro/accel sensitivity coeffs (SDL3)
These vary by controller, so using the stored values should improve the accuracy of the sensor data.

(cherry picked from commit 558a89fdb6)
2025-06-13 12:18:43 -07:00
e4m2
ad8e517227 Tweak Vulkan include guard check and 64-bit platform defines (#13210)
(cherry picked from commit c5b1341757)
2025-06-12 09:32:32 -07:00
Sam Lantinga
8d578d590f Fixed replacing existing specific gamepad mappings
If the first mapping we see doesn't have a CRC, continue looking for another exact CRC match.

Fixes testautomation --filter TestVirtualJoystick

(cherry picked from commit 5826966873)
2025-06-06 09:55:04 -07:00
Sam Lantinga
6b4a211374 Added support for the ZEROPLUS P4 Wired Gamepad
(cherry picked from commit f90a21483c)
2025-06-06 09:27:17 -07:00
Sam Lantinga
55b023c961 Remove the CRC from automatically generated gamepad mappings
Fixes https://github.com/libsdl-org/SDL/issues/13127

(cherry picked from commit 638acdc02a)
2025-06-06 09:25:19 -07:00
Frank Praznik
e2d0fe3e2f x11: Resize fixed-size windows after mapping on xmonad
XMonad ignores size hints and shrinks the client area to overlay borders on fixed-size windows, even if no borders were requested, resulting in the window client area being smaller than requested. Calling XResizeWindow after mapping seems to fix it, even though resizing fixed-size windows in this manner doesn't work on any other window manager.

(cherry picked from commit 45eb6310a8)
2025-06-06 11:35:56 -04:00
Frank Praznik
6b56ff7a97 win32: Ensure that text input is initially disabled when creating a window
Windows seems to implicitly enable IME text input on windows created while an IME is active, which causes the IME suggestion window to pop up when keys are pressed, even if a client never explicitly enabled it. Ensure that IME support is initially disabled on new windows; SDL will enable it at a later time, if required.

(cherry picked from commit 22fa45b3c1)
2025-06-05 12:21:49 -04:00
Ethan Lee
67f796ebde gdk: Ignore focus loss events caused by text input showing the OSK 2025-06-04 09:41:06 -04:00
Sam Lantinga
06da7490fc Added support for the NACON Revolution X Unlimited controller on macOS
This adds support for the controller in Bluetooth mode.

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

(cherry picked from commit 6622f4e1ea)
2025-06-03 15:08:11 -07:00
Sam Lantinga
af83c442d3 Fixed input from the MayFlash GameCube adapter with version 7 firmware
(cherry picked from commit 7457857304)
2025-06-03 11:14:09 -07:00
Sam Lantinga
d726e98596 Updated to version 3.2.17 for development 2025-06-02 15:57:36 -07:00
Caleb Cornett
c9a6709bd2 gpu: Add BC2_RGBA_UNORM_SRGB to GetBlockWidth/Height functions 2025-06-02 13:53:42 -07:00
Evan Hemsley
25816bea41 GPU: Binding validation and prevent null dereference if expected binding is missing (#13164) 2025-06-02 13:40:40 -07:00
Sam Lantinga
e0f6e96da0 Use HEAPU8.set rather than Module.HEAPU8.set (thanks @sbc100!)
The Module object is the external interface to the application, internal symbols like HEAPU8 don't need to be exported to be used and usage should not be prefixed with Module.

Fixes https://github.com/libsdl-org/SDL/issues/13156
Closes https://github.com/libsdl-org/SDL/pull/13157

(cherry picked from commit cf6c42e6e6)
2025-06-02 09:48:55 -07:00
Sam Lantinga
57de46ae7e Mark gamepads as invalid if they can't be opened
Fixes https://github.com/libsdl-org/SDL/issues/13129

(cherry picked from commit 4b0f48c4cf)
2025-06-02 09:25:10 -07:00
Sam Lantinga
59693c8996 Updated to version 3.2.16 for release 2025-06-01 14:37:23 -07:00
Ryan C. Gordon
f0efffc093 x11: Be a little less aggressive with Xinput2IsInitialized checks.
Just in case this ever get deinitialized sooner, we'd still like to SDL_free()
things on shutdown, etc.

Reference PR #13148.

(cherry picked from commit 9e0d9f30a7)
2025-06-01 10:15:54 -04:00
Mason Remaley
1b41cd759c Checks if xinput is loaded before trying to call xinput functions
(cherry picked from commit 57b6e6c7f9)
2025-06-01 10:15:47 -04:00
Ryan C. Gordon
d42a1402e8 audio: corrected comment about device format minimums.
(cherry picked from commit ac3ab026fe)
2025-06-01 03:01:47 -04:00
Ryan C. Gordon
5c44678d55 audio: Opened device spec must be >= simple minimums, not device's defaults.
Fixes #13159.

(cherry picked from commit 83cc3bc234)
2025-06-01 02:58:41 -04:00
Ryan C. Gordon
0638fd58ce pulseaudio: Request more recording data per-fragment.
This seems to help some devices that can't keep up with smaller fragment sizes
for whatever reason.

Fixes #13110.

(cherry picked from commit 14a4ae521a)
2025-06-01 02:48:49 -04:00
Ryan C. Gordon
cb662b6730 cocoa: add explicit tracking areas to the window.
This makes sure we get reliable mouse enter/exit events from the system on
older macOS releases.

Newer releases don't have this problem--my assumption is that Cocoa has a
more aggressive default tracking area installed for some newer UI feature.

For 3.2.16, we'll use the explicit tracking area on older macOSes only, but
I'll remove that check in revision control for newer OSes and see what
happens.

Fixes #12725.

(cherry picked from commit f61d956a04)
2025-05-31 14:45:43 -04:00
Caleb Heuer
e874c7515e Pass text input rect to steam deck keyboard invocation
(cherry picked from commit 51dfca813b)
2025-05-30 09:54:53 -07:00
Ethan Lee
2ba797576b storage: Declare a private bootstrap for NDA user storage 2025-05-30 12:15:43 -04:00
Sam Lantinga
180b454d61 kmsdrm: fixed creating GBM surfaces on NVIDIA cards
(cherry picked from commit fc1c0618de)
2025-05-29 11:20:44 -07:00
DracoRooks
6ce7ae77b1 Update SDL_pixels.h
Added an opening bracket in line 520, in the comment block of SDL_PixelFormat. Simple addition to the readability of documentation.

(cherry picked from commit 03a6d98aee)
2025-05-29 11:03:54 -07:00
Sam Lantinga
abbaf95cf0 Added macros to push/pop error messages while cleaning up
(cherry picked from commit 885e611f3c)
2025-05-29 10:54:46 -07:00
Sam Lantinga
1081b70951 Fixed typos
(cherry picked from commit 61d105247e)
2025-05-29 10:54:46 -07:00
Sam Lantinga
4f51f956ad Updated SDL_StretchSurface() documentation
Fixes https://github.com/libsdl-org/SDL/issues/13135

(cherry picked from commit 7db0ac7380)
2025-05-29 09:09:29 -07:00
Sam Lantinga
b076f4b590 Removed obsolete documentation
(cherry picked from commit 737b9e117d)
2025-05-28 15:57:23 -07:00
Sam Lantinga
91180f8cb4 Disable SDL_HINT_JOYSTICK_RAWINPUT by default
Windows can get in a state when it stops reporting raw input events for game controllers until reboot.

The downside of this change is that we lose support for trigger rumble and are limited to 4 controllers again, but if that's important for your application you can use SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, true) to enable this functionality.

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

(cherry picked from commit aa870d511e)
2025-05-27 09:51:58 -07:00
Ethan Lee
99aa859362 gpu: Xbox buildfix 2025-05-27 12:42:46 -04:00
Frank Praznik
31267feb03 wayland: Use raw timestamps to calculate the elapsed repeat time on a key up event
Using processed timestamps can result in anomalies that cause excessive repeat events, and hard caps can cause issues.

In the key event handler, use the raw elapsed time to calculate any remaining repeat events to avoid the artifacts that can result from using processed timestamps.

The Wayland key repeat rate ranges from 0 to 1000 per second, so millisecond resolution doesn't lose any precision.

(cherry picked from commit e3d44cdd51)
2025-05-27 11:18:56 -04:00
Sander Ledegen
6a5bac72cb PSP fullscreen is the only mode (#13125)
(cherry picked from commit 9b025e3cab)
2025-05-26 10:32:13 -07:00
Ozkan Sezer
2ed5062950 SDL_video.c: remove two stray line continuation chars .
(cherry picked from commit 25db127450)
2025-05-26 01:45:50 +03:00
Christian Kündig
0b0b02c5a1 emscripten: Proxy Emscripten_GetSystemTheme and EMSCRIPTENAUDIO_OpenDevice to the main thread.
(cherry picked from commit 168d1a9253)
2025-05-25 13:50:19 -07:00
mattbsage
28c71368a1 Clean up INTERFACE_COMPILE_OPTIONS
The extra text causes Meson/Ninja builds to fail as headers are not found.

(cherry picked from commit f62572344f)
2025-05-24 19:13:41 -07:00
Frank Praznik
25bd4285ab x11: Assume the window was mapped after showing
Not all window managers send a MapNotify or PropertyNotify event when the window is shown, so assume that it was mapped and set the flag accordingly.

(cherry picked from commit b70919ecd9)
2025-05-24 10:00:43 -04:00
Frank Praznik
180171cad6 x11: Always send fullscreen dimensions except on XWayland
More non-compositing window managers than just openbox seem to need this, so always force sending the window position and dimensions when entering/leaving fullscreen. If they are wrong, they will be immediately overwritten by the correct dimensions from a subsequent ConfigureNotify event.

This is disabled on XWayland, as it seems to cause hitching on some compositors.

(cherry picked from commit 0657ece55d)
2025-05-24 10:00:43 -04:00
Sam Lantinga
bc3eeecf7f Set the initial axis values for HIDAPI and XInput controllers
Fixes https://github.com/libsdl-org/SDL/issues/13020

(cherry picked from commit 1f6b5c681d)
2025-05-23 12:09:58 -07:00
Frank Praznik
9178d14519 x11: Include the XTest header when needed
Fixes building when statically linking.

(cherry picked from commit fdc4f8fa39)
2025-05-23 13:12:47 -04:00
Ivan Epifanov
6cd35f5b72 VITA: support only fullscreen windows. Fixes #13079
(cherry picked from commit 2b4d61e4a6)
2025-05-23 08:45:49 -07:00
kyle-sylvestre
72d5eb0ecb fix error handling in WideCharToMultiByte
(cherry picked from commit ead32c706d)
2025-05-22 15:25:58 -07:00
kyle-sylvestre
5cf924420d bugfix advancing UTF-8 length in UTF-16 string
(cherry picked from commit 8ddb074889)
2025-05-22 15:25:58 -07:00
Ryan C. Gordon
290574e6f6 stdinc: Corrected documentation for SDL_atan2 and SDL_atan2f.
Fixes #13099.

(cherry picked from commit 8d9a4fe843)
2025-05-22 09:52:51 -04:00
Frank Praznik
d9db975b4b wayland: Use SDL_memcpy instead of SDL_copyp to copy the repeated text string
SDL_copyp is not intended to copy arrays. Use SDL_memcpy with the explicit size instead.

(cherry picked from commit abcfa1b7de)
2025-05-21 20:39:03 -04:00
Matteo Hausner
e5c0e5efa7 Fix #13083 segfault in SDL_RemoveTrayEntry() for submenu entries
Use `g_object_ref_sink()` in `SDL_CreateTraySubmenu()` as introduced with
3be67ced64 for the top-level menu.

(cherry picked from commit 22828d5f2a)
2025-05-21 13:32:47 -07:00
Sam Lantinga
26a1aae098 Fixed the Bluetooth flag for the combined Joy-Con controller
(cherry picked from commit 264eb8d440)
2025-05-21 13:30:30 -07:00
Frank Praznik
ab114490fc wayland: Cap the max key repeat elapsed time
Cap the elapsed time to something sane in case the compositor sends a bad timestamp, which can result it in it looking like the key has been pressed for a *very* long time, bringing everything to a halt while it tries to enqueue all the repeat events.

(cherry picked from commit 05f779f61e)
2025-05-21 12:20:31 -04:00
kyle-sylvestre
9546c54286 use SDL style - else on same line as closing brace
(cherry picked from commit b8e055ce64)
2025-05-20 17:13:47 -07:00
kyle-sylvestre
4d3cdb70b5 get preferred locales on android
(cherry picked from commit 8e22194217)
2025-05-20 17:13:47 -07:00
Anthony Fisher
a66816a72f gpu/d3d12: Acknowledge that we've bound vertex buffers (#13088) 2025-05-20 16:34:27 -04:00
Francisco Javier Trujillo Mata
c925f72562 Fix wrong callback type
(cherry picked from commit c89357bf60)
2025-05-20 11:11:01 -07:00
Logan
ef97329f41 GPU: Update D3D12 to create multisample textures with default MSAA alignment
(cherry picked from commit f4942b3eae)
2025-05-20 11:07:54 -07:00
Frank Praznik
195f709eda wayland: Set the text input cursor rect properly
The text input cursor should reflect the cursor position, not the entire text input rect. Set it correctly so that IME chooser dialogs appear in the correct location.

(cherry-picked from commit c7549eb0b6)
2025-05-20 13:42:21 -04:00
cosmonaut
eb57d94ec5 GPU: Add missing compute-writeable texture formats 2025-05-19 18:11:06 -07:00
Sam Lantinga
d6212ae839 Fixed rare crash trying to interrupt SDL_WaitEvent()
Fixes https://github.com/libsdl-org/SDL/issues/12797

(cherry picked from commit 992e4c59bd)
2025-05-19 14:16:25 -07:00
Frank Praznik
b494897b3d wayland: Don't add the nanosecond timestamp offset to the pre-conversion millisecond value
(cherry picked from commit 6c61a94a4b)
2025-05-19 14:00:12 -04:00
Sam Lantinga
559d4415eb Fixed touch not being delivered as mouse events by default on Vita
Closes https://github.com/libsdl-org/SDL/pull/13070

(cherry picked from commit 25f2376e79)
2025-05-19 08:33:28 -07:00
Joe [ReRezd]
49e9134774 Fix: GameCube controller adapter hotplug not working
SDL_PrivateJoystickAdded was called before setting the InstanceId in the adapters ctx->joysticks array.  This would eventually broadcast the SDL_EVENT_JOYSTICK_ADDED event with the new InstanceId, if your program listens for the added events and opens joysticks at that point it would always fail because there would be no matching InstanceId in the ctx->joysticks array.

(cherry picked from commit afd1e51023)
2025-05-19 08:25:16 -07:00
Logan
9571b0ece8 GPU: Update to set supported shader formats inside CreateDevice
(cherry picked from commit 8289656a4e)
2025-05-18 18:33:07 -07:00
danginsburg
b55cfaf90b Fix #13057 - fixes bug with NSEventTypeMouseMoved having a NULL window causing us to suppress future mouse move events because the window was considered out of focus.
(cherry picked from commit 968222e74f)
2025-05-16 17:07:49 -07:00
ScolderCreations
509168856f Fix reference to nonexistent "README-3ds.md"
(cherry picked from commit d16371b923)
2025-05-15 11:23:17 -07:00
Stéphane GINIER
24fa2722c3 MacOS: fix cocoa clipboard text
Adjust Cocoa_SetClipboardData so that SetClipboardText text can be pasted outside SDL

(cherry picked from commit 945eb6dc87)
2025-05-15 10:54:15 -07:00
Evan Hemsley
142700f909 GPU: Check that a texture format is valid for compute writes (#13044) 2025-05-14 16:25:24 -07:00
Evan Hemsley
f3611681df GPU: Always return NULL if beginning a pass fails an assert check 2025-05-14 15:23:57 -07:00
Sam Lantinga
7f0a5d6a10 Updated to version 3.2.15 for development 2025-05-14 13:08:44 -07:00
cosmonaut
2001cc15d5 GPU: Debug mode layer and level index checks 2025-05-14 12:25:18 -07:00
239 changed files with 4662 additions and 2160 deletions

View File

@@ -20,7 +20,6 @@ class AppleArch(Enum):
class MsvcArch(Enum):
X86 = "x86"
X64 = "x64"
Arm32 = "arm"
Arm64 = "arm64"
@@ -31,7 +30,9 @@ class JobOs(Enum):
Ubuntu22_04 = "ubuntu-22.04"
Ubuntu24_04 = "ubuntu-24.04"
Ubuntu24_04_arm = "ubuntu-24.04-arm"
Macos13 = "macos-13"
Macos14 = "macos-14" # macOS Sonoma (2023)
Macos15 = "macos-15" # macOS Sequoia (2024)
Macos26 = "macos-26" # macOS Tahoe (2025)
class SdlPlatform(Enum):
@@ -54,6 +55,7 @@ class SdlPlatform(Enum):
Riscos = "riscos"
FreeBSD = "freebsd"
NetBSD = "netbsd"
OpenBSD = "openbsd"
class Msys2Platform(Enum):
@@ -108,7 +110,6 @@ JOB_SPECS = {
"msvc-x86": JobSpec(name="Windows (MSVC, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, msvc_project="VisualC/SDL.sln", ),
"msvc-clang-x64": JobSpec(name="Windows (MSVC, clang-cl x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x64", msvc_arch=MsvcArch.X64, clang_cl=True, ),
"msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ),
"msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ),
"msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ),
"msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ),
"ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", ),
@@ -116,7 +117,7 @@ JOB_SPECS = {
"steamrt-sniper": JobSpec(name="Steam Linux Runtime (Sniper)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-slrsniper", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta", ),
"ubuntu-intel-icx": JobSpec(name="Ubuntu 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ),
"ubuntu-intel-icc": JobSpec(name="Ubuntu 22.04 (Intel Compiler)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-icc", intel=IntelCompiler.Icc, ),
"macos-framework-x64": JobSpec(name="MacOS (Framework) (x64)", os=JobOs.Macos13, platform=SdlPlatform.MacOS, artifact="SDL-macos-framework", apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, xcode=True, ),
"macos-framework-x64": JobSpec(name="MacOS (Framework) (x64)", os=JobOs.Macos14, platform=SdlPlatform.MacOS, artifact="SDL-macos-framework", apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, xcode=True, ),
"macos-framework-arm64": JobSpec(name="MacOS (Framework) (arm64)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact=None, apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, ),
"macos-gnu-arm64": JobSpec(name="MacOS (GNU prefix)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact="SDL-macos-arm64-gnu", apple_framework=False, apple_archs={AppleArch.Aarch64, }, ),
"ios": JobSpec(name="iOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Ios, artifact="SDL-ios-arm64", xcode=True, ),
@@ -137,6 +138,7 @@ JOB_SPECS = {
"vita-pvr": JobSpec(name="Sony PlayStation Vita (GLES w/ PVR_PSP2)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Vita, artifact="SDL-vita-pvr", container="vitasdk/vitasdk:latest", vita_gles=VitaGLES.Pvr, ),
"riscos": JobSpec(name="RISC OS", os=JobOs.UbuntuLatest, platform=SdlPlatform.Riscos, artifact="SDL-riscos", container="riscosdotinfo/riscos-gccsdk-4.7:latest", ),
"netbsd": JobSpec(name="NetBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.NetBSD, artifact="SDL-netbsd-x64", ),
"openbsd": JobSpec(name="OpenBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.OpenBSD, artifact="SDL-openbsd-x64", ),
"freebsd": JobSpec(name="FreeBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.FreeBSD, artifact="SDL-freebsd-x64", ),
}
@@ -174,6 +176,7 @@ class JobDetails:
brew_packages: list[str] = dataclasses.field(default_factory=list)
cmake_toolchain_file: str = ""
cmake_arguments: list[str] = dataclasses.field(default_factory=list)
cmake_generator: str = "Ninja"
cmake_build_arguments: list[str] = dataclasses.field(default_factory=list)
clang_tidy: bool = True
cppflags: list[str] = dataclasses.field(default_factory=list)
@@ -222,6 +225,7 @@ class JobDetails:
check_sources: bool = False
setup_python: bool = False
pypi_packages: list[str] = dataclasses.field(default_factory=list)
binutils_strings: str = "strings"
def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]:
data = {
@@ -255,6 +259,7 @@ class JobDetails:
"cflags": my_shlex_join(self.cppflags + self.cflags),
"cxxflags": my_shlex_join(self.cppflags + self.cxxflags),
"ldflags": my_shlex_join(self.ldflags),
"cmake-generator": self.cmake_generator,
"cmake-toolchain-file": self.cmake_toolchain_file,
"clang-tidy": self.clang_tidy,
"cmake-arguments": my_shlex_join(self.cmake_arguments),
@@ -289,6 +294,7 @@ class JobDetails:
"check-sources": self.check_sources,
"setup-python": self.setup_python,
"pypi-packages": my_shlex_join(self.pypi_packages),
"binutils-strings": self.binutils_strings,
}
return {k: v for k, v in data.items() if v != ""}
@@ -403,10 +409,6 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.msvc_vcvars_arch = "x64_x86"
case MsvcArch.X64:
job.msvc_vcvars_arch = "x64"
case MsvcArch.Arm32:
job.msvc_vcvars_arch = "x64_arm"
job.msvc_vcvars_sdk = "10.0.22621.0" # 10.0.26100.0 dropped ARM32 um and ucrt libraries
job.run_tests = False
case MsvcArch.Arm64:
job.msvc_vcvars_arch = "x64_arm64"
job.run_tests = False
@@ -514,9 +516,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.ccache = True
job.apt_packages = []
job.brew_packages.extend((
"ccache",
"ninja",
))
if job.ccache:
job.brew_packages.append("ccache")
if job.clang_tidy:
job.brew_packages.append("llvm")
if spec.xcode:
@@ -550,6 +553,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
"testmultiaudio-apk",
"testsprite-apk",
]
# -fPIC is required after updating NDK from 21 to 28
job.cflags.append("-fPIC")
job.cxxflags.append("-fPIC")
case SdlPlatform.Emscripten:
job.clang_tidy = False # clang-tidy does not understand -gsource-map
job.shared = False
@@ -675,13 +682,16 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.shared_lib = SharedLibType.SO_0
job.static_lib = StaticLibType.A
case SdlPlatform.N3ds:
job.ccache = True
job.cmake_generator = "Unix Makefiles"
job.cmake_build_arguments.append("-j$(nproc)")
job.ccache = False
job.shared = False
job.apt_packages = ["ccache", "ninja-build", "binutils"]
job.apt_packages = []
job.clang_tidy = False
job.run_tests = False
job.cc_from_cmake = True
job.cmake_toolchain_file = "${DEVKITPRO}/cmake/3DS.cmake"
job.binutils_strings = "/opt/devkitpro/devkitARM/bin/arm-none-eabi-strings"
job.static_lib = StaticLibType.A
case SdlPlatform.Msys2:
job.ccache = True
@@ -713,7 +723,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
))
job.cmake_toolchain_file = "/home/riscos/env/toolchain-riscos.cmake"
job.static_lib = StaticLibType.A
case SdlPlatform.FreeBSD | SdlPlatform.NetBSD:
case SdlPlatform.FreeBSD | SdlPlatform.NetBSD | SdlPlatform.OpenBSD:
job.cpactions = True
job.no_cmake = True
job.run_tests = False
@@ -723,7 +733,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
match spec.platform:
case SdlPlatform.FreeBSD:
job.cpactions_os = "freebsd"
job.cpactions_version = "14.2"
job.cpactions_version = "14.3"
job.cpactions_arch = "x86-64"
job.cpactions_setup_cmd = "sudo pkg update"
job.cpactions_install_cmd = "sudo pkg install -y cmake ninja pkgconf libXcursor libXext libXinerama libXi libXfixes libXrandr libXScrnSaver libXxf86vm wayland wayland-protocols libxkbcommon mesa-libs libglvnd evdev-proto libinotify alsa-lib jackit pipewire pulseaudio sndio dbus zh-fcitx ibus libudev-devd"
@@ -737,6 +747,12 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.cpactions_arch = "x86-64"
job.cpactions_setup_cmd = "export PATH=\"/usr/pkg/sbin:/usr/pkg/bin:/sbin:$PATH\"; export PKG_CONFIG_PATH=\"/usr/pkg/lib/pkgconfig\";export PKG_PATH=\"https://cdn.netBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r|cut -f \"1 2\" -d.)/All/\";echo \"PKG_PATH=$PKG_PATH\";echo \"uname -a -> \"$(uname -a)\"\";sudo -E sysctl -w security.pax.aslr.enabled=0;sudo -E sysctl -w security.pax.aslr.global=0;sudo -E pkgin clean;sudo -E pkgin update"
job.cpactions_install_cmd = "sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1"
case SdlPlatform.OpenBSD:
job.cpactions_os = "openbsd"
job.cpactions_version = "7.7"
job.cpactions_arch = "x86-64"
job.cpactions_setup_cmd = "sudo pkg_add -u"
job.cpactions_install_cmd = "sudo pkg_add cmake ninja pkgconf wayland wayland-protocols libxkbcommon libinotify pulseaudio dbus ibus"
case _:
raise ValueError(f"Unsupported platform={spec.platform}")

View File

@@ -75,8 +75,8 @@ jobs:
if: ${{ matrix.platform.android-ndk }}
id: setup-ndk
with:
local-cache: true
ndk-version: r21e
local-cache: false
ndk-version: r28c
- name: 'Configure Android NDK variables'
if: ${{ matrix.platform.android-ndk }}
shell: sh
@@ -201,7 +201,7 @@ jobs:
#shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -GNinja \
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -G "${{ matrix.platform.cmake-generator }}" \
-Wdeprecated -Wdev -Werror \
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-DSDL_WERROR=${{ matrix.platform.werror }} \
@@ -232,9 +232,9 @@ jobs:
run: |
echo "This should show us the SDL_REVISION"
echo "Shared library:"
${{ (matrix.platform.shared-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
${{ (matrix.platform.shared-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
echo "Static library:"
${{ (matrix.platform.static-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
${{ (matrix.platform.static-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
- name: 'Run build-time tests (CMake)'
id: tests
if: ${{ !matrix.platform.no-cmake && matrix.platform.run-tests }}
@@ -321,7 +321,7 @@ jobs:
- name: 'Build (cross-platform-actions, BSD)'
id: cpactions
if: ${{ matrix.platform.cpactions }}
uses: cross-platform-actions/action@v0.27.0
uses: cross-platform-actions/action@v0.29.0
with:
operating_system: '${{ matrix.platform.cpactions-os }}'
architecture: '${{ matrix.platform.cpactions-arch }}'
@@ -406,6 +406,14 @@ jobs:
build-scripts/test-versioning.sh
python build-scripts/check_android_jni.py
python build-scripts/check_stdlib_usage.py
- name: 'Verify alignment of Android test apks'
if: ${{ matrix.platform.android-ndk && !matrix.platform.no-cmake }}
run: |
find ./ -iname '*.apk' | xargs -L1 ./build-scripts/check_elf_alignment.sh
- name: 'Verify alignment of Android .so files'
if: ${{ matrix.platform.android-ndk && !matrix.platform.no-cmake }}
run: |
find ./ -iname '*.so' | xargs -L1 ./build-scripts/check_elf_alignment.sh
- name: 'Upload binary package'
uses: actions/upload-artifact@v4
if: ${{ always() && matrix.platform.artifact != '' && (steps.package.outcome == 'success' || steps.cpactions.outcome == 'success') && (matrix.platform.enable-artifacts || steps.tests.outcome == 'failure') }}
@@ -428,4 +436,4 @@ jobs:
with:
if-no-files-found: error
name: '${{ matrix.platform.artifact }}-apks'
path: build/test/*.apk
path: build/test/*.apk

View File

@@ -95,9 +95,17 @@ jobs:
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
- name: 'CMake (configure + build + tests + examples)'
run: |
set -e
cmake -S ${{ steps.tar.outputs.path }} -B /tmp/build -DSDL_TEST_LIBRARY=TRUE -DSDL_TESTS=TRUE -DSDL_EXAMPLES=TRUE
cmake --build /tmp/build --verbose
ctest --test-dir /tmp/build --no-tests=error --output-on-failure
- name: 'Verify SDL_REVISION contains SDL-'
run: |
set -e
if test "x$(strings /tmp/build/libSDL3.so.0 | grep SDL- | grep -v SDL-tray | wc -l)" != x1; then
echo "SDL- string not found: must be present in SDL_REVISION"
exit 1
fi
dmg:
needs: [src]
@@ -204,10 +212,22 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_ios
cmake --build build_ios --config Release --verbose
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64" \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_ios2
cmake --build build_ios2 --config Release --verbose
- name: 'CMake (configure + build) tvOS'
run: |
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
@@ -217,10 +237,22 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_tvos
cmake --build build_tvos --config Release --verbose
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64" \
-DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_tvos2
cmake --build build_tvos2 --config Release --verbose
- name: 'CMake (configure + build) iOS simulator'
run: |
sysroot=$(xcodebuild -version -sdk iphonesimulator Path)
@@ -237,6 +269,19 @@ jobs:
-Werror=dev \
-B build_ios_simulator
cmake --build build_ios_simulator --config Release --verbose
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64_x86_64-simulator" \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_SYSROOT="${sysroot}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_ios_simulator2
cmake --build build_ios_simulator2 --config Release --verbose
- name: 'CMake (configure + build) tvOS simulator'
run: |
sysroot=$(xcodebuild -version -sdk appletvsimulator Path)
@@ -254,9 +299,22 @@ jobs:
-B build_tvos_simulator
cmake --build build_tvos_simulator --config Release --verbose
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64_x86_64-simulator" \
-DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_SYSROOT="${sysroot}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_tvos_simulator2
cmake --build build_tvos_simulator2 --config Release --verbose
msvc:
needs: [src]
runs-on: windows-2019
runs-on: windows-2025
outputs:
VC-x86: ${{ steps.releaser.outputs.VC-x86 }}
VC-x64: ${{ steps.releaser.outputs.VC-x64 }}
@@ -532,10 +590,11 @@ jobs:
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Setup Android NDK'
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
local-cache: true
ndk-version: r21e
local-cache: false
ndk-version: r28c
- name: 'Setup Java JDK'
uses: actions/setup-java@v4
with:
@@ -561,6 +620,8 @@ jobs:
run: |
python build-scripts/build-release.py \
--actions android \
--android-api 21 \
--android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
--commit ${{ inputs.commit }} \
--root "${{ steps.tar.outputs.path }}" \
--github \
@@ -607,8 +668,14 @@ jobs:
python "${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" -o /tmp/SDL3-android
echo "prefix=/tmp/SDL3-android" >>$GITHUB_OUTPUT
echo "sdl3-aar=/tmp/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" >>$GITHUB_OUTPUT
- name: 'Verify alignment of libSDL3.so (arm64-v8a/x86_64)'
run: |
set -e
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/arm64-v8a/libSDL3.so
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/x86_64/libSDL3.so
- name: 'CMake (configure + build) x86, x64, arm32, arm64'
run: |
set -e
android_abis="x86 x86_64 armeabi-v7a arm64-v8a"
for android_abi in ${android_abis}; do
echo "Configuring ${android_abi}..."

View File

@@ -5,7 +5,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
endif()
# See docs/release_checklist.md
project(SDL3 LANGUAGES C VERSION "3.2.14")
project(SDL3 LANGUAGES C VERSION "3.2.31")
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(SDL3_MAINPROJECT ON)
@@ -46,6 +46,7 @@ endif()
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLanguage)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
@@ -79,6 +80,12 @@ include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")
SDL_DetectCompiler()
SDL_DetectTargetCPUArchitectures(SDL_CPUS)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES _num_arches)
if(_num_arches GREATER 1)
set(APPLE_MULTIARCH TRUE)
endif()
endif()
# Increment this if there is an incompatible change - but if that happens,
# we should rename the library from SDL3 to SDL4, at which point this would
@@ -183,26 +190,6 @@ if(MSVC)
set(SDL_RELOCATABLE_DEFAULT ON)
endif()
if(MSVC)
if(NOT SDL_LIBC)
# Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
endif()
if(MSVC_CLANG)
# clang-cl treats /W4 as '-Wall -Wextra' -- we don't need -Wextra
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/W4" "/W3" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
endif()
endif()
set(SDL_SHARED_DEFAULT ON)
set(SDL_STATIC_DEFAULT ON)
@@ -370,7 +357,7 @@ dep_option(SDL_WASAPI "Use the Windows WASAPI audio driver" ON "WIN
dep_option(SDL_RENDER_D3D "Enable the Direct3D 9 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_D3D11 "Enable the Direct3D 11 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF)
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;APPLE" OFF)
dep_option(SDL_RENDER_GPU "Enable the SDL_GPU render driver" ON "SDL_RENDER;SDL_GPU" OFF)
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
@@ -421,6 +408,29 @@ if(SDL_PRESEED)
SDL_Preseed_CMakeCache()
endif()
if(MSVC)
if(NOT SDL_LIBC)
# Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
set(CMAKE_MSVC_RUNTIME_CHECKS "")
endif()
if(MSVC_CLANG)
# clang-cl treats /W4 as '-Wall -Wextra' -- we don't need -Wextra
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/W4" "/W3" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
endif()
endif()
if(SDL_SHARED)
add_library(SDL3-shared SHARED)
add_library(SDL3::SDL3-shared ALIAS SDL3-shared)
@@ -606,12 +616,7 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC)
endif()
endif()
if(APPLE)
check_linker_flag(C "-Wl,-undefined,error" LINKER_SUPPORTS_WL_UNDEFINED_ERROR)
if(LINKER_SUPPORTS_WL_UNDEFINED_ERROR)
sdl_shared_link_options("-Wl,-undefined,error")
endif()
elseif(NOT OPENBSD)
if(NOT OPENBSD)
cmake_push_check_state()
check_linker_flag(C "-Wl,--no-undefined" LINKER_SUPPORTS_WL_NO_UNDEFINED)
#FIXME: originally this if had an additional "AND NOT (USE_CLANG AND WINDOWS)"
@@ -634,6 +639,11 @@ if(MSVC)
# Mark SDL3.dll as compatible with Control-flow Enforcement Technology (CET)
sdl_shared_link_options("-CETCOMPAT")
endif()
# for VS >= 17.14 targeting ARM64: inline the Interlocked funcs
if(MSVC_VERSION GREATER 1943 AND SDL_CPU_ARM64 AND NOT SDL_LIBC)
sdl_compile_options(PRIVATE "/forceInterlockedFunctions-")
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
@@ -650,7 +660,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -mmmx")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <mmintrin.h>
void ints_add(int *dest, int *a, int *b, unsigned size) {
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
@@ -660,7 +670,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char *argv[]) {
ints_add((int*)0, (int*)0, (int*)0, 0);
return 0;
}" COMPILER_SUPPORTS_MMX)
}]==] COMPILER_SUPPORTS_MMX)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_MMX)
set(HAVE_MMX TRUE)
@@ -671,7 +681,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -msse")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <xmmintrin.h>
void floats_add(float *dest, float *a, float *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
@@ -681,7 +691,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
floats_add((float*)0, (float*)0, (float*)0, 0);
return 0;
}" COMPILER_SUPPORTS_SSE)
}]==] COMPILER_SUPPORTS_SSE)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_SSE)
set(HAVE_SSE TRUE)
@@ -692,7 +702,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -msse2")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <emmintrin.h>
void doubles_add(double *dest, double *a, double *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
@@ -702,7 +712,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
doubles_add((double*)0, (double*)0, (double*)0, 0);
return 0;
}" COMPILER_SUPPORTS_SSE2)
}]==] COMPILER_SUPPORTS_SSE2)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_SSE2)
set(HAVE_SSE2 TRUE)
@@ -713,7 +723,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -msse3")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <pmmintrin.h>
void ints_add(int *dest, int *a, int *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
@@ -723,7 +733,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
ints_add((int*)0, (int*)0, (int*)0, 0);
return 0;
}" COMPILER_SUPPORTS_SSE3)
}]==] COMPILER_SUPPORTS_SSE3)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_SSE3)
set(HAVE_SSE3 TRUE)
@@ -734,7 +744,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.1")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <smmintrin.h>
void ints_mul(int *dest, int *a, int *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
@@ -744,7 +754,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
ints_mul((int*)0, (int*)0, (int*)0, 0);
return 0;
}" COMPILER_SUPPORTS_SSE4_1)
}]==] COMPILER_SUPPORTS_SSE4_1)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_SSE4_1)
set(HAVE_SSE4_1 TRUE)
@@ -753,21 +763,16 @@ if(SDL_ASSEMBLY)
if(SDL_SSE4_2)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2 -mcrc32")
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <nmmintrin.h>
unsigned calc_crc32c(const char *text, unsigned len) {
unsigned crc32c = ~0;
for (; len >= 4; len -= 4, text += 4) {
crc32c = (unsigned)_mm_crc32_u32(crc32c, *(unsigned*)text);
}
return crc32c;
}
__m128i bitmask;
char data[16];
int main(int argc, char **argv) {
calc_crc32c(\"SDL_SSE4\",8);
bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), _mm_loadu_si128((void*)data));
return 0;
}" COMPILER_SUPPORTS_SSE4_2)
}]==] COMPILER_SUPPORTS_SSE4_2)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_SSE4_2)
set(HAVE_SSE4_2 TRUE)
@@ -778,7 +783,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <immintrin.h>
void floats_add(float *dest, float *a, float *b, unsigned size) {
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
@@ -788,7 +793,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
floats_add((float*)0, (float*)0, (float*)0, 0);
return 0;
}" COMPILER_SUPPORTS_AVX)
}]==] COMPILER_SUPPORTS_AVX)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_AVX)
set(HAVE_AVX TRUE)
@@ -799,7 +804,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx2")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <immintrin.h>
void ints_add(int *dest, int *a, int *b, unsigned size) {
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
@@ -809,7 +814,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
ints_add((int*)0, (int*)0, (int*)0, 0);
return 0;
}" COMPILER_SUPPORTS_AVX2)
}]==] COMPILER_SUPPORTS_AVX2)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_AVX2)
set(HAVE_AVX2 TRUE)
@@ -820,7 +825,7 @@ if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx512f")
endif()
check_c_source_compiles("
check_x86_source_compiles([==[
#include <immintrin.h>
void floats_add(float *dest, float *a, float *b, unsigned size) {
for (; size >= 16; size -= 16, dest += 16, a += 16, b += 16) {
@@ -830,7 +835,7 @@ if(SDL_ASSEMBLY)
int main(int argc, char **argv) {
floats_add((float*)0, (float*)0, (float*)0, 0);
return 0;
}" COMPILER_SUPPORTS_AVX512F)
}]==] COMPILER_SUPPORTS_AVX512F)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_AVX512F)
set(HAVE_AVX512F TRUE)
@@ -838,18 +843,17 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_ARMNEON)
check_c_source_compiles("
#include <arm_neon.h>
void floats_add(float *dest, float *a, float *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
vst1q_f32(dest, vaddq_f32(vld1q_f32(a), vld1q_f32(b)));
}
check_arm_source_compiles([==[
#include <arm_neon.h>
void floats_add(float *dest, float *a, float *b, unsigned size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
vst1q_f32(dest, vaddq_f32(vld1q_f32(a), vld1q_f32(b)));
}
int main(int argc, char *argv[]) {
floats_add((float*)0, (float*)0, (float*)0, 0);
return 0;
}" COMPILER_SUPPORTS_ARMNEON)
}
int main(int argc, char *argv[]) {
floats_add((float*)0, (float*)0, (float*)0, 0);
return 0;
}]==] COMPILER_SUPPORTS_ARMNEON)
if(COMPILER_SUPPORTS_ARMNEON)
set(HAVE_ARMNEON TRUE)
endif()
@@ -890,7 +894,17 @@ if(SDL_ASSEMBLY)
cmake_pop_check_state()
if(COMPILER_SUPPORTS_LSX AND HAVE_LSXINTRIN_H)
set_property(SOURCE "${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c" APPEND PROPERTY COMPILE_OPTIONS "-mlsx")
set_property(SOURCE
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c"
"${SDL3_SOURCE_DIR}/src/video/SDL_blit_A.c"
"${SDL3_SOURCE_DIR}/src/video/SDL_fillrect.c"
APPEND PROPERTY COMPILE_OPTIONS "-mlsx")
set_property(SOURCE
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c"
"${SDL3_SOURCE_DIR}/src/video/SDL_blit_A.c"
"${SDL3_SOURCE_DIR}/src/video/SDL_fillrect.c"
PROPERTY SKIP_PRECOMPILE_HEADERS 1)
set(HAVE_LSX TRUE)
endif()
endif()
@@ -1052,8 +1066,10 @@ if(SDL_LIBC)
cmake_push_check_state()
if(MSVC)
string(APPEND CMAKE_REQUIRED_FLAGS " -we4244 -WX") # 'conversion' conversion from 'type1' to 'type2', possible loss of data
else()
elseif(HAVE_GCC_WFLOAT_CONVERSION)
string(APPEND CMAKE_REQUIRED_FLAGS " -Wfloat-conversion -Werror")
else()
string(APPEND CMAKE_REQUIRED_FLAGS " -Wconversion -Werror")
endif()
foreach(math_fn isinf isnan)
string(TOUPPER "${math_fn}" MATH_FN)
@@ -1090,7 +1106,10 @@ if(SDL_LIBC)
check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
check_symbol_exists(gethostname "unistd.h" HAVE_GETHOSTNAME)
check_symbol_exists(getpagesize "unistd.h" HAVE_GETPAGESIZE)
check_symbol_exists(getresgid "unistd.h" HAVE_GETRESGID)
check_symbol_exists(getresuid "unistd.h" HAVE_GETRESUID)
check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
check_symbol_exists(sigtimedwait "signal.h" HAVE_SIGTIMEDWAIT)
check_symbol_exists(setjmp "setjmp.h" HAVE_SETJMP)
check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP)
check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R)
@@ -1336,9 +1355,7 @@ if(ANDROID)
set(HAVE_SDL_HAPTIC TRUE)
endif()
if(SDL_HIDAPI)
CheckHIDAPI()
endif()
CheckHIDAPI()
if(SDL_JOYSTICK)
set(SDL_JOYSTICK_ANDROID 1)
@@ -1480,6 +1497,9 @@ if(ANDROID)
endif()
endif()
endif()
if(TARGET SDL3-static)
target_link_options(SDL3-static INTERFACE "-Wl,-u,JNI_OnLoad")
endif()
elseif(EMSCRIPTEN)
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new
@@ -1905,7 +1925,7 @@ elseif(WINDOWS)
target_compile_options(SDL_uclibc PRIVATE $<$<COMPILE_LANGUAGE:C,CXX>:/GS-> $<$<COMPILE_LANGUAGE:C,CXX>:/Gs1048576>)
if(SDL_CPU_X86)
target_compile_options(SDL3-shared PRIVATE "/arch:SSE")
target_compile_options(SDL3-SDL_uclibc PRIVATE "/arch:SSE")
target_compile_options(SDL_uclibc PRIVATE "/arch:SSE")
endif()
endif()
@@ -2954,7 +2974,7 @@ if(WINDOWS)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/process/windows/*.c")
set(SDL_PROCESS_WINDOWS 1)
set(HAVE_SDL_PROCESS TRUE)
else()
elseif(NOT ANDROID)
check_c_source_compiles("
#include <spawn.h>
#include <unistd.h>
@@ -3144,14 +3164,15 @@ endforeach()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt")
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt" revisions)
list(GET revisions 0 revisions_0)
string(STRIP "${revisions_0}" SDL_REVISION)
string(STRIP "${revisions_0}" revisions_0_stripped)
set(SDL_REVISION "SDL-${revisions_0_stripped}")
else()
set(SDL_REVISION "" CACHE STRING "Custom SDL revision (only used when REVISION.txt does not exist)")
endif()
if(NOT SDL_REVISION)
# If SDL_REVISION is not overrided, use git to describe
git_describe(SDL_REVISION_GIT)
set(SDL_REVISION "SDL3-${SDL3_VERSION}-${SDL_REVISION_GIT}")
set(SDL_REVISION "SDL-${SDL3_VERSION}-${SDL_REVISION_GIT}")
endif()
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include-revision/SDL3")
@@ -3460,6 +3481,8 @@ if(SDL_SHARED)
set_property(TARGET SDL3-shared PROPERTY INTERFACE_SDL3_SHARED TRUE)
set_property(TARGET SDL3-shared APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL3-shared PROPERTY INTERFACE_SDL_VERSION "SDL${SDL3_VERSION_MAJOR}")
set_property(TARGET SDL3-shared APPEND PROPERTY EXPORT_PROPERTIES "SDL_FULL_VERSION")
set_property(TARGET SDL3-shared PROPERTY SDL_FULL_VERSION "${PROJECT_VERSION}")
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
target_precompile_headers(SDL3-shared PRIVATE "$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:${PROJECT_SOURCE_DIR}/src/SDL_internal.h>")
endif()
@@ -3484,6 +3507,8 @@ if(SDL_STATIC)
set_property(TARGET SDL3-static PROPERTY INTERFACE_SDL3_SHARED FALSE)
set_property(TARGET SDL3-static APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL3-static PROPERTY INTERFACE_SDL_VERSION "SDL${SDL3_VERSION_MAJOR}")
set_property(TARGET SDL3-static APPEND PROPERTY EXPORT_PROPERTIES "SDL_FULL_VERSION")
set_property(TARGET SDL3-static PROPERTY SDL_FULL_VERSION "${PROJECT_VERSION}")
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
target_precompile_headers(SDL3-static PRIVATE "$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:${PROJECT_SOURCE_DIR}/src/SDL_internal.h>")
endif()

View File

@@ -781,7 +781,6 @@
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />

View File

@@ -108,7 +108,6 @@
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />

View File

@@ -627,7 +627,6 @@
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />

View File

@@ -1460,7 +1460,6 @@
<ClCompile Include="..\..\src\sensor\windows\SDL_windowssensor.c">
<Filter>sensor\windows</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_d3dmath.c">
<Filter>render</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_render.c">

View File

@@ -1,6 +1,17 @@
This is a list of major changes in SDL's version history.
---------------------------------------------------------------------------
3.2.22:
---------------------------------------------------------------------------
* SDL_HINT_JOYSTICK_WGI is disabled by default
---------------------------------------------------------------------------
3.2.16:
---------------------------------------------------------------------------
* SDL_HINT_JOYSTICK_RAWINPUT is disabled by default
---------------------------------------------------------------------------
3.2.10:
---------------------------------------------------------------------------

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.2.14</string>
<string>3.2.31</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>3.2.14</string>
<string>3.2.31</string>
</dict>
</plist>

View File

@@ -292,7 +292,6 @@
A7D8BA2523E2514400DCD162 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FC23E2514000DCD162 /* SDL_drawpoint.c */; };
A7D8BA2B23E2514400DCD162 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FD23E2514000DCD162 /* SDL_blendfillrect.c */; };
A7D8BA3123E2514400DCD162 /* SDL_rotate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8FE23E2514000DCD162 /* SDL_rotate.h */; };
A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */; };
A7D8BA4923E2514400DCD162 /* SDL_render_gles2.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A90423E2514000DCD162 /* SDL_render_gles2.c */; };
A7D8BA4F23E2514400DCD162 /* SDL_shaders_gles2.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A90523E2514000DCD162 /* SDL_shaders_gles2.h */; };
A7D8BA5523E2514400DCD162 /* SDL_gles2funcs.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A90623E2514000DCD162 /* SDL_gles2funcs.h */; };
@@ -869,7 +868,6 @@
A7D8A8FC23E2514000DCD162 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
A7D8A8FD23E2514000DCD162 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
A7D8A8FE23E2514000DCD162 /* SDL_rotate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rotate.h; sourceTree = "<group>"; };
A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_d3dmath.c; sourceTree = "<group>"; };
A7D8A90423E2514000DCD162 /* SDL_render_gles2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gles2.c; sourceTree = "<group>"; };
A7D8A90523E2514000DCD162 /* SDL_shaders_gles2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_gles2.h; sourceTree = "<group>"; };
A7D8A90623E2514000DCD162 /* SDL_gles2funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gles2funcs.h; sourceTree = "<group>"; };
@@ -2135,7 +2133,6 @@
A7D8A90C23E2514000DCD162 /* opengl */,
A7D8A90323E2514000DCD162 /* opengles2 */,
A7D8A8EF23E2514000DCD162 /* software */,
A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */,
A7D8A8DC23E2514000DCD162 /* SDL_d3dmath.h */,
A7D8A8DB23E2514000DCD162 /* SDL_render.c */,
E4F7981D2AD8D86A00669F54 /* SDL_render_unsupported.c */,
@@ -2833,7 +2830,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Build an xcframework with both device and simulator files for all platforms.\n# Adapted from an answer in\n# https://developer.apple.com/forums/thread/666335?answerId=685927022#685927022\n\nif [ \"$XCODE_VERSION_ACTUAL\" -lt 1100 ]\nthen\n echo \"error: Building an xcframework requires Xcode 11 minimum.\"\n exit 1\nfi\n\nFRAMEWORK_NAME=\"SDL3\"\nPROJECT_NAME=\"SDL\"\nSCHEME=\"SDL3\"\n\nMACOS_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-macosx.xcarchive\"\nIOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphonesimulator.xcarchive\"\nIOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphoneos.xcarchive\"\nTVOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvsimulator.xcarchive\"\nTVOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvos.xcarchive\"\n\nOUTPUT_DIR=\"./build/\"\n\n# macOS\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${MACOS_ARCHIVE_PATH} \\\n -destination 'generic/platform=macOS,name=Any Mac' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n \n# iOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# iOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# Clean-up any existing instance of this xcframework from the Products directory\nrm -rf \"${OUTPUT_DIR}${FRAMEWORK_NAME}.xcframework\"\n\n# Create final xcframework\nxcodebuild -create-xcframework \\\n -framework \"${MACOS_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${IOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${TVOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework\n\n# Ensure git doesn't pick up on our Products folder. \nrm -rf ${OUTPUT_DIR}/.gitignore\necho \"*\" >> ${OUTPUT_DIR}/.gitignore\n";
shellScript = "# Build an xcframework with both device and simulator files for all platforms.\n# Adapted from an answer in\n# https://developer.apple.com/forums/thread/666335?answerId=685927022#685927022\n\nif [ \"$XCODE_VERSION_ACTUAL\" -lt 1100 ]\nthen\n echo \"error: Building an xcframework requires Xcode 11 minimum.\"\n exit 1\nfi\n\nFRAMEWORK_NAME=\"SDL3\"\nPROJECT_NAME=\"SDL\"\nSCHEME=\"SDL3\"\n\nMACOS_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-macosx.xcarchive\"\nIOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphonesimulator.xcarchive\"\nIOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphoneos.xcarchive\"\nTVOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvsimulator.xcarchive\"\nTVOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvos.xcarchive\"\n\nOUTPUT_DIR=\"./build/\"\n\n# macOS\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${MACOS_ARCHIVE_PATH} \\\n -destination 'generic/platform=macOS,name=Any Mac' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n \n# iOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# iOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# Clean-up any existing instance of this xcframework from the Products directory\nrm -rf \"${OUTPUT_DIR}${FRAMEWORK_NAME}.xcframework\"\n\n# Create final xcframework\nxcodebuild -create-xcframework \\\n -framework \"${MACOS_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${MACOS_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${IOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${IOS_DEVICE_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${TVOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${TVOS_DEVICE_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework\n\n# Ensure git doesn't pick up on our Products folder. \nrm -rf ${OUTPUT_DIR}/.gitignore\necho \"*\" >> ${OUTPUT_DIR}/.gitignore\n";
};
/* End PBXShellScriptBuildPhase section */
@@ -2903,7 +2900,6 @@
A7D8BBE723E2574800DCD162 /* SDL_uikitviewcontroller.m in Sources */,
A7D8ADF223E2514100DCD162 /* SDL_blit_A.c in Sources */,
A7D8BBDD23E2574800DCD162 /* SDL_uikitmodes.m in Sources */,
A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */,
F3A9AE9C2C8A13C100AAC390 /* SDL_pipeline_gpu.c in Sources */,
75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
F338A11A2D1B37E4007CDFDF /* SDL_tray.c in Sources */,
@@ -3086,7 +3082,7 @@
CLANG_ENABLE_OBJC_ARC = YES;
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 201.0.0;
DYLIB_CURRENT_VERSION = 201.14.0;
DYLIB_CURRENT_VERSION = 201.31.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -3121,7 +3117,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.2.14;
MARKETING_VERSION = 3.2.31;
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
PRODUCT_NAME = SDL3;
@@ -3138,6 +3134,8 @@
baseConfigurationReference = F3F7BE3B2CBD79D200C984AF /* config.xcconfig */;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
OTHER_LDFLAGS = "-liconv";
SUPPORTS_MACCATALYST = YES;
};
@@ -3150,7 +3148,7 @@
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
DYLIB_COMPATIBILITY_VERSION = 201.0.0;
DYLIB_CURRENT_VERSION = 201.14.0;
DYLIB_CURRENT_VERSION = 201.31.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -3182,7 +3180,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.2.14;
MARKETING_VERSION = 3.2.31;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
@@ -3200,6 +3198,8 @@
baseConfigurationReference = F3F7BE3B2CBD79D200C984AF /* config.xcconfig */;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
OTHER_LDFLAGS = "-liconv";
SUPPORTS_MACCATALYST = YES;
};

View File

@@ -1,4 +1,4 @@
Title SDL 3.2.14
Title SDL 3.2.31
Version 1
Description SDL Library for macOS (http://www.libsdl.org)
DefaultLocation /Library/Frameworks

View File

@@ -1,8 +1,9 @@
# SDL3 CMake configuration file:
# This file is meant to be placed in Resources/CMake of a SDL3 framework
# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
# INTERFACE_LINK_OPTIONS needs CMake 3.12
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.12...4.0)
include(FeatureSummary)
set_package_properties(SDL3 PROPERTIES
@@ -31,16 +32,31 @@ endmacro()
set(SDL3_FOUND TRUE)
# Compute the installation prefix relative to this file.
set(_sdl3_framework_path "${CMAKE_CURRENT_LIST_DIR}") # > /SDL3.framework/Resources/CMake/
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH) # > /SDL3.framework/Versions/Current/Resources/CMake
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH) # > /SDL3.framework/Versions/A/Resources/CMake/
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/A/Resources/
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/A/
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/
get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH) # > /
# Compute the installation prefix relative to this file:
# search upwards for the .framework directory
set(_current_path "${CMAKE_CURRENT_LIST_DIR}")
get_filename_component(_current_path "${_current_path}" REALPATH)
set(_sdl3_framework_path "")
while(NOT _sdl3_framework_path)
if(IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "/SDL3\\.framework$")
set(_sdl3_framework_path "${_current_path}")
break()
endif()
get_filename_component(_next_current_path "${_current_path}" DIRECTORY)
if("${_current_path}" STREQUAL "${_next_current_path}")
break()
endif()
set(_current_path "${_next_current_path}")
endwhile()
unset(_current_path)
unset(_next_current_path)
if(NOT _sdl3_framework_path)
message(FATAL_ERROR "Could not find SDL3.framework root from ${CMAKE_CURRENT_LIST_DIR}")
endif()
get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH)
# All targets are created, even when some might not be requested though COMPONENTS.
# This is done for compatibility with CMake generated SDL3-target.cmake files.

View File

@@ -1,16 +1,26 @@
# based on the files generated by CMake's write_basic_package_version_file
# SDL CMake version configuration file:
# This file is meant to be placed in Resources/CMake of a SDL3 framework
# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.12...4.0)
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory of SDL2.framework")
# Find SDL_version.h
set(_sdl_version_h_path "")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
endif()
if(NOT _sdl_version_h_path)
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory or the CMake directory of SDL3.framework.")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h" _sdl_version_h)
file(READ "${_sdl_version_h_path}" _sdl_version_h)
string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
@@ -21,9 +31,12 @@ if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
else()
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()
unset(_sdl_version_h)
unset(_sdl_version_h_path)
unset(_sdl_major_re)
unset(_sdl_major)
unset(_sdl_minor_re)

View File

@@ -92,7 +92,7 @@ if(NOT TARGET SDL3::Headers)
add_library(SDL3::Headers INTERFACE IMPORTED)
set_target_properties(SDL3::Headers
PROPERTIES
INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${_sdl3_framework_parent_path}\""
INTERFACE_COMPILE_OPTIONS "-F${_sdl3_framework_parent_path}"
)
endif()
set(SDL3_Headers_FOUND TRUE)

View File

@@ -16,6 +16,7 @@ set(_sdl3_version_h "${_sdl3_framework}/Headers/SDL_version.h")
if(NOT EXISTS "${_sdl3_version_h}")
message(AUTHOR_WARNING "Cannot not find ${_sdl3_framework}. This script is meant to be placed in share/cmake/SDL3, next to SDL3.xcframework")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()
@@ -36,6 +37,7 @@ if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
else()
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()

View File

@@ -7,4 +7,4 @@
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
# Min runtime API level
APP_PLATFORM=android-16
APP_PLATFORM=android-21

View File

@@ -51,6 +51,8 @@
boolean supportsRelativeMouse();
int openFileDescriptor(java.lang.String, java.lang.String);
boolean showFileDialog(java.lang.String[], boolean, boolean, int);
java.lang.String getPreferredLocales();
java.lang.String formatLocale(java.util.Locale);
}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager {

View File

@@ -23,6 +23,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.LocaleList;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.util.DisplayMetrics;
@@ -60,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
private static final String TAG = "SDL";
private static final int SDL_MAJOR_VERSION = 3;
private static final int SDL_MINOR_VERSION = 2;
private static final int SDL_MICRO_VERSION = 14;
private static final int SDL_MICRO_VERSION = 31;
/*
// Display InputType.SOURCE/CLASS of events and devices
//
@@ -1127,6 +1128,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
int orientation_landscape = -1;
int orientation_portrait = -1;
if (w <= 1 || h <= 1) {
// Invalid width/height, ignore this request
return;
}
/* If set, hint "explicitly controls which UI orientations are allowed". */
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
@@ -2116,6 +2122,44 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
int requestCode;
boolean multipleChoice;
}
/**
* This method is called by SDL using JNI.
*/
public static String getPreferredLocales() {
String result = "";
if (Build.VERSION.SDK_INT >= 24 /* Android 7 (N) */) {
LocaleList locales = LocaleList.getAdjustedDefault();
for (int i = 0; i < locales.size(); i++) {
if (i != 0) result += ",";
result += formatLocale(locales.get(i));
}
} else if (mCurrentLocale != null) {
result = formatLocale(mCurrentLocale);
}
return result;
}
public static String formatLocale(Locale locale) {
String result = "";
String lang = "";
if (locale.getLanguage() == "in") {
// Indonesian is "id" according to ISO 639.2, but on Android is "in" because of Java backwards compatibility
lang = "id";
} else if (locale.getLanguage() == "") {
// Make sure language is never empty
lang = "und";
} else {
lang = locale.getLanguage();
}
if (locale.getCountry() == "") {
result = lang;
} else {
result = lang + "_" + locale.getCountry();
}
return result;
}
}
/**
@@ -2157,7 +2201,11 @@ class SDLClipboardHandler implements
}
public boolean clipboardHasText() {
return mClipMgr.hasPrimaryClip();
if (Build.VERSION.SDK_INT >= 28 /* Android 9 (P) */) {
return mClipMgr.hasPrimaryClip();
} else {
return mClipMgr.hasText();
}
}
public String clipboardGetText() {
@@ -2175,10 +2223,19 @@ class SDLClipboardHandler implements
}
public void clipboardSetText(String string) {
mClipMgr.removePrimaryClipChangedListener(this);
ClipData clip = ClipData.newPlainText(null, string);
mClipMgr.setPrimaryClip(clip);
mClipMgr.addPrimaryClipChangedListener(this);
mClipMgr.removePrimaryClipChangedListener(this);
if (string.isEmpty()) {
if (Build.VERSION.SDK_INT >= 28 /* Android 9 (P) */) {
mClipMgr.clearPrimaryClip();
} else {
ClipData clip = ClipData.newPlainText(null, "");
mClipMgr.setPrimaryClip(clip);
}
} else {
ClipData clip = ClipData.newPlainText(null, string);
mClipMgr.setPrimaryClip(clip);
}
mClipMgr.addPrimaryClipChangedListener(this);
}
@Override

View File

@@ -15,6 +15,7 @@ import android.view.Display;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -362,6 +363,16 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
}
}
// Prevent android internal NullPointerException (https://github.com/libsdl-org/SDL/issues/13306)
@Override
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
try {
return super.onResolvePointerIcon(event, pointerIndex);
} catch (NullPointerException e) {
return null;
}
}
// Captured pointer events for API 26.
public boolean onCapturedPointerEvent(MotionEvent event)
{

View File

@@ -542,6 +542,7 @@ class AndroidApiVersion:
def __repr__(self) -> str:
return f"<{self.name} ({'.'.join(str(v) for v in self.ints)})>"
ANDROID_ABI_EXTRA_LINK_OPTIONS = {}
class Releaser:
def __init__(self, release_info: dict, commit: str, revision: str, root: Path, dist_path: Path, section_printer: SectionPrinter, executer: Executer, cmake_generator: str, deps_path: Path, overwrite: bool, github: bool, fast: bool):
@@ -1013,6 +1014,7 @@ class Releaser:
android_devel_file_tree = ArchiveFileTree()
for android_abi in android_abis:
extra_link_options = ANDROID_ABI_EXTRA_LINK_OPTIONS.get(android_abi, "")
with self.section_printer.group(f"Building for Android {android_api} {android_abi}"):
build_dir = self.root / "build-android" / f"{android_abi}-build"
install_dir = self.root / "install-android" / f"{android_abi}-install"
@@ -1023,8 +1025,12 @@ class Releaser:
"cmake",
"-S", str(self.root),
"-B", str(build_dir),
f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
# NDK 21e does not support -ffile-prefix-map
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f"-DANDROID_USE_LEGACY_TOOLCHAIN=0",
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
f"-DCMAKE_PREFIX_PATH={str(android_deps_path)}",
f"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH",
@@ -1121,8 +1127,7 @@ class Releaser:
for dep, depinfo in self.release_info.get("dependencies", {}).items():
startswith = depinfo["startswith"]
dep_repo = depinfo["repo"]
# FIXME: dropped "--exclude-pre-releases"
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--exclude-pre-releases", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
dep_data = json.loads(dep_string_data)
dep_tag = dep_data["tagName"]
dep_version = dep_data["name"]
@@ -1512,7 +1517,7 @@ def main(argv=None) -> int:
if args.android_home is None or not Path(args.android_home).is_dir():
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
parser.error("Invalid $ANDROID_NDK_HOME or --android-ndk-home: must be a directory containing the Android NDK")
if args.android_api is None:
with section_printer.group("Detect Android APIS"):
args.android_api = releaser._detect_android_api(android_home=args.android_home)
@@ -1530,7 +1535,7 @@ def main(argv=None) -> int:
parser.error("Invalid --android-api, and/or could not be detected")
android_api_path = Path(args.android_home) / f"platforms/{args.android_api.name}"
if not android_api_path.is_dir():
parser.error(f"Android API directory does not exist ({android_api_path})")
logger.warning(f"Android API directory does not exist ({android_api_path})")
with section_printer.group("Android arguments"):
print(f"android_home = {args.android_home}")
print(f"android_ndk_home = {args.android_ndk_home}")

View File

@@ -0,0 +1,127 @@
#!/bin/bash
progname="${0##*/}"
progname="${progname%.sh}"
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk]
cleanup_trap() {
if [ -n "${tmp}" -a -d "${tmp}" ]; then
rm -rf ${tmp}
fi
exit $1
}
usage() {
echo "Host side script to check the ELF alignment of shared libraries."
echo "Shared libraries are reported ALIGNED when their ELF regions are"
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
echo
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
}
if [ ${#} -ne 1 ]; then
usage
exit
fi
case ${1} in
--help | -h | -\?)
usage
exit
;;
*)
dir="${1}"
;;
esac
if ! [ -f "${dir}" -o -d "${dir}" ]; then
echo "Invalid file: ${dir}" >&2
exit 1
fi
if [[ "${dir}" == *.apk ]]; then
trap 'cleanup_trap' EXIT
echo
echo "Recursively analyzing $dir"
echo
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
echo "=== APK zip-alignment ==="
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
echo "========================="
else
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
echo " You can install the latest build-tools by running the below command"
echo " and updating your \$PATH:"
echo
echo " sdkmanager \"build-tools;35.0.0-rc3\""
fi
dir_filename=$(basename "${dir}")
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
dir="${tmp}"
fi
if [[ "${dir}" == *.apex ]]; then
trap 'cleanup_trap' EXIT
echo
echo "Recursively analyzing $dir"
echo
dir_filename=$(basename "${dir}")
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
dir="${tmp}"
fi
RED="\e[31m"
GREEN="\e[32m"
ENDCOLOR="\e[0m"
unaligned_libs=()
unaligned_critical_libs=()
echo
echo "=== ELF alignment ==="
matches="$(find "${dir}" -type f)"
IFS=$'\n'
for match in $matches; do
# We could recursively call this script or rewrite it to though.
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
[[ $(file "${match}") == *"ELF"* ]] || continue
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
else
unaligned_libs+=("${match}")
# Check if this is a critical architecture (arm64-v8a or x86_64)
if [[ "${match}" == *"arm64-v8a"* ]] || [[ "${match}" == *"x86_64"* ]]; then
unaligned_critical_libs+=("${match}")
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
else
echo -e "${match}: UNALIGNED ($res)"
fi
fi
done
if [ ${#unaligned_libs[@]} -gt 0 ]; then
echo -e "Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
fi
echo "====================="
# Exit with appropriate code: 1 if critical unaligned libs found, 0 otherwise
if [ ${#unaligned_critical_libs[@]} -gt 0 ]; then
echo -e "${RED}Found ${#unaligned_critical_libs[@]} critical unaligned libs.${ENDCOLOR}"
exit 1
else
echo -e "${GREEN}ELF Verification Successful${ENDCOLOR}"
exit 0
fi

View File

@@ -33,9 +33,9 @@
#cmakedefine SDL_VENDOR_INFO "@SDL_VENDOR_INFO@"
#if defined(SDL_VENDOR_INFO)
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#else
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@"
#endif
#endif /* SDL_revision_h_ */

View File

@@ -48,9 +48,9 @@
*/
#define SDL_REVISION "Some arbitrary string decided at SDL build time"
#elif defined(SDL_VENDOR_INFO)
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
#else
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@"
#endif
#endif /* SDL_revision_h_ */

View File

@@ -183,7 +183,7 @@
],
"api-minimum": 21,
"api-target": 35,
"ndk-minimum": 21,
"ndk-minimum": 28,
"aar-files": {
"": [
"android-project/app/proguard-rules.pro:proguard.txt",

View File

@@ -1,21 +0,0 @@
#!/bin/sh
#
# libtool assumes that the compiler can handle the -fPIC flag
# This isn't always true (for example, nasm can't handle it)
command=""
while [ $# -gt 0 ]; do
case "$1" in
-?PIC)
# Ignore -fPIC and -DPIC options
;;
-fno-common)
# Ignore -fPIC and -DPIC options
;;
*)
command="$command $1"
;;
esac
shift
done
echo $command
exec $command

View File

@@ -164,6 +164,22 @@ function(get_git_head_revision _refspecvar _hashvar)
"${GIT_DATA}/grabRef.cmake" @ONLY)
include("${GIT_DATA}/grabRef.cmake")
# Fallback for reftable or other storage formats
if(NOT HEAD_HASH OR HEAD_HASH STREQUAL "")
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE HEAD_HASH
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(HEAD_HASH "")
endif()
endif()
endif()
set(${_refspecvar}
"${HEAD_REF}"
PARENT_SCOPE)

View File

@@ -25,19 +25,21 @@ if(HEAD_CONTENTS MATCHES "ref")
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
elseif(EXISTS "@GIT_DIR@/packed-refs")
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
elseif(EXISTS "@GIT_DIR@/reftable/tables.list")
configure_file("@GIT_DIR@/reftable/tables.list" "@GIT_DATA@/reftable-tables.list" COPYONLY)
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
if(NOT HEAD_HASH AND EXISTS "@GIT_DATA@/head-ref")
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@@ -1,16 +1,21 @@
# Helper for Find modules
function(get_flags_from_pkg_config _library _pc_prefix _out_prefix)
if("${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$")
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
if(MINGW)
set(re_shared_suffix ".dll.a$")
else()
set(re_shared_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
endif()
if("${_library}" MATCHES "${re_shared_suffix}")
set(_cflags ${_pc_prefix}_CFLAGS_OTHER)
set(_link_libraries ${_pc_prefix}_LIBRARIES)
set(_link_options ${_pc_prefix}_LDFLAGS_OTHER)
set(_library_dirs ${_pc_prefix}_LIBRARY_DIRS)
else()
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
endif()
# The *_LIBRARIES lists always start with the library itself

View File

@@ -946,22 +946,22 @@ macro(CheckUSBHID)
cmake_push_check_state()
check_library_exists(usbhid hid_init "" LIBUSBHID)
if(LIBUSBHID)
check_include_file(usbhid.h HAVE_USBHID_H)
check_include_files("stdint.h;usbhid.h" HAVE_USBHID_H)
if(HAVE_USBHID_H)
set(USB_CFLAGS "-DHAVE_USBHID_H")
endif()
check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
check_include_files("stdint.h;libusbhid.h" HAVE_LIBUSBHID_H)
if(HAVE_LIBUSBHID_H)
string(APPEND USB_CFLAGS " -DHAVE_LIBUSBHID_H")
endif()
set(USB_LIBS ${USB_LIBS} usbhid)
else()
check_include_file(usb.h HAVE_USB_H)
check_include_files("stdint.h;usb.h" HAVE_USB_H)
if(HAVE_USB_H)
set(USB_CFLAGS "-DHAVE_USB_H")
endif()
check_include_file(libusb.h HAVE_LIBUSB_H)
check_include_files("stdint.h;libusb.h" HAVE_LIBUSB_H)
if(HAVE_LIBUSB_H)
string(APPEND USB_CFLAGS " -DHAVE_LIBUSB_H")
endif()
@@ -1077,6 +1077,14 @@ endmacro()
# Check for HIDAPI support
macro(CheckHIDAPI)
if(ANDROID)
enable_language(CXX)
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp")
endif()
if(IOS OR TVOS)
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/ios/hid.m")
set(SDL_FRAMEWORK_COREBLUETOOTH 1)
endif()
if(SDL_HIDAPI)
set(HAVE_HIDAPI ON)
if(SDL_HIDAPI_LIBUSB)
@@ -1109,14 +1117,6 @@ macro(CheckHIDAPI)
endif()
if(HAVE_HIDAPI)
if(ANDROID)
enable_language(CXX)
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp")
endif()
if(IOS OR TVOS)
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/ios/hid.m")
set(SDL_FRAMEWORK_COREBLUETOOTH 1)
endif()
set(HAVE_SDL_HIDAPI TRUE)
if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK)
@@ -1156,7 +1156,8 @@ macro(CheckRPI)
set(HAVE_SDL_VIDEO TRUE)
set(SDL_VIDEO_DRIVER_RPI 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/raspberry/*.c")
sdl_link_dependency(rpi-video LIBS PkgConfig::PC_BCM_HOST PKG_CONFIG_PREFIX PC_BCM_HOST PKG_CONFIG_SPECS ${BCM_HOST_PKG_CONFIG_SPEC})
sdl_link_dependency(rpi-video-bcm_host LIBS PkgConfig::PC_BCM_HOST PKG_CONFIG_PREFIX PC_BCM_HOST PKG_CONFIG_SPECS ${BCM_HOST_PKG_CONFIG_SPEC})
sdl_link_dependency(rpi-video-brcmegl LIBS PkgConfig::PC_BRCMEGL PKG_CONFIG_PREFIX PC_BRCMEGL PKG_CONFIG_SPECS ${BRCMEGL_PKG_CONFIG_SPEC})
endif()
endif()
endif()

View File

@@ -160,3 +160,63 @@ function(SDL_AddCommonCompilerFlags TARGET)
endif()
endif()
endfunction()
function(check_x86_source_compiles BODY VAR)
if(ARGN)
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
endif()
if(APPLE_MULTIARCH AND (SDL_CPU_X86 OR SDL_CPU_X64))
set(test_conditional 1)
else()
set(test_conditional 0)
endif()
check_c_source_compiles("
#if ${test_conditional}
# if defined(__i386__) || defined(__x86_64__)
# define test_enabled 1
# else
# define test_enabled 0 /* feign success in Apple multi-arch configs */
# endif
#else /* test normally */
# define test_enabled 1
#endif
#if test_enabled
${BODY}
#else
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
#endif" ${VAR})
endfunction()
function(check_arm_source_compiles BODY VAR)
if(ARGN)
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
endif()
if(APPLE_MULTIARCH AND (SDL_CPU_ARM32 OR SDL_CPU_ARM64))
set(test_conditional 1)
else()
set(test_conditional 0)
endif()
check_c_source_compiles("
#if ${test_conditional}
# if defined(__arm__) || defined(__aarch64__)
# define test_enabled 1
# else
# define test_enabled 0 /* feign success in Apple multi-arch configs */
# endif
#else /* test normally */
# define test_enabled 1
#endif
#if test_enabled
${BODY}
#else
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
#endif" ${VAR})
endfunction()

View File

@@ -4,15 +4,15 @@ function(SDL_DetectTargetCPUArchitectures DETECTED_ARCHS)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
foreach(known_arch IN LISTS known_archs)
set(SDL_CPU_${known_arch} "0")
set(SDL_CPU_${known_arch} "0" PARENT_SCOPE)
endforeach()
set(detected_archs)
foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES)
if(osx_arch STREQUAL "x86_64")
set(SDL_CPU_X64 "1")
set(SDL_CPU_X64 "1" PARENT_SCOPE)
list(APPEND detected_archs "X64")
elseif(osx_arch STREQUAL "arm64")
set(SDL_CPU_ARM64 "1")
set(SDL_CPU_ARM64 "1" PARENT_SCOPE)
list(APPEND detected_archs "ARM64")
endif()
endforeach()

View File

@@ -131,7 +131,7 @@ function(sdl_compile_options)
target_compile_options(SDL3-static ${visibility} ${escaped_opts})
endif()
if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE))
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}")
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}")
endif()
endfunction()

View File

@@ -4,3 +4,4 @@ SDL is fully supported on BSD platforms, and is built using [CMake](README-cmake
If you want to run on the console, you can take a look at [KMSDRM support on BSD](README-kmsbsd.md)
SDL is [not designed to be used in setuid or setgid executables](README-platforms.md#setuid).

View File

@@ -8,6 +8,7 @@ system does not have the XRandR libraries installed, it will be disabled
at runtime, and you won't get a missing library error, at least with the
default configuration parameters.
SDL is [not designed to be used in setuid or setgid executables](README-platforms.md#setuid).
Build Dependencies
--------------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@ NSApplicationDelegate implementation:
```objc
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
if (SDL_GetEventState(SDL_EVENT_QUIT) == SDL_ENABLE) {
if (SDL_EventEnabled(SDL_EVENT_QUIT)) {
SDL_Event event;
SDL_zero(event);
event.type = SDL_EVENT_QUIT;
@@ -61,7 +61,7 @@ NSApplicationDelegate implementation:
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
if (SDL_GetEventState(SDL_EVENT_DROP_FILE) == SDL_ENABLE) {
if (SDL_EventEnabled(SDL_EVENT_DROP_FILE)) {
SDL_Event event;
SDL_zero(event);
event.type = SDL_EVENT_DROP_FILE;
@@ -73,6 +73,8 @@ NSApplicationDelegate implementation:
}
```
SDL is [not designed to be used in setuid or setgid executables](README-platforms.md#setuid).
# Using the Simple DirectMedia Layer with a traditional Makefile
An existing build system for your SDL app has good chances to work almost

View File

@@ -11,7 +11,7 @@
- [macOS](README-macos.md)
- [NetBSD](README-bsd.md)
- [Nintendo Switch](README-switch.md)
- [Nintendo 3DS](README-3ds.md)
- [Nintendo 3DS](README-n3ds.md)
- [OpenBSD](README-bsd.md)
- [PlayStation 2](README-ps2.md)
- [PlayStation 4](README-ps4.md)
@@ -38,3 +38,18 @@ All of these still work with [SDL2](/SDL2), which is an incompatible API, but an
- QNX
- WinPhone
- WinRT/UWP
## General notes for Unix platforms
Some aspects of SDL functionality are common to all Unix-based platforms.
### <a name=setuid></a>Privileged processes (setuid, setgid, setcap)
SDL is not designed to be used in programs with elevated privileges,
such as setuid (`chmod u+s`) or setgid (`chmod g+s`) executables,
or executables with file-based capabilities
(`setcap cap_sys_nice+ep` or similar).
It does not make any attempt to avoid trusting environment variables
or other aspects of the inherited execution environment.
Programs running with elevated privileges in an attacker-controlled
execution environment should not call SDL functions.

View File

@@ -20,7 +20,7 @@
*/
/**
* Main include header for the SDL library, version 3.2.14
* Main include header for the SDL library, version 3.2.31
*
* It is almost always best to include just this one header instead of
* picking out individual headers included here. There are exceptions to

View File

@@ -126,7 +126,7 @@ extern "C" {
*/
#define SDL_TriggerBreakpoint() TriggerABreakpointInAPlatformSpecificManner
#elif defined(_MSC_VER) && _MSC_VER >= 1310
#elif defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1310)
/* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak()
@@ -362,7 +362,7 @@ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *
#define SDL_enabled_assert(condition) \
do { \
while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \

View File

@@ -942,7 +942,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
* Binding a stream to a device will set its output format for playback
* devices, and its input format for recording devices, so they match the
* device's settings. The caller is welcome to change the other end of the
* stream's format at any time with SDL_SetAudioStreamFormat().
* stream's format at any time with SDL_SetAudioStreamFormat(). If the other
* end of the stream's format has never been set (the audio stream was created
* with a NULL audio spec), this function will set it to match the device
* end's format.
*
* \param devid an audio device to bind a stream to.
* \param streams an array of audio streams to bind.
@@ -1021,7 +1024,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream);
/**
* Query an audio stream for its currently-bound device.
*
* This reports the audio device that an audio stream is currently bound to.
* This reports the logical audio device that an audio stream is currently bound to.
*
* If not bound, or invalid, this returns zero, which is not a valid device
* ID.

View File

@@ -119,7 +119,7 @@ typedef struct SDL_CameraSpec
int width; /**< Frame width */
int height; /**< Frame height */
int framerate_numerator; /**< Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds) */
int framerate_denominator; /**< Frame rate demoninator ((num / denom) == FPS, (denom / num) == duration in seconds) */
int framerate_denominator; /**< Frame rate denominator ((num / denom) == FPS, (denom / num) == duration in seconds) */
} SDL_CameraSpec;
/**

View File

@@ -106,7 +106,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardText(const char *text);
/**
* Get UTF-8 text from the clipboard.
*
* This functions returns an empty string if there was not enough memory left
* This function returns an empty string if there is not enough memory left
* for a copy of the clipboard's content.
*
* \returns the clipboard text on success or an empty string on failure; call
@@ -155,7 +155,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text);
/**
* Get UTF-8 text from the primary selection.
*
* This functions returns an empty string if there was not enough memory left
* This function returns an empty string if there is not enough memory left
* for a copy of the primary selection's content.
*
* \returns the primary selection text on success or an empty string on
@@ -194,15 +194,14 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
* clipboard is cleared or new data is set. The clipboard is automatically
* cleared in SDL_Quit().
*
* \param userdata a pointer to provided user data.
* \param userdata a pointer to the provided user data.
* \param mime_type the requested mime-type.
* \param size a pointer filled in with the length of the returned data.
* \returns a pointer to the data for the provided mime-type. Returning NULL
* or setting length to 0 will cause no data to be sent to the
* "receiver". It is up to the receiver to handle this. Essentially
* returning no data is more or less undefined behavior and may cause
* breakage in receiving applications. The returned data will not be
* freed so it needs to be retained and dealt with internally.
* or setting the length to 0 will cause zero length data to be sent
* to the "receiver", which should be able to handle this. The
* returned data will not be freed, so it needs to be retained and
* dealt with internally.
*
* \since This function is available since SDL 3.2.0.
*
@@ -211,10 +210,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size);
/**
* Callback function that will be called when the clipboard is cleared, or new
* Callback function that will be called when the clipboard is cleared, or when new
* data is set.
*
* \param userdata a pointer to provided user data.
* \param userdata a pointer to the provided user data.
*
* \since This function is available since SDL 3.2.0.
*
@@ -231,7 +230,7 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
* respond with the data for the requested mime-type.
*
* The size of text data does not include any terminator, and the text does
* not need to be null terminated (e.g. you can directly copy a portion of a
* not need to be null-terminated (e.g., you can directly copy a portion of a
* document).
*
* \param callback a function pointer to the function that provides the
@@ -239,7 +238,7 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
* \param cleanup a function pointer to the function that cleans up the
* clipboard data.
* \param userdata an opaque pointer that will be forwarded to the callbacks.
* \param mime_types a list of mime-types that are being offered.
* \param mime_types a list of mime-types that are being offered. SDL copies the given list.
* \param num_mime_types the number of mime-types in the mime_types list.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
@@ -269,10 +268,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback
extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void);
/**
* Get the data from clipboard for a given mime type.
* Get the data from the clipboard for a given mime type.
*
* The size of text data does not include the terminator, but the text is
* guaranteed to be null terminated.
* guaranteed to be null-terminated.
*
* \param mime_type the mime type to read from the clipboard.
* \param size a pointer filled in with the length of the returned data.
@@ -292,8 +291,8 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, s
/**
* Query whether there is data in the clipboard for the provided mime type.
*
* \param mime_type the mime type to check for data for.
* \returns true if there exists data in clipboard for the provided mime type,
* \param mime_type the mime type to check for data.
* \returns true if data exists in the clipboard for the provided mime type,
* false if it does not.
*
* \threadsafety This function should only be called on the main thread.
@@ -310,7 +309,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardData(const char *mime_type);
*
* \param num_mime_types a pointer filled with the number of mime types, may
* be NULL.
* \returns a null terminated array of strings with mime types, or NULL on
* \returns a null-terminated array of strings with mime types, or NULL on
* failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed.
*

View File

@@ -46,7 +46,7 @@
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
#ifdef __clang__
#if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch)
#ifndef __PRFCHWINTRIN_H
#define __PRFCHWINTRIN_H
static __inline__ void __attribute__((__always_inline__, __nodebug__))
@@ -128,7 +128,7 @@ _m_prefetch(void *__P)
* \sa SDL_BIG_ENDIAN
*/
#define SDL_BYTEORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN
#elif defined(SDL_PLATFORM_LINUX)
#elif defined(SDL_PLATFORM_LINUX) || defined(__GLIBC__)
#include <endian.h>
#define SDL_BYTEORDER __BYTE_ORDER
#elif defined(SDL_PLATFORM_SOLARIS)
@@ -486,7 +486,7 @@ SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return x_but_byteswapped; }
*
* \since This function is available since SDL 3.2.0.
*/
SDL_FORCE_INLINE Uint32 SDL_Swap64(Uint64 x) { return x_but_byteswapped; }
SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { return x_but_byteswapped; }
/**
* Swap a 16-bit value from littleendian to native byte order.

View File

@@ -1043,7 +1043,7 @@ typedef union SDL_Event
} SDL_Event;
/* Make sure we haven't broken binary compatibility */
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding));
/* Function prototypes */

View File

@@ -224,8 +224,8 @@
* - `drawIndirectFirstInstance`
*
* **D3D12:** Supported on Windows 10 or newer, Xbox One (GDK), and Xbox
* Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level
* 11_1.
* Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and
* Resource Binding Tier 2 or above.
*
* **Metal:** Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware
* requirements vary by operating system:
@@ -1091,7 +1091,7 @@ typedef enum SDL_GPUCompareOp
SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */
SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */
SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */
SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */
SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evaluates reference >= test. */
SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */
} SDL_GPUCompareOp;
@@ -1549,7 +1549,7 @@ typedef struct SDL_GPUSamplerCreateInfo
typedef struct SDL_GPUVertexBufferDescription
{
Uint32 slot; /**< The binding slot of the vertex buffer. */
Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */
Uint32 pitch; /**< The size of a single element + the offset between elements. */
SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */
Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */
} SDL_GPUVertexBufferDescription;
@@ -2648,7 +2648,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
const char *text);
/**
* Begins a debug group with an arbitary name.
* Begins a debug group with an arbitrary name.
*
* Used for denoting groups of calls when viewing the command buffer
* callstream in a graphics debugging tool.

View File

@@ -595,7 +595,7 @@ extern "C" {
* A variable that limits what CPU features are available.
*
* By default, SDL marks all features the current CPU supports as available.
* This hint allows to limit these to a subset.
* This hint allows the enabled features to be limited to a subset.
*
* When the hint is unset, or empty, SDL will enable all detected CPU
* features.
@@ -2026,8 +2026,8 @@ extern "C" {
*
* The variable can be set to the following values:
*
* - "0": RAWINPUT drivers are not used.
* - "1": RAWINPUT drivers are used. (default)
* - "0": RAWINPUT drivers are not used. (default)
* - "1": RAWINPUT drivers are used.
*
* This hint should be set before SDL is initialized.
*
@@ -2126,8 +2126,8 @@ extern "C" {
*
* The variable can be set to the following values:
*
* - "0": WGI is not used.
* - "1": WGI is used. (default)
* - "0": WGI is not used. (default)
* - "1": WGI is used.
*
* This hint should be set before SDL is initialized.
*

View File

@@ -79,7 +79,7 @@ typedef Uint32 SDL_InitFlags;
#define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_VIDEO 0x00000020u /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread */
#define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD */
#define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */
#define SDL_INIT_HAPTIC 0x00001000u
#define SDL_INIT_GAMEPAD 0x00002000u /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
#define SDL_INIT_EVENTS 0x00004000u

View File

@@ -280,12 +280,14 @@ _m_prefetch(void *__P)
* \sa SDL_TARGETING
*/
#define SDL_HAS_TARGET_ATTRIBS
#elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15)
/* LoongArch requires GCC 15+ for target attribute support */
# define SDL_HAS_TARGET_ATTRIBS
#elif defined(__clang__) && defined(__has_attribute)
# if __has_attribute(target)
# define SDL_HAS_TARGET_ATTRIBS
# endif
#elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
#elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
# define SDL_HAS_TARGET_ATTRIBS
#elif defined(__ICC) && __ICC >= 1600
# define SDL_HAS_TARGET_ATTRIBS

View File

@@ -360,7 +360,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mut
* \sa SDL_LockMutex
* \sa SDL_UnlockMutex
*/
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex);
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex);
/**
* Unlock the mutex.
@@ -559,7 +559,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
* \sa SDL_TryLockRWLockForWriting
* \sa SDL_UnlockRWLock
*/
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock);
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock);
/**
* Try to lock a read/write lock _for writing_ without blocking.
@@ -589,7 +589,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
* \sa SDL_TryLockRWLockForReading
* \sa SDL_UnlockRWLock
*/
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock);
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock);
/**
* Unlock the read/write lock.

View File

@@ -517,7 +517,7 @@ typedef enum SDL_PackedLayout
* ABGR32, define a platform-independent encoding into bytes in the order
* specified. For example, in RGB24 data, each pixel is encoded in 3 bytes
* (red, green, blue) in that order, and in ABGR32 data, each pixel is
* encoded in 4 bytes alpha, blue, green, red) in that order. Use these
* encoded in 4 bytes (alpha, blue, green, red) in that order. Use these
* names if the property of a format that is important to you is the order
* of the bytes in memory or on disk.
* - Names with a bit count per component, such as ARGB8888 and XRGB1555, are

View File

@@ -125,10 +125,10 @@ typedef struct SDL_FRect
*/
SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect)
{
frect->x = (float)rect->x;
frect->y = (float)rect->y;
frect->w = (float)rect->w;
frect->h = (float)rect->h;
frect->x = SDL_static_cast(float, rect->x);
frect->y = SDL_static_cast(float, rect->y);
frect->w = SDL_static_cast(float, rect->w);
frect->h = SDL_static_cast(float, rect->h);
}
/**

View File

@@ -2612,7 +2612,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, flo
* Draw debug text to an SDL_Renderer.
*
* This function will render a printf()-style format string to a renderer.
* Note that this is a convinence function for debugging, with severe
* Note that this is a convenience function for debugging, with severe
* limitations, and is not intended to be used for production apps and games.
*
* For the full list of limitations and other useful information, see

View File

@@ -208,7 +208,7 @@ typedef enum SDL_Scancode
SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
* keyboards have over ANSI ones,
* located between left shift and Y.
* located between left shift and Z.
* Produces GRAVE ACCENT and TILDE in a
* US or UK Mac layout, REVERSE SOLIDUS
* (backslash) and VERTICAL LINE in a

View File

@@ -138,7 +138,8 @@ typedef enum SDL_SensorType
SDL_SENSOR_ACCEL_L, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */
SDL_SENSOR_GYRO_L, /**< Gyroscope for left Joy-Con controller */
SDL_SENSOR_ACCEL_R, /**< Accelerometer for right Joy-Con controller */
SDL_SENSOR_GYRO_R /**< Gyroscope for right Joy-Con controller */
SDL_SENSOR_GYRO_R, /**< Gyroscope for right Joy-Con controller */
SDL_SENSOR_COUNT
} SDL_SensorType;

View File

@@ -1164,7 +1164,7 @@ typedef struct SDL_alignment_test
void *b;
} SDL_alignment_test;
SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *)));
SDL_COMPILE_TIME_ASSERT(two_s_complement, (int)~(int)0 == (int)(-1));
SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1));
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
/** \endcond */
@@ -3426,7 +3426,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes
* Convert an integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3454,7 +3454,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix);
* Convert an unsigned integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3482,7 +3482,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int
* Convert a long integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3510,7 +3510,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix);
* Convert an unsigned long integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3540,7 +3540,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int
* Convert a long long integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3568,7 +3568,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(long long value, char *str, int rad
* Convert an unsigned long long integer into a string.
*
* This requires a radix to specified for string format. Specifying 10
* produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2
* produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2
* to 36.
*
* Note that this function will overflow a buffer if `str` is not large enough
@@ -3923,7 +3923,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str
extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
/**
* Searches a string for the first occurence of any character contained in a
* Searches a string for the first occurrence of any character contained in a
* breakset, and returns a pointer from the string to that character.
*
* \param str The null-terminated string to be searched. Must not be NULL, and
@@ -3931,7 +3931,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *st
* \param breakset A null-terminated string containing the list of characters
* to look for. Must not be NULL, and must not overlap with
* `str`.
* \returns A pointer to the location, in str, of the first occurence of a
* \returns A pointer to the location, in str, of the first occurrence of a
* character present in the breakset, or NULL if none is found.
*
* \threadsafety It is safe to call this function from any thread.
@@ -4656,7 +4656,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_atanf(float x);
*
* Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
*
* Range: `-Pi/2 <= y <= Pi/2`
* Range: `-Pi <= y <= Pi`
*
* This function operates on double-precision floating point values, use
* SDL_atan2f for single-precision floats.
@@ -4692,7 +4692,7 @@ extern SDL_DECLSPEC double SDLCALL SDL_atan2(double y, double x);
*
* Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
*
* Range: `-Pi/2 <= y <= Pi/2`
* Range: `-Pi <= y <= Pi`
*
* This function operates on single-precision floating point values, use
* SDL_atan2 for double-precision floats.
@@ -5821,7 +5821,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
* This function converts text between encodings, reading from and writing to
* a buffer.
*
* It returns the number of succesful conversions on success. On error,
* It returns the number of successful conversions on success. On error,
* SDL_ICONV_E2BIG is returned when the output buffer is too small, or
* SDL_ICONV_EILSEQ is returned when an invalid input sequence is encountered,
* or SDL_ICONV_EINVAL is returned when an incomplete input sequence is
@@ -5921,7 +5921,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
*
* \since This macro is available since SDL 3.2.0.
*/
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1))
/**
* Convert a UTF-8 string to UCS-4.
@@ -5935,7 +5935,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
*
* \since This macro is available since SDL 3.2.0.
*/
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1))
/**
* Convert a wchar_t string to UTF-8.
@@ -5949,7 +5949,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
*
* \since This macro is available since SDL 3.2.0.
*/
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t))
/* force builds using Clang's static analysis tools to use literal C runtime

View File

@@ -1279,10 +1279,11 @@ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src
*
* \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied, may not be NULL.
* copied, or NULL to copy the entire surface.
* \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the target rectangle in
* the destination surface, may not be NULL.
* the destination surface, or NULL to fill the entire
* destination surface.
* \param scaleMode the SDL_ScaleMode to be used.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.

View File

@@ -62,7 +62,7 @@ extern "C" {
*
* \since This macro is available since SDL 3.2.0.
*/
#define SDL_MICRO_VERSION 14
#define SDL_MICRO_VERSION 31
/**
* This macro turns the version numbers into a numeric value.

View File

@@ -1167,6 +1167,15 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int
* Popup windows implicitly do not have a border/decorations and do not appear
* on the taskbar/dock or in lists of windows such as alt-tab menus.
*
* By default, popup window positions will automatically be constrained to keep
* the entire window within display bounds. This can be overridden with the
* `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property.
*
* By default, popup menus will automatically grab keyboard focus from the parent
* when shown. This behavior can be overridden by setting the `SDL_WINDOW_NOT_FOCUSABLE`
* flag, setting the `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or
* toggling it after creation via the `SDL_SetWindowFocusable()` function.
*
* If a parent window is hidden or destroyed, any child popup windows will be
* recursively hidden or destroyed as well. Child popup windows not explicitly
* hidden will be restored when the parent is shown.
@@ -1207,6 +1216,9 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
* be always on top
* - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no
* window decoration
* - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip" and
* "menu" window types should be automatically constrained to be entirely within
* display bounds (default), false if no constraints on the position are desired.
* - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the
* window will be used with an externally managed graphics context.
* - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should
@@ -1321,6 +1333,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_Prop
#define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "SDL.window.create.always_on_top"
#define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "SDL.window.create.borderless"
#define SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN "SDL.window.create.constrain_popup"
#define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "SDL.window.create.focusable"
#define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "SDL.window.create.external_graphics_context"
#define SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER "SDL.window.create.flags"
@@ -1460,7 +1473,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
* - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)`
* NSWindow associated with the window
* - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
* assocated with metal views on the window
* associated with metal views on the window
*
* On OpenVR:
*

View File

@@ -51,14 +51,14 @@
extern "C" {
#endif
/* Avoid including vulkan.h, don't define VkInstance if it's already included */
#ifdef VULKAN_H_
/* Avoid including vulkan_core.h, don't define VkInstance if it's already included */
#ifdef VULKAN_CORE_H_
#define NO_SDL_VULKAN_TYPEDEFS
#endif
#ifndef NO_SDL_VULKAN_TYPEDEFS
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64)
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
#else
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;

View File

@@ -174,6 +174,7 @@
#cmakedefine HAVE_MEMFD_CREATE 1
#cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_SIGACTION 1
#cmakedefine HAVE_SIGTIMEDWAIT 1
#cmakedefine HAVE_SA_SIGACTION 1
#cmakedefine HAVE_ST_MTIM 1
#cmakedefine HAVE_SETJMP 1
@@ -194,6 +195,8 @@
#cmakedefine HAVE_ELF_AUX_INFO 1
#cmakedefine HAVE_POLL 1
#cmakedefine HAVE__EXIT 1
#cmakedefine HAVE_GETRESUID 1
#cmakedefine HAVE_GETRESGID 1
#endif /* HAVE_LIBC */

View File

@@ -111,6 +111,9 @@ typedef unsigned int uintptr_t;
# define SDL_DISABLE_AVX 1
#endif
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
/* This can be disabled to avoid C runtime dependencies and manifest requirements */
#ifndef HAVE_LIBC
#define HAVE_LIBC 1
@@ -122,8 +125,6 @@ typedef unsigned int uintptr_t;
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
@@ -153,7 +154,6 @@ typedef unsigned int uintptr_t;
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRPBRK 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_ACOS 1
#define HAVE_ASIN 1
@@ -211,10 +211,7 @@ typedef unsigned int uintptr_t;
#if _MSC_VER >= 1400
#define HAVE__FSEEKI64 1
#endif
#endif /* _MSC_VER */
#else
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#endif /* _MSC_VER */
#endif
/* Enable various audio drivers */

View File

@@ -65,7 +65,7 @@
// Initialization/Cleanup routines
#include "timer/SDL_timer_c.h"
#ifdef SDL_VIDEO_DRIVER_WINDOWS
#ifdef SDL_PLATFORM_WINDOWS
extern bool SDL_HelperWindowCreate(void);
extern void SDL_HelperWindowDestroy(void);
#endif
@@ -317,7 +317,7 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
SDL_DBus_Init();
#endif
#ifdef SDL_VIDEO_DRIVER_WINDOWS
#ifdef SDL_PLATFORM_WINDOWS
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
if (!SDL_HelperWindowCreate()) {
goto quit_and_error;
@@ -653,7 +653,7 @@ void SDL_Quit(void)
SDL_bInMainQuit = true;
// Quit all subsystems
#ifdef SDL_VIDEO_DRIVER_WINDOWS
#ifdef SDL_PLATFORM_WINDOWS
SDL_HelperWindowDestroy();
#endif
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);

View File

@@ -265,6 +265,12 @@ extern "C" {
#include "SDL_utils_c.h"
#include "SDL_hashtable.h"
#define PUSH_SDL_ERROR() \
{ char *_error = SDL_strdup(SDL_GetError());
#define POP_SDL_ERROR() \
SDL_SetError("%s", _error); SDL_free(_error); }
// Do any initialization that needs to happen before threads are started
extern void SDL_InitMainThread(void);

View File

@@ -597,15 +597,21 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
}
// If message truncated, allocate and re-render
if (len >= sizeof(stack_buf) && SDL_size_add_check_overflow(len, 1, &len_plus_term)) {
// Allocate exactly what we need, including the zero-terminator
message = (char *)SDL_malloc(len_plus_term);
if (!message) {
return;
if (len >= sizeof(stack_buf)) {
if (SDL_size_add_check_overflow(len, 1, &len_plus_term)) {
// Allocate exactly what we need, including the zero-terminator
message = (char *)SDL_malloc(len_plus_term);
if (!message) {
return;
}
va_copy(aq, ap);
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
va_end(aq);
} else {
// Allocation would overflow, use truncated message
message = stack_buf;
len = sizeof(stack_buf);
}
va_copy(aq, ap);
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
va_end(aq);
} else {
message = stack_buf;
}

View File

@@ -1153,7 +1153,10 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
// We should have updated this elsewhere if the format changed!
SDL_assert(SDL_AudioSpecsEqual(&stream->dst_spec, &device->spec, NULL, NULL));
SDL_assert(stream->src_spec.format != SDL_AUDIO_UNKNOWN);
const int br = SDL_GetAtomicInt(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
failed = true;
SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die.
@@ -1195,6 +1198,8 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
// We should have updated this elsewhere if the format changed!
SDL_assert(SDL_AudioSpecsEqual(&stream->dst_spec, &outspec, NULL, NULL));
SDL_assert(stream->src_spec.format != SDL_AUDIO_UNKNOWN);
/* this will hold a lock on `stream` while getting. We don't explicitly lock the streams
for iterating here because the binding linked list can only change while the device lock is held.
(we _do_ lock the stream during binding/unbinding to make sure that two threads can't try to bind
@@ -1249,7 +1254,11 @@ void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
// Wait for the audio to drain if device didn't die.
if (!SDL_GetAtomicInt(&device->zombie)) {
SDL_Delay(((frames * 1000) / device->spec.freq) * 2);
int delay = ((frames * 1000) / device->spec.freq) * 2;
if (delay > 100) {
delay = 100;
}
SDL_Delay(delay);
}
current_audio.impl.ThreadDeinit(device);
SDL_AudioThreadFinalize(device);
@@ -1330,6 +1339,7 @@ bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
SDL_assert(stream->src_spec.format == ((logdev->postmix || (logdev->gain != 1.0f)) ? SDL_AUDIO_F32 : device->spec.format));
SDL_assert(stream->src_spec.channels == device->spec.channels);
SDL_assert(stream->src_spec.freq == device->spec.freq);
SDL_assert(stream->dst_spec.format != SDL_AUDIO_UNKNOWN);
void *final_buf = output_buffer;
@@ -1391,6 +1401,7 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
typedef struct CountAudioDevicesData
{
int devs_seen;
int devs_skipped;
const int num_devices;
SDL_AudioDeviceID *result;
const bool recording;
@@ -1406,7 +1417,13 @@ static bool SDLCALL CountAudioDevices(void *userdata, const SDL_HashTable *table
const bool isphysical = !!(devid & (1<<1));
if (isphysical && (devid_recording == data->recording)) {
SDL_assert(data->devs_seen < data->num_devices);
data->result[data->devs_seen++] = devid;
SDL_AudioDevice *device = (SDL_AudioDevice *) value; // this is normally risky, but we hold the device_hash_lock here.
const bool zombie = SDL_GetAtomicInt(&device->zombie) != 0;
if (zombie) {
data->devs_skipped++;
} else {
data->result[data->devs_seen++] = devid;
}
}
return true; // keep iterating.
}
@@ -1422,10 +1439,11 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
num_devices = SDL_GetAtomicInt(recording ? &current_audio.recording_device_count : &current_audio.playback_device_count);
result = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
if (result) {
CountAudioDevicesData data = { 0, num_devices, result, recording };
CountAudioDevicesData data = { 0, 0, num_devices, result, recording };
SDL_IterateHashTable(current_audio.device_hash, CountAudioDevices, &data);
SDL_assert(data.devs_seen == num_devices);
result[data.devs_seen] = 0; // null-terminated.
SDL_assert((data.devs_seen + data.devs_skipped) == num_devices);
num_devices = data.devs_seen; // might be less if we skipped any.
result[num_devices] = 0; // null-terminated.
}
}
SDL_UnlockRWLock(current_audio.device_hash_lock);
@@ -1567,7 +1585,9 @@ int *SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count)
SDL_AudioDevice *device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
if (device) {
channels = device->spec.channels;
result = SDL_ChannelMapDup(device->chmap, channels);
if (channels > 0 && device->chmap) {
result = SDL_ChannelMapDup(device->chmap, channels);
}
}
ReleaseAudioDevice(device);
@@ -1743,13 +1763,18 @@ static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
SDL_copyp(&spec, inspec ? inspec : &device->default_spec);
PrepareAudioFormat(device->recording, &spec);
/* We allow the device format to change if it's better than the current settings (by various definitions of "better"). This prevents
something low quality, like an old game using S8/8000Hz audio, from ruining a music thing playing at CD quality that tries to open later.
(or some VoIP library that opens for mono output ruining your surround-sound game because it got there first).
/* We impose a simple minimum on device formats. This prevents something low quality, like an old game using S8/8000Hz audio,
from ruining a music thing playing at CD quality that tries to open later, or some VoIP library that opens for mono output
ruining your surround-sound game because it got there first.
These are just requests! The backend may change any of these values during OpenDevice method! */
device->spec.format = (SDL_AUDIO_BITSIZE(device->default_spec.format) >= SDL_AUDIO_BITSIZE(spec.format)) ? device->default_spec.format : spec.format;
device->spec.freq = SDL_max(device->default_spec.freq, spec.freq);
device->spec.channels = SDL_max(device->default_spec.channels, spec.channels);
const SDL_AudioFormat minimum_format = device->recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT;
const int minimum_channels = device->recording ? DEFAULT_AUDIO_RECORDING_CHANNELS : DEFAULT_AUDIO_PLAYBACK_CHANNELS;
const int minimum_freq = device->recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY;
device->spec.format = (SDL_AUDIO_BITSIZE(minimum_format) >= SDL_AUDIO_BITSIZE(spec.format)) ? minimum_format : spec.format;
device->spec.channels = SDL_max(minimum_channels, spec.channels);
device->spec.freq = SDL_max(minimum_freq, spec.freq);
device->sample_frames = SDL_GetDefaultSampleFramesFromFreq(device->spec.freq);
SDL_UpdatedAudioDeviceFormat(device); // start this off sane.
@@ -1960,10 +1985,6 @@ bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *stre
} else if (logdev->simplified) {
result = SDL_SetError("Cannot change stream bindings on device opened with SDL_OpenAudioDeviceStream");
} else {
// !!! FIXME: We'll set the device's side's format below, but maybe we should refuse to bind a stream if the app's side doesn't have a format set yet.
// !!! FIXME: Actually, why do we allow there to be an invalid format, again?
// make sure start of list is sane.
SDL_assert(!logdev->bound_streams || (logdev->bound_streams->prev_binding == NULL));
@@ -1998,9 +2019,17 @@ bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *stre
if (result) {
// Now that everything is verified, chain everything together.
const bool recording = device->recording;
for (int i = 0; i < num_streams; i++) {
SDL_AudioStream *stream = streams[i];
if (stream) { // shouldn't be NULL, but just in case...
// if the stream never had its non-device-end format set, just set it to the device end's format.
if (recording && (stream->dst_spec.format == SDL_AUDIO_UNKNOWN)) {
SDL_copyp(&stream->dst_spec, &device->spec);
} else if (!recording && (stream->src_spec.format == SDL_AUDIO_UNKNOWN)) {
SDL_copyp(&stream->src_spec, &device->spec);
}
stream->bound_device = logdev;
stream->prev_binding = NULL;
stream->next_binding = logdev->bound_streams;

View File

@@ -537,8 +537,10 @@ static void SDL_TARGETING("ssse3") SDL_Convert_Swap32_SSSE3(Uint32* dst, const U
// behavior. However, the compiler support for this pragma is bad.
#if defined(__clang__)
#if __clang_major__ >= 12
#if defined(__aarch64__)
#pragma STDC FENV_ACCESS ON
#endif
#endif
#elif defined(_MSC_VER)
#pragma fenv_access (on)
#elif defined(__GNUC__)
@@ -814,8 +816,10 @@ static void SDL_Convert_Swap32_NEON(Uint32* dst, const Uint32* src, int num_samp
#if defined(__clang__)
#if __clang_major__ >= 12
#if defined(__aarch64__)
#pragma STDC FENV_ACCESS DEFAULT
#endif
#endif
#elif defined(_MSC_VER)
#pragma fenv_access (off)
#elif defined(__GNUC__)

View File

@@ -1775,6 +1775,7 @@ static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uin
int result;
Uint32 chunkcount = 0;
Uint32 chunkcountlimit = 10000;
const Sint64 flen = SDL_GetIOSize(src); // this might be -1 if the IOStream can't determine the total size.
const char *hint;
Sint64 RIFFstart, RIFFend, lastchunkpos;
bool RIFFlengthknown = false;
@@ -1883,6 +1884,14 @@ static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uin
fmtchunk = *chunk;
}
} else if (chunk->fourcc == DATA) {
/* If the data chunk is bigger than the file, it might be corrupt
or the file is truncated. Try to recover by clamping the file
size. This also means a malicious file can't allocate 4 gigabytes
for the chunks without actually supplying a 4 gigabyte file. */
if ((flen > 0) && ((chunk->position + chunk->length) > flen)) {
chunk->length = (Uint32) (flen - chunk->position);
}
/* Only use the first data chunk. Handling the wavl list madness
* may require a different approach.
*/
@@ -2114,8 +2123,8 @@ bool SDL_LoadWAV_IO(SDL_IOStream *src, bool closeio, SDL_AudioSpec *spec, Uint8
result = WaveLoad(src, &file, spec, audio_buf, audio_len);
if (!result) {
SDL_free(*audio_buf);
audio_buf = NULL;
audio_len = 0;
*audio_buf = NULL;
*audio_len = 0;
}
// Cleanup

View File

@@ -461,8 +461,6 @@ static void ALSA_CloseDevice(SDL_AudioDevice *device)
{
if (device->hidden) {
if (device->hidden->pcm) {
// Wait for the submitted audio to drain. ALSA_snd_pcm_drop() can hang, so don't use that.
SDL_Delay(((device->sample_frames * 1000) / device->spec.freq) * 2);
ALSA_snd_pcm_close(device->hidden->pcm);
}
SDL_free(device->hidden->mixbuf);
@@ -1156,7 +1154,7 @@ static bool ALSA_OpenDevice(SDL_AudioDevice *device)
#if SDL_ALSA_DEBUG
snd_pcm_uframes_t bufsize;
ALSA_snd_pcm_hw_params_get_buffer_size(cfg_ctx.hwparams, &bufsize);
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO,
"ALSA: period size = %ld, periods = %u, buffer size = %lu",
cfg_ctx.persize, cfg_ctx.periods, bufsize);
#endif

View File

@@ -420,7 +420,8 @@ static bool UpdateAudioSession(SDL_AudioDevice *device, bool open, bool allow_pl
hint = SDL_GetHint(SDL_HINT_AUDIO_CATEGORY);
if (hint) {
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0) {
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0 ||
SDL_strcasecmp(hint, "ambient") == 0) {
category = AVAudioSessionCategoryAmbient;
} else if (SDL_strcasecmp(hint, "AVAudioSessionCategorySoloAmbient") == 0) {
category = AVAudioSessionCategorySoloAmbient;

View File

@@ -206,7 +206,7 @@ static void DSOUND_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe
{
#ifdef HAVE_MMDEVICEAPI_H
if (SupportsIMMDevice) {
SDL_IMMDevice_EnumerateEndpoints(default_playback, default_recording);
SDL_IMMDevice_EnumerateEndpoints(default_playback, default_recording, SDL_AUDIO_UNKNOWN);
} else
#endif
{

View File

@@ -189,7 +189,7 @@ static bool EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
}
// limit to native freq
device->spec.freq = EM_ASM_INT({ return Module['SDL3'].audioContext.sampleRate; });
device->spec.freq = MAIN_THREAD_EM_ASM_INT({ return Module['SDL3'].audioContext.sampleRate; });
device->sample_frames = SDL_GetDefaultSampleFramesFromFreq(device->spec.freq) * 2; // double the buffer size, some browsers need more, and we'll just have to live with the latency.
SDL_UpdatedAudioDeviceFormat(device);

View File

@@ -426,28 +426,33 @@ static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
static bool OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)
{
/* If we want to add floating point audio support (requires API level 21)
it can be done as described here:
https://developer.android.com/ndk/guides/audio/opensl/android-extensions.html#floating-point
*/
/* according to https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android,
Android's OpenSL ES only supports Uint8 and _littleendian_ Sint16.
(and float32, with an extension we use, below.) */
if (SDL_GetAndroidSDKVersion() >= 21) {
const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format);
SDL_AudioFormat test_format;
while ((test_format = *(closefmts++)) != 0) {
if (SDL_AUDIO_ISSIGNED(test_format)) {
switch (test_format) {
case SDL_AUDIO_U8:
case SDL_AUDIO_S16LE:
case SDL_AUDIO_F32:
break;
default:
continue;
}
break;
}
if (!test_format) {
// Didn't find a compatible format :
LOGI("No compatible audio format, using signed 16-bit audio");
test_format = SDL_AUDIO_S16;
LOGI("No compatible audio format, using signed 16-bit LE audio");
test_format = SDL_AUDIO_S16LE;
}
device->spec.format = test_format;
} else {
// Just go with signed 16-bit audio as it's the most compatible
device->spec.format = SDL_AUDIO_S16;
device->spec.format = SDL_AUDIO_S16LE;
}
// Update the fragment size as size in bytes

View File

@@ -114,7 +114,7 @@ static bool PSPAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, in
} else {
rc = sceAudioOutputPannedBlocking(device->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, (void *) buffer);
}
return (rc == 0);
return (rc >= 0);
}
static bool PSPAUDIO_WaitDevice(SDL_AudioDevice *device)

View File

@@ -595,6 +595,71 @@ static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata)
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details.
}
// Channel maps that match the order in SDL_Audio.h
static const pa_channel_position_t Pulse_map_1[] = { PA_CHANNEL_POSITION_MONO };
static const pa_channel_position_t Pulse_map_2[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT };
static const pa_channel_position_t Pulse_map_3[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_LFE };
static const pa_channel_position_t Pulse_map_4[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
static const pa_channel_position_t Pulse_map_5[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
static const pa_channel_position_t Pulse_map_6[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
static const pa_channel_position_t Pulse_map_7[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_REAR_CENTER,
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT };
static const pa_channel_position_t Pulse_map_8[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT };
#define COPY_CHANNEL_MAP(c) SDL_memcpy(pacmap->map, Pulse_map_##c, sizeof(Pulse_map_##c))
static void PulseCreateChannelMap(pa_channel_map *pacmap, uint8_t channels)
{
SDL_assert(channels <= PA_CHANNELS_MAX);
pacmap->channels = channels;
switch (channels) {
case 1:
COPY_CHANNEL_MAP(1);
break;
case 2:
COPY_CHANNEL_MAP(2);
break;
case 3:
COPY_CHANNEL_MAP(3);
break;
case 4:
COPY_CHANNEL_MAP(4);
break;
case 5:
COPY_CHANNEL_MAP(5);
break;
case 6:
COPY_CHANNEL_MAP(6);
break;
case 7:
COPY_CHANNEL_MAP(7);
break;
case 8:
COPY_CHANNEL_MAP(8);
break;
}
}
static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
{
const bool recording = device->recording;
@@ -672,7 +737,8 @@ static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
paspec.rate = device->spec.freq;
// Reduced prebuffering compared to the defaults.
paattr.fragsize = device->buffer_size; // despite the name, this is only used for recording devices, according to PulseAudio docs!
paattr.fragsize = device->buffer_size * 2; // despite the name, this is only used for recording devices, according to PulseAudio docs! (times 2 because we want _more_ than our buffer size sent from the server at a time, which helps some drivers).
paattr.tlength = device->buffer_size;
paattr.prebuf = -1;
paattr.maxlength = -1;
@@ -682,9 +748,8 @@ static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
const char *name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
// The SDL ALSA output hints us that we use Windows' channel mapping
// https://bugzilla.libsdl.org/show_bug.cgi?id=110
PULSEAUDIO_pa_channel_map_init_auto(&pacmap, device->spec.channels, PA_CHANNEL_MAP_WAVEEX);
PulseCreateChannelMap(&pacmap, device->spec.channels);
h->stream = PULSEAUDIO_pa_stream_new(
pulseaudio_context,

View File

@@ -337,7 +337,7 @@ typedef struct
static bool mgmtthrtask_DetectDevices(void *userdata)
{
mgmtthrtask_DetectDevicesData *data = (mgmtthrtask_DetectDevicesData *)userdata;
SDL_IMMDevice_EnumerateEndpoints(data->default_playback, data->default_recording);
SDL_IMMDevice_EnumerateEndpoints(data->default_playback, data->default_recording, SDL_AUDIO_F32);
return true;
}

View File

@@ -814,7 +814,7 @@ static void ANDROIDCAMERA_Deinitialize(void)
static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
{
// !!! FIXME: slide this off into a subroutine
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime.
// system libraries are in android-24 and later; we currently target android-21 and later, so check if they exist at runtime.
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
if (!libcamera2) {
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());

View File

@@ -61,7 +61,7 @@ static SDL_CameraFrameResult EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, S
SDL3.camera.ctx2d.drawImage(SDL3.camera.video, 0, 0, w, h);
const imgrgba = SDL3.camera.ctx2d.getImageData(0, 0, w, h).data;
Module.HEAPU8.set(imgrgba, rgba);
HEAPU8.set(imgrgba, rgba);
return 1;
}, device->actual_spec.width, device->actual_spec.height, rgba);

View File

@@ -570,7 +570,7 @@ static bool V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (xioctl(fd, VIDIOC_G_PARM, &setfps) == 0) {
if ( (setfps.parm.capture.timeperframe.denominator != spec->framerate_numerator) ||
(setfps.parm.capture.timeperframe.numerator = spec->framerate_denominator) ) {
(setfps.parm.capture.timeperframe.numerator != spec->framerate_denominator) ) {
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = spec->framerate_denominator;
setfps.parm.capture.timeperframe.denominator = spec->framerate_numerator;
@@ -796,7 +796,7 @@ static void MaybeAddDevice(const char *path)
const int stepw = (int) frmsizeenum.stepwise.step_width;
const int steph = (int) frmsizeenum.stepwise.step_height;
for (int w = minw; w <= maxw; w += stepw) {
for (int h = minh; w <= maxh; w += steph) {
for (int h = minh; h <= maxh; h += steph) {
#if DEBUG_CAMERA
SDL_Log("CAMERA: * Has %s size %dx%d", (frmsizeenum.type == V4L2_FRMSIZE_TYPE_STEPWISE) ? "stepwise" : "continuous", w, h);
#endif

View File

@@ -207,7 +207,6 @@ Sint32 JNI_OnLoad(void *vm, void *reserved)
{
(void)vm;
(void)reserved;
SDL_Unsupported();
return -1; // JNI_ERR
return 0x00010004; // JNI_VERSION_1_4
}
#endif

View File

@@ -371,6 +371,7 @@ static jmethodID midShowTextInput;
static jmethodID midSupportsRelativeMouse;
static jmethodID midOpenFileDescriptor;
static jmethodID midShowFileDialog;
static jmethodID midGetPreferredLocales;
// audio manager
static jclass mAudioManagerClass;
@@ -660,6 +661,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
midSupportsRelativeMouse = (*env)->GetStaticMethodID(env, mActivityClass, "supportsRelativeMouse", "()Z");
midOpenFileDescriptor = (*env)->GetStaticMethodID(env, mActivityClass, "openFileDescriptor", "(Ljava/lang/String;Ljava/lang/String;)I");
midShowFileDialog = (*env)->GetStaticMethodID(env, mActivityClass, "showFileDialog", "([Ljava/lang/String;ZZI)Z");
midGetPreferredLocales = (*env)->GetStaticMethodID(env, mActivityClass, "getPreferredLocales", "()Ljava/lang/String;");
if (!midClipboardGetText ||
!midClipboardHasText ||
@@ -691,7 +693,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
!midShowTextInput ||
!midSupportsRelativeMouse ||
!midOpenFileDescriptor ||
!midShowFileDialog) {
!midShowFileDialog ||
!midGetPreferredLocales) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
}
@@ -1077,7 +1080,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeAddTouch)(
{
const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
SDL_AddTouch((SDL_TouchID)touchId, SDL_TOUCH_DEVICE_DIRECT, utfname);
SDL_AddTouch(Android_ConvertJavaTouchID(touchId),
SDL_TOUCH_DEVICE_DIRECT, utfname);
(*env)->ReleaseStringUTFChars(env, name, utfname);
}
@@ -1725,18 +1729,24 @@ static bool Android_JNI_ExceptionOccurred(bool silent)
exceptionName = (jstring)(*env)->CallObjectMethod(env, exceptionClass, mid);
exceptionNameUTF8 = (*env)->GetStringUTFChars(env, exceptionName, 0);
(*env)->DeleteLocalRef(env, classClass);
mid = (*env)->GetMethodID(env, exceptionClass, "getMessage", "()Ljava/lang/String;");
exceptionMessage = (jstring)(*env)->CallObjectMethod(env, exception, mid);
(*env)->DeleteLocalRef(env, exceptionClass);
if (exceptionMessage != NULL) {
const char *exceptionMessageUTF8 = (*env)->GetStringUTFChars(env, exceptionMessage, 0);
SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
(*env)->ReleaseStringUTFChars(env, exceptionMessage, exceptionMessageUTF8);
(*env)->DeleteLocalRef(env, exceptionMessage);
} else {
SDL_SetError("%s", exceptionNameUTF8);
}
(*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
(*env)->DeleteLocalRef(env, exceptionName);
}
return true;
@@ -2160,7 +2170,7 @@ bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *b
mid = (*env)->GetMethodID(env, clazz,
"messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I");
*buttonID = (*env)->CallIntMethod(env, context, mid,
messageboxdata->flags,
(jint)messageboxdata->flags,
title,
message,
button_flags,
@@ -2414,7 +2424,7 @@ const char *SDL_GetAndroidCachePath(void)
// fileObj = context.getExternalFilesDir();
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
"getCacheDir", "()Ljava/io/File;");
fileObject = (*env)->CallObjectMethod(env, context, mid, NULL);
fileObject = (*env)->CallObjectMethod(env, context, mid);
if (!fileObject) {
SDL_SetError("Couldn't get cache directory");
LocalReferenceHolder_Cleanup(&refs);
@@ -2585,65 +2595,22 @@ bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int x
bool Android_JNI_GetLocale(char *buf, size_t buflen)
{
AConfiguration *cfg;
SDL_assert(buflen > 6);
// Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED)
Internal_Android_Destroy_AssetManager();
if (!asset_manager) {
Internal_Android_Create_AssetManager();
}
if (!asset_manager) {
return false;
}
cfg = AConfiguration_new();
if (!cfg) {
return false;
}
{
char language[2] = {};
char country[2] = {};
size_t id = 0;
AConfiguration_fromAssetManager(cfg, asset_manager);
AConfiguration_getLanguage(cfg, language);
AConfiguration_getCountry(cfg, country);
// Indonesian is "id" according to ISO 639.2, but on Android is "in" because of Java backwards compatibility
if (language[0] == 'i' && language[1] == 'n') {
language[1] = 'd';
}
// copy language (not null terminated)
if (language[0]) {
buf[id++] = language[0];
if (language[1]) {
buf[id++] = language[1];
bool result = false;
if (buf && buflen > 0) {
*buf = '\0';
JNIEnv *env = Android_JNI_GetEnv();
jstring string = (jstring)(*env)->CallStaticObjectMethod(env, mActivityClass, midGetPreferredLocales);
if (string) {
const char *utf8string = (*env)->GetStringUTFChars(env, string, NULL);
if (utf8string) {
result = true;
SDL_strlcpy(buf, utf8string, buflen);
(*env)->ReleaseStringUTFChars(env, string, utf8string);
}
(*env)->DeleteLocalRef(env, string);
}
buf[id++] = '_';
// copy country (not null terminated)
if (country[0]) {
buf[id++] = country[0];
if (country[1]) {
buf[id++] = country[1];
}
}
buf[id++] = '\0';
SDL_assert(id <= buflen);
}
AConfiguration_delete(cfg);
return true;
return result;
}
bool Android_JNI_OpenURL(const char *url)
@@ -2807,6 +2774,7 @@ bool Android_JNI_OpenFileDialog(
if (filters) {
jclass stringClass = (*env)->FindClass(env, "java/lang/String");
filtersArray = (*env)->NewObjectArray(env, nfilters, stringClass, NULL);
(*env)->DeleteLocalRef(env, stringClass);
// Convert to string
for (int i = 0; i < nfilters; i++) {

View File

@@ -105,7 +105,7 @@ bool GDK_RegisterChangeNotifications(void)
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler");
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this) {
if (constrained) {
if (constrained && !((_this->windows) && _this->windows->text_input_active)) {
SDL_SetKeyboardFocus(NULL);
} else {
SDL_SetKeyboardFocus(_this->windows);

View File

@@ -546,16 +546,16 @@ void SDL_EVDEV_Poll(void)
* be window-relative in that case. */
switch (item->touchscreen_data->slots[j].delta) {
case EVDEV_TOUCH_SLOTDELTA_DOWN:
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_EVENT_FINGER_DOWN, norm_x, norm_y, norm_pressure);
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, mouse->focus, SDL_EVENT_FINGER_DOWN, norm_x, norm_y, norm_pressure);
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
break;
case EVDEV_TOUCH_SLOTDELTA_UP:
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_EVENT_FINGER_UP, norm_x, norm_y, norm_pressure);
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, mouse->focus, SDL_EVENT_FINGER_UP, norm_x, norm_y, norm_pressure);
item->touchscreen_data->slots[j].tracking_id = 0;
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
break;
case EVDEV_TOUCH_SLOTDELTA_MOVE:
SDL_SendTouchMotion(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, norm_x, norm_y, norm_pressure);
SDL_SendTouchMotion(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, mouse->focus, norm_x, norm_y, norm_pressure);
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
break;
default:

View File

@@ -25,6 +25,7 @@
#include "SDL_fcitx.h"
#include "../../video/SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../core/unix/SDL_appid.h"
#include "SDL_dbus.h"
#ifdef SDL_VIDEO_DRIVER_X11
@@ -53,32 +54,14 @@ typedef struct FcitxClient
static FcitxClient fcitx_client;
static char *GetAppName(void)
static const char *GetAppName(void)
{
#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD)
char *spot;
char procfile[1024];
char linkfile[1024];
int linksize;
#ifdef SDL_PLATFORM_LINUX
(void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid());
#elif defined(SDL_PLATFORM_FREEBSD)
(void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid());
#endif
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
if (linksize > 0) {
linkfile[linksize] = '\0';
spot = SDL_strrchr(linkfile, '/');
if (spot) {
return SDL_strdup(spot + 1);
} else {
return SDL_strdup(linkfile);
}
const char *exe_name = SDL_GetExeName();
if (exe_name) {
return exe_name;
}
#endif // SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD
return SDL_strdup("SDL_App");
return "SDL_App";
}
static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus,
@@ -281,7 +264,7 @@ static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname,
static bool FcitxClientCreateIC(FcitxClient *client)
{
char *appname = GetAppName();
const char *appname = GetAppName();
char *ic_path = NULL;
SDL_DBusContext *dbus = client->dbus;
@@ -290,8 +273,6 @@ static bool FcitxClientCreateIC(FcitxClient *client)
ic_path = NULL; // just in case.
}
SDL_free(appname);
if (ic_path) {
SDL_free(client->ic_path);
client->ic_path = SDL_strdup(ic_path);

90
src/core/unix/SDL_gtk.c Normal file
View File

@@ -0,0 +1,90 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#include "SDL_gtk.h"
#include <errno.h>
#include <unistd.h>
#ifndef HAVE_GETRESUID
// Non-POSIX, but Linux and some BSDs have it.
// To reduce the number of code paths, if getresuid() isn't available at
// compile-time, we behave as though it existed but failed at runtime.
static inline int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
errno = ENOSYS;
return -1;
}
#endif
#ifndef HAVE_GETRESGID
// Same as getresuid() but for the primary group
static inline int getresgid(uid_t *ruid, uid_t *euid, uid_t *suid)
{
errno = ENOSYS;
return -1;
}
#endif
bool SDL_CanUseGtk(void)
{
// "Real", "effective" and "saved" IDs: see e.g. Linux credentials(7)
uid_t ruid = -1, euid = -1, suid = -1;
gid_t rgid = -1, egid = -1, sgid = -1;
if (!SDL_GetHintBoolean("SDL_ENABLE_GTK", true)) {
SDL_LogDebug(SDL_LOG_CATEGORY_SYSTEM, "Not using GTK due to hint");
return false;
}
// This is intended to match the check in gtkmain.c, rather than being
// an exhaustive check for having elevated privileges: as a result
// we don't use Linux getauxval() or prctl PR_GET_DUMPABLE,
// BSD issetugid(), or similar OS-specific detection
if (getresuid(&ruid, &euid, &suid) != 0) {
ruid = suid = getuid();
euid = geteuid();
}
if (getresgid(&rgid, &egid, &sgid) != 0) {
rgid = sgid = getgid();
egid = getegid();
}
// Real ID != effective ID means we are setuid or setgid:
// GTK will refuse to initialize, and instead will call exit().
if (ruid != euid || rgid != egid) {
SDL_LogDebug(SDL_LOG_CATEGORY_SYSTEM, "Not using GTK due to setuid/setgid");
return false;
}
// Real ID != saved ID means we are setuid or setgid, we previously
// dropped privileges, but we can regain them; this protects against
// accidents but does not protect against arbitrary code execution.
// Again, GTK will refuse to initialize if this is the case.
if (ruid != suid || rgid != sgid) {
SDL_LogDebug(SDL_LOG_CATEGORY_SYSTEM, "Not using GTK due to saved uid/gid");
return false;
}
return true;
}

View File

@@ -19,6 +19,11 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_pspvideo.h"
#include "SDL_internal.h"
// Functions to be exported
#ifndef SDL_gtk_h_
#define SDL_gtk_h_
extern bool SDL_CanUseGtk(void);
#endif // SDL_gtk_h_

View File

@@ -120,7 +120,7 @@ void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device)
}
}
static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid)
static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid, SDL_AudioFormat force_format)
{
/* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever).
In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for
@@ -162,7 +162,7 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn
SDL_zero(spec);
spec.channels = (Uint8)fmt->Format.nChannels;
spec.freq = fmt->Format.nSamplesPerSec;
spec.format = SDL_WaveFormatExToSDLFormat((WAVEFORMATEX *)fmt);
spec.format = (force_format != SDL_AUDIO_UNKNOWN) ? force_format : SDL_WaveFormatExToSDLFormat((WAVEFORMATEX *)fmt);
device = SDL_AddAudioDevice(recording, devname, &spec, handle);
if (!device) {
@@ -183,6 +183,7 @@ typedef struct SDLMMNotificationClient
{
const IMMNotificationClientVtbl *lpVtbl;
SDL_AtomicInt refcount;
SDL_AudioFormat force_format;
} SDLMMNotificationClient;
static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_QueryInterface(IMMNotificationClient *client, REFIID iid, void **ppv)
@@ -241,6 +242,7 @@ static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceRemoved(IMMNoti
static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *iclient, LPCWSTR pwstrDeviceId, DWORD dwNewState)
{
SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient;
IMMDevice *device = NULL;
if (SUCCEEDED(IMMDeviceEnumerator_GetDevice(enumerator, pwstrDeviceId, &device))) {
@@ -255,7 +257,7 @@ static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IM
GUID dsoundguid;
GetMMDeviceInfo(device, &utf8dev, &fmt, &dsoundguid);
if (utf8dev) {
SDL_IMMDevice_Add(recording, utf8dev, &fmt, pwstrDeviceId, &dsoundguid);
SDL_IMMDevice_Add(recording, utf8dev, &fmt, pwstrDeviceId, &dsoundguid, client->force_format);
SDL_free(utf8dev);
}
} else {
@@ -286,7 +288,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = {
SDLMMNotificationClient_OnPropertyValueChanged
};
static SDLMMNotificationClient notification_client = { &notification_client_vtbl, { 1 } };
static SDLMMNotificationClient notification_client = { &notification_client_vtbl, { 1 }, SDL_AUDIO_UNKNOWN };
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
{
@@ -363,7 +365,7 @@ bool SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool reco
return true;
}
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device)
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device, SDL_AudioFormat force_format)
{
/* Note that WASAPI separates "adapter devices" from "audio endpoint devices"
...one adapter device ("SoundBlaster Pro") might have multiple endpoint devices ("Speakers", "Line-Out"). */
@@ -405,7 +407,7 @@ static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **de
SDL_zero(dsoundguid);
GetMMDeviceInfo(immdevice, &devname, &fmt, &dsoundguid);
if (devname) {
SDL_AudioDevice *sdldevice = SDL_IMMDevice_Add(recording, devname, &fmt, devid, &dsoundguid);
SDL_AudioDevice *sdldevice = SDL_IMMDevice_Add(recording, devname, &fmt, devid, &dsoundguid, force_format);
if (default_device && default_devid && SDL_wcscmp(default_devid, devid) == 0) {
*default_device = sdldevice;
}
@@ -422,10 +424,12 @@ static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **de
IMMDeviceCollection_Release(collection);
}
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording, SDL_AudioFormat force_format)
{
EnumerateEndpointsForFlow(false, default_playback);
EnumerateEndpointsForFlow(true, default_recording);
EnumerateEndpointsForFlow(false, default_playback, force_format);
EnumerateEndpointsForFlow(true, default_recording, force_format);
notification_client.force_format = force_format;
// if this fails, we just won't get hotplug events. Carry on anyhow.
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)&notification_client);

View File

@@ -37,7 +37,7 @@ typedef struct SDL_IMMDevice_callbacks
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
void SDL_IMMDevice_Quit(void);
bool SDL_IMMDevice_Get(struct SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
void SDL_IMMDevice_EnumerateEndpoints(struct SDL_AudioDevice **default_playback, struct SDL_AudioDevice **default_recording);
void SDL_IMMDevice_EnumerateEndpoints(struct SDL_AudioDevice **default_playback, struct SDL_AudioDevice **default_recording, SDL_AudioFormat force_format);
LPGUID SDL_IMMDevice_GetDirectSoundGUID(struct SDL_AudioDevice *device);
LPCWSTR SDL_IMMDevice_GetDevID(struct SDL_AudioDevice *device);
void SDL_IMMDevice_FreeDeviceHandle(struct SDL_AudioDevice *device);

View File

@@ -53,6 +53,78 @@ typedef enum RO_INIT_TYPE
#define WC_ERR_INVALID_CHARS 0x00000080
#endif
// Fake window to help with DirectInput events.
HWND SDL_HelperWindow = NULL;
static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow");
static ATOM SDL_HelperWindowClass = 0;
/*
* Creates a HelperWindow used for DirectInput.
*/
bool SDL_HelperWindowCreate(void)
{
HINSTANCE hInstance = GetModuleHandle(NULL);
WNDCLASS wce;
// Make sure window isn't created twice.
if (SDL_HelperWindow != NULL) {
return true;
}
// Create the class.
SDL_zero(wce);
wce.lpfnWndProc = DefWindowProc;
wce.lpszClassName = SDL_HelperWindowClassName;
wce.hInstance = hInstance;
// Register the class.
SDL_HelperWindowClass = RegisterClass(&wce);
if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) {
return WIN_SetError("Unable to create Helper Window Class");
}
// Create the window.
SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
SDL_HelperWindowName,
WS_OVERLAPPED, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, HWND_MESSAGE, NULL,
hInstance, NULL);
if (!SDL_HelperWindow) {
UnregisterClass(SDL_HelperWindowClassName, hInstance);
return WIN_SetError("Unable to create Helper Window");
}
return true;
}
/*
* Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
*/
void SDL_HelperWindowDestroy(void)
{
HINSTANCE hInstance = GetModuleHandle(NULL);
// Destroy the window.
if (SDL_HelperWindow != NULL) {
if (DestroyWindow(SDL_HelperWindow) == 0) {
WIN_SetError("Unable to destroy Helper Window");
return;
}
SDL_HelperWindow = NULL;
}
// Unregister the class.
if (SDL_HelperWindowClass != 0) {
if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
WIN_SetError("Unable to destroy Helper Window Class");
return;
}
SDL_HelperWindowClass = 0;
}
}
// Sets an error message based on an HRESULT
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
@@ -198,6 +270,24 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
return result;
#endif
BOOL WIN_IsWine(void)
{
static bool checked;
static bool is_wine;
if (!checked) {
HMODULE ntdll = LoadLibrary(TEXT("ntdll.dll"));
if (ntdll) {
if (GetProcAddress(ntdll, "wine_get_version") != NULL) {
is_wine = true;
}
FreeLibrary(ntdll);
}
checked = true;
}
return is_wine;
}
// this is the oldest thing we run on (and we may lose support for this in SDL3 at any time!),
// so there's no "OrGreater" as that would always be TRUE. The other functions are here to
// ask "can we support a specific feature?" but this function is here to ask "do we need to do

View File

@@ -133,6 +133,9 @@ extern void WIN_CoUninitialize(void);
extern HRESULT WIN_RoInitialize(void);
extern void WIN_RoUninitialize(void);
// Returns true if we're running on Wine
extern BOOL WIN_IsWine(void);
// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
extern BOOL WIN_IsWindowsXP(void);

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,14,0
PRODUCTVERSION 3,2,14,0
FILEVERSION 3,2,31,0
PRODUCTVERSION 3,2,31,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "3, 2, 14, 0\0"
VALUE "FileVersion", "3, 2, 31, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL3.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "3, 2, 14, 0\0"
VALUE "ProductVersion", "3, 2, 31, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -27,6 +27,8 @@
#import <Cocoa/Cocoa.h>
#import <UniformTypeIdentifiers/UTType.h>
extern void Cocoa_SetWindowHasModalDialog(SDL_Window *window, bool has_modal);
static void AddFileExtensionType(NSMutableArray *types, const char *pattern_ptr)
{
if (!*pattern_ptr) {
@@ -163,6 +165,9 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
if (window) {
w = (__bridge NSWindow *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL);
if (w) {
Cocoa_SetWindowHasModalDialog(window, true);
}
}
if (w) {
@@ -186,6 +191,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
callback(userdata, files, -1);
}
Cocoa_SetWindowHasModalDialog(window, false);
ReactivateAfterDialog();
}];
} else {
@@ -206,6 +212,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
const char *files[1] = { NULL };
callback(userdata, files, -1);
}
ReactivateAfterDialog();
}
}

View File

@@ -261,7 +261,7 @@ void windows_ShowFileDialog(void *ptr)
chosen_files_list[nfiles] = NULL;
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) >= MAX_PATH) {
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) == 0) {
SDL_SetError("Path too long or invalid character in path");
SDL_free(chosen_files_list);
callback(userdata, NULL, -1);
@@ -273,7 +273,7 @@ void windows_ShowFileDialog(void *ptr)
SDL_strlcpy(chosen_file, chosen_folder, MAX_PATH);
chosen_file[chosen_folder_size] = '\\';
file_ptr += SDL_strlen(chosen_folder) + 1;
file_ptr += SDL_wcslen(file_ptr) + 1;
while (*file_ptr) {
nfiles++;
@@ -295,7 +295,7 @@ void windows_ShowFileDialog(void *ptr)
int diff = ((int) chosen_folder_size) + 1;
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) >= MAX_PATH - diff) {
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) == 0) {
SDL_SetError("Path too long or invalid character in path");
for (size_t i = 0; i < nfiles - 1; i++) {
@@ -308,7 +308,7 @@ void windows_ShowFileDialog(void *ptr)
return;
}
file_ptr += SDL_strlen(chosen_file) + 1 - diff;
file_ptr += SDL_wcslen(file_ptr) + 1;
chosen_files_list[nfiles - 1] = SDL_strdup(chosen_file);

View File

@@ -1077,16 +1077,11 @@ static void SDL_SendWakeupEvent(void)
return;
}
SDL_LockMutex(_this->wakeup_lock);
{
if (_this->wakeup_window) {
_this->SendWakeupEvent(_this, _this->wakeup_window);
// No more wakeup events needed until we enter a new wait
_this->wakeup_window = NULL;
}
// We only want to do this once while waiting for an event, so set it to NULL atomically here
SDL_Window *wakeup_window = (SDL_Window *)SDL_SetAtomicPointer(&_this->wakeup_window, NULL);
if (wakeup_window) {
_this->SendWakeupEvent(_this, wakeup_window);
}
SDL_UnlockMutex(_this->wakeup_lock);
#endif
}
@@ -1113,7 +1108,8 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAct
if (action == SDL_ADDEVENT) {
if (!events) {
SDL_UnlockMutex(SDL_EventQ.lock);
return SDL_InvalidParamError("events");
SDL_InvalidParamError("events");
return -1;
}
for (i = 0; i < numevents; ++i) {
used += SDL_AddEvent(&events[i]);
@@ -1524,18 +1520,7 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu
*/
SDL_PumpEventsInternal(true);
SDL_LockMutex(_this->wakeup_lock);
{
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST);
// If status == 0 we are going to block so wakeup will be needed.
if (status == 0) {
_this->wakeup_window = wakeup_window;
} else {
_this->wakeup_window = NULL;
}
}
SDL_UnlockMutex(_this->wakeup_lock);
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST);
if (status < 0) {
// Got an error: return
break;
@@ -1548,8 +1533,6 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu
if (timeoutNS > 0) {
Sint64 elapsed = SDL_GetTicksNS() - start;
if (elapsed >= timeoutNS) {
// Set wakeup_window to NULL without holding the lock.
_this->wakeup_window = NULL;
return 0;
}
loop_timeoutNS = (timeoutNS - elapsed);
@@ -1562,9 +1545,9 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu
loop_timeoutNS = poll_intervalNS;
}
}
SDL_SetAtomicPointer(&_this->wakeup_window, wakeup_window);
status = _this->WaitEventTimeout(_this, loop_timeoutNS);
// Set wakeup_window to NULL without holding the lock.
_this->wakeup_window = NULL;
SDL_SetAtomicPointer(&_this->wakeup_window, NULL);
if (status == 0 && poll_intervalNS != SDL_MAX_SINT64 && loop_timeoutNS == poll_intervalNS) {
// We may have woken up to poll. Try again
continue;
@@ -1664,6 +1647,8 @@ bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
#ifdef SDL_PLATFORM_ANDROID
for (;;) {
SDL_PumpEventsInternal(true);
if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) > 0) {
return true;
}

View File

@@ -336,19 +336,6 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
if (keyboard->focus && !window) {
// We won't get anymore keyboard messages, so reset keyboard state
SDL_ResetKeyboard();
// Also leave mouse relative mode
if (mouse->relative_mode) {
SDL_SetRelativeMouseMode(false);
SDL_Window *focus = keyboard->focus;
if ((focus->flags & SDL_WINDOW_MINIMIZED) != 0) {
// We can't warp the mouse within minimized windows, so manually restore the position
float x = focus->x + mouse->x;
float y = focus->y + mouse->y;
SDL_WarpMouseGlobal(x, y);
}
}
}
// See if the current window has lost focus
@@ -363,6 +350,21 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
}
}
if (keyboard->focus && !window) {
// Also leave mouse relative mode
if (mouse->relative_mode) {
SDL_SetRelativeMouseMode(false);
SDL_Window *focus = keyboard->focus;
if ((focus->flags & SDL_WINDOW_MINIMIZED) != 0) {
// We can't warp the mouse within minimized windows, so manually restore the position
float x = focus->x + mouse->x;
float y = focus->y + mouse->y;
SDL_WarpMouseGlobal(x, y);
}
}
}
keyboard->focus = window;
if (keyboard->focus) {

View File

@@ -138,21 +138,25 @@ static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name
#ifdef SDL_PLATFORM_VITA
static void SDLCALL SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
Uint8 vita_touch_mouse_device = 1;
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
if (hint) {
switch (*hint) {
default:
case '0':
mouse->vita_touch_mouse_device = 1;
vita_touch_mouse_device = 1;
break;
case '1':
mouse->vita_touch_mouse_device = 2;
vita_touch_mouse_device = 2;
break;
case '2':
mouse->vita_touch_mouse_device = 3;
vita_touch_mouse_device = 3;
break;
default:
break;
}
}
mouse->vita_touch_mouse_device = vita_touch_mouse_device;
}
#endif

View File

@@ -46,8 +46,10 @@ static bool send_foregrounding_pending = false;
static void SDL_HandleSIG(int sig)
{
// Reset the signal handler
#ifndef HAVE_SIGACTION
// Reset the signal handler if it was installed with signal()
(void)signal(sig, SDL_HandleSIG);
#endif
// Send a quit event next time the event loop pumps.
// We can't send it in signal handler; SDL_malloc() might be interrupted!

View File

@@ -77,9 +77,6 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
}
SDL_assert(SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW));
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
return false;
}
switch (windowevent) {
case SDL_EVENT_WINDOW_SHOWN:
if (!(window->flags & SDL_WINDOW_HIDDEN)) {
@@ -212,6 +209,10 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
break;
}
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
return false;
}
// Post the event, if desired
SDL_Event event;
event.type = windowevent;

View File

@@ -371,10 +371,10 @@ static const SDL_Scancode xfree86_scancode_table2[] = {
/* 188, 0x0bc */ SDL_SCANCODE_F18, // XF86Launch9
/* 189, 0x0bd */ SDL_SCANCODE_F19, // NoSymbol
/* 190, 0x0be */ SDL_SCANCODE_F20, // XF86AudioMicMute
/* 191, 0x0bf */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadToggle
/* 192, 0x0c0 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOn
/* 193, 0x0c1 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOff
/* 194, 0x0c2 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
/* 191, 0x0bf */ SDL_SCANCODE_F21, // XF86TouchpadToggle
/* 192, 0x0c0 */ SDL_SCANCODE_F22, // XF86TouchpadOn
/* 193, 0x0c1 */ SDL_SCANCODE_F23, // XF86TouchpadOff
/* 194, 0x0c2 */ SDL_SCANCODE_F24, // NoSymbol
/* 195, 0x0c3 */ SDL_SCANCODE_MODE, // Mode_switch
/* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
/* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, // NoSymbol

View File

@@ -45,7 +45,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
// trim down to a single path separator at the end, in case the caller added one or more.
pathwithseplen--;
while ((pathwithseplen >= 0) && (pathwithsep[pathwithseplen] == '/')) {
while ((pathwithseplen > 0) && (pathwithsep[pathwithseplen] == '/')) {
pathwithsep[pathwithseplen--] = '\0';
}

View File

@@ -78,7 +78,7 @@ static char *search_path_for_binary(const char *bin)
char *envr;
size_t alloc_size;
char *exe = NULL;
char *start = envr;
char *start;
char *ptr;
if (!envr_real) {
@@ -86,7 +86,7 @@ static char *search_path_for_binary(const char *bin)
return NULL;
}
envr = SDL_strdup(envr_real);
start = envr = SDL_strdup(envr_real);
if (!envr) {
return NULL;
}

Some files were not shown because too many files have changed in this diff Show More