Commit Graph

561 Commits (a7b79c483c9bd03d17a14304982622b3f0c8bfec)

Author SHA1 Message Date
Sam Lantinga 2faae8457d The C standard defines a boolean expression as a signed integer value.
Microsoft came to the same conclusion:
https://devblogs.microsoft.com/oldnewthing/20110328-00/?p=11113

Fixes https://github.com/libsdl-org/SDL/issues/8761
2023-12-30 11:44:40 -08:00
Sam Lantinga e3d50619f8 Fixed fatal error: SDL_pen.h: No such file or directory 2023-12-29 20:04:40 -08:00
Sam Lantinga 7681695875 Revert "Fixed signed/unsigned warnings with Visual Studio when comparing SDL_bool with boolean expressions"
This reverts commit 61db102da9.

This causes the build to fail:
SDL_waylandwindow.c:1876:45: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            wind->fullscreen_was_positioned = SDL_TRUE;
2023-12-29 17:14:05 -08:00
Sam Lantinga ebd7f9adbd Fixed warning C4245: 'initializing': conversion from 'int' to 'Uint32', signed/unsigned mismatch in SDL_video.c 2023-12-29 10:37:28 -08:00
Sam Lantinga 61db102da9 Fixed signed/unsigned warnings with Visual Studio when comparing SDL_bool with boolean expressions 2023-12-29 09:23:47 -08:00
Sam Lantinga d71454da17 Store the surface properties in the reserved pointer of a surface
This prevents us from exposing the properties publicly and allows us to repurpose the pointer later if necessary.

Fixes https://github.com/libsdl-org/SDL/issues/8758
2023-12-29 08:17:06 -08:00
SDL Wiki Bot 5df3eac925 Sync SDL3 wiki -> header 2023-12-27 20:21:11 +00:00
Sam Lantinga a3b5eb07b2 Removed extern "C" linkage from main() declaration
According to the C++ spec, main() should not have any linkage specifier:
https://en.cppreference.com/w/cpp/language/main_function

Fixes https://github.com/libsdl-org/SDL/issues/8738
2023-12-26 10:19:22 -08:00
Sam Lantinga 50e309bb17 Include SDL_events.h in SDL_main.h
Applications shouldn't need to include it separately if they want to process events using the main callbacks.

Fixes https://github.com/libsdl-org/SDL/issues/8746
2023-12-26 10:11:48 -08:00
SDL Wiki Bot 07e9603398 Sync SDL3 wiki -> header 2023-12-22 17:14:22 +00:00
Sylvain ffd82fb7c4 Add scaleMode to SDL_SoftStretch(), remove SDL_SoftStretchLinear(). 2023-12-22 09:13:21 -08:00
Sylvain 5dba04b29b Remove SDL_{Set,Get}SurfaceScale().
Add Scale parameter to SDL_BlitSurfaceScaled() and SDL_BlitSurfaceScaledUnchecked()
(see #8732)
2023-12-22 02:08:49 -08:00
Sam Lantinga 2ad50e9675 Make the SDL3 surface ABI compatible with SDL2
We'll use properties for new data associated with a surface, which lets us preserve ABI compatibility with SDL2 and any surfaces created by applications and passed in to SDL functions.
2023-12-21 06:58:22 -08:00
Sam Lantinga 4bb5e1f0f9 Added migration notes for migrating Steam Input support from SDL2 to SDL3 2023-12-20 14:15:09 -08:00
SDL Wiki Bot 2c4360ce8f Sync SDL3 wiki -> header 2023-12-20 18:41:23 +00:00
Sam Lantinga c981a597dc Added Steam Input API support for game controllers
Added support for getting the real controller info, as well as the function SDL_GetGamepadSteamHandle() to get the Steam Input API handle, from the virtual gamepads provided by Steam.

Also added an event SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED which is triggered when a controller's API handle changes, e.g. the controllers were reassigned slots in the Steam UI.
2023-12-20 10:40:28 -08:00
Sylvain a4496f7dcf Update doc: SDL_SoftStretch() and SDL_SoftStretchLinear() #8667 2023-12-18 06:35:52 -08:00
Sylvain 84a0d5f623 Added SDL_SetSurfaceScaleMode() and SDL_GetSurfaceScaleMode() to control scale mode using SDL_BlitSurfaceScaled() 2023-12-17 15:39:53 -08:00
Max Maisel c1a7d0f96e Add steam deck detection and HIDAPI driver scaffold. 2023-12-12 12:51:37 -08:00
Sam Lantinga 5173b0c2cc Make built-in joystick device lists extendable by using hints
Fixes https://github.com/libsdl-org/SDL/issues/8595
2023-12-10 12:53:03 -08:00
SDL Wiki Bot 20250aecc5 Sync SDL3 wiki -> header 2023-12-07 18:27:25 +00:00
Frank Praznik 4fd778119b video: Implement asynchronous windowing
SDL window size, state, and position functions have been considered immediate, with their effects assuming to have taken effect upon successful return of the function. However, several windowing systems handle these requests asynchronously, resulting in the functions blocking until the changes have taken effect, potentially for long periods of time. Additionally, some windowing systems treat these as requests, and can potentially deny or fulfill the request in a manner differently than the application expects, such as not allowing a window to be positioned or sized beyond desktop borders, prohibiting fullscreen, and so on.

With these changes, applications can make requests of the window manager that do not block, with the understanding that an associated event will be sent if the request is fulfilled. Currently, size, position, maximize, minimize, and fullscreen calls are handled as asynchronous requests, with events being returned if the request is honored. If the application requires that the change take effect immediately, it can call the new SDL_SyncWindow function, which will attempt to block until the request is fulfilled, or some arbitrary timeout period elapses, the duration of which depends not only on the windowing system, but on the operation requested as well (e.g. a 100ms timeout is fine for most X11 events, but maximizing a window can take considerably longer for some reason). There is also a new hint 'SDL_VIDEO_SYNC_ALL_WINDOW_OPS' that will mimic the old behavior by synchronizing after every window operation with, again, the understanding that using this may result in the associated calls blocking for a relatively long period.

The deferred model also results in the window size and position getters not reporting false coordinates anymore, as they only forward what the window manager reports vs allowing applications to set arbitrary values, and fullscreen enter/leave events that were initiated via the window manager update the window state appropriately, where they didn't before.

Care was taken to ensure that order of operations is maintained, and that requests are not ignored or dropped. This does require some implicit internal synchronization in the various backends if many requests are made in a short period, as some state and behavior depends on other bits of state that need to be known at that particular point in time, but this isn't something that typical applications will hit, unless they are sending a lot of window state in a short time as the tests do.

The automated tests developed to test the previous behavior also resulted in previously undefined behavior being defined and normalized across platforms, particularly when it comes to the sizing and positioning of windows when they are in a fixed-size state, such as maximized or fullscreen. Size and position requests made when the window is not in a movable or resizable state will be deferred until it can be applied, so no requests are lost. These changes fix another long-standing issue with renderers recreating maximized windows, where the original non-maximized size was lost, resulting in the window being restored to the wrong size. All automated video tests pass across all platforms.

Overall, the "make a request/get an event" model better reflects how most windowing systems work, and some backends avoid spending significant time blocking while waiting for operations to complete.
2023-12-07 10:26:19 -08:00
Sam Lantinga ac0751a652 Added SDL_strnstr() 2023-12-03 15:06:46 -08:00
Sam Lantinga ecd56bb8f0 Removed SDL_GetErrorMsg(), trivially implemented in application code 2023-12-01 09:08:23 -08:00
SDL Wiki Bot e4582e6edc Sync SDL3 wiki -> header 2023-11-30 15:22:19 +00:00
Ryan C. Gordon d1b831e232 include: Clarified documentation for two functions. 2023-11-29 20:50:44 -05:00
Ryan C. Gordon daa38dc793 touch: Replace GetNumTouchDevices/GetTouchDevice with a single function.
Now it returns an array and optional count, to match other SDL3 APIs.

SDL_GetTouchName() was replaced with a function that takes an instance ID
instead of an index, too.
2023-11-29 20:50:44 -05:00
Ryan C. Gordon dd47da8a5c gamepad: Replace GetNumMappings/GetMappingByIndex with a single function.
Now it returns an array and optional count, to match other SDL3 APIs.
2023-11-29 20:50:44 -05:00
Ryan C. Gordon dfee3f9e92 render: Replaced SDL_RenderFlush with SDL_FlushRenderer.
This uses the same `SDL_VerbNoun` format as the rest of SDL3, and also
adds stronger effort to invalidate cached state in the backend, so cooperation
improves with apps that are using lowlevel rendering APIs directly.

Fixes #367.
2023-11-29 14:24:26 -05:00
shenleban tongying 3e6513c773 document the purpose of SDL_SetTextInputRect 2023-11-28 12:06:16 -08:00
Ryan C. Gordon 6ba90f7775 render: Batching is always enabled now!
Make sure your app uses SDL_RenderFlush() before it talks to D3D/OpenGL/etc!

Fixes #8584.
2023-11-23 20:37:52 -05:00
Sam Lantinga 81fc7ded78 Removed the window shape API for SDL 3.0
Fixes https://github.com/libsdl-org/SDL/issues/6654
Fixes https://github.com/libsdl-org/SDL/issues/6897
2023-11-22 14:11:10 -08:00
Anonymous Maarten d6291d4d42 alloca: use alloca from <stdlib.h> on NetBSD
The only generally portable way to do this is to use -std=gnu99,
"#include <stdlib.h>", and write "alloca".
__builtin_alloca does not seem to be available on NetBSD
2023-11-22 06:33:50 +03:00
Zack Middleton 5e9b0820f3 Add cursors for X11/Wayland window resizing 2023-11-21 08:34:13 -08:00
Sam Lantinga 30a2291d59 Fixed compatibility with sdl2-compat (thanks @sezero!) 2023-11-20 08:46:12 -08:00
Cameron Cawley 753bbd199e Add SDL_PIXELFORMAT_INDEX2LSB and SDL_PIXELFORMAT_INDEX2MSB 2023-11-17 08:45:32 -08:00
Ozkan Sezer 39870031d1 use format string attributes for functions accepting va_list params, too 2023-11-17 15:56:10 +03:00
Sam Lantinga 708f18d49e Added SDL_HINT_JOYSTICK_IOKIT and SDL_HINT_JOYSTICK_MFI to control whether the IOKit and GCController drivers should be used for joystick support.
This can be used to work around issues where the Apple GCController driver doesn't work for some controllers but there's no way to know which GCController maps to which IOKit device.
2023-11-14 10:28:19 -08:00
Sam Lantinga 1c64366b80 Added SDL_CreateRendererWithProperties() and SDL_CreateTextureWithProperties() 2023-11-14 06:06:51 -08:00
Sam Lantinga 7203641597 Note that the SDL window properties are read-only 2023-11-14 06:06:51 -08:00
Sam Lantinga e0c45c6c98 Renamed SDL_WINDOW_FOREIGN to SDL_WINDOW_EXTERNAL 2023-11-14 06:06:51 -08:00
Sam Lantinga 229b7b9d50 SDL_CreateWindowWithPosition() and SDL_CreateWindowFrom() have been replaced with SDL_CreateWindowWithProperties()
This is a more general interface that can be extended in the future as needed.
2023-11-14 06:06:51 -08:00
Ryan C. Gordon dd8ab67bd9
Sync wiki -> headers. 2023-11-13 15:46:29 -05:00
Ryan C. Gordon 91460fc13d
include: Fixed up documentation in SDL_pen.h 2023-11-13 15:40:55 -05:00
Ryan C. Gordon 8766aa39d6
Sync wiki -> headers. 2023-11-13 13:03:42 -05:00
Ryan C. Gordon e5ffd6d8eb
include: Removed `\link` and `\endlink` Doxygen tags. 2023-11-13 13:01:25 -05:00
Sam Lantinga 1c4723ac66 SDL_CreateWindowFrom() now takes a set of properties that describe the native window and options. 2023-11-12 21:58:58 -08:00
Sam Lantinga bd269b0f41 Added SDL_SetBooleanProperty() and SDL_GetBooleanProperty() 2023-11-12 21:58:58 -08:00
Ryan C. Gordon c47ac5b2df
include: Fixed copy/paste error 2023-11-12 23:41:22 -05:00
Ozkan Sezer 45fc828c95 move SDL_EVENT_WINDOW_PEN_ENTER and SDL_EVENT_WINDOW_PEN_LEAVE down
... to preserve compatibility with sdl2-compat.
2023-11-12 12:22:43 -08:00