When iterating over the keymap entries, a valid xkb state object has already been allocated, so use that instead of allocating/destroying a new state object for every lookup, which avoids a calloc/free operation inside libxkbcommon. Any state set by the level lookup function will be overwritten with valid state after keymap iteration has completed.
The spec doesn't guarantee that a modifier event won't arrive before a keymap event, or that it will always be sent after a keymap change if the modifiers and layout index haven't changed, so restore any valid state after allocation when building a new keymap.
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().
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.
This is probably something we already cleaned up that has something running
in an unexpected order now that we've moved disconnect work to the main thread.
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>
SDL_CreateGPURenderer() now allows passing in an existing GPU device and passing in a NULL window to create an offscreen renderer.
Also renamed SDL_SetRenderGPUState() to SDL_SetGPURenderState().
This function is only available since version 1.0.0, but the SDL minimum is 0.5.0, and Steam Runtime 2 'soldier' uses 0.8.2, so add a fallback function with similar functionality for older versions.
xkb_keymap_key_get_mods_for_level() is more efficient, so it is still favored when available.