Commit Graph

21650 Commits

Author SHA1 Message Date
Sam Lantinga
e21f7d77f3 Fixed unaligned 16-bit memory access
The previous code technically works on platforms with SSE2, but this fixes an ubsan warning.
2026-04-02 14:08:20 -07:00
Anonymous Maarten
03f74f3ad3 testyuv: make test params static const 2026-04-02 21:25:41 +02:00
Anonymous Maarten
b77fdcc638 Disable UB sanitizer in signed shift test 2026-04-02 21:25:41 +02:00
Anonymous Maarten
f7661ff016 Avoid unaligned memory access while testing SSE4.2 CRC intrinsics 2026-04-02 21:25:41 +02:00
Anonymous Maarten
df72e3f59d Shifting a number into the sign bit of a signed integer is UB
Shift as a unsigned number instead.
2026-04-02 21:25:41 +02:00
Anonymous Maarten
48e80c8f26 memcpy with a NULL src/dst argument is UB
malloc of UBSAN returns NULL when allocating 0 bytes, causing a call to memcpy(NULL, xxx, 0);
2026-04-02 21:25:41 +02:00
Sam Lantinga
501ee05129 Don't strip the alpha channel when scaling surfaces if it will be needed
Fixes https://github.com/libsdl-org/SDL/issues/15297
2026-04-02 11:00:17 -07:00
Sam Lantinga
156187bf58 Added a hint "SDL_SURFACE_MALLOC" to disable aligned surface allocation
This is needed for sdl12-compat, where all surfaces were not aligned.
2026-04-02 10:30:32 -07:00
Janne Virtala
b5ef75249f SDL_PrivateJoystickForceRecentering(): fix infinite loop 2026-04-02 09:27:18 -07:00
Ryan C. Gordon
32ef82caaf pipewire: Don't mark a device disconnected if pw_stream_dequeue_buffer fails.
Apparently this _can_ happen under load, or maybe some other weird condition.

Hopefully this will encourage PipeWire to fire output_callback again, and
we'll just try again later.

Reference Issue #14916.
2026-04-02 11:48:35 -04:00
Ryan C. Gordon
4d17b99d0a aaudio: Respect SDL_HINT_AUDIO_DEVICE_STREAM_ROLE hint.
Fixes #15299.
2026-04-01 22:17:23 -04:00
Sam Lantinga
6466c10ae4 Added documentation to fix building on macOS with Xcode 12.2 (thanks @buhman!)
Fixes https://github.com/libsdl-org/SDL/issues/15167
2026-04-01 16:37:14 -07:00
Sam Lantinga
8e1bdbaa92 Updated support for the GameSir Pro 8K
The latest firmware (v1.97) corrects the report frequency, and no longer reports the mute button.
2026-03-31 11:18:03 -07:00
Petar Popovic
d6129d063f SDL_GlobDirectory(): Don't descend into sub-directories, if not requested by pattern 2026-03-30 16:38:39 -04:00
Ryan C. Gordon
f13cd9a666 process: Don't duplicate NULL stdio handles on Windows.
It's okay to pass null handles to win32's CreateProcess().

Fixes #14977.
2026-03-30 16:22:53 -04:00
Sam Lantinga
b878ab1691 Fix msvc analyzer warnings
- Initialize some out variables that are annotated inout in the function setting them.

- Fix 'dwVerHandle' might not be '0' warning from msvc analyzer calling GetFileVersionInfoA. MSDN says that
  the lpdwHandle param to GetFileVersionInfoSize is optional (set to zero) and the dwHandle param to
  GetFileVersionInfoA is ignored. msvc goes a step further and explicitly warns if dwHandle is not provably 0.

Fixes the following:
SDL3\src\stdlib\SDL_string.c(2359): warning C6054: String 'text' might not be zero-terminated.
SDL3\src\video\windows\SDL_windowsevents.c(897): warning C6001: Using uninitialized memory 'devName'.
SDL3\src\video\windows\SDL_windowskeyboard.c(644): warning C6388: 'dwVerHandle' might not be '0':  this does not adhere to the specification for the function 'GetFileVersionInfoA'.
2026-03-30 10:38:55 -07:00
Ryan C. Gordon
0756603e6d thread: SDL_CreateThread() shouldn't return before the new thread is set up.
Fixes #15290.
2026-03-30 10:39:17 -04:00
zn-arf
e66f1b5162 Fix Metal GPU backend not being included in CMake configuration
Fixes #15285

