Commit Graph

722 Commits

Author SHA1 Message Date
Sam Lantinga 54fb629da5 SDL_WindowFlags is now 64-bit
Fixes https://github.com/libsdl-org/SDL/issues/7321
2024-05-09 10:39:54 -07:00
Sam Lantinga 1944c009e9 SDL_Keycode is now Uint32 2024-05-09 10:00:46 -07:00
Sam Lantinga 88fc529261 Removed misleading documentation for SDL_AppEvent()
Fixes https://github.com/libsdl-org/SDL/issues/9731
2024-05-09 09:01:27 -07:00
Frank Praznik 3a6d9c59f4 wayland: Add mouse pointer warp support
The pointer confinement protocol does allow attempted warping the pointer via a hint, provided that the pointer is locked at the time of the request, and the requested coordinates fall within the bounds of the window.

Toggle the pointer locked state and request the pointer warp when the required protocol is available. This is similar to what XWayland does internally.
2024-05-03 12:33:19 -04:00
Sam Lantinga b18a071639 Removed SDL_DROPEVENT_DATA_SIZE and SDL_TEXTEDITINGEVENT_TEXT_SIZE
Fixes https://github.com/libsdl-org/SDL/issues/9681
2024-05-03 09:19:49 -07:00
Ryan C. Gordon 46b69af5a3
SDL_vulkan.h: Remove Tizen compatibility typedefs.
Any app for this system that wants to move to SDL3 will have to adjust to
all the other API changes anyhow, so there's no need to keep these anymore.

Fixes #9678.
2024-05-02 23:25:44 -04:00
Petar Popovic 7bfecacc02 Removing function macro SDL_TABLESIZE() 2024-04-29 13:52:48 -07:00
SDL Wiki Bot d42d661498 Sync SDL3 wiki -> header 2024-04-26 18:04:12 +00:00
Sam Lantinga 14f584a94b SDL_CreateWindowAndRenderer() takes the window title as the first parameter
Fixes https://github.com/libsdl-org/SDL/issues/9626
2024-04-25 20:00:14 -07:00
Ryan C. Gordon 42579e2af1
docs: Remove README-hg.md
It's been a few years in general, and SDL3 has never been in Mercurial.

We'll leave this document alive in the SDL2 branch, though!
2024-04-23 15:48:29 -04:00
SDL Wiki Bot 64d5fb6ab6 Sync SDL3 wiki -> header 2024-04-18 17:41:14 +00:00
Ryan C. Gordon 093160904d
SDL_Keymod: Removed SDL_KMOD_RESERVED.
Fixes #9481.
2024-04-17 17:30:10 -04:00
Ryan C. Gordon 235bfe2631
SDL_log.h: Remove SDL_MAX_LOG_MESSAGE.
The message length limit was removed in 2.0.24, so there's no need for
this define in SDL3 at all.

Fixes #9467.
2024-04-16 00:31:57 -04:00
Sam Lantinga 70ce808c09 Changed SDL_KeyCode values to defines
This clears up confusion about whether to use SDL_KeyCode or SDL_Keycode and makes it clear that the values aren't the full set of possible keycodes.

Fixes https://github.com/libsdl-org/SDL/issues/9493
2024-04-15 11:08:51 -10:00
Sam Lantinga 1862a62b5d Replaced SDL_GetNumTouchFingers() and SDL_GetTouchFinger() with SDL_GetTouchFingers()
Fixes https://github.com/libsdl-org/SDL/issues/9484
2024-04-15 09:22:41 -10:00
Ryan C. Gordon 9c8c254af2
include: Removed SDL_quit.h
It only had one (sort of scary) macro in it.

Fixes #9534.
2024-04-15 11:35:39 -04:00
Petar Popovic 56e6f05440 SDL_RendererFlip rename fixes 2024-04-15 03:32:23 -10:00
Ryan C. Gordon 239b34d760
docs: Added some notes about iOS and the main callbacks. 2024-04-13 15:14:32 -04:00
Ryan C. Gordon 6e1ed94913
ios: Renamed APIs that referred to "iPhone" to refer to "iOS".
Macros that papered over this difference in SDL2 have been removed for SDL3.

Fixes #9527.
2024-04-13 14:30:30 -04:00
Ryan C. Gordon d252a8fe12
joystick: SDL_VirtualJoystickDesc no longer takes a struct version.
If we need to extend this in the future, we'll make a second struct and
a second SDL_AttachVirtualJoystickEx-style function that uses it.

Just zero the struct and don't set a version.

Fixes #9489.
2024-04-13 14:16:12 -04:00
Ryan C. Gordon 98e9f361a8
winrt: Remove SDL_WinRTGetFSPathUNICODE, rename SDL_WinRTGetFSPathUTF8.
Fixes #9470.
2024-04-13 08:24:12 -04:00
Frank Praznik d7dcf4916f docs: Mention the SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS hint in the migration guide 2024-04-10 21:51:03 -04:00
Petar Popovic 9b5944a14f Removing SDL_Colour macro 2024-04-09 12:25:36 -04:00
Petar Popovic c8a066019b Renaming SDL_eventaction to SDL_EventAction 2024-04-08 14:28:52 -04:00
Sam Lantinga 5fa87e29e7 Removed SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE
These flags are unnecessary and have always been a source of confusion.
2024-04-04 13:30:49 -07:00
Sam Lantinga 8847b35244 Separate joystick power state into battery status and percentage
This allows you to see battery percentage while the controller is charging
2024-04-01 13:59:00 -07:00
Sam Lantinga 5e624c2083 Moved display and window event renaming to the correct header section
Closes https://github.com/libsdl-org/SDL/pull/9396
2024-04-01 13:57:05 -07:00
Ryan C. Gordon 74b58aebb9
README-migration: fix function signature on SDL_(Read|Write)IO docs. 2024-03-31 16:43:53 -04:00
Ryan C. Gordon 6b20152bda
README-migration: Removed duplicate paragraph.
(Exact same text also exists earlier in the SDL_audio.h section.)
2024-03-31 16:26:08 -04:00
Mirko Galimberti 60cacc8277 README-migration: Fix wrong new name for SDL_WINDOWEVENT_ENTER and SDL_WINDOWEVENT_LEAVE 2024-03-31 12:47:55 -07:00
Ryan C. Gordon a5c892d2c3 stdlib: Improve Unicode support and consistency in string comparison functions.
SDL_strcasecmp (even when calling into a C runtime) does not work with
Unicode chars, and depending on the user's locale, might not work with
even basic ASCII strings.

This implements the function from scratch, using "case-folding,"
which is a more robust method that deals with various languages. It
involves a hashtable of a few hundred codepoints that are "uppercase" and
how to map them to lowercase equivalents (possibly increasing the size of
the string in the process). The vast majority of human languages (and
Unicode) do not have letters with different cases, but still, this static
table takes about 10 kilobytes on a 64-bit machine.

Even this will fail in one known case: the Turkish 'i' folds differently
if you're writing in Turkish vs other languages. Generally this is seen as
unfortunate collateral damage in cases where you can't specify the language
in use.

In addition to case-folding the codepoints, the new functions also know how
to decode the various formats to turn them into codepoints in the first
place, instead of blindly stepping by one byte (or one wchar_t) per
character.

Also included is casefolding.txt from the Unicode Consortium and a perl
script to generate the hashtable from that text file, so we can trivially
update this if new languages are added in the future.

A simple test using the new function:

```c
 #include <SDL3/SDL.h>

 int main(void)
 {
     const char *a = "α ε η";
     const char *b = "Α Ε Η";
     SDL_Log("    strcasecmp(\"%s\", \"%s\") == %d\n", a, b, strcasecmp(a, b));
     SDL_Log("SDL_strcasecmp(\"%s\", \"%s\") == %d\n", a, b, SDL_strcasecmp(a, b));
     return 0;
 }
```

Produces:

```
INFO:     strcasecmp("α ε η", "Α Ε Η") == 32
INFO: SDL_strcasecmp("α ε η", "Α Ε Η") == 0
```

glibc strcasecmp() fails to compare a Greek lowercase string to its uppercase
equivalent, even with a UTF-8 locale, but SDL_strcasecmp() works.

Other SDL_stdinc.h functions are changed to be more consistent, which is to
say they now ignore any C runtime and often dictate that only English-based
low-ASCII works with them.

Fixes Issue #9313.
2024-03-29 15:01:40 -04:00
Sam Lantinga 0aa1022358 Clarify that SDL_SetWindowKeyboardGrab() is only needed if you set SDL_HINT_GRAB_KEYBOARD 2024-03-28 09:25:22 -07:00
Ryan C. Gordon ad92c9e300
README-main-functions.md: Added notes about the new `appstate` parameter. 2024-03-27 23:04:36 -04:00
Sam Lantinga 7a9f99cff3 Corrected migration documentation for SDL_GetDisplayDPI()
Fixes https://github.com/libsdl-org/SDL/issues/9386
2024-03-27 18:27:57 -07:00
Sam Lantinga a9dbdb1947 Removed SDL_RenderSetIntegerScale() renaming note
Fixes https://github.com/libsdl-org/SDL/issues/9384
2024-03-27 12:47:23 -07:00
Sam Lantinga cde2dcd0d4 Note that SDL_EVENT_SYSWM has been removed
Fixes https://github.com/libsdl-org/SDL/issues/9382
2024-03-27 11:39:10 -07:00
Sam Lantinga fed5f3a81b We no longer automatically set up a logical presentation mode 2024-03-26 10:40:40 -07:00
Sam Lantinga b9a88bbecb Removed SDL_TextInputShown()
This was only implemented on Windows and often confused with SDL_ScreenKeyboardShown()
2024-03-25 13:26:23 -07:00
Sam Lantinga 6443c75eda Removed SDL_TEXTINPUTEVENT_TEXT_SIZE 2024-03-25 13:26:23 -07:00
Cameron Gutman f14fb979c1 Remove legacy SDL2 input grab API 2024-03-24 16:53:23 -07:00
SDL Wiki Bot 8f33f5cc33 Sync SDL3 wiki -> header 2024-03-24 18:34:24 +00:00
Sam Lantinga a20eec1415 Tweaking documentation for the SDL 3.0 preview release 2024-03-24 06:16:02 -07:00
Sam Lantinga 72fc6f86e5 Text input is no longer automatically enabled when initializing video.
Fixes https://github.com/libsdl-org/SDL/issues/9309
Fixes https://github.com/libsdl-org/SDL/issues/9268
2024-03-23 16:31:00 -07:00
Sam Lantinga a1a0156756 Renamed SDL_SizeIO() SDL_GetIOSize() 2024-03-18 00:27:18 -04:00
Sam Lantinga d65ae710a1 Renamed SDL_LogGetOutputFunction() and SDL_LogSetOutputFunction() to match SDL 3.0 naming convention 2024-03-17 12:28:11 -07:00
Ryan C. Gordon c175eb488c
iostream: Note that the new name has nothing to do with C++'s iostream class. 2024-03-15 01:16:31 -04:00
Ryan C. Gordon 5a21d87e69
rwops: Changed filenames that reference "rwops" to "iostream". 2024-03-14 23:30:59 -04:00
Ryan C. Gordon 5440fd7d12
README-migration.md: Fixed some RWops mistakes. 2024-03-14 23:13:26 -04:00
Ryan C. Gordon 3a344cf877
rwops: Fixed some SDL2 symbols that got missed. 2024-03-14 21:57:21 -04:00
Ryan C. Gordon fc7afa9cbf
rwops: Renamed SDL_RWops to SDL_IOStream, and other related symbols. 2024-03-14 19:38:12 -04:00
Ryan C. Gordon 7d4d8ccde0
rwops: Rename everything from SDL_RWxxx to SDL_XxxRW. 2024-03-14 19:37:04 -04:00
Ryan C. Gordon 655ceb3b31
rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW and SDL_CloseRW. 2024-03-14 19:37:01 -04:00
Ryan C. Gordon 525919b315
rwops: Reworked RWops for SDL3.
- SDL_RWops is now an opaque struct.
- SDL_AllocRW is gone. If an app is creating a custom RWops, they pass the
  function pointers to SDL_CreateRW(), which are stored internally.
- SDL_RWclose is gone, there is only SDL_DestroyRW(), which calls the
  implementation's `->close` method before freeing other things.
- There is only one path to create and use RWops now, so we don't have to
  worry about whether `->close` will call SDL_DestroyRW, or if this will
  risk any Properties not being released, etc.
- SDL_RWFrom* still works as expected, for getting a RWops without having
  to supply your own implementation. Objects from these functions are also
  destroyed with SDL_DestroyRW.
- Lots of other cleanup and SDL3ization of the library code.
2024-03-14 19:36:08 -04:00
Sam Lantinga efbbafb3f1 Re-added balls to the SDL joystick API
It turns out these were being used on Linux and at least one virtual driver was making use of them (thanks @mrfixit2001!)
2024-03-10 21:30:14 -07:00
Sam Lantinga 5643fd683f Added migration notes for enum type changes 2024-03-06 16:59:28 -08:00
Susko3 4f58d18373 Typedef `SDL_WindowFlags`
Window flags were previously an enum with the same name.
See ebd7f9adbd.
2024-03-06 15:08:12 -08:00
Sam Lantinga 860155680d SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events. 2024-03-06 09:51:15 -08:00
SDL Wiki Bot e0dadba6f5 Sync SDL3 wiki -> header 2024-02-25 22:26:23 +00:00
Anonymous Maarten e6d9251ecb docs: improve CMake documentation for Apple 2024-02-25 23:25:11 +01:00
Sam Lantinga 276566235c Removed SDL_ClearHints() from the public API
Fixes https://github.com/libsdl-org/SDL/issues/9129
2024-02-24 21:07:50 -08:00
Anonymous Maarten 58e6eacf97 docs: SDL_INIT_EVERYTHING does not exist anymore 2024-02-21 00:52:04 +01:00
Ryan C. Gordon bc984f78bf android: Remove blocking permission request code. Async only in SDL3!
(this actually still blocks at our internal points of usage, though, for
replacement at a later time.)
2024-02-13 12:06:51 -05:00
Sam Lantinga 734d6fa1f3 Fixed documentation of SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN 2024-02-12 18:53:26 -08:00
Sam Lantinga dca2721b91 Removed SDL_HINT_VIDEO_EXTERNAL_CONTEXT
This is replaced with SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT in SDL_CreateWindowWithProperties()
2024-02-12 09:54:33 -08:00
Sam Lantinga 2f7c24e4be Removed SDL_HINT_RENDER_SCALE_QUALITY
Textures now default to linear filtering, use SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST) if you want nearest pixel mode instead.
2024-02-12 09:54:33 -08:00
Sam Lantinga 20051f805f Removed SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4
Replaced with SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, defaulting to SDL_TRUE
2024-02-12 09:54:33 -08:00
Sam Lantinga 7cb1ca60ec Removed SDL_HINT_RENDER_OPENGL_SHADERS
Shaders are always used if they are available.
2024-02-12 09:54:33 -08:00
Sam Lantinga 9920e062d5 Removed SDL_HINT_THREAD_STACK_SIZE
The stack size can be specified using SDL_CreateThreadWithStackSize()
2024-02-12 09:54:33 -08:00
Sam Lantinga 9e505252c0 Renamed SDL_HINT_PS2_DYNAMIC_VSYNC SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC 2024-02-12 09:54:33 -08:00
Sam Lantinga a538936821 Renamed SDL_HINT_LINUX_JOYSTICK_DEADZONES to SDL_HINT_JOYSTICK_LINUX_DEADZONES 2024-02-12 09:54:33 -08:00
Sam Lantinga 980c379a0b Renamed SDL_HINT_LINUX_JOYSTICK_CLASSIC to SDL_HINT_JOYSTICK_LINUX_CLASSIC 2024-02-12 09:54:33 -08:00
Sam Lantinga 1f7936d545 Renamed SDL_HINT_LINUX_HAT_DEADZONES to SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES 2024-02-12 09:54:33 -08:00
Sam Lantinga 39cfb437ed Renamed SDL_HINT_LINUX_DIGITAL_HATS to SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS 2024-02-12 09:54:33 -08:00
Sam Lantinga b557c15bcf Renamed SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE to SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE 2024-02-12 09:54:33 -08:00
Sam Lantinga 4f628b5b62 Renamed SDL_HINT_GDK_TEXTINPUT_DEFAULT to SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT 2024-02-12 09:54:33 -08:00
Sam Lantinga fd5d761128 Renamed SDL_HINT_DIRECTINPUT_ENABLED to SDL_HINT_JOYSTICK_DIRECTINPUT 2024-02-12 09:54:33 -08:00
Sam Lantinga a5da7d0dd5 Renamed SDL_HINT_ALLOW_TOPMOST to SDL_HINT_WINDOW_ALLOW_TOPMOST 2024-02-12 09:54:33 -08:00
Sam Lantinga 9ce7fe2848 Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK
Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days.

Closes https://github.com/libsdl-org/SDL/pull/7879
2024-02-12 09:54:33 -08:00
Sam Lantinga cacac6cc34 Updated structure and field names for consistency
Type names are camel case and field names are snake case except for fields ending in id, which are capitalized.

Fixes https://github.com/libsdl-org/SDL/issues/6955
2024-02-11 08:27:56 -08:00
Sam Lantinga f95b7ee4da Renamed SDL_HasWindowSurface to SDL_WindowHasSurface
Fixes https://github.com/libsdl-org/SDL/issues/9034
2024-02-09 17:42:18 -08:00
Sam Lantinga f6b92c9b88 Re-added a simplified version of SDL_SetWindowShape()
In order to handle mouse click transparency this needs to be implemented inside SDL
2024-02-09 16:04:46 -08:00
Sam Lantinga 3158342441 Use SDL_Color for SDL_RenderGeometryRaw() and add SDL_RenderGeometryRawFloat()
Eventually we can re-add a fast path for that data down to the individual renderers. Setting color scale would still require converting to float, and most hardware accelerated renderers prefer to consume colors as float, so this requires some thought and performance testing.

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-02-06 18:16:41 -08:00
Sam Lantinga 327b976bc4 SDL_COLORSPACE_JPEG is the default YUV colorspace 2024-02-04 13:09:40 -08:00
Sam Lantinga 89b9d6cbdc SDL_RenderReadPixels() now returns a surface
Fixes https://github.com/libsdl-org/SDL/issues/8977
2024-02-03 11:49:15 -08:00
Sam Lantinga 50a805cdd1 Use YUV colorspaces instead of a global YUV conversion mode
Fixes https://github.com/libsdl-org/SDL/issues/8669
2024-02-03 07:36:18 -08:00
Sam Lantinga 554f0625d3 Renderer colors now have floating point precision 2024-01-30 09:48:02 -08:00
Frank Praznik 94240c197d docs: Hint envvars needs to use the hint string, not the macro name 2024-01-28 15:12:03 -05:00
SDL Wiki Bot 00a8ca403e Sync SDL3 wiki -> header 2024-01-28 18:32:23 +00:00
Frank Praznik 5b8ca05f1a wayland: Add a forced screen space scaling mode
Add a mode that forces Wayland windows to output with scaling that forces 1:1 pixel mapping.

This is intended to allow legacy applications to be displayed without desktop scaling being applied, and may have issues with some display configurations, as this forces the window to behave in a way that Wayland desktops were not designed to accommodate (rounding errors can result from certain combinations of window/scale values, the window may be unusably small, jump in size at times, or appear to be larger than the desktop space, and cursor precision may be reduced).

Windows flagged as DPI-aware are not affected by this.

The automated video test suite passes with the hint turned on.
2024-01-28 13:31:42 -05:00
Sam Lantinga f66fe7e221 Replaced SDL_GetJoystickCaps() with joystick properties
Fixes https://github.com/libsdl-org/SDL/issues/8927
2024-01-27 15:11:52 -08:00
Sam Lantinga 3b55c7d1f4 Shortened SDL property names 2024-01-27 13:00:50 -08:00
Ryan C. Gordon 8814095aa8
main: Indented SDL_main headers for readability, removed SDL2 compat macros.
Specifically, SDL_WinRTRunApp, SDL_UIKitRunApp, and SDL_GDKRunApp macros were
removed, as likely unnecessary to SDL3 users. A note was added to the
migration doc about how to roll replacements. These are not going into
SDL_oldnames.h.

Fixes #8245.
2024-01-25 17:39:38 -05:00
Ryan C. Gordon b8081e8e35
video: lowercase some video backend names. 2024-01-25 15:22:57 -05:00
Sam Lantinga 594eef99ec Added a migration note about SDL_TouchID and SDL_FingerID 2024-01-25 07:30:08 -08:00
Sam Lantinga 95a67278d1 Updated documentation after 2654c52d0e 2024-01-24 11:00:13 -08:00
Anonymous Maarten 31d133db40
Define SDL_PLATFORM_* macros instead of underscored ones (#8875) 2024-01-24 01:40:51 +00:00
Sam Lantinga cd231a65f6 Added SDL_GetJoystickCaps() and SDL_GetGamepadCaps() to get the capabilities of controllers
Also added SDL_GAMEPAD_CAP_PLAYER_LED to let the application know if the controller has a visible player LED
2024-01-22 19:23:42 -08:00
Sam Lantinga 7a069cc4b0 Allow optimizing memcpy and memset where possible
Modern C runtimes have well optimized memset and memcpy, so use those instead of dispatching into SDL's versions. In addition, some compilers can analyze memset and memcpy calls and directly turn them into optimized assembly.
2024-01-21 06:55:29 -08:00
Sam Lantinga 308906ba25 Added SDL_FlipSurface() to flip a surface vertically or horizontally
Fixes https://github.com/libsdl-org/SDL/issues/8857
2024-01-20 06:31:37 -08:00
Sam Lantinga f86b3ac605 Fixed types used in documentation (thanks @Dragon-Baroque!) 2024-01-19 05:23:38 -08:00
Edoardo Lolletti b19d43a74d Add SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING to migration readme 2024-01-18 10:19:18 -08:00
Sam Lantinga fc0c774976 Renamed SDL_ThreadID() to SDL_GetCurrentThreadID()
Also renamed SDL_threadID to SDL_ThreadID and made it Uint64 for consistency with other ID types
2024-01-18 08:18:37 -08:00
Sam Lantinga 464f4d19fe Removed obsolete XInput mapping hint 2024-01-18 07:00:21 -08:00
Sam Lantinga c540c77756 Removed SDL_INIT_EVERYTHING
Fixes https://github.com/libsdl-org/SDL/issues/8709
2024-01-18 06:17:58 -08:00
Sam Lantinga a2665f54c8 Updated the atomic API for SDL 3.0 naming conventions
Fixes https://github.com/libsdl-org/SDL/issues/7388
2024-01-18 04:41:34 -08:00
Sam Lantinga fb898d6df0 Clarify that desktop mode is the non-exclusive borderless fullscreen mode
Fixes https://github.com/libsdl-org/SDL/issues/8413
2024-01-18 04:06:32 -08:00
Sam Lantinga f224af5ac5 Updated Haptic API for SDL 3.0 conventions
Also removed the XInput haptic support since using the haptic API for rumble is no longer supported.
2024-01-18 03:26:11 -08:00
SDL Wiki Bot 464a41411e Sync SDL3 wiki -> header 2024-01-15 18:55:24 +00:00
Frank Praznik 4f3d4bd110 wayland: Add the ability to import and wrap external surfaces
Add the ability to import and wrap external surfaces from external toolkits such as Qt and GTK.

Wayland surfaces and windows are more intrinsically tied to the client library than other windowing systems, so it is necessary to provide a way to initialize SDL with an existing wl_display object, which needs to be set prior to video system initialization, or export the internal SDL wl_display object for use by external applications or toolkits. For this, the global property SDL_PROPERTY_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER is used.

A Wayland example was added to testnative, and a basic example of Qt 6 interoperation is provided in the Wayland readme to demonstrate the use of external windows with both SDL owning the wl_display, and an external toolkit owning it.
2024-01-15 13:54:35 -05:00
SDL Wiki Bot 99f6bcf504 Sync SDL3 wiki -> header 2024-01-15 04:32:24 +00:00
chalonverse 3a4ac15a27
Make Xbox GDK code public (and fix some GDK code rot) (#8844) 2024-01-14 20:31:41 -08:00
SDL Wiki Bot 05d18aab1c Sync SDL3 wiki -> header 2024-01-08 19:55:19 +00:00
Frank Praznik f7dd0f9491 wayland: Allow the creation of roleless window surfaces for custom application use
Allow for the creation of SDL windows with a roleless surface that applications can use for their own purposes, such as with a windowing protocol other than XDG toplevel.

The property `wayland.surface_role_custom` will create a window with a surface that SDL can render to and handles input for, but is not associated with a toplevel window, so applications can use it for their own, custom purposes (e.g. wlr_layer_shell).

A test/minimal example is included in tests/testwaylandcustom.c
2024-01-08 14:54:47 -05:00
Sam Lantinga 7eae08cfc4 Removed SDL_GL_BindTexture() and SDL_GL_UnbindTexture()
Now that we have the OpenGL texture properties, you can directly bind them yourself.

Fixes https://github.com/libsdl-org/SDL/issues/2124
2024-01-07 20:19:19 -08:00
Sam Lantinga 1a13dae219 Added constant definitions for SDL properties
Fixes https://github.com/libsdl-org/SDL/issues/8622
2024-01-07 16:59:41 -08:00
Sam Lantinga 21c80ac843 Added a practical example of confirm/cancel gamepad button handling 2024-01-04 22:51:43 -08:00
Frank Praznik 73d02184d7 docs: Add Wayland to the SysWM migration example
Wayland will be increasingly encountered going forward and needs to be handled by applications requesting window handles to initialize the Vulkan WSI and such, so include it in the migration example to reflect current best practices.
2024-01-04 14:59:14 -05: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 39e24e52c8 Fixed example of creating a window with properties 2023-12-28 16:35:31 -08:00
Sam Lantinga dc450ba908 Added an example of creating a window with position 2023-12-28 16:34:13 -08:00
Sam Lantinga ce4fe32ce3 Added documentation for getting the X11 display from an SDL window 2023-12-28 16:26:55 -08:00
Sam Lantinga 327d31a5d9 Added documentation for getting the NSWindow from an SDL window 2023-12-28 16:09:59 -08:00
Sam Lantinga 3976bbef2a Added documentation for getting the X11 window from an SDL window 2023-12-28 15:56:37 -08: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 4bb5e1f0f9 Added migration notes for migrating Steam Input support from SDL2 to SDL3 2023-12-20 14:15:09 -08: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 ecd56bb8f0 Removed SDL_GetErrorMsg(), trivially implemented in application code 2023-12-01 09:08:23 -08:00
SDL Wiki Bot 675423f096 Sync SDL3 wiki -> header 2023-12-01 06:39:09 +00:00
Ryan C. Gordon 1072b6e86e
docs: fixed typo 2023-11-30 10:08:23 -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
Ryan C. Gordon f32575dfab
docs: Convert everything to Unix-style endlines.
Fixes #8640.
2023-11-29 11:29:57 -05: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
Sam Lantinga 5c8c3931f2 Removed outdated information about SDL_GetWindowWMInfo() 2023-11-16 09:56:16 -08:00
Sam Lantinga e0d0d140b2 Fixed SDL_GetWindowWMInfo() code example 2023-11-16 09:55:06 -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
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 2991b9f6ac SDL now represents gamepad buttons as positional elements with a separate label
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user.

Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect.

Fixes https://github.com/libsdl-org/SDL/issues/6117
2023-11-10 12:21:43 -08:00
Sam Lantinga fd4a2cce9e SDL_syswm.h has been removed and replaced with window properties 2023-11-08 12:01:48 -08:00
Sam Lantinga a1941fad6c Replaced SDL_RenderGetD3D11Device(), SDL_RenderGetD3D12Device(), and SDL_RenderGetD3D9Device() with renderer properties. 2023-11-08 12:01:48 -08:00
Ryan C. Gordon 2f92807087
vulkan: SDL_Vulkan_CreateSurface now accepts an app-provided allocator.
Fixes #3638.
2023-11-06 13:31:20 -05:00
Sam Lantinga 20cd789bab Improved migration documentation for the event memory change. 2023-11-05 21:20:48 -08:00
Sam Lantinga 70c149c88f Automatically clean up memory associated with events 2023-11-05 09:14:11 -08:00
SDL Wiki Bot ff3c20a799 Sync SDL3 wiki -> header 2023-11-05 14:11:05 +00:00
SDL Wiki Bot 17a0fe3a0c Sync SDL3 wiki -> header 2023-11-05 14:06:05 +00:00
SDL Wiki Bot 14d2471a8f Sync SDL3 wiki -> header 2023-11-05 14:04:05 +00:00
SDL Wiki Bot 2ad22eeeb5 Sync SDL3 wiki -> header 2023-11-05 14:02:06 +00:00
Sam Lantinga 75ea3a8d32 Dynamically allocate long text for SDL_EVENT_TEXT_INPUT events
This prevents input text from being split across Unicode combining or modifier characters, and in practice allocations will rarely happen.
2023-11-04 20:55:10 -07:00
Sam Lantinga 46b940d571 Updated documentation to note that the event callback is called on the same thread as the main iteration callback 2023-11-04 11:31:54 -07:00
Sam Lantinga 274da8561c Updated the migration guide to note that you can check the return value of SDL_AddEventWatch() 2023-11-04 10:42:28 -07:00
Ryan C. Gordon a19029e3c1
docs: Updated README-main-functions.md based on feedback. 2023-11-04 10:03:10 -04:00
Sam Lantinga 7e445da569 Added SDL_CleanupEvent()
This is used to free any dynamically allocated memory in events.
2023-11-04 06:47:24 -07:00
SDL Wiki Bot cf7e5bd0e8 Sync SDL3 wiki -> header 2023-11-03 15:41:14 +00:00
Ryan C. Gordon 853c28e624
docs: Added first draft of README-main-functions.md
Reference PR #8247.
2023-11-03 11:39:53 -04:00
Sam Lantinga ea02630143 More audio migration clarification 2023-11-03 00:28:05 -07:00
Sam Lantinga 14980b25a8 Clarify documentation for audio callback migration 2023-11-02 22:32:25 -07:00
Ryan C. Gordon 5b3a2c6df6
docs: Updated SDL_Vulkan_GetInstanceExtensions info in README-migration.md.
Reference PR #8457.
2023-11-02 14:57:13 -04:00
Ryan C. Gordon e6116d399a
mutex: Removed SDL_MUTEX_MAXWAIT.
Fixes #8436.
2023-10-26 14:21:53 -04:00
Ryan C. Gordon 899eb0d042 thread: Locking mutexes and rwlocks are now void functions.
Almost nothing checks these return values, and there's no reason a valid
lock should fail to operate. The cases where a lock isn't valid (it's a
bogus pointer, it was previously destroyed, a thread is unlocking a lock it
doesn't own, etc) are undefined behavior and always were, and should be
treated as an application bug.

Reference Issue #8096.
2023-10-26 08:57:34 -04:00
Sam Lantinga c98a14fdeb Renamed display added/removed events for consistency with the rest of the API
Fixes https://github.com/libsdl-org/SDL/issues/8425
2023-10-23 09:14:54 -07:00
Sam Lantinga 4368f70ff9 Added properties to various SDL objects
The following objects now have properties that can be user modified:
* SDL_AudioStream
* SDL_Gamepad
* SDL_Joystick
* SDL_RWops
* SDL_Renderer
* SDL_Sensor
* SDL_Surface
* SDL_Texture
* SDL_Window
2023-10-11 22:38:00 -07:00
Ryan C. Gordon 321fc18417
README-migration.md: Added note about SDL_HasRDTSC removal.
Fixes #8374.
2023-10-11 01:20:18 -04:00
Sam Lantinga 859dc14add Replaced SDL_GetGamepadBindForAxis() and SDL_GetGamepadBindForButton() with SDL_GetGamepadBindings() 2023-09-13 23:01:28 -07:00
Sam Lantinga 9e50048ab6 Revert "Removed SDL_GamepadBinding from the API"
This reverts commit eb0955ef89.
2023-09-13 22:42:47 -07:00
Ryan C. Gordon 9da34e8fb5
docs: Updated README-emscripten.md.
This is updated from the rewrite in the SDL2 branch.
2023-09-12 21:27:40 -04:00
Ryan C. Gordon cb44146089
docs: Whoops, this got added by the wiki bridge by accident! 2023-09-12 17:36:02 -04:00
Sam Lantinga cd633b9a88 Renamed SDL_IsAudioDevicePaused() to SDL_AudioDevicePaused()
This aligns with the SDL3 convention of removing "Is" from self-explanatory function names

Also improved some documentation in SDL_audio.h
2023-09-12 12:11:09 -07:00
SDL Wiki Bot c6cad07faa Sync SDL3 wiki -> header 2023-09-12 18:28:12 +00:00
Sam Huang e22282b097 Added README about transparent windows in Win32 2023-09-11 22:35:05 -07:00
Sam Lantinga 233789b0d1 Audio types have the same naming convention as other SDL endian types, e.g. [S|U][BITS][LE|BE]
Native endian types have no LE/BE suffix
2023-09-04 09:48:44 -07:00
SDL Wiki Bot 8387fae698 Sync SDL3 wiki -> header 2023-09-03 15:11:13 +00:00
Frank Praznik 8321813452 docs: Add note about Wayland application icons
Wayland doesn't support programmatically setting the app icon, so note this restriction and specify that a desktop entry file that points to the desired icon image is required.
2023-09-03 11:10:29 -04:00
Sam Lantinga e0ab597549 Simplified SDL_main.h migration notes
Thanks for the feedback!
https://github.com/exult/exult/issues/379#issuecomment-1701066992
2023-08-31 09:29:59 -07:00
Ryan C. Gordon 58c859f64d audio: Rename SDL_GetAudioStreamBinding to SDL_GetAudioStreamDevice. 2023-08-27 16:54:30 -04:00
Ryan C. Gordon 1e775e0eef audio: Replace SDL_CreateAndBindAudioStream with SDL_OpenAudioDeviceStream.
This is meant to offer a simplified API for people that are either migrating
directly from SDL2 with minimal effort or just want to make noise without
any of the fancy new API features.

Users of this API can just deal with a single SDL_AudioStream as their only
object/handle into the audio subsystem.

They are still allowed to open multiple devices (or open the same device
multiple times), but cannot change stream bindings on logical devices opened
through this function.

Destroying the single audio stream will also close the logical device behind
the scenes.
2023-08-27 16:54:30 -04:00
Sam Lantinga 615824a806 Updated documentation now that SDL_GetAudioDevices() has been split into separate functions for output and capture devices 2023-08-26 17:30:57 -07:00
Ethan Lee c0cd8c8142 gdk: Add SDL_GDKGetDefaultUser, SDL_GetPrefPath implementation 2023-08-25 10:40:16 -04:00
Sam Lantinga 1e9d314482 Updated to Android minSdkVersion 19 and targetSdkVersion 34
This is updated to meet the latest requirements for apps on the Google Play store
2023-08-24 08:23:06 -07:00
Simon McVittie efe15588d5 Relabel back paddles as left or right
The sequence order of the four paddles is not obvious, with SDL and Xbox
controllers swapping the order of P2 and P3 relative to each other.
If we group them into left and right, then it becomes more obvious.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-09 11:03:30 -07:00
Sam Lantinga 279ff8909f Changed example code to avoid potential divide by zero 2023-08-08 16:52:09 -07:00
Sam Lantinga b903ccf945 SDL_rwops read/write functions return size_t again
The current status is stored in the SDL_rwops 'status' field to be able to determine whether a 0 return value is caused by end of file, an error, or a non-blocking source not being ready.

The functions to read sized datatypes now return SDL_bool so you can detect read errors.

Fixes https://github.com/libsdl-org/SDL/issues/6729
2023-08-07 20:36:21 -07:00
Ryan C. Gordon e7d56dd0b2
audio: Renamed new API SDL_UnpauseAudioDevice to SDL_ResumeAudioDevice. 2023-08-05 19:20:14 -04:00
Ryan C. Gordon 18c59cc969
Merge the SDL3 audio subsystem redesign!
This rips up the entire SDL audio subsystem! While we still feed the audio device from a separate thread, the audio callback into the app is now gone a totally optional alternative.

Now the app will bind an SDL_AudioStream to a given device and feed data to it. As many streams as one likes can be bound to a device; SDL will mix them all into a single buffer and feed the device from there.

So not only does this function as a basic mixer, it also means that multiple device opens are handled seamlessly (so if you want to open the device for your game, but you also link to a library that provides VoIP and it wants to open the device separately, you don't have to worry about stepping on each other, or that the OS will fail to allow multiple opens of the same device, etc).

Merged from pull request #7704.

Fixes #7379.
Reference Issue #6889.
Reference Issue #6632.
2023-08-03 21:27:54 -04:00
Sam Lantinga b7f32f74ce Note the removal of the SDL_RENDERER_TARGETTEXTURE flag
Render targets are a core feature of SDL 3.0, so this flag has been removed.

The OpenGL ES renderer still doesn't support them, but we'll deal with that later.

Fixes https://github.com/libsdl-org/SDL/issues/8059
2023-07-31 08:36:44 -07:00
Ryan C. Gordon 323ecce123
docs: Added migration note about SDL_AUDIODEVICEREMOVED. 2023-07-30 11:55:57 -04:00
Ryan C. Gordon eee407caf8
docs: migration guide note that SDL_LoadWAV has a different return type. 2023-07-30 11:55:56 -04:00
Ryan C. Gordon db39cbf208
audio: Allow SDL_GetAudioDeviceFormat() to query the default devices.
Officially removed SDL_GetDefaultAudioInfo(), as its functionality that
isn't obsolete is now offered elsewhere.
2023-07-30 11:55:55 -04:00
Ryan C. Gordon e50cb72eb6
docs: Note that audio opening doesn't implicitly init SDL now. 2023-07-30 11:55:54 -04:00
Ryan C. Gordon 97b2f747d0
docs: Corrections to audio section of README-migration.md 2023-07-30 11:55:54 -04:00
Ryan C. Gordon 01f7b53865
audio: Readded (logical) device pausing. 2023-07-30 11:55:53 -04:00
Ryan C. Gordon 26525f5fd3
audio: Readd SDL_AudioSpec, but just with format/channels/freq fields. 2023-07-30 11:55:52 -04:00
Ryan C. Gordon 56b1bc2198
audio: SDL_AudioStream now has callbacks for Get and Put operations.
This allows code to feed a stream (or feed from a stream) on-demand,
which is to say: it can efficiently simulate the SDL2 audio callback.
2023-07-30 11:55:51 -04:00
Ryan C. Gordon 905c4fff5b
audio: First shot at the SDL3 audio subsystem redesign!
This is a work in progress! (and this commit will probably get
force-pushed over at some point).
2023-07-30 11:55:51 -04:00
Anonymous Maarten e24b3e2fa4 cmake: rename SDL_TEST -> SDL_TEST_LIBRARY 2023-07-28 04:41:29 +02:00
SDL Wiki Bot f2ae00c1ad Sync SDL3 wiki -> header 2023-07-27 22:43:14 +00:00
Anonymous Maarten 41a96c8133 doc: document building of SDL tests with CMake 2023-07-28 00:41:26 +02:00