- TODO: update INSTALL.txt to replace the autotools configure
instructions with cmake.
- TODO: update make build system to provide an equivalent to
autotools' `make dist` ?
- TODO: update / revise github actions, replace autotools-only
ones with cmake (e.g.: vmactions.yml for FreeBSD.)
Reference issue: https://github.com/libsdl-org/SDL/issues/6571
SDL_HINT_VIDEO_X11_FORCE_EGL was deprecated in favor of the more general SDL_HINT_VIDEO_FORCE_EGL, and Xinerama and Xvidmode support was previously removed from SDL, rendering their associated hints nonfunctional.
* The header is no longer dependent on SDL build configuration
* The structures are versioned separately from the rest of SDL
* SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application
* Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0
Depending on the underlying EGL library, it may be desirable to
conditionally set some specific EGL attributes depending on available
extensions and other application state.
SDL's EGL usage makes this a little bit complicated because:
- there are multiple functions used to set up a working EGL context
- some of these functions take different types of EGL attributes
(EGLAttrib vs EGLint)
- the EGL extension list before creating an EGLDisplay differs from the
extension list after (i.e. display vs client extensions)
- all of the above happens in a single SDL_CreateWindow call
This leaves no place for the application to discover what EGL extensions
are available and provide custom attribute lists.
Until now, if a developer wants to add a custom EGL attribute for
eglGetPlatformDisplay, eglCreateWindowSurface or eglCreateContext, they
needed to patch SDL itself. This is very undesirable, since such
developers would have to disable the SDL dynapi in order to maintain
compatibility with their needs.
This patch implements some callbacks which developers can use to
dynamically generate custom EGL attributes for SDL to use during
SDL_CreateWindow.
These functions allow applications to call EGL functions against the SDL
EGL context. For example, applications can use an EGL API loader via
SDL_EGL_GetCurrentDisplay and SDL_EGL_GetProcAddress, and can call
functions such as eglQuerySurface against the internal EGLSurface and
EGLDisplay.
This fallback is undesirable when using ANGLE, because it will end up
using some default configuration (e.g. on Windows it defaults to the
D3D11 backend).
This implements a new SDL_GL_EGL_PLATFORM attribute to set the
"platform" argument for SDL_EGL_LoadLibrary on Windows, macOS, and
Linux. I've limited it to those three operating systems because that's
what I've been able to test against.
This adds support for forcing the use of EGL on Windows and MacOS. The
SDL_HINT_VIDEO_X11_FORCE_EGL hint is retained for backwards
compatibility but is now deprecated.
Downstream distributors can use this to mark a version with their
preferred version information, like a Linux distribution package version
or the Steam revision it was built to be bundled into, or just to mark
it with the vendor it was built by or the environment it's intended to
be used in.
For instance, in Debian I'd use this by configuring with:
--enable-vendor-info="${DEB_VENDOR} ${DEB_VERSION}"
to get a SDL_REVISION like:
release-2.24.1-0-ga1d1946dc (Debian 2.24.1+dfsg-2)
which gives a Debian user enough information to track down the patches
and build-time configuration that were used for package revision 2.
In Autotools and CMake, this is a configure-time option like any other,
and will go into both SDL_REVISION (via SDL_revision.h) and
SDL_GetRevision().
In other build systems (MSVC, Xcode, etc.), defining the
SDL_VENDOR_INFO macro will get it into the output of SDL_GetRevision(),
although not SDL_REVISION.
Resolves: https://github.com/libsdl-org/SDL/issues/6418
Signed-off-by: Simon McVittie <smcv@collabora.com>
Instead of using a URL and git sha1, this uses `git describe` to
describe the version relative to the nearest previous git tag, which
gives a better indication of whether this is a release, a prerelease,
a slightly patched prerelease, or a long way after the last release
during active development.
This serves two purposes: it makes those APIs more informative, and it
also puts this information into the binary in a form that is easy to
screen-scrape using strings(1). For instance, if the bundled version of
SDL in a game has this, we can see at a glance what version it is.
It's also shorter than using the web address of the origin git
repository and the full git commit sha1.
Also write the computed version into a file ./VERSION in `make dist`
tarballs, so that when we build from a tarball on a system that doesn't
have git available, we still get the version details.
For the Perforce code path in showrev.sh, output the version number
followed by the Perforce revision, in a format reminiscent of
`git describe` (with p instead of g to indicate Perforce).
For the code path with no VCS available at all, put a suffix on the
version number to indicate that this is just a guess (we can't know
whether this SDL version is actually a git snapshot or has been
patched locally or similar).
Resolves: https://github.com/libsdl-org/SDL/issues/6418
Signed-off-by: Simon McVittie <smcv@collabora.com>
Disabling RAWINPUT on Windows 10 causes these issues:
* All Xbox controllers are named "XInput Controller".
* Trigger rumble no longer works.
* "XInput Controllers" are now also listed as separate haptic devices
It's only needed to support more than 4 Xbox controllers, and adds significant complexity to the joystick processing, and we regularly get bugs from people who aren't using an SDL window who need to turn on SDL_HINT_JOYSTICK_THREAD.
* Consolidated scancode mapping tables into a single location for all backends
* Verified that the xfree86_scancode_table2 is largely identical to the Linux scancode table
* Updated the Linux scancode table with the latest kernel keycodes (still unmapped)
* Route X11 keysym -> scancode mapping through the linux scancode table (which a few hand-written exceptions), which will allow mappings to automatically get picked up as they are added in the Linux scancode table
* Disabled verbose reporting of missing keysym mappings, we have enough data for now
Several games (including Source and GoldSrc games, and Bioshock
Infinite) attempt to "fake" relative mouse mode by repeatedly warping
the cursor to the centre of the screen. Since mouse warping is not
supported under Wayland, the viewport ends up "stuck" in a rectangular
area.
Detect this case (mouse warp while the cursor is not visible), and
enable relative mouse mode, which tracks the cursor position
independently, and so can Warp successfully.
This is behind the SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP hint, which
is enabled by default, unless the application enables relative mouse
mode itself using SDL_SetRelativeMouseMode(SDL_TRUE).
Note that there is a behavoural difference, in that relative mouse mode
typically doesn't take mouse accelleration into account, but the
repeated-warping technique does, so mouse movement can seem very slow
with this (unless the game has its own mouse accelleration option, such
as in Portal 2).
* Added support for vertical mode for Joy-Con controllers
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS for switching to this mode
* Added support for SL/SR buttons in combined/vertical mode and L/ZL/R/ZR buttons in mini-gamepad mode
X11 has a so-called primary selection, which you can use by marking text and middle-clicking elsewhere to copy the marked text.
There are 3 new API functions in `SDL_clipboard.h`, which work exactly like their clipboard equivalents.
## Test Instructions
* Run the tests (just a copy of the clipboard tests): `$ ./test/testautomation --filter Clipboard`
* Build and run this small application:
<details>
```C
#include <SDL.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void print_error(const char *where)
{
const char *errstr = SDL_GetError();
if (errstr == NULL || errstr[0] == '\0')
return;
fprintf(stderr, "SDL Error after '%s': %s\n", where, errstr);
SDL_ClearError();
}
int main()
{
char text_buf[256];
srand(time(NULL));
SDL_Init(SDL_INIT_VIDEO);
print_error("SDL_INIT()");
SDL_Window *window = SDL_CreateWindow("Primary Selection Test", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 400, 400, SDL_WINDOW_SHOWN);
print_error("SDL_CreateWindow()");
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
print_error("SDL_CreateRenderer()");
bool quit = false;
unsigned int do_render = 0;
while (!quit) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
print_error("SDL_PollEvent()");
switch (event.type) {
case SDL_QUIT: {
quit = true;
break;
} case SDL_KEYDOWN: {
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
case SDLK_q:
quit = true;
break;
case SDLK_c:
snprintf(text_buf, sizeof(text_buf), "foo%d", rand());
SDL_SetClipboardText(text_buf);
print_error("SDL_SetClipboardText()");
printf("clipboard: set_to=\"%s\"\n", text_buf);
break;
case SDLK_v: {
printf("clipboard: has=%d, ", SDL_HasClipboardText());
print_error("SDL_HasClipboardText()");
char *text = SDL_GetClipboardText();
print_error("SDL_GetClipboardText()");
printf("text=\"%s\"\n", text);
SDL_free(text);
break;
} case SDLK_d:
snprintf(text_buf, sizeof(text_buf), "bar%d", rand());
SDL_SetPrimarySelectionText(text_buf);
print_error("SDL_SetPrimarySelectionText()");
printf("primselec: set_to=\"%s\"\n", text_buf);
break;
case SDLK_f: {
printf("primselec: has=%d, ", SDL_HasPrimarySelectionText());
print_error("SDL_HasPrimarySelectionText()");
char *text = SDL_GetPrimarySelectionText();
print_error("SDL_GetPrimarySelectionText()");
printf("text=\"%s\"\n", text);
SDL_free(text);
break;
} default:
break;
}
break;
} default: {
break;
}}
}
// create less noise with WAYLAND_DEBUG=1
if (do_render == 0) {
SDL_RenderPresent(renderer);
print_error("SDL_RenderPresent()");
}
do_render += 1;
usleep(12000);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
print_error("quit");
return 0;
}
```
</details>
* Use c,v,d,f to get and set the clipboard and primary selection.
* Mark text and middle-click also in other applications.
* For wayland under x:
* `$ mutter --wayland --no-x11 --nested`
* `$ XDG_SESSION_TYPE=wayland SDL_VIDEODRIVER=wayland ./<path_to_test_appl_binary>`
This makes the joystick locking more robust by holding the lock while updating joysticks.
The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().
It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.
Fixes https://github.com/libsdl-org/SDL/issues/6063
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.
Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.
sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.
Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
- This allows looking up the display index for an arbitrary location rather than requiring an active window to do so.
- This change also reimplements the fallback display lookup that found the display with center closest to the window's center to instead find the display rect edge
closest to the window center (this was done in the almost identical display lookup used in SDL_windowsmodes.c, which now uses `SDL_GetPointDisplayIndex`). In
practice this should almost never be hit as it requires the window's center to not be enclosed by any display rect.
* Added support for mini-gamepad mode for Joy-Con controllers, matching the mapping for hid-nintendo on Linux and iOS 16
* Added the ability to merge left and right Joy-Con controllers into a single Pro-style controller
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_COMBINE_JOY_CONS to control this merging functionality
* Removed the hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
Extend the SDL_WINDOW_ALLOW_HIGHDPI flag documentation to stress the importance of querying the window drawable size after every window event to avoid rendering issues in a mixed-DPI environment.
The documentation doesn't state that the argument is ever modified,
and no implementation does so currently.
This is a non-breaking change to guarantee as much to callers.
* Xbox GDK support (14 squashed commits)
* Added basic keyboard testing
* Update readme
* Code review fixes
* Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
Also added test functions for multi-line debug text display
Currently this only supports ASCII, as the font doesn't have the correct Latin-1 characters
Without using <inttypes.h>, SDL_PRIx64 will expand to llx, but on 64-bit
FreeBSD platforms (u)int64_t is `(usigned) long`:
SDL_test_memory.c:261:77: error: format specifies type 'unsigned long long' but the argument has type 'Uint64' (aka 'unsigned long') [-Werror,-Wformat]
This commit updates config_minimal.h to also assume presence of inttypes.h
for everything except old MSVC.
Adds hint "SDL_WINDOWS_DPI_SCALING" which can be set to "1" to
change the SDL coordinate system units to be DPI-scaled points, rather
than pixels everywhere.
This means windows will be appropriately sized, even when created on
high-DPI displays with scaling.
e.g. requesting a 640x480 window from SDL, on a display with 125%
scaling in Windows display settings, will create a window with an
800x600 client area (in pixels).
Setting this to "1" implicitly requests process DPI awareness
(setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2").
This is the first part of High-DPI support on Windows ( https://github.com/libsdl-org/SDL/issues/2119 ).
It doesn't implement a virtualized SDL coordinate system, which will be
addressed in a later commit. (This hint could be useful for SDL apps
that want 1 SDL unit = 1 pixel, though.)
Detecting and behaving correctly under per-monitor V2
(calling AdjustWindowRectExForDpi where needed) should fix the
following issues:
https://github.com/libsdl-org/SDL/issues/3286https://github.com/libsdl-org/SDL/issues/4712
Add the hint "SDL_VIDEO_WAYLAND_MODE_EMULATION", which can be used to disable mode emulation under Wayland. When disabled, only the desktop and/or native display resolution is exposed.
- SDL_JoystickGUID -> SDL_GUID (though we retain a type alias)
- Operations for GUID <-> String ops are now in
src/SDL_guid.c and include/SDL_guid.h
- The corresponding Joystick operations delegate to SDL_guid.c
- Added test/testguid.c
Added the ability to specify a name and the product VID/PID for a virtual controller
Also added a test case to testgamecontroller, if you pass --virtual as a parameter
* Add changes from code review by @ccawley2011, #5597, overall cleanup
* Update N-Gage README, minor cleanup and rephrasing
* Call SDL_SetMainReady() before calling SDL_main, return SDL_main instead of main
This can be used to check whether untrusted sizes would cause overflow
when used to calculate how much memory is needed.
Signed-off-by: Simon McVittie <smcv@collabora.com>
For stable releases, this gives us the ability to make bugfix-only point
releases such as 2.24.1 if we want to, and distinguish between them
programmatically. For example, this ability could have been useful after
2.0.16 to fix Xwayland regressions, and after 2.0.18 to fix event loop
regressions.
For development releases, this gives us the ability to make multiple
prereleases during the same feature cycle, and distinguish between them
programmatically. For example, this would have been useful during 2.0.22
development, which went through three prereleases before reaching the
final release.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Now that we've said this will be removed from SDL 3, we're free to use
any encoding that is compatible with existing SDL versions and will still
compare correctly for all SDL 2 version numbers. This allows the SDL 2
minor version to go beyond 1 digit, limited only by the size of
SDL_version.minor (which is 8 bits), making the largest possible version
number 2.255.99.
The patchlevel (micro version) is still limited to 2 digits.
Signed-off-by: Simon McVittie <smcv@collabora.com>
The encoding used in SDL_VERSIONNUM (e.g. 2.0.22 -> 2022) cannot
represent 2-digit minor versions without overflowing from the hundreds
digit into the thousands digit, which produces confusing version
numbers that will compare incorrectly when the major version is increased
to 3.
However, we can sidestep this problem by declaring that SDL_VERSIONNUM
will no longer be present in SDL 3, which means it only needs to be able
to represent SDL 2 version numbers losslessly.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This comparison normally happens at compile-time, not at runtime, so
it doesn't matter if it isn't optimal. This avoids incorrect comparison
if the minor version in SDL_COMPILEDVERSION and SDL_VERSIONNUM has more
than one digit, which would cause it to overflow from the hundreds place
into the thousands place.
Signed-off-by: Simon McVittie <smcv@collabora.com>
* Add initial support for the Nokia N-Gage
* N-Gage: disable clipping for the time being, issue needs to be resolved later
* Move va_copy definition to SDL_internal.h
* Move stdlib.h include to SDL_config_ngage.h, much cleaner this way
* Remove redundant include, add HAVE_STDLIB_H
* Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later"
This reverts commit 4f5f0fc36cc7f34fad05e45671dfa7b8dc32fd51.
* N-Gage: fix clipping issue by providing proper math functions
This hint allows libdecor to be used even when xdg-decoration is
available. It's mostly useful for debugging libdecor, but could in
theory be used by applications which want to (for example) bundle their
own libdecor plugins.
* Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown
* Fixed: Documentation and code style issues raised during code review.
This adds support for all 3 of the gamecube controller's rumble modes
Rumble: 1
Stop: 0
StopHard: 2
This is useful for applications that need the full range of support
This also adds a hint to control rumble behavior, defaults 0 to maintain compatibility