Missing Metal GPU block in CMakeLists.txt prevents `HAVE_SDL_GPU` from being set when only Metal is enabled.
2026-03-30 09:30:36 -04:00
Semphris
a54dd7ba45 Fix Windows file dialog calling the callback twice
If the modern implementation of file dialogs on Windows fails, it will invoke the callback on error and report an error, then SDL would attempt invoking the dialog again using an older implementation, which would call the callback again.

This is not desired behavior, so it has been changed as follows:
- If the modern dialog fails before showing (missing library/symbol), don't call the callback and try the older dialogs in case we're on an old platform.
- If the dialog fails while or after showing, assume the error is a normal invocation error (such as an invalid path), call the callback and don't show the older dialogs to prevent showing two dialogs in succession to the user.
2026-03-29 02:05:33 -04:00
Sam Lantinga
815fd4bf45 Removed spurious whitespace 2026-03-28 22:22:39 -07:00
Ryan C. Gordon
a157d96de8 stdlib: Patched SDL_rand_f to compile on pre-C99 compilers.
Visual Studio _still_ doesn't report itself as C99 compatible, afaict, but
does support the syntax as of VS2017 15.6, apparently.

This page mentions the first version of Visual Studio that handles hexidecimal
float notation:

https://stackoverflow.com/questions/18180116/vc-rejecting-hexadecimal-floating-point-constant?utm_source=chatgpt.com

If not Visual Studio, we also take the messier path for things that don't
report themselves as C99. Most things will take the cleaner path, though.

Closes #15276.
2026-03-28 11:18:03 -04:00
Frank Praznik
1df279a04f x11: Look for text/uri-list in the list of MIME types more thoroughly
A uri-list of files is the preferred format, so don't bail if a preferred text format is encountered first.
2026-03-27 12:21:40 -04:00
Sam Lantinga
995d4e10a6 Added documentation for getting the full resolution in iOS 2026-03-27 08:43:30 -07:00
Sam Lantinga
122ad3d6f6 Added SDL_IsPhone() 2026-03-27 05:45:36 -07:00
Strultz
6a9449c098 Fix window caption drawing on borderless windows (#15275) 2026-03-27 05:14:19 -07:00
c4veman
159bba9aa1 Check Windows version before setting window attributes 2026-03-26 10:43:52 -07:00
Petar Popovic
53c799a7a9 SDL_SetWindowShape(): Remove shape when argument is NULL 2026-03-26 10:42:12 -07:00
Regan Green
1d2f9f0e0e Use DSBFREQUENCY_MAX instead of hardcoded constant for DirectSound driver max frequency. 2026-03-25 20:39:19 -04:00
Clownacy
6efe0e19a7 Fix DirectSound buffer creation failure with >200kHz
Caps the sample rate at 200kHz so that SDL's mixer will downsample any streams which are higher than that.

My Mega Drive emulator outputs at 223721Hz (the sample rate of the PSG chip), and `SDL_OpenAudioDeviceStream` fails due to DirectSound's `CreateSoundBuffer` returning an 'invalid parameter' error code. Lowering the sample rate makes the error go away.

Reported to me by @B3HKO in this issue:
https://github.com/Clownacy/clownmdemu-frontend/issues/60

The 200kHz limit is documented here:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee419022(v=vs.85)

DirectSound's Wikipedia article mentions that problems may occur with sample rates above 192kHz, but no source is provided, so I am unsure whether to take it seriously.
2026-03-25 13:23:24 -07:00
Ryan C. Gordon
dcc177faa4 emscripten: Add support for automounting persistent storage before SDL_main.
Now apps can have persistent files available during SDL_main()/SDL_AppInit()
and don't have to mess with Emscripten-specific code to prepare the filesystem
for use.
2026-03-25 14:16:07 -04:00
Anonymous Maarten
be6f1efa26 ci: clang-tools-extra is no longer available for mingw32
mingw32 and mingw64 are in the process of being deprecated
2026-03-25 18:41:00 +01:00
c4veman
8eeef53a80 Fix endmacro syntax in macros.cmake 2026-03-25 08:30:58 -07:00
nmlgc
989de77f4f render: Skip UV check when software-rendering untextured quads
Fixes a crash when calling SDL_RenderGeometryRaw() with both `texture`
and `uv` set to `NULL`, and with geometry that is laid out in a way
that passes the quad checks.
2026-03-25 07:24:55 -07:00
Green Sky
998159fa95 video: add more direct mjpeg to yuv conversions 2026-03-24 08:59:50 -07:00
Sam Lantinga
299ed51984 Added an internal hint to set OpenVR overlay flags 2026-03-23 15:23:38 -07:00
Ian Monroe
608416b5a9 support updating media name in the PipeWire backend
with this, applications can do something like this:
SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "current song")
and this will be reflected in the Audio Devices Plasmoid, pavucontrol etc

also cleaned up PW_KEY_MEDIA_NAME and PW_KEY_NODE_NAME; setting them to the
same appears string appears to break convention, as it results in redundant
titles in PipeWire application lists.
2026-03-23 15:26:54 -04:00
William Horvath
983e984afc windowsrawinput: Unregister/register raw input devices as necessary.
The thread is still created once and only shut down on WIN_VideoQuit,
but the thread will unregister the devices when they're disabled to avoid
wasting time processing raw input that won't be appreciated by anyone.

This also allows RIDEV_NOLEGACY to be set on the devices, otherwise they
swallow up the WM_MOUSE* events that would be going to the main thread
when relative mode is disabled. That's out of scope for this change, though.
2026-03-22 17:57:02 -07:00
William Horvath
706e7f9043 windowsrawinput: Fix incorrect INVALID_HANDLE_VALUE checks.
CreateEvent/CreateThread return NULL on failure.
2026-03-22 17:57:02 -07:00
William Horvath
00f9a25879 windowsrawinput: Add missing WIN_SetRawKeyboardFlag_Inputsink stub. 2026-03-22 17:57:02 -07:00
SDL Wiki Bot
28423eed96 Sync SDL3 wiki -> header
[ci skip]
2026-03-23 00:53:55 +00:00
Sam Lantinga
f22e088211 Clarified SDL_MostSignificantBitIndex32() documentation
Fixes https://github.com/libsdl-org/SDL/issues/15247
2026-03-22 17:52:32 -07:00
Edgar J San Martin
ad91384704 Base GCMouse raw input implementation
Fix duplicate button/scroll events when GCMouse active

Fix duplicate events and add thread-safe atomic for GCMouse

Fix GCMouse relative mode sync when connected after mode enabled

Respect SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE in GCMouse handler

Fix variable shadowing in GCMouse motion handler
2026-03-22 08:25:22 -07:00
Sam Lantinga
a48dee5ac1 Updated documentation on customizing your Android app name 2026-03-21 16:03:40 -07:00
Sam Lantinga
0f9292a367 Fixed incorrect sampler when changing Metal draw state 2026-03-21 14:08:40 -07:00
SDL Wiki Bot
3462494ec1 Sync SDL3 wiki -> header
[ci skip]
2026-03-20 18:21:04 +00:00
SDL Wiki Bot
7360a37181 Sync SDL3 wiki -> header
[ci skip]
2026-03-20 15:39:03 +00:00
SDL Wiki Bot
0e50195d37 Sync SDL3 wiki -> header
[ci skip]
2026-03-20 01:07:55 +00:00
Konstantin Tomashevich
291d1b6491 SDL_systhread.c: Remove SIGCHLD from blocked signal mask.
When SIGCHLD is blocked, some executables (for example CMake) do not exit properly when executed using `SDL_CreateProcess` from any SDL thread (not main thread). `SDL_CreateProcessWithProperties` docs say that `SIGCHILD` should not be ignored or handled, therefore blocking it during thread creation is a likely reason for the bug. Should fix #15210.

Signed-off-by: Konstantin Tomashevich <konstantin.tomashevich@gmail.com>
2026-03-18 13:10:03 -07:00
Ryan C. Gordon
b0cf826227 dynapi: Minor cleanups to library loading code. 2026-03-18 14:50:58 -04:00
sunshineinabox
6b060435e3 egl: Handle error when binding EGL API in context creation 2026-03-18 13:47:27 -04:00