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>
(cherry picked from commit 291d1b6491)
When emulating display modes or using display scaling, custom cursors need to be scaled, or they can appear too large or small relative to the window size.
(cherry picked from commit 3d21b3bc68)
The SDL keyboard and mouse will be removed when destroying the seat, so there is no need to preemptively remove them.
(cherry picked from commit 566448d95a)
Technically we only want to do this for controllers that are opened, but we don't have a way to match up controllers using other APIs with individual GCControllers.
(cherry picked from commit 11adfd2008)
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)
This PR makes the GameInput joystick backend ignore non-gamepad controllers if DirectInput or XInput backends are enabled. This is done to prevent possible bugs and/or regressions.
(cherry picked from commit 419dcfe747)
(This was corrected in main, but there isn't a clean cherry-pick we can do for
the release-3.4.x branch at this point, since various pieces of the sRGB work
made it in here in a different order, but this is the one crucial line that
appears to be missing.)
Reference Issue #14898.
This PR includes small improvements to the GameInput joystick backend:
- Device subtypes
- Compatibility with DirectInput joystick mappings (if the controller is not a gamepad, i.e. `GAMEINPUT_InternalIsGamepad()` returns `false`)
- Fallback to DirectInput/XInput for currently unsupported devices (force feedback ones and the ones that are neither gamepads nor controllers, I'm not sure if that's possible, but maybe racing wheels and other device subtypes would count?)
(cherry picked from commit 0138843eb7)
PS4/5 controllers put device specific data into a specific region in the report, so we have to extract it separately.
No known guitars use the right stick on the guitar, so to keep things working similarly to PS3, i have opted to map whammy and tilt the same way as the PS3 rb guitars.
(cherry picked from commit 94f17d6c61)
Apparently, because PlaneSlice wasn't initialized, we couldn't use SDL_GPU_TEXTURETYPE_2D_ARRAY and SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE together, as the error d3d12:
"ID3D12Device::CreateUnorderedAccessView occurred: The PlaneSlice -858993460 is invalid when the resource format is R8G8B8A8_UNORM and the view format is R8G8B8A8_UNORM. Only Plane Slice 0 is valid when creating a view on a non-planar format. [ STATE_CREATION ERROR #344: CREATEUNORDEREDACCESSVIEW_INVALIDPLANESLICE]"
(cherry picked from commit 89cab56536)
SDL normalizes the super/GUI modifier away, so adding a key with this modifier will overwrite the base, unmodified value.
(cherry picked from commit 8c8efd4ccd)
- Use exact numerator/denominator from spec for CMTime to avoid rounding errors.
- Wrap frame rate setting in @try-catch to prevent crashes on strict drivers.
(cherry picked from commit e2a2e2c31e)
Don't disable this functionality when defining SDL_LEAN_AND_MEAN, but if you need to, you can define SDL_DISABLE_STB if you want to compile this out.
Fixes https://github.com/libsdl-org/SDL/issues/15139
(cherry picked from commit 72d5fe213f)
We have an implementation that uses 128-bit math and one that handles large values without it (thanks @jessechounard and @rabbit-ecl!)
Fixes https://github.com/libsdl-org/SDL/issues/15042
(cherry picked from commit 24404d9047)
V4L2 is able to advertise that a video device is able to display any frame
interval within a continuous range. SDL does not allow advertising this and
only exposes discrete frame intervals. To work around this, SDL attempted to
generate a subset of the range with a fixed interval. Unfortunately, the way
this was accomplish is inherently broken and led to attempting to allocate a
very large number of formats per resolution and colorspace. With the Magewell
Pro Capture HDMI, which can expose FRMSIZE_TYPE_CONTINUOUS as well, this can
expose a truly astronomical number of formats, exceeding 1 PB of RAM. This will
lead to an OOM kill for any process that tries to initialize the camera
subsystem.
This patch just tests to see if some common frame rates are within the
contiuous range and expose those. SDL still does not handle
FRMSIZE_TYPE_CONTINUOUS in a graceful way so it still uses over a gigabyte of
RAM for each possible combination of sizes, but with this patch it no longer
leads to an OOM kill. The API will need amending for proper support for both
continuous frame sizes and frame intervals.
(cherry picked from commit ab6dd970ac)
to eliminate discrepancies between release-3.4.x and main branches.
(cherry picked from commit 165bfd3e83)
(cherry picked from commit 90aaa23977)
(cherry picked from commit 7d27ca282e)
(cherry picked from commit 6fc31b7f0b)
(cherry picked from commit c71c53c406)
(cherry picked from commit c9b7ca0c42)
(cherry picked from commit e2bc4be482)
(cherry picked from commit ae4fb50316)
(cherry picked from commit 6f45f97af0)
(cherry picked from commit d2ca570050)
(cherry picked from commit 73500019ea)
(cherry picked from commit 72ed7d0f87)
(cherry picked from commit 2aacf018f0)
[ci skip]
This is only useful if the application knows to add the flag introduced by this
extension, and at that point the application can also include the extension
themselves.
Case in point: SDL_gpu_vulkan was already doing this!
DSV creation was missing a TEXTURE2DARRAY branch for array, cube, and
cube-array depth textures. It fell through to TEXTURE2D, so
FirstArraySlice was never set and all layers' DSVs targeted layer 0.
This caused incorrect rendering when using depth textures with multiple
layers, such as cubemap shadow maps.
Previously it would have reported success but not returned a valid string, and
didn't check for the (probably extremely unlikely) case of overflowing our
locale list array.
(cherry picked from commit 3aa531000a)
SDL_GetGrabbedWindow() can be called when the video system is uninitialized, and, since there is no window parameter, _this must be checked for validity to avoid a segfault.
(cherry picked from commit be82f316c4)
It SDL_SYS_EnumerateDirectory was changing the path string and passing it to
the callback, causing chaos in the glob handler, which expected the original
string to pass through.
Fixes#15057.
(cherry picked from commit a3b0403412)
Fixes browsers on phone that change screen orientation during fullscreen not
getting a resize event.
Fixes#15024.
(cherry picked from commit 0f2d415dee)
Avoids a null dereference of currentRegion->vulkanTexture->container in DefragmentMemory:
} else if (!currentRegion->isBuffer && !currentRegion->vulkanTexture->markedForDestroy) {
...
¤tRegion->vulkanTexture->container->header.info
... (among others)
by not "VULKAN_Submit"ting (and thus adding it to the defrag pool) before setting the container.
Although rare (defrag almost never ran), this crash happened in a real-world application.
(cherry picked from commit 06bf8d1924)
Getting device names can hang for a long time on certain devices, so make sure this is done on a separate thread to avoid blocking initialization and the main loop.
Fixes https://github.com/libsdl-org/SDL/issues/12913
(cherry picked from commit bc623d1af6)
Some devices with broken drivers hang when their name is queried, so added a workaround for applications that don't need input device details. The long term fix is to move the hotplug detection into a separate thread.
(cherry picked from commit a66988621a)
It's now SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER, since it does more than mess
with the srgb-capable context attribute now.
Reference Issue #14898.
(cherry picked from commit 10b524c7cc)
The default varies between OpenGL and OpenGL ES, so try to force it to what
the app actually requested with SDL_GL_FRAMEBUFFER_SRGB_CAPABLE.
Fixes#14898.
(cherry picked from commit 083c6b8872)
FS.mkdir() will throw a javascript exception if the scratch directory already
exists, so catch/ignore that.
Wrap the rest of the scratch i/o in a try/catch block; the event will only
send if everything works out.
Wrap some calls from Javascript to the C runtime's free() in an
EMSCRIPTEN_KEEPALIVE function, so that the compiler doesn't optimize the
function out and crash at runtime.
Fixes#14999.
(cherry picked from commit 267e681a0b)
This controller has 3 interfaces, one for the Xbox gamepad protocol, and two HID interfaces. We should only handle the Xbox interface in the Xbox driver.
(cherry picked from commit 9f8c70713a)
Removed obsolete documentation that shows this usage and macros that attempt it.
Also allow SDL_FUNCTION to be redefined by the application.
Fixes https://github.com/libsdl-org/SDL/issues/15004
(cherry picked from commit 6feb0e1333)
In SDL_audio.c:OpenPhysicalAudioDevice, an attempt is made to SDL_CreateThread
if ProvidesOwnCallbackThread is false, but SDL_CreateThreadWithPropertiesRuntime
is not implemented for Emscripten, so this always fails. I'm not sure if/when
this ever worked, but it simply cannot work in its current state.
(cherry picked from commit 8ee7dc2f9f)
The patterns we were using don't match the official patterns, which fill up as
many lights as players instead of just using the nth player LED. Above 4,
there are some special patterns, as documented on Nintendo's Singaporean site:
https://www.nintendo.com/sg/support/qa/detail/33822
(cherry picked from commit 017d950b6b)
This hint is documented to not just turn off fullscreen windows going into a
new Fullscreen Space, but also to make the green button on a resizeable
window's title bar do a maximize/zoom instead of make the window fullscreen.
Previously, this only did the former and not the latter (or perhaps it worked
and the defaults changed in a newer macOS, we aren't sure).
Fixes#7470.
(cherry picked from commit 50f3adec77)
This also delays pen proximity out events to make sure that the pen is really gone before delivering them. On Android, you get a HOVER_EXIT event when the pen contacts the surface, which we don't want to treat as the pen leaving proximity.
(cherry picked from commit bddf6d3e2a)
In this case, it's available via both libusb and hidraw, but the hidraw device isn't usable. If a device needs to be opened via libusb, don't expose it via hidraw enumeration.
(cherry picked from commit f60231759d)
On Windows there is a separate HIDAPI device for each slot. On Linux and macOS, there is a single HIDAPI device and the slot is included in the report.
(cherry picked from commit cdffbdfeaf)
We still need the task to go through the IoRing, even though the flush
operation we use to get it there will always fail on a read-only file. So
check for this specific case and don't report failure.
Fixes#14878.
(cherry picked from commit 4df13e8806)
Transform clearing of arrays into SDL_zeroa(), and
clearing through a T* with size(T) into SDL_zerop().
Extends commit 83fb7b6636.
(cherry picked from commit 248223592a)
This reverts commit cd31381185.
Linking libbrcmEGL.so explicitly breaks (causes segmentation faults) in other code that links and runs the X11 EGL.
Reopens https://github.com/libsdl-org/SDL/issues/14749
At least in my Raspbian Stretch build environment, the vc_dispmanx symbols that were missing are found in libbcm_host.so, which is linked by default.
(cherry picked from commit 7fe30b04bf)
This avoids some misleading error messages when running unit tests with
the dummy driver: on a typical desktop Linux system, it's normal for
opening keyboards and mouse in `/dev/input/*` to fail with `EACCES`,
and in container technologies that share `/sys` but not `/dev` with the
container, we can find that we fail to open them with `ENOENT`.
Resolves: https://github.com/libsdl-org/SDL/issues/14872
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9ceb982a63)
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)
Otherwise, the quit event can be sent prematurely. The topmost status must be queried and cached before sending the close request event, as the window may be destroyed in an event handler.
(cherry picked from commit 34b620c3f8)
Stop the frame callback and flag the cursor for a refresh when the pointer re-enters the surface, but don't set a null cursor, as it may have already been set after entering a surface that is part of the window decorations, resulting in an unwanted invisible cursor.
(cherry picked from commit 5e2977709b)
Avoids UBSan warning (among other similar ones in SDL_thread.c):
src/thread/SDL_thread.c:109:13: runtime error: index 1 out of bounds for type 'struct (unnamed struct at src/thread/SDL_thread_c.h:70:5)[1]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/thread/SDL_thread.c:109:13
(cherry picked from commit f9395a766f)
Requesting certain MIME types (e.g. EPS formats offered by KDE) can be *very* slow, on the order of multiple seconds, due to requiring significant processing. Only try to load image MIME types that SDL is known to support (BMP and PNG).
(cherry picked from commit 32747ceb84)
The default timeout value of 14ms is ideal when querying clipboard data while polling events, to prevent excessive lag if the source takes a long time to respond, however, when reading from SDL_GetClipboardData(), the timeout can be too short if a large amount of data must be processed or transferred. SDL_GetClipboardData() is not called while polling events, so using a longer read timeout to greatly increase the chance of success is acceptable.
Use a 5 second timeout when reading from SDL_GetClipboardData() and GetPrimarySelectionText() to greatly increase the chances of a successful read, even if the requested format requires heavy processing.
(cherry picked from commit 2a0d04613c)
Clients that defer repainting may hang in SDL_WaitEvent() while interactively resizing if they only redraw when an appropriate event is received, as resizing defers the new state until a frame callback is received, and if too much time elapsed since the last redraw, the last frame callback may have already occurred. Send an exposure event when deferring resizes so the client will make forward progress and trigger a frame callback to ack the pending configure state.
(cherry picked from commit 2212c4f085)
Prevent mouse and keyboard events from being processed twice by
skipping [super sendEvent:] for events SDL has already handled via
Cocoa_DispatchEvent. Other event types still go through AppKit's
normal handling.
(cherry picked from commit dd52dd8995)
Older versions of XInput2 do not declare struct XIGesturePinchEvent
in XInput2.h, causing compilation failure in SDL_x11xinput2.c
Check for XIGesturePinchEvent in the test for enabling
SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
(cherry picked from commit 7690e00f42)
In rare cases, a leave event can be grouped with relative motion in a frame. Ensure a valid focus window when dispatching relative motion.
(cherry picked from commit fab42a1432)
hid.dll simply cannot send 7 bytes reports unlike other platforms
It enforces full length repots of 17 from the device's descriptor,
which does not work on the device.
This breaks ffb and led control, so we disable this by default on
windows.
(cherry picked from commit 6c2f9bc41e)
CGDisplayPixelsHigh(kCGDirectMainDisplay) involves an IPC call to the
Window Server on each invocation. Cache the main display height in
SDL_CocoaVideoData and update it only when display configuration changes,
reducing overhead during high-frequency mouse event processing.
(cherry picked from commit 3ee8d1406c)
`target_get_dynamic_library` should not be called if `SDL_HIDAPI_LIBUSB_SHARED` is set to OFF, it otherwise causes a warning at best, or a build failure if libusb is provided by a parent project and not installed on the system
(cherry picked from commit 4a29b6a651)
It turns out the reason this function was having so many overread issues was because our row copies were wrong - for compressed images we also need to reduce the row count based on the block size, similar to what we already do for pitch calculation - these copies are byte copies, not pixel copies!
(cherry picked from commit f472f93db8)
The event core will do so automatically, and this may end up dropping events in rare cases when exiting fullscreen if an event with the final bordered window size is sent before the event notifying that the borders have come back on.
Don't decide if the button is pressed by the `buttons` bitmask, but rather by
event type. On macOS, the trackpad might produce a mousedown event with taps
instead of full clicks--if tapping is enabled in System Preferences--and in
this case might not set the flag in the bitmask.
Fixes#14640.
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.
Anecdotally, some force-feedback wheels have been reported to experience a
reduced "definition", "texture", "precision", or "je ne sais quoi", which
appears to be caused by sending more update flags than necessary to
DirectInput.
This may be related to the fact that there are two USB PID packets that are
sent when updating a device: One contains the "general" force data, and the
other contains the "type-specific" data. My speculation is that many wheels
expect to only receive the latter, and misbehave when receiving both.
This has been tested and validated anecdotally by others who have received
a hacked-together version of PCSX2 that corrects the flags sent to DirectInput,
who noted a significant improvement in the "feeling" of the FFB effects.
The only way to validate this at a technical level is to grab a wheel that uses
the "generic" DirectInput FFB drivers (which map nearly 1:1 with the USB PID
specification), and inspect the USB packets (e.g. with USBPcap) to check whether
redundant data is being sent.
This upsets things, because you end up calling a javascript function with
more arguments than it expects, and if asserts are enabled, Emscripten notices
this and aborts the program when you hit this code.
Reference Issue #14670.
Wayland icons must be square, so scale non-square images to fit a square region instead of failing. This matches X11 behavior.
A warning that the image will be scaled will be logged.
As 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>
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>
Currently, no compositor that supports the warp protocol sends a motion event after doing so, so SDL must synthesize one when using the warp protocol, as it did with the locking protocol.
This can be avoided once
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/340 is completed.
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.
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.
This matches other platforms.
Also make sure Android explicitly sets vsync on restore, regardless of the
specific setting, to make sure it's consistent.
Fixes#14642.
Calling SteamAPI_InitEx() will set environment variables that SDL uses to properly support the Steam virtual gamepad. Make sure that we fall back to the real environment for the variables that Steam sets.
We might be setting an environment variable along with other application code setting environment variables (like code in SteamAPI_InitEx()) before initializing SDL.
Core X11 events are used for absolute motion while the mouse is grabbed, as XInput doesn't receive motion events from the master pointer, and the position from the slave devices lags one report behind. However, pointer events emulated from multitouch events can't be filtered out when using core events, as the XInput flags are not passed through.
Use the absolute position from slave devices in XInput motion events while the mouse is grabbed and touch events are active to allow filtering out pointer events emulated from touch events. Pointer events in this case may be a report behind the master device, but receiving input from both the pointer and touches simultaneously is not likely to be a common occurrence.
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.
It turns out that some distros set SDL_IM_MODULE globally, which leads to broken text input with this check, and there really is no reason not to use the text input protocol when available.
Reverts 2b375d9704
Wayland cursors are surfaces sized in scaled points, so this hint wouldn't change the size, just prevent larger backbuffers from being used to draw sharper scaled cursors.
This gives us more robust handling of Bluetooth Xbox controllers which may vary the report format between firmware versions.
Firmware versions tested:
Xbox One S: 3.1.1, 4.8.1923, 5.13.3143
Xbox One S/X: 5.11.3118, 5.23.6
Xbox Elite Series 2: 5.22.16, 5.23.6
Fixes https://github.com/libsdl-org/SDL/issues/14597
We only want to change cursor display scale if the application or the user opts in by setting a hint. Otherwise cursors could change size unexpectedly when upgrading to SDL 3.4.0.
Windows may be destroyed in event handlers, so check the window validity after pushing window events onto the queue to ensure that the window and its properties are still valid.
This reverts commit 3ee29f2e7a, among other
changes. This means getting a scary warning on the javascript console in
Emscripten by default, but this is easily fixed by setting a GL swap
interval at startup or creating a 2D renderer with the appropriate property
(or call to SDL_SetRenderVSync()).
Fixes#14625.
The was duplicated in the XInput2 code, but taking an SDL_VideoData parameter instead of SDL_VideoDevice. Remove the duplicated XInput2 function, and use an SDL_VideoData parameter for X11_FindWindow to avoid an unnecessary dereference.
A common use case is asking someone to clone SDL and run a test. This simplifies the instructions so we don't also have to tell them how to enable the tests. Anyone savvy can just add -DSDL_TESTS=OFF if they don't want to have them.
The Emscripten support for setting window icons introduced in #14490 does not work when using pthreads. Using `SetWindowIcon` will cause the program to crash. The reason for that is that the `Blob` constructor does not accept shared memory (`SharedArrayBuffer`).
We need to create a local copy of the icon data if necessary.
* Implemented EnumerateStorageDirectory()
* Implemented RemoveStoragePath()
* Fixed init failure if the application previously crashed with a write batch in progress
* Allow creation of multiple Steam storage objects, the write batch is complete when the last storage is closed
* Check to see if a file exists in GetStoragePathInfo()
If you want access to the SDL_REVISION define,
you must explicitly include this header.
Language like this was present in the SDL2 version,
but disappeared in SDL3, even though it's still true.
This reverts commit a3992f504c.
The reason SDL_revision.h was not included by SDL.h or SDL_version.h is because SDL_revision.h changes with every git commit, causing a complete SDL rebuild for every trivial git commit.
* GPU: D3D12: Missing WinPixEventRuntime.dll now logs warning at device creation time.
* GPU: D3D12: Debug label functions are now a no-op when WinPixEventRuntime.dll is missing.
* Docs: GPU: Debug function documentation now notes WinPixEventRuntime.dll is required under D3D12.
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.
We already set the main thread when creating a thread or calling SDL_Init(), and applications can call SDL_SetMainReady() themselves for special cases, so there isn't a lot of value of forcing everyone through the SDL_RunApp() flow.
Fixes https://github.com/libsdl-org/SDL/issues/14580
This prevents validation errors on D3D12 caused by the previous solution
that utilized internal D3D12 functions. This is still the fallback
solution if WinPixEventRuntime.dll is not present in PATH, but a warning
is printed to let you know how to fix these errors.
SDL_SetWindowFullscreen now reports failure while a fullscreen transition is
already in progress on Emscripten, upsetting the test when it tries to come
back to windowed mode, but testautomation will never give correct results here
even when we fix the backend to queue pending reversal requests, because
you'll have to return to the Emscripten mainloop before these state changes
will occur.
It's just sort of luck this specific test passed before on this target.
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())
If video is initialized, the main thread is the one that initialized video, otherwise if events are initialized, the main thread is the thread that initialized events, otherwise the main thread is the one that called the main function.
Fixes https://github.com/libsdl-org/SDL/issues/14511
This lets applications choose which scene their windows are being created in. For example one window might be video output in a scene with a session role of UIWindowSceneSessionRoleExternalDisplayNonInteractive, and video controls in a scene with a session role of UIWindowSceneSessionRoleApplication.
Now other projects can use it with their headers, if they provide an options
file with specifics and are willing to follow some SDLish header conventions.
This shouldn't affect SDL satellite projects, etc, since they literally use
the SDL symbols, like `SDLCALL` and such, which are the defaults in the script
if a .wikiheaders-options file doesn't override them.
Grabbing the mouse interrupts touch events in progress, so if someone
enables relative mode while a button is pressed, wait for the button to
be released before grabbing the mouse.
It'll usually replace it with `{ "SDL_app", NULL }`, but things like Win32
can query the OS for the original command line arguments.
This allows apps/scripting languages that provide their own entry points to
use SDL_RunApp and not have to worry about how to compose an argv array on
things like Windows, when SDL was going to do it for them anyhow.
Most things won't experience any change with this commit, including apps that
that want extra control but originate in a standard main()-style entry point
and can just pass the existing argc/argv through to SDL_RunApp.
Windows isn't addressed here, since a previous commit already updated it.
GDK has a different fix here, but we'll unify that in a later commit.
Closes#12676.
This, strictly speaking, doesn't _need_ to be public domain any more, since
SDL3 no longer inserts this code into apps via a static SDL_main library; it's
just part of the normal zlib-licensed SDL library and called into through a
well-defined entry point at startup, now.
But removing a public domain notice isn't the done thing, so we'll leave it in.
(To a related point: even if others have rewritten good portions of this code,
they're doing it under the assumption that this specific file has a public
domain license.)
This new implementation only parses the command line into an argv when
the provided argv is NULL. This lets programs that don't want to/can't
include `SDL_main.h` to do their own custom argument processing before
explicitly calling `SDL_RunApp()` without having SDL clobber the argv.
If the user includes `SDL_main.h` as normal, the behavior remains the
same as before (because `SDL_main_impl.h` passes a NULL argv).
In addition, this new implementation performs fewer allocations and no
longer leaks on failure.
Instead of only using it for the side effect of making MsgWaitForMultipleObjects block on the next call.
This has the added benefit of avoiding an extra MsgWaitForMultipleObjects call if there was actually new raw input in the queue already.
This still had a bunch of text that wasn't updated for SDL3's ability to deal
with pre-user-interaction pages. Same idea, but changed text that suggested
you have to wait to open the audio device.
Same deal as the current Windows code: this "fixes" proximity but limits you
to a single pen device. But this is probably okay for most reasonable use
cases.
Now everything will attempt to track pens through proximity changes (instead
of removing the pen entirely). testpen.c has been updated to reflect this.
Some platforms and devices are better at this than others, but this seems like
a significant usability improvement across the board.
Fixes#12992.
This reverts commit 964bedfdd9.
The vendorName is more expressive and lets the user distinguish between different controllers of the same type, e.g. "PlayStation VR2 Sense Controller (R)" and "PlayStation VR2 Sense Controller (L)" vs "Spatial Controller"
If the product category is necessary, we can add a property to store that as additional information on the controller.
Normally the gamepad is used for navigation on visionOS, but when the controller subsystem is enabled we want to receive gamepad input as gamepad events instead.
An active cursor being destroyed may still have a frame callback referencing the thread queue, so clean it up before destroying the thread queue to ensure that no references to the queue remain when it is destroyed.
This PR adds support to the cmake build scripts so to allow building SDL with the Tiny C Compiler (tcc).
TinyCC supports the subset of C99 used by SDL and will complete the build once the --version-script linker flag is removed. The changes have been tested with various build configurations, including X11 and Wayland, and using tcc version 0.9.28rc 2025-10-27 mob@f4e01bfc on x86_64 Linux.
Some caveats:
- the fake pen will leave proximity only when relative mode is disabled
- unsure if detecting proximity is even possible from raw mouse input
Fixes#12324.
This changes the default for SDL_GL_FRAMEBUFFER_SRGB_CAPABLE to -1 (for
"don't care"). Minor ABI break, but technically this never worked correctly.
Fixes#13055.
The OpenGL headers are not always implicitly available, so this improves the check by calling `find_package` and using the `OPENGL_INCLUDE_DIRS` or `OPENGL_INCLUDE_DIR` var for the `check_c_source_compiles` test.
The minimum CMake version currently set is 3.16, `OPENGL_INCLUDE_DIRS` was only added in 3.29, so the code is set to choose `OPENGL_INCLUDE_DIRS` if it exists. If the minimum CMake version is ever set to >= 3.29 this check can be removed and just the `OPENGL_INCLUDE_DIRS` variable can be chosen.
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.
This block was a sloppy way of trying to avoid prioritizing lavapipe over another device, but truthfully the only way to guarantee avoiding CPU drivers is to add a property to allow apps to require hardware acceleration.
If a dispatch event when showing a window returns a failure code, handle the display disconnected condition and break out of the loop, otherwise, it will hang forever.
Compositors that send multiple resize events per frame could result in the most recent configuration requests being left un-acked when the resize ends. Ack the most recent resized state on frame callbacks, so as to always ack the most recent configuration within a reasonable timeframe.
When running on 32-bit Windows, DefWindowProc resolves to a function in ntdll.dll, but after the window is created the actual window proc is a function in user32.dll. We solve this by using our own custom default window proc and looking for that instead.
Fixes https://github.com/libsdl-org/SDL/issues/1442
This fixes a crash if a surface is RLE encoded, then locked and unlocked.
We also mark the surface as no longer needing to be locked after undoing RLE encoding
We don't need to aggressively disable RLE acceleration anymore because the original pixels remain available for operations that aren't supported by the RLE blitter.
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.
The HID descriptor maps the C buttons as a right thumbstick, but this mapping matches the HIDAPI Nintendo 64 mapping.
The start button resets the controller in both USB and Bluetooth mode on macOS, but I've kept the mapping assuming this is a macOS bug that will be fixed.
It happens fairly often that people enable X11 support but don't install the extension libraries that SDL depends on. This makes those required if not explicitly disabled, which should help prevent accidentally broken builds.
Recalculate the backing viewport dimensions in the resize handler, otherwise, this data can be out-of-sync with the logical window size if queried during transition animations.
This makes sure that anything that hooks window creation to set up window proc hooks will call DefWindowProc instead of infinitely recursing when we set up our window proc afterwards.
Fixes https://github.com/libsdl-org/SDL/issues/10529
The controller can be in XInput mode or enhanced mode, so it will always show up as an XInput controller, and the enhanced mode controller will come and go as enhanced mode is enabled or disabled in the FlyDigi Space Station app.
Store the images in order from smallest to largest to simplify lookup and be able to early-out of the search loop even if there is no exact match for the scale.
Some compositors don't implicitly use the pointer cursor when the tablet cursor is not set, and the presence of a tablet doesn't necessarily guarantee pointer capability. Set the cursor for tablet tools independently of pointer cursors.
This required refactoring of cursor state handling, as well as some tablet related structures.
Cache the cursor image data at creation time, and use a viewport to render scaled custom cursors, instead of generating new cursor images for every scale.
The OS uses the presence of the UILaunchScreen key to determine whether to display the application in compatibility mode or display using the whole screen.
Allowing GCC/Clang to auto-vectorize with AltiVec support breaks support
for non-AltiVec compatible processors. Adding this option allows the
existing AltiVec specific code to function as it always did, but
prevents the compiler from inserting AltiVec instructions into arbitrary
codepaths that SDL can't gate off via the existing CPUInfo code.
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.
Setting AudioCategory_GameChat breaks audio on several devices, including Behringer U-PHORIA UM2 and RODE NT-USB Mini. We'll disable this for now until we understand more about what's happening.
This means we exercise the non-dlopen()-based code paths for these,
as used in Debian and the Steam Runtime.
Signed-off-by: Simon McVittie <smcv@collabora.com>
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>
Stopping the thread also destroys the queue used by pointer surfaces, and if any seats still have a surface associated with the queue at that time, it will cause a libwayland warning. Destroying the seats first ensures that all surfaces associated with the thread queue are destroyed before the queue is destroyed.
DBus does not require a video backend, and DBus messages still need to be processed even when a video backend is not initialized. Move the DBus pump call to the main event message pump function so that DBus events are still dispatched, even when a video backend has not been initialized.
2025-10-23 21:03:09 -04:00
1254 changed files with 20773 additions and 9488 deletions
"steamrt3":JobSpec(name="Steam Linux Runtime 3.0 (x86_64)",os=JobOs.UbuntuLatest,platform=SdlPlatform.Linux,artifact="SDL-steamrt3",container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest",),
"steamrt3-arm64":JobSpec(name="Steam Linux Runtime 3.0 (arm64)",os=JobOs.Ubuntu24_04_arm,platform=SdlPlatform.Linux,artifact="SDL-steamrt3-arm64",container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk/arm64:latest",),
"steamrt3":JobSpec(name="Steam Linux Runtime 3.0 (x86_64)",os=JobOs.UbuntuLatest,platform=SdlPlatform.Linux,artifact="SDL-steamrt3",container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest"),
"steamrt3-arm64":JobSpec(name="Steam Linux Runtime 3.0 (arm64)",os=JobOs.Ubuntu24_04_arm,platform=SdlPlatform.Linux,artifact="SDL-steamrt3-arm64",container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk/arm64:latest"),
"steamrt4":JobSpec(name="Steam Linux Runtime 4.0 (x86_64)",os=JobOs.UbuntuLatest,platform=SdlPlatform.Linux,artifact="SDL-steamrt4",container="registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk:latest",more_hard_deps=True,),
"steamrt4-arm64":JobSpec(name="Steam Linux Runtime 4.0 (arm64)",os=JobOs.Ubuntu24_04_arm,platform=SdlPlatform.Linux,artifact="SDL-steamrt4-arm64",container="registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:latest",more_hard_deps=True,),
@@ -7,69 +7,128 @@ This is a list of major changes in SDL's version history.
General:
* Added SDL_CreateAnimatedCursor() to create animated color cursors
* Added SDL_HINT_MOUSE_DPI_SCALE_CURSORS to automatically scale cursors based on the display scale
* Added SDL_SetWindowProgressState(), SDL_SetWindowProgressValue(), SDL_GetWindowProgressState(), and SDL_GetWindowProgressValue() to show progress in the window's taskbar icon on Windows and Linux
* Added SDL_GetGPUDeviceProperties() to get the properties of an SDL GPU device
* Added GPU device creation properties to enable the GPU API on older hardware if you're not using these features:
* Added SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER to enable configuring Vulkan features when creating a GPU device
* Added SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN to allow requiring Vulkan hardware acceleration when creating a GPU device
* Added SDL_GetGPUDeviceProperties() to query information from a GPU device:
- SDL_PROP_GPU_DEVICE_NAME_STRING
- SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING
- SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING
- SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING
* Added SDL_GetPixelFormatFromGPUTextureFormat() and SDL_GetGPUTextureFormatFromPixelFormat()
* Added SDL_CreateGPURenderer() and SDL_GetGPURendererDevice() to create a 2D renderer for use with GPU rendering.
* Added SDL_CreateGPURenderState(), SDL_SetGPURenderStateFragmentUniforms(), SDL_SetGPURenderState(), and SDL_DestroyGPURenderState() to use fragment shaders with a GPU 2D renderer
* Added SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER to create a 2D texture from an existing GPU texture
* Added SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER to get the GPU texture from a 2D texture when using the GPU 2D renderer
* Added support for YUV textures and HDR colorspaces to the GPU 2D renderer
* Added support for textures with palettes, and SDL_GetTexturePalette() and SDL_SetTexturePalette() to interact with them
* Added SDL_RenderTexture9GridTiled() to do tiled instead of stretched 9-grid texture rendering
* Added SDL_GetDefaultTextureScaleMode() and SDL_SetDefaultTextureScaleMode() to set the texture scale mode for new textures
* Added SDL_GetRenderTextureAddressMode() and SDL_SetRenderTextureAddressMode() to change the texture addressing mode
* Added SDL_TEXTURE_ADDRESS_WRAP to allow wrapping of textures if the renderer has SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN set
* The default YUV colorspace is BT.601 limited range, for compatibility with SDL2
* Added SDL_SCALEMODE_PIXELART as an improved scaling algorithm for pixel art without introducing blurring
* Added SDL_FLIP_HORIZONTAL_AND_VERTICAL to flip a surface both horizontally and vertically
* Added SDL_LoadPNG(), SDL_LoadPNG_IO(), SDL_SavePNG(), and SDL_SavePNG_IO() to load and save PNG images
* Added SDL_LoadSurface() and SDL_LoadSurface_IO() to detect BMP and PNG formats and load them as surfaces
* Added SDL_PROP_SURFACE_ROTATION_FLOAT to indicate the rotation needed to display camera images upright
* Added SDL_RotateSurface() to create a rotated copy of a surface
* SDL_EVENT_WINDOW_EXPOSED now sets data1 to true if it is sent during live resizing
* Added SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, which is sent when the usable desktop bounds change
* Added SDL_EVENT_SCREEN_KEYBOARD_SHOWN, which is sent when the on-screen keyboard has been shown
* Added SDL_EVENT_SCREEN_KEYBOARD_HIDDEN, which is sent when the on-screen keyboard has been hidden
* SDL_EVENT_AUDIO_DEVICE_ADDED will be sent during initialization for each audio device
* SDL_GetCameraPermissionState() returns SDL_CameraPermissionState instead of int
* Added SDL_PutAudioStreamDataNoCopy() to do more efficient audio stream processing in some cases
* Added SDL_PutAudioStreamPlanarData() to add planar audio data instead of interleaved data to an audio stream
* Added SDL_HINT_AUDIO_DEVICE_RAW_STREAM to signal that the OS shouldn't do further audio processing, useful for applications that handle noise canceling, etc.
* Added SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN to allow streams that persist beyond the audio subsystem lifetime.
* Added enhanced support for 8BitDo controllers
* Added enhanced support for FlyDigi controllers
* Added enhanced support for Hand Held Legend SInput controllers
* Added support for wired Nintendo Switch 2 controllers when built with libusb
* Added SDL_hid_get_properties() to associate SDL properties with HID devices
* Added SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER to query the libusb handle from an SDL_hid_device, if it's been opened with libusb
* Added SDL_SetRelativeMouseTransform() to add custom mouse input transformation
* Added SDL_GetPenDeviceType() to determine whether a pen is on the screen or on a separate touchpad
* SDL_HINT_MAIN_CALLBACK_RATE may be set to a floating point callback rate
* Added SDL_GetEventDescription() to get an English description of an event, suitable for logging
* Added SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER to allow custom freeing of the memory used by SDL_IOFromMem() and SDL_IOFromConstMem()
* Added SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING to set the working directory for new processes
* Added verbose log output when the DEBUG_INVOCATION environment variable is set to "1"
* Added SDL_AddAtomicU32()
* Added SDL_GetSystemPageSize() to get the system page size
* Added SDL_ALIGNED() to signal that data should have a specific alignment
Windows:
* Added SDL_HINT_RENDER_DIRECT3D11_WARP to enable D3D11 software rasterization
* Using SDL_InsertGPUDebugLabel(), SDL_PushGPUDebugGroup(), and SDL_PopGPUDebugGroup() requires WinPixEventRuntime.dll to be in your PATH or in the same directory as your executable
* Added SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER so you can query the HMONITOR associated with a display
* SDL_HINT_AUDIO_DEVICE_STREAM_ROLE is used by the WASAPI audio driver to set the audio stream category
* Added SDL_HINT_AUDIO_DEVICE_RAW_STREAM to signal whether the OS audio driver should do additional signal processing
* Added SDL_HINT_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS to allow disabling some system hotkeys when in raw input mode
* SDL_HINT_WINDOWS_GAMEINPUT is disabled by default
macOS:
* Added SDL_HINT_MAC_PRESS_AND_HOLD to control whether holding down a key will repeat the pressed key or open the accents menu
Linux:
* Added atomic support for KMSDRM
* Added SDL_HINT_KMSDRM_ATOMIC to control whether KMSDRM will use atomic functionality
* Added SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER so you can query the wl_output associated with a display
Emscripten:
* Added SDL_HINT_EMSCRIPTEN_FILL_DOCUMENT for applications that don't want to be fullscreen, but would like to fill the window
* Added SDL_WINDOW_FILL_DOCUMENT to indicate that windows expand to fill the whole browser window
* Added SDL_SetWindowFillDocument() to change whether windows expand to fill the whole browser window
* Added SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING to allow setting the SDL canvas ID, and SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING to query it on existing windows
* Added SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING to specify where keyboard input is bound, and SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING to query it on existing windows
iOS:
* SDL now supports window scenes, fixing the warning "CLIENT OF UIKIT REQUIRES UPDATE"
* Added SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER to specify the window scene for a window
visionOS:
* The default refresh rate has been increased to 90Hz
* SDL_SetWindowSize() changes the size of the window on Vision Pro headsets
PlayStation 2:
* Added the following hints to control the display parameters: SDL_HINT_PS2_GS_WIDTH, SDL_HINT_PS2_GS_HEIGHT, SDL_HINT_PS2_GS_PROGRESSIVE, SDL_HINT_PS2_GS_MODE
Note: On Unix platforms SDL provides ELF notes describing its non-mandatory library dependencies in the format described by https://systemd.io/ELF_DLOPEN_METADATA/. Some of these libraries are quite important, so distribution vendors who package SDL should parse the ELF notes and consider generating dependencies at the packaging level, for example by using https://github.com/systemd/package-notes. Other libraries and games can add similar ELF notes to describe their own dependencies by using the SDL_ELF_NOTE_DLOPEN macro.
$str.=".\\\" https://github.com/libsdl-org/SDL/issues/new?title=Misgenerated%20manpage%20for%20$sym\n";# !!! FIXME: if this becomes a problem for other projects, we'll generalize this.
$str.=".\\\" $projectshortname can be found at $projecturl\n";
# Define a .URL macro. The "www.tmac" thing decides if we're using GNU roff (which has a .URL macro already), and if so, overrides the macro we just created.
Without getting deep into the history, MinGW is a long running project that aims to bring gcc to Windows. That said, there's many distributions, versions, and forks floating around. We recommend installing [MSYS2](https://www.msys2.org/), as it's the easiest way to get a modern toolchain with a package manager to help with dependency management. This would allow you to follow the MSYS2 section below.
Without getting deep into the history, MinGW is a long running project that aims to bring gcc to Windows. That said, there's many distributions, versions, and forks floating around. We recommend installing [MSYS2](https://www.msys2.org/), as it's the easiest way to get a modern toolchain with a package manager to help with dependency management. This would allow you to follow the MSYS2 section below.
Otherwise you'll want to follow the "Other Distributions" section below.
@@ -89,7 +89,7 @@ This should print out which library directory we'll need to use when compiling,
Now we should have everything needed to compile and run our program. You'll need to ensure to replace `<version>` with the version of the release of SDL3 you downloaded, as well as use the `<arch>` we learned in the previous section.
@@ -32,7 +32,8 @@ The Windows GDK port supports the full set of Win32 APIs, renderers, controllers
* Single-player games have some additional features available:
* Call `SDL_GetGDKDefaultUser` to get the default XUserHandle pointer.
*`SDL_GetPrefPath` still works, but only for single-player titles.
*`SDL_GetPrefPath` and `SDL_Storage` still work, but only for single-player titles.
* To enable support for these APIs, use `SDL_SetHint` to set `SDL_GDK_SERVICE_CONFIGURATION_ID` to your SCID string at startup (it should be formatted like `"00000000-0000-0000-0000-000000000000"`)
These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.