Previously, a failure of SDL_SetClipboardData() would leave the clipboard in an unknown state, as the degree to which the internal state was cleaned up depended on where in the process the failure occurred: the clipboard may have been cleared and completely reset, or it may have reported failure while the backend continued to hold references to the passed parameters.
Clear the clipboard consistently when the setting process fails, so callers can be ensured that no references to their data remains held. In the case of early failure, the cleanup function, if any, will still be called to ensure consistency.
You can also set the asynchronous polling interval using SDL_HINT_JOYSTICK_ASYNC_UPDATE_INTERVAL if you'd like it separate from the event loop update frequency.
Fixes https://github.com/libsdl-org/SDL/issues/15403
This allows matching up controllers and their associated audio devices, e.g. DualSense controllers and their associated haptic audio endpoint.
Fixes https://github.com/libsdl-org/SDL/issues/9197
- They now work when the app specifies a NULL spec (verses a spec with zero'd
fields).
- They now favor the hint, falling back to the device's default settings
(before they would fall back to `DEFAULT_AUDIO_*` defines, but it's better
to default to what the hardware natively offers, and if the device doesn't
specify a default, they'll be set to those defines earlier anyhow). This
uses `device->default_spec` instead of `device->spec` so if something opens
the device at a low-quality, it doesn't force all future default opens to
conform to it.
- Hint docs now explain this.
Fixes#16652.
This prevents joystick activity on a separate thread from blocking input processing on the main thread.
One side effect of this is that joystick events need to be dispatched while the joystick lock isn't being held, to prevent deadlocks if an event watcher calls a joystick function. To handle this, joystick events for the current update are sent all at once at the end of the joystick update while the joystick lock is no longer held.
The joystick and sensor subsystems call into each other, so they share the same lock and sensor events are queued and dispatched similarly.
Use pthread_condattr_setclock() and sem_clockwait() when available, so that wait operations will be timed against the monotonic clock. This avoids potential hangs if the realtime clock experiences a discontinuity.
We had logic to do this, but due to the nature of iOS, we never actually
called it because the process terminated before we could. This was likely
true on Android, HarmonyOS, and Emscripten, too, so this adds a new interface
that various platforms can use as appropriate when the event fires.
The generic implementation just attempts to set apprc to success, which will
result in normal process termination, including calling SDL_AppQuit(), which
matched current behavior, but to be fair, all the platforms that use the
generic backend shouldn't ever fire this event.
When calling SDL_AppQuit() due to SDL_EVENT_TERMINATING, the other backends
leave the SDL_AppResult as SDL_APP_CONTINUE (assuming SDL_AppEvent() didn't
respond to SDL_EVENT_TERMINATING by returning a terminating result), so that
SDL_AppQuit() has a signal that they have arrived at termination in an unusual
way, instead of the app explicitly requesting it.
Fixes#16457.
It's the only thing you would need to query with an external function, and the
pen ID could be invalid by the time you run the event queue, so it's easier to
just include it with the events.
Fixes#16316.
Nothing in here has public API documentation (intentionally), and since it's
in the same category as SDL_main.h, it would overwrite its function-order list,
causing the "Main" section to be dropped from the Quick Reference pages.
Applications drawing client-side decorations (shadows, invisible resize borders) can declare their insets via four new window properties. SDL sets the xdg geometry to the surface minus the insets and translates configure sizes, size limits and popup positioning accordingly. All-zero insets (the default) leave protocol traffic unchanged; the configure-size dedup becomes state-aware so a maximize/fullscreen toggle at unchanged dimensions is re-adopted rather than skipped.
In addition to adding properties to audio devices, the new property,
`SDL_PROP_AUDIO_DEVICE_UNIQUE_ID_STRING`, allows a best-effort option to find
the same specific audio device used on a previous run of a program, even in an
imperfect way. Most backends don't support this, but CoreAudio on macOS and
IMMDevice on Windows can.
coreaudio: Rework device enumeration queries, acquire unique_id.
- No longer keeps multiple AudioObjectPropertyAddress objects, just change the
selector for each query.
- Move string retrieval for AudioObjectProperties off to a separate function.
- Query for unique_id.
- If a device name is blank, don't reject the device, try to come up with a
name of some sort (either the unique_id or "Unnamed audio device").
windows: Add unique audio device identifiers to IMMDevice support.
This uses the new "StableId" property on Windows 11 if available, and the
device id (IMMDevice::GetId()) otherwise.
Microsoft claims that GetId() remains valid between reboots and even
disconnecting and reconnecting the audio device (although I am dubious that is
universally true when plugging into a different USB port, etc), but driver and
OS updates might change the identifier. StableId goes further, promising that
software updates won't change it, either.
This adds support to our WASAPI and DirectSound backends, if you're on at
least Windows Vista. Windows XP will not offer a unique ID for devices.
Fixes#16258.
This is my port of SDL3 to HarmonyOS/OpenHarmony. It has been tested on real
hardware from Huawei, and commercial games are being prepped to ship with it
already.
There is _heavy_ documentation in docs/README-harmonyos.md, including how to
set up a development environment and project, build, and debug, for the
completely uninitiated.
This work was sponsored by Outfit7: https://outfit7.com/Fixes#9837.
This makes the Vulkan code match the D3D/Metal/GPU renderers, and avoids bugs and unsupported format/sampler combinations on various vendor's drivers (including NVIDIA!)