Commit Graph

2309 Commits (2f78e5f321b5aca80344b2a75fee0e9d7ae9b2b9)

Author SHA1 Message Date
Ryan C. Gordon df438a3170
opengl: OpenGL renderers need to support texture target in properties.
Otherwise this has to become an awkward heuristic in sdl2-compat.
2024-01-08 14:08:35 -05:00
SDL Wiki Bot 44adab7dfd Sync SDL3 wiki -> header 2024-01-08 17:36:24 +00:00
Simon McVittie 059fb560ba gamepad: Clarify range and direction of axes
It would be easy to assume that all APIs that reference
SDL_JOYSTICK_AXIS_MAX work the same way, but they do not: triggers
generally use the full signed 16-bit range in the lower-level joystick
API, but are normalized to be non-negative by the higher-level gamepad
API.

We also never said explicitly which direction is positive here.
Experimentally, it's right (X), down (Y), and pressed (triggers).

Resolves: https://github.com/libsdl-org/SDL/issues/8793
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-08 09:35:25 -08:00
SDL Wiki Bot 4942027117 Sync SDL3 wiki -> header 2024-01-08 17:34:23 +00:00
Ryan C. Gordon e056f52f7d
include: Remove string literals from properties documentation.
I'm going to let the wiki bridge clean up the word wrapping for me, here. :)
2024-01-08 12:33:29 -05:00
SDL Wiki Bot e8c595af5c Sync SDL3 wiki -> header 2024-01-08 17:16:19 +00:00
Ryan C. Gordon adef35b9ec
include: Attempt to make new properties documentation wiki bridge friendly. 2024-01-08 12:14:08 -05:00
SDL Wiki Bot 4ffec098b7 Sync SDL3 wiki -> header 2024-01-08 15:18:26 +00:00
Ryan C. Gordon 9bc7cfc755
render: Added SDL_GetTextureRenderer(). 2024-01-08 10:17:38 -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
SDL Wiki Bot 4d5bffc323 Sync SDL3 wiki -> header 2024-01-08 01:02:25 +00: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 3deefa6b43 Updated documentation for SDL_HINT_SHUTDOWN_DBUS_ON_QUIT 2024-01-07 14:20:16 -08:00
Semphris 2348e8b6a2 Add hint to make SDL handle dbus_shutdown() 2024-01-07 14:11:33 -08:00
J. Neuschäfer 139a0931a3 Fix memory barriers on ARMv5
The ARM926EJ-S Technical Reference Manual states:

> You can only access CP15 registers with MRC and MCR instructions in a
> privileged mode. CDP, LDC, STC, MCRR, and MRRC instructions, and unprivileged
> MRC or MCR instructions to CP15 cause the Undefined instruction exception to
> be taken.

Furthermore, `MCR p15, 0, <Rd>, c7, c10, 5` (later called Data Memory Barrier)
is not specified for the ARM926. Thus, SDL should not use these cache
instructions on ARMv5.
2024-01-05 09:00:47 -08:00
Sam Lantinga 5b3ee51c6c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
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
Ozkan Sezer 42c8366fdc revise iconv detection:
- check libiconv with a linkage test with iconv.h included
- check libc iconv with a linkage test with iconv.h included
  and LIBICONV_PLUG defined (in case libiconv header is in
  include path)
- add new configuration option to prefer iconv from libiconv,
  if available, over the libc version: SDL_LIBICONV, defaults
  to disabled.
- remove FindIconv + pkg_check_modules for iconv, and use our
  manual iconv finding only
- change FreeBSD specific LIBICONV_PLUG define in SDL_iconv.c
  to configuration result.
2023-11-23 04:30:56 +03: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
Sam Lantinga 0907f345cb Added property types: pointer, string, number, float 2023-11-12 10:48:38 -08:00
Christoph Reichenbach 7c80ac6df7 API for pressure-sensitive pens + XInput2/Wayland
This patch adds an API for querying pressure-
sensitive pens, cf. SDL_pen.h:
- Enumerate all pens
- Get pen capabilities, names, GUIDs
- Distinguishes pens and erasers
- Distinguish attached and detached pens
- Pressure and tilt support
- Rotation, distance, throttle wheel support
  (throttle wheel untested)
- Pen type and meta-information reporting
  (partially tested)

Pen event reporting:
- Three new event structures: PenTip, PenMotion, and
  PenButton
- Report location with sub-pixel precision
- Include axis and button status, is-eraser flag

Internal pen tracker, intended to be independent
of platform APIs, cf. SDL_pen_c.h:
- Track known pens
- Handle pen hotplugging

Automatic test:
- testautomation_pen.c

Other features:
- XInput2 implementation, incl. hotplugging
- Wayland implementation, incl. hotplugging
- Backward compatibility: pen events default to
  emulating pens with mouse ID SDL_PEN_MOUSEID
- Can be toggled via SDL_HINT_PEN_NOT_MOUSE
- Test/demo program (testpen)
- Wacom pen feature identification by pen ID

Acknowledgements:
- Ping Cheng (Wacom) provided extensive feedback
  on Wacom pen features and detection so that
  hopefully untested Wacom devices have a
  realistic chance of working out of the box.
2023-11-12 09:52:02 -08:00
Sam Lantinga d3e43668d0 Revert "Sync SDL3 wiki -> header"
This reverts commit 43571769f1.
2023-11-12 09:02:22 -08:00
SDL Wiki Bot 43571769f1 Sync SDL3 wiki -> header 2023-11-12 15:55:10 +00:00
Sam Lantinga b374105975 Replaced SDL_GetTextureDXGIResource() with texture properties
Fixes https://github.com/libsdl-org/SDL/issues/8529
2023-11-10 20:38:13 -08:00
Sam Lantinga 312faf9305 Updated documentation for the controller face buttons 2023-11-10 16:39:32 -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
Ryan C. Gordon aa7baf63aa
Sync wiki -> headers. 2023-11-09 20:11:23 -05:00
Sylvain 59f93e20a7 Add SDL Video Capture, with back-end for linux/macos/ios/android 2023-11-09 08:36:23 -08:00
Sam Lantinga 979214363f Added SDL_GetGlobalProperties()
We'll undoubtedly want to have global properties available
2023-11-08 12:01:48 -08:00
Sam Lantinga 151cdfa99f Added the "SDL.window.wayland.registry" property
Fixes https://github.com/libsdl-org/SDL/issues/8393
2023-11-08 12:01:48 -08:00
Sam Lantinga 6c91b28e71 Added the "SDL.renderer.d3d12.command_queue" property
Fixes https://github.com/libsdl-org/SDL/issues/8491
2023-11-08 12:01:48 -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 aea6e6de6f Simplified SDL_SetProperty() and added SDL_SetPropertyWithCleanup()
Most of the time people won't need to set a cleanup callback, so we can simplify the more commonly used API.
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
Sam Lantinga 0cd4b7d3e3 Added display properties 2023-11-08 12:01:48 -08:00
Sam Lantinga 8668943746 Standardized property names for internal SDL properties 2023-11-08 12:01:48 -08:00
Sam Lantinga b5057edf29 Remove unused SDL_TextureModulate enum
Fixes https://github.com/libsdl-org/SDL/issues/6387
2023-11-07 09:23:26 -08:00
Sam Lantinga 9458cbf75e Removed unused SDL_OSEvent 2023-11-07 09:14:35 -08:00
Frank Praznik 1a57f6bb29 wayland: Remove QtWayland extensions
These were added a very long time ago and seem to serve no purpose now, as the functionality they provided is now in core Wayland protocols, current information on their usage and status is nonexistent, no modern compositor seems to support them, and the code paths are untested and subject to bit-rot at this point. It also causes duplicate symbol issues when statically linking an application to both Qt and SDL.
2023-11-07 11:00:32 -05:00
SDL Wiki Bot fccec65afe Sync SDL3 wiki -> header 2023-11-06 18:32:15 +00: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
Ryan C. Gordon c53843a961
docs: Remove Doxygen `\brief` tags.
Doxygen and the wiki bridge don't need them; they'll both just use the first
line/sentence instead.

Fixes #8446.
2023-11-06 10:26:06 -05:00
Ozkan Sezer c132295ad7 SDL_FlushEventMemory is not a public procedure. 2023-11-06 17:40:56 +03:00
Ryan C. Gordon 7ac281f800
Sync wiki -> headers. 2023-11-06 09:33:05 -05:00
Sam Lantinga f7d40b7594 Added 10-bit pixel formats in addition to SDL_PIXELFORMAT_ARGB2101010
Added SDL_PIXELFORMAT_XRGB2101010, SDL_PIXELFORMAT_XBGR2101010, SDL_PIXELFORMAT_ABGR2101010

Fixes https://github.com/libsdl-org/SDL/issues/3553
2023-11-06 00:41:09 -08:00
Sam Lantinga 04dfca958a Added a note to events indicating that memory is owned by SDL 2023-11-05 21:25:43 -08:00
Sam Lantinga 70c149c88f Automatically clean up memory associated with events 2023-11-05 09:14:11 -08:00
Sam Lantinga d3f2eb2aba Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!)
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE

Fixes https://github.com/libsdl-org/SDL/issues/2797

(cherry picked from commit e8f4045d0bccacbf8f4b716d0dde17140e9f2cc4)
2023-11-04 22:28:09 -07: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 2a1660ab51 Additional cleanup for SDL_RWprintf() (thanks @sezero!) 2023-11-04 20:47:08 -07:00
Ryan C. Gordon e5f2cea234
Sync wiki -> headers 2023-11-04 22:18:38 -04:00
Sam Lantinga ad842dd5ad Fixed a typo in SDL_log.h 2023-11-04 16:46:08 -07:00
Sam Lantinga f9d11807c0 Added SDL_RWprintf() and SDL_RWvprintf() to do formatted printing to an SDL_rwops stream
Fixes https://github.com/libsdl-org/SDL/issues/2390
2023-11-04 16:46:08 -07:00
Sam Lantinga 91f0456391 Add the source application for drag and drop events (thanks Nathan!)
This is only implemented on iOS, but is useful for third party application integrations.

Fixes https://github.com/libsdl-org/SDL/issues/2024
2023-11-04 13:00:41 -07:00
Ryan C. Gordon 1a8bf31a69 include: Fixing whitespace on SDL_MixAudioFormat. 2023-11-04 15:06:41 -04:00
Sam Lantinga d07a264a9b Use the default UCS2/UCS4 conversion rather than non-portable INTERNAL encoding
Fxies https://github.com/libsdl-org/SDL/issues/1497
2023-11-04 12:01:30 -07:00
Sam Lantinga ad9dcdbbce Clarify that you should use the other field when reading the event 2023-11-04 09:58:35 -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 3ab6670cb1 Sync SDL3 wiki -> header 2023-11-04 05:36:15 +00:00
Sam Lantinga f439ccfc1a Updated return values for SDL event functions
SDL_PollEvent(), SDL_WaitEvent(), and SDL_WaitEventTimeout() all return SDL_bool.
SDL_AddEventWatch() returns an int result code.

Also improved timeout accuracy in SDL_WaitEventTimeout()
2023-11-03 22:31:42 -07:00
Sam Lantinga a76d8e39aa Changed SDL_bool from an enum to unsigned int
Fixes https://github.com/libsdl-org/SDL/issues/7957
2023-11-03 09:54:04 -07:00
Ryan C. Gordon 70d75b4a23
Sync wiki -> headers 2023-11-03 10:13:46 -04:00
Ryan C. Gordon 07a776f255
include: Fixed documentation for SDL_Vulkan_GetInstanceExtensions. 2023-11-02 15:12:24 -04:00
ilyas-taouaou 9224a0a2d8 Fix emscripten, android, uikit and windows 2023-11-02 14:27:36 -04:00
ilyas-taouaou d0d8b28df1 Change SDL_Vulkan_GetInstanceExtensions 2023-11-02 14:27:36 -04:00
Ryan C. Gordon 9c664b0062
main: Added _optional_ callback entry points.
This lets apps optionally have a handful of callbacks for their entry points instead of a single main function. If used, the actual main/SDL_main/whatever entry point will be implemented in the single-header library SDL_main.h and the app will implement four separate functions:

First:

    int SDL_AppInit(int argc, char **argv);

This will be called once before anything else. argc/argv work like they always do. If this returns 0, the app runs. If it returns < 0, the app calls SDL_AppQuit and terminates with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. This function should not go into an infinite mainloop; it should do any one-time startup it requires and then return.

Then:

     int SDL_AppIterate(void);

This is called over and over, possibly at the refresh rate of the display or some other metric that the platform dictates. This is where the heart of your app runs. It should return as quickly as reasonably possible, but it's not a "run one memcpy and that's all the time you have" sort of thing. The app should do any game updates, and render a frame of video. If it returns < 0, SDL will call SDL_AppQuit and terminate the process with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. If it returns 0, then SDL_AppIterate will be called again at some regular frequency. The platform may choose to run this more or less (perhaps less in the background, etc), or it might just call this function in a loop as fast as possible. You do not check the event queue in this function (SDL_AppEvent exists for that).

Next:

    int SDL_AppEvent(const SDL_Event *event);

This will be called once for each event pushed into the SDL queue. This may be called from any thread, and possibly in parallel to SDL_AppIterate. The fields in event do not need to be free'd (as you would normally need to do for SDL_EVENT_DROP_FILE, etc), and your app should not call SDL_PollEvent, SDL_PumpEvent, etc, as SDL will manage this for you. Return values are the same as from SDL_AppIterate(), so you can terminate in response to SDL_EVENT_QUIT, etc.

Finally:

    void SDL_AppQuit(void);

This is called once before terminating the app--assuming the app isn't being forcibly killed or crashed--as a last chance to clean up. After this returns, SDL will call SDL_Quit so the app doesn't have to (but it's safe for the app to call it, too). Process termination proceeds as if the app returned normally from main(), so atexit handles will run, if your platform supports that.

The app does not implement SDL_main if using this. To turn this on, define SDL_MAIN_USE_CALLBACKS before including SDL_main.h. Defines like SDL_MAIN_HANDLED and SDL_MAIN_NOIMPL are also respected for callbacks, if the app wants to do some sort of magic main implementation thing.

In theory, on most platforms these can be implemented in the app itself, but this saves some #ifdefs in the app and lets everyone struggle less against some platforms, and might be more efficient in the long run, too.

On some platforms, it's possible this is the only reasonable way to go, but we haven't actually hit one that 100% requires it yet (but we will, if we want to write a RetroArch backend, for example).

Using the callback entry points works on every platform, because on platforms that don't require them, we can fake them with a simple loop in an internal implementation of the usual SDL_main.

The primary way we expect people to write SDL apps is with SDL_main, and this is not intended to replace it. If the app chooses to use this, it just removes some platform-specific details they might have to otherwise manage, and maybe removes a barrier to entry on some future platform.

Fixes #6785.
Reference PR #8247.
2023-11-01 18:40:41 -04:00
Anonymous Maarten 6127ac0871 Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h 2023-10-28 18:54:12 +02:00
SDL Wiki Bot 2e9eb1073d Sync SDL3 wiki -> header 2023-10-26 18:23:13 +00:00
Ryan C. Gordon e6116d399a
mutex: Removed SDL_MUTEX_MAXWAIT.
Fixes #8436.
2023-10-26 14:21:53 -04:00
SDL Wiki Bot 82f48be3ef Sync SDL3 wiki -> header 2023-10-26 12:58:14 +00: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
Ryan C. Gordon b16165a33f
rwlock: SDL_UnlockRWLock was incorrectly tagged with SDL_RELEASE_SHARED.
It needs to be SDL_RELEASE_GENERIC, because it releases both exclusive
(writer) and shared (reader) locks.

Without this fix, clang's `-Wthread-safety` tests generate incorrect warnings.

Reference Issue #8096.
2023-10-24 14:42:02 -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
SDL Wiki Bot 594fda4120 Sync SDL3 wiki -> header 2023-10-19 17:13:15 +00:00
Sam Lantinga 0d7c5a2c56 Updated Android API documentation 2023-10-19 10:12:34 -07:00
SDL Wiki Bot 142366c837 Sync SDL3 wiki -> header 2023-10-19 14:03:06 +00:00
Sam Lantinga 1f8f82b379 Removed redundant thread-safety information 2023-10-18 22:19:50 -07:00
SDL Wiki Bot a6edc75fe7 Sync SDL3 wiki -> header 2023-10-19 05:18:12 +00:00
Sam Lantinga 3c8edeb79b Clarified SDL property thread-safety information 2023-10-18 22:17:02 -07:00
SDL Wiki Bot 4fa821cb3e Sync SDL3 wiki -> header 2023-10-19 05:14:13 +00:00
Sam Lantinga 1c70760c0b Added thread-safety information for the new SDL properties API 2023-10-18 22:13:33 -07:00
Sam Lantinga b45a0d9016 Updated the documentation for SDL_LoadWAV_RW() 2023-10-17 20:27:49 -07:00
Zhile Zhu 6ddd96a4d0 Fix some wrong gamepad/controller event enums 2023-10-16 08:35:54 -04:00
Ryan C. Gordon ac71831350
Sync wiki -> headers 2023-10-12 15:20:53 -04: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
Sam Lantinga 973c8b3273 Added SDL properties API
Fixes https://github.com/libsdl-org/SDL/issues/7799
2023-10-11 22:38:00 -07:00
Ryan C. Gordon 0fe95cfba3
Sync wiki -> header 2023-10-10 10:49:24 -04:00
Sam Lantinga 2bd478ae65 Added SDL_GetTextureDXGIResource() to get the DXGI resource associated with a render texture.
Also switched the D3D11 and D3D12 renderers to use real NV12 textures for NV12 data.

The combination of these two changes allows us to implement 0-copy video decode and playback for D3D11 in testffmpeg without any access to the renderer internals.
2023-10-10 03:32:46 -07:00
Simon McVittie d88bf687a8 surface: Document the in-memory layout of the pixels
I don't think we ever explicitly said this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:24:43 -07:00
Simon McVittie 3698630bbc pixels: Document the naming convention
Whenever I have to fix something endianness-related, I always get
confused about whether the byte-oriented format that guarantees to put
red in byte 0 is RGBA8888 or RGBA32. (The answer is that it's RGBA32.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:24:43 -07:00
Simon McVittie 0d68f45879 test: Extract SDLTest_ReadSurfacePixel
This is essentially the same as was added in d95d2d70, but with clearer
error handling. It's implemented in a private header file so that it
can be shared with SDL_shape, which also wants this functionality.

Resolves: https://github.com/libsdl-org/SDL/issues/8319
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:23:20 -07:00
Frank Praznik 2a1058713c Bump libdecor feature check to look for 0.2.0
The version of libdecor tagged with support for the suspended event and min/max getters is 0.2.0, so update the checks to reflect this.
2023-09-25 12:07:54 -04:00
Ryan C. Gordon a4541a255e
audio: SDL_GetAudioStreamQueued now returns bytes, not frames.
Reference #8266.
2023-09-20 14:15:47 -04:00
Ryan C. Gordon 703aefbce0
Sync SDL3 wiki -> header 2023-09-20 14:08:32 -04:00
Ryan C. Gordon 34b931f7eb audio: Added SDL_GetAudioStreamQueued 2023-09-20 10:15:03 -04:00
Ryan C. Gordon 23206b9e3f audio: Added SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
This fires if an opened device changes formats (which it can on Windows,
if the user changes this in the system control panel, and WASAPI can
report), or if a default device migrates to new hardware and the format
doesn't match.

This will fire for all logical devices on a physical device (and if it's
a format change and not a default device change, it'll fire for the
physical device too, but that's honestly not that useful and might change).

Fixes #8267.
2023-09-20 10:12:10 -04:00
Ryan C. Gordon 31229fd47f
include: Added a note about SDL's iOS app delegate functions.
Fixes #8250.
2023-09-15 09:50:24 -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
Sam Lantinga 9f17d1a9d8 Don't reference the same function in "see also" 2023-09-13 11:01:00 -07:00
Ozkan Sezer 86505ea630 fix SDL_AudioStreamCallback documentation 2023-09-13 18:35:30 +03:00
SDL Wiki Bot d885d5c310 Sync SDL3 wiki -> header 2023-09-13 15:04:13 +00:00
Ryan C. Gordon 2f43f7bc53
audio: Allow querying of device buffer size. 2023-09-13 11:03:17 -04:00
Ryan C. Gordon cf95721130
audio: Added a hint to let apps force device buffer size.
This is a hint because apps might (probably mistakenly) believe they need this
to migrate from SDL2, but most things don't need to specify this.
2023-09-13 10:42:08 -04:00
Ryan C. Gordon 8b26e95f91
audio: Change SDL_AudioStreamCallback
Now it offers the total requested bytes in addition to the amount
immediately needed (and immediately needed might be zero if the stream
already has enough queued to satisfy the request.
2023-09-13 10:11:23 -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
Ryan C. Gordon a6e52f9e48
Sync SDL3 wiki -> header 2023-09-12 14:27:21 -04:00
Ryan C. Gordon 3a992af446 audio: Added a postmix callback to logical devices.
You can see it in action in testaudio by mousing over a logical device; it
will show a visualizer for the current PCM (whatever is currently being
recorded on a capture device, or whatever is being mixed for output on
playback devices).

Fixes #8122.
2023-09-09 16:26:37 -04:00
Ryan C. Gordon 116b0ec977
include: minor tweak to audio API documentation 2023-09-07 10:45:45 -04:00
Ryan C. Gordon fb13770353
include: Replaced old Bugzilla URL. 2023-09-07 10:44:30 -04:00
Brick f2ca9a615b Added SDL_AUDIO_FRAMESIZE 2023-09-05 17:56:58 -07:00
Brick 53122593f8 Added SDL_AUDIO_BYTESIZE 2023-09-05 17:56:58 -07:00
SDL Wiki Bot 544351c98e Sync SDL3 wiki -> header 2023-09-05 21:19:16 +00:00
Sam Lantinga 2e7d2b94eb Clarify that SDL_BlitSurface() ignores the width and height in dstrect 2023-09-05 14:18:43 -07:00
Sam Lantinga 3a932141e4 Restore audio format binary compatibility with SDL 2.0 2023-09-04 10:16:53 -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 36b5f3e35c Sync SDL3 wiki -> header 2023-09-04 14:47:15 +00:00
Brick 0e552761b7 Renamed AudioStreamSpeed to AudioStreamFrequencyRatio 2023-09-04 07:46:18 -07:00
Brick 5394a805f4 Improved testaudiostreamdynamicresample
Tweaked color palette
2023-09-01 14:38:45 -04:00
Brick e55844274d Added SDL_(Get|Set)AudioStreamSpeed 2023-09-01 14:38:45 -04:00
Jeremy Demeule 6ff31e10cf
metal: Add hint to select low power device instead of the default one (#8182)
On some system like MacBook Pro Intel with AMD card, asking for the default device will always return the AMD GPU.
This is not an issue for 99% of the case when the renderer context is here to provide the maximum performance level like for game.
However, for video application using GPU for 1 quad and 1 texture, using the discrete GPU for that lead to an important power consumption (4 to 8W), heat increase, and fan noise.
With this patch, I successfully amend ffplay to only use the integrated GPU (i.e. the Intel one), instead of the discrete GPU (i.e. the AMD one).
2023-08-31 01:23:45 -07:00
SDL Wiki Bot f84c87f204 Sync SDL3 wiki -> header 2023-08-31 03:26:13 +00:00
Sam Lantinga a5e7214795 Add SDL_WINDOW_NOT_FOCUSABLE flag to set that the window should not be able to gain key focus
- Also adds SDL_SetWindowFocusable() to set/clear flag on existing windows
2023-08-30 20:29:51 -07:00
Sam Lantinga 82db2b58f9 Renamed audio stream callback and moved the userdata parameter first
In general SDL API callbacks are called with the userdata paramter first, to mimic C++ method call convention
2023-08-27 14:43:21 -07:00
SDL Wiki Bot 5bdad5210f Sync SDL3 wiki -> header 2023-08-27 20:55:12 +00:00
Ryan C. Gordon 58c859f64d audio: Rename SDL_GetAudioStreamBinding to SDL_GetAudioStreamDevice. 2023-08-27 16:54:30 -04:00
Ryan C. Gordon efd2023a72 audio: Fixed documentation. 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
Brick 82e481b520 Added --randmem test parameter 2023-08-27 13:08:15 -07:00
SDL Wiki Bot e30e5c77e6 Sync SDL3 wiki -> header 2023-08-25 14:42:25 +00:00
Ethan Lee c0cd8c8142 gdk: Add SDL_GDKGetDefaultUser, SDL_GetPrefPath implementation 2023-08-25 10:40:16 -04:00
Sam Lantinga 8924d0d927 Added missing function prototype for SDL_WriteS64BE() 2023-08-23 21:19:25 -07:00
Frank Praznik be8c42cfd7 Clarify that a window being 'hidden' means that it is unmapped/ordered out
SDL considers a hidden window to be unmapped and blocks or defers certain operations until the window is shown again, however, the X11 and Cocoa backends would set the hidden flag when the window was minimized, which blocked the functionality of SDL_RestoreWindow().

Specify that a window with the hidden flag set is unmapped and not visible on the desktop or in the dock/taskbar without a call to SDL_ShowWindow(), and don't set the hidden flag in the X11 and Cocoa backends when the window is in the minimized state, but still mapped to the desktop.
2023-08-14 13:20:24 -04:00
David CARLIER 723bcd0a8b SDL_TriggerBreakppoint for riscv arch (both 32/64) version.
`ebreak` acts like int3 for x86, giving control of running process to debuggers.
2023-08-13 11:36:49 -04:00
Anonymous Maarten b7889a7389 winrt: use windowsio in non-libc mode
CMake's SDL_build_config.h force disables HAVE_STDIO_H when buiding
winrt in non-libc mode.

Becase CreateFileEx is not available in UWP mode, use CreateFile2
instead.
2023-08-12 17:37:52 +02:00
Sam Lantinga 80850af7ce The controller update complete events are no longer disabled by default 2023-08-10 17:45:00 -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
Ravbug 690eae7d22 Implement visionOS support 2023-08-08 22:25:04 -07:00
Sam Lantinga 12deed91f8 Added information on how to enable thread-safety analysis 2023-08-08 22:09:46 -07:00
Anonymous Maarten 917e036f6f MSVC has __declspec(deprecated) 2023-08-09 02:54:18 +02:00
Sam Lantinga a2d594269c Fixed pixel format compatibility with SDL2 2023-08-07 22:45:21 -07:00
SDL Wiki Bot 8fdebdd3e0 Sync SDL3 wiki -> header 2023-08-08 03:37:14 +00: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 6af0448af9
include: fixed a typo in SDL_RenderGetMetalCommandEncoder docs.
(cherry picked from commit 8087c0a5d2e2e47b7841cdd9d3fdff8cfb23e241)
2023-08-06 10:45:46 -04:00
Ozkan Sezer f3cb46b083 SDL_thread.h: do not conflict with sdl2-compat::sdl3_include_wrapper.h
The windows hacks in there will not be needed any longer
2023-08-06 14:11:02 +03:00
Sam Lantinga 080b1dfbdb Revert "Improved fallback for SDL_COMPILE_TIME_ASSERT() (thanks @icculus!)"
This reverts commit 9d453daa23.

Oops, it totally doesn't work:
error: unused variable 'SDL_compile_time_assert_SDL_copyp' [-Werror=unused-variable]
2023-08-05 19:23:30 -07:00
Sam Lantinga 9d453daa23 Improved fallback for SDL_COMPILE_TIME_ASSERT() (thanks @icculus!) 2023-08-05 19:18:31 -07:00
Sam Lantinga 1fb2419882 Removed reference to renamed function 2023-08-05 19:11:10 -07:00
Ryan C. Gordon e7d56dd0b2
audio: Renamed new API SDL_UnpauseAudioDevice to SDL_ResumeAudioDevice. 2023-08-05 19:20:14 -04:00
SDL Wiki Bot 4bb426abad Sync SDL3 wiki -> header 2023-08-05 17:45:14 +00:00
meyraud705 3a752ce650 Reapply "Changed 'freesrc' parameter from int to SDL_bool" to SDL_wave.c
Commit bea99d4 was partially reverted by 905c4ff "audio: First shot at the SDL3 audio subsystem redesign!"
2023-08-05 13:44:48 -04:00
SDL Wiki Bot 35ad68e126 Sync SDL3 wiki -> header 2023-08-04 17:40:16 +00:00
Frank Praznik 70323a8350 Add a function to display the system menu for a window
Add SDL_ShowWindowSystemMenu() to display the system-level menu for windows. Typically, this is done by right-clicking on the system provided window decorations, however, if an application is rendering its own client-side decorations, there is currently no way to display it. This menu is provided by the system and can provide privileged desktop functionality such as moving or pinning a window to a specific workspace or display, setting the always-on-top property, or taking screenshots. In many cases, there are no APIs which allow applications to perform these actions manually.

Implemented for Wayland via functionality provided by the xdg_toplevel protocol, Win32 via the undocumented message 0x313 (typically called WM_POPUPSYSTEMMENU), and X11 via the "_GTK_SHOW_WINDOW_MENU" atom (supported in GNOME and KDE).
2023-08-04 13:39:45 -04:00
SDL Wiki Bot c0a88930bf Sync SDL3 wiki -> header 2023-08-04 01:28:15 +00: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
SDL Wiki Bot 8f00d7856d Sync SDL3 wiki -> header 2023-07-31 23:40:15 +00:00
Semphris d4a867a256 Rename SDL_GetPath to SDL_GetUserFolder
The documentation has been edited accordingly, and certain parts have been clarified.
2023-07-31 16:39:33 -07: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 660054f3dc
include: Correct comment about audio device hotplug events. 2023-07-30 11:56:41 -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 464640440f
audio: Added SDL_GetAudioStreamBinding.
Now you can open a device, bind a stream, and forget about the device ID
until you're ready to shutdown, where you can query the stream for it.
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 fd4c9f4e11
audio: documentation improvements. 2023-07-30 11:55:53 -04:00
Ryan C. Gordon b2e020958f
audio: Wrap device access in opening of logical devices.
Now you open an audio device and attach streams, as planned, but each
open generates a new logical device. Each logical device has its own
streams that are managed as a group, but all streams on all logical
devices are mixed into a single buffer for a single OS-level open of
the physical device.

This allows multiple opens of a device that won't interfere with each
other and also clean up just what the opener assigned to their logical
device, so all their streams will go away on close but other opens will
continue to mix as they were.

More or less, this makes things work as expected at the app level, but
also gives them the power to group audio streams, and (once added) pause
them all at once, etc.
2023-07-30 11:55:53 -04:00
Ryan C. Gordon 3d65a2cefe
audio: Made SDL_LoadWAV a real function, not just a macro. 2023-07-30 11:55:52 -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 e6aaed7d79
include: Audio is not, and has not been, a raw mixing buffer for a long time. 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
Sam Lantinga 0dc85f3078 Improved the documentation for the gamepad paddle buttons 2023-07-27 11:27:42 -07:00
SDL Wiki Bot d086d9874d Sync SDL3 wiki -> header 2023-07-27 13:36:07 +00:00
SDL Wiki Bot ad0c0d3cde Sync SDL3 wiki -> header 2023-07-26 17:17:06 +00:00
Starbuck5 666f81bace Add more endian-specific aliases for 32 bit pixelformats
Add these for all the RGBX variants, just like all the RGBA variants already have.
2023-07-25 23:35:42 -07:00
Anonymous Maarten 8105f1d5b5 SDL_atomic.h: __ARM_ARCH is not always defined for an arm platform
e.g. riscos toolchain
2023-07-22 15:55:48 -04:00
Anonymous Maarten 3ab4665956 cmake: bump minimum required CMake version to 3.16
main features:

- No more sdl-build-options/sdl-shared-build-options/sdl-global-options
- Dependency information is stored on SDL3-collector for sdl3.pc
- Use helper functions to modify the SDL targets;
    - sdl_sources to add sources
    - sdl_glob_sources to add glob soruces
    - sdl_link_dependency to add a link dependency that might also
      appear in sdl3.pc/SDL3Config.cmake
    - sdl_compile_definitions to add macro's
    - sdl_compile_options for compile options
    - sdl_include_directories for include directories
  They avoid repeated checks for existence of the SDL targets
- A nice feature of the previous is the ability to generate
  a sdl3.pc or SDL3Config.cmake that describes its dependencies
  accurately.

various:

- remove duplicate libc symbol list
- add CheckVulkan
- remove unused HAVE_MPROTECT
- add checks for getpagesize
2023-07-20 17:58:06 +02:00
Frank Praznik 44536b7537 Add and event and flag to report when a window has been occluded
Adds the SDL_EVENT_WINDOW_OCCLUDED events and the window flag SDL_WINDOW_OCCLUDED to report when the window occlusion state has changed, so that the application can take appropriate measures, as it may wish to suspend drawing, throttle, or otherwise behave in a more energy efficient manner when the window is not visible. When the window is no longer occluded, the SDL_EVENT_WINDOW_EXPOSED event is sent and the occlusion flag is cleared.

This is handled on macOS via the window occlusion state event (available as of 10.9), and via the xdg-shell protocol on Wayland (version 6, wayland-protocols 1.32, passed through in libdecor 0.1.2).
2023-07-18 16:42:05 -04:00
Sam Lantinga 9db2cb3513 Added SDL_ReloadGamepadMappings() to reset the SDL gamepad mappings 2023-07-18 12:50:10 -07:00
Sam Lantinga 75e7a6fcfa SDL_AddGamepadMappingsFromFile() has been made into a real function 2023-07-18 12:05:04 -07:00
Sam Lantinga 0a4e6f6d29 Added SDL_strnlen() and SDL_wcsnlen() 2023-07-17 19:37:51 -07:00
Sam Lantinga 75d4a91aaa Use SDL_GAMEPAD_TYPE_UNKNOWN, not SDL_GAMEPAD_TYPE_INVALID 2023-07-17 13:54:55 -07:00
SDL Wiki Bot 27556e098e Sync SDL3 wiki -> header 2023-07-17 20:00:18 +00:00
Sam Lantinga b271e92c6e Added the ability to specify a gamepad type in the mapping
Also renamed most cases of SDL_GAMEPAD_TYPE_UNKNOWN to SDL_GAMEPAD_TYPE_STANDARD, and SDL_GetGamepadType() will return SDL_GAMEPAD_TYPE_UNKNOWN only if the gamepad is invalid.
2023-07-17 12:59:56 -07:00
SDL Wiki Bot 74612701bb Sync SDL3 wiki -> header 2023-07-16 11:33:16 +00:00
Sam Lantinga 57cfd1e106 Removed SDL_GAMEPAD_TYPE_VIRTUAL, SDL_GAMEPAD_TYPE_AMAZON_LUNA, SDL_GAMEPAD_TYPE_GOOGLE_STADIA, and SDL_GAMEPAD_TYPE_NVIDIA_SHIELD
Removing SDL_GAMEPAD_TYPE_VIRTUAL allows a virtual controller to emulate another gamepad type. The other controller types can be treated as generic controllers by applications without special glyph or functionality treatment.
2023-07-16 04:32:12 -07:00
Sam Lantinga f3d6320bac Added SDL_strndup() 2023-07-16 04:32:12 -07:00
Sam Lantinga a1615dea85 Added SDL_SetGamepadMapping() to set the mapping for a specific device 2023-07-16 04:32:12 -07:00
Sam Lantinga eb0955ef89 Removed SDL_GamepadBinding from the API
The text format is more expressive and widely used than the binary structure
2023-07-16 04:32:12 -07:00
Sam Lantinga 2e3404db01 Added SDL_GetGamepadPowerLevel() to get the power level directly from a gamepad 2023-07-11 10:20:08 -07:00
Sam Lantinga 3cbf16b944 Added SDL_GetGamepadInstanceID() 2023-07-10 19:13:42 -07:00
SDL Wiki Bot 550c84b4df Sync SDL3 wiki -> header 2023-07-09 20:50:16 +00:00
Sam Lantinga bea99d48f2 Changed 'freesrc' parameter from int to SDL_bool 2023-07-09 13:49:04 -07:00
Sam Lantinga 32d529bf70 Use size_t for the size of memory RWops 2023-07-09 13:36:00 -07:00
Sam Lantinga 3a654b4b1c Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers 2023-07-08 09:32:24 -07:00
Sylvain aab3cbf207 SDL_thread.h: fix parameter name in comment 2023-07-07 21:55:20 +02:00
Sylvain ec90c2e26d Add 'return' comment to SDL_ClearClipboardData 2023-07-07 10:25:06 +02:00
Sam Lantinga dda474504f Fixed prototype definition 2023-07-06 13:00:03 -07:00
SDL Wiki Bot 17e95345e3 Sync SDL3 wiki -> header 2023-07-06 03:08:15 +00:00
Sam Lantinga 55ff09de38 Reimplement clipboard text in terms of clipboard data
This will simplify the X11 and Wayland implementations, which were doing that under the hood, and makes application interaction between the two APIs consistent.
2023-07-05 20:06:59 -07:00
Sam Lantinga c980ce2120 Removed SDL_EVENT_CLIPBOARD_CANCELLED in favor of the cleanup callback 2023-07-05 20:06:59 -07:00
Sam Lantinga 35876da3c4 Clipboard data API revamp
The clipboard data API is now supported on all platforms, at least for internal use.
2023-07-05 20:06:59 -07:00
luzpaz 37e567994d
Fix remaining typos (#7921)
* Fix remaining typos

Found via `codespell -q 3 -S *.hex,*.pdf,./src/libm,./src/hidapi,./src/stdlib/SDL_malloc.c,./src/video/x11/edid.h -L caf,currenty,datas,einstance,fo,hda,lod,mata,parm,parms,pevent,pevents,pixelx,requestor,ser,statics,te,texturers,thid,uscaled,windowz`
2023-07-03 12:46:47 -07:00
Sam Lantinga f010411492 Rename SDL_strtokr() to SDL_strtok_r()
Fixes https://github.com/libsdl-org/SDL/issues/7914
2023-07-03 06:20:06 -07:00
SDL Wiki Bot b8d6023a91 Sync SDL3 wiki -> header 2023-07-03 01:49:13 +00:00
Sam Lantinga 3c04be4486 The rectangles passed to SDL_BlitSurfaceUnchecked() and SDL_BlitSurfaceUncheckedScaled() are const.
The destination rectangle passed to SDL_BlitSurface() and SDL_BlitSurfaceScaled() is non-const and filled in with the final destination rectangle after clipping, and now documented as such.

Fixes https://github.com/libsdl-org/SDL/issues/7911
2023-07-02 18:45:11 -07:00
Sam Lantinga ced153a24a Fixed reference to old function (thanks @tom-seddon!)
Fixes https://github.com/libsdl-org/SDL/issues/7912
2023-07-02 18:24:53 -07:00
Sam Lantinga 50b6e5eb7e Implemented SDL_LoadBMP() and SDL_SaveBMP() as functions
Fixes https://github.com/libsdl-org/SDL/issues/7902
2023-07-02 00:00:06 -07:00
Sam Lantinga e264bb5178 Rename SDL_PIXELFORMAT_RGB888 and SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XRGB8888 and SDL_PIXELFORMAT_XBGR8888 for clarity
Fixes https://github.com/libsdl-org/SDL/issues/7903
2023-07-01 17:58:34 -07:00
Sam Lantinga 97380dcdab We don't need to reserve window flag bits for sdl2-compat
sdl2-compat does the appropriate bit twiddling to preserve compatibility
2023-06-29 22:02:24 -07:00
Sam Lantinga 8da9b22c17 The SDL_WINDOW_SKIP_TASKBAR flag has been replaced by the SDL_WINDOW_UTILITY flag
The SDL_WINDOW_UTILITY flag has the same functionality, and is now implemented on Windows.
2023-06-29 21:43:17 -07:00
Sylvain ad12bb4fd1 Remove hints that weren't used anymore ! 2023-06-28 06:22:20 -07:00
Sam Lantinga 0f4679102c Fixed pedantic warning: comma at end of enumerator list
Fixes https://github.com/libsdl-org/SDL/issues/7878
2023-06-27 21:52:33 -07:00
SDL Wiki Bot a3e0cd5208 Sync SDL3 wiki -> header 2023-06-22 13:45:16 +00:00
Sylvain 627165a2b2 Fix comments 2023-06-22 15:44:48 +02:00
Sam Lantinga 4c9fb3e169 Added the events SDL_EVENT_JOYSTICK_UPDATE_COMPLETE and SDL_EVENT_GAMEPAD_UPDATE_COMPLETE
This allows the application to tell when a joystick polling cycle is complete and can process state changes as a single atomic update. It is disabled by default, at least for now.
2023-06-21 13:59:53 -07:00
Sam Lantinga 4e81b4e8de Added SDL_HINT_VIDEO_X11_SCALING_FACTOR to allow overriding the content scale on X11 (thanks Andres!) 2023-06-18 12:19:43 -07:00
Sam Lantinga 9fe384b696 Fixed display orientation function names for SDL 3.0 convention 2023-06-17 09:28:27 -07:00
Sam Lantinga d91e96e7f5 Use SDL_HINT_GAMECONTROLLER_SENSOR_FUSION as a list of controllers to enable sensor fusion
There are too many wraparound style controllers out there to enumerate them all, so instead make this a user option in applications that support it.
2023-06-17 08:59:52 -07:00
Sam Lantinga e6d1ba2a17 Added the concept of display natural orientation
Also renamed SDL_GetDisplayOrientation() SDL_GetDisplayCurrentOrientation()

The natural orientation of the primary display is the frame of reference for accelerometer and gyro sensor readings.
2023-06-17 07:42:16 -07:00
Sam Lantinga 8de6ce7e92 Rotate the sensor axes to match gamepad orientation when using the device sensors for game controllers 2023-06-16 17:48:34 -07:00
Sam Lantinga 42e4639a5e For gamepads that don't have their own sensors, try to use the system sensors.
This allows using the gyro and accelerometer in handheld devices in conjunction with built-in or wraparound controllers.
2023-06-16 14:44:59 -07:00
Sam Lantinga e72935a445 Check for modff in addition to modf 2023-06-15 16:43:35 -07:00
Sam Lantinga 2e465ae31b Revert "Added SDL_nextafter() and SDL_nextafterf()"
This reverts commit bc5d074818.

It's not clear that we need these yet, so I'm going to remove them for now.
2023-06-14 11:05:10 -07:00
Sam Lantinga bc5d074818 Added SDL_nextafter() and SDL_nextafterf() 2023-06-13 10:32:21 -07:00
SDL Wiki Bot 7f86415146 Sync SDL3 wiki -> header 2023-06-10 15:42:15 +00:00
Sam Lantinga 281018f169 Make it clear that you can't mix 2D rendering and the window surface API
Also added functions to query and destroy the window surface so you can switch between modes if you want.

See https://github.com/pygame-community/pygame-ce/issues/2190 for more details.
2023-06-10 08:39:20 -07:00
Alibek Omarov 56520372ca hints: clarify support for comma-separated values for QtWayland orientation that's available since 2.0.22
Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
(cherry picked from commit c39524042520d6962434228ab8af9ba7e0542308)
2023-06-02 07:42:06 -07:00
Nikita Krapivin c886e80675 gdk: Virtual keyboard and text input backend 2023-05-31 13:11:39 -07:00
Frank Praznik adad6514d4 wayland: Add aspect-correct output for scaled modes
Add aspect-correct output of scaled video modes and a hint to control this behavior (aspect, stretch, or none).

The Wayland spec states that fullscreen surfaces that do not cover the entire output shall be centered with the borders masked by the compositor, so no additional work is required aside from calculating the proper window dimensions.

The default is still 'stretch' mode, as some window managers as of this time (KDE and older versions of GNOME still found in LTS distros) don't behave according to the spec and present an unmasked window that is not centered, so it's not yet safe to change the default.
2023-05-31 13:41:49 -04:00
Frank Praznik 2f75596d5a Consolidate the X11 WM_CLASS and Wayland app ID envvars
Consolidate the X11_WMCLASS and WAYLAND_WMCLASS envvars into one SDL_HINT_APP_ID hint. This hint serves the same purpose on both windowing systems to allow desktop compositors to identify and group windows together, as well as associate applications with their desktop settings and icons.

The common code for retrieving the value is now consolidated under core/unix/SDL_appid.c as it's common to *nix platforms, and the value is now retrieved at window creation time instead of being cached by the video driver at startup so that changes to the hint after video initialization and before window creation will be seen, as well as to accommodate cases where applications want to use different values for different windows.
2023-05-28 19:15:36 -04:00
SDL Wiki Bot 4d6ed7173e Sync SDL3 wiki -> header 2023-05-27 17:52:16 +00:00
Sam Lantinga 0ffeca8a1c Added SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS to control whether SDL_hid_enumerate() enumerates all HID devices or only controllers.
By default SDL will only enumerate controllers, to reduce risk of hanging or crashing on devices with bad drivers and avoiding macOS keyboard capture permission prompts.
2023-05-27 10:51:52 -07:00
Nikita Krapivin 97a927b44e gdk: Fix the project 2023-05-26 14:53:17 -07:00
Ozkan Sezer a8a72de6fb fix mingw build failures in CI with clang-tidy. 2023-05-26 23:55:04 +03:00
Sam Lantinga cb73bed6eb SDL API renaming: SDL TLS functions
Fixes https://github.com/libsdl-org/SDL/issues/7743
2023-05-26 08:33:15 -07:00
SDL Wiki Bot 2a271aeaf1 Sync SDL3 wiki -> header 2023-05-26 15:20:16 +00:00
Sam Lantinga af45ae7296 Update the SDL HIDAPI API to match upstream hidapi 0.14.0 2023-05-26 08:19:04 -07:00
Sam Lantinga c9d8a04945 Added SDL_swprintf() and SDL_vswprintf() 2023-05-26 08:19:04 -07:00
Sam Lantinga 6c28546828 Added SDL_wcstol() 2023-05-26 08:19:04 -07:00
Sam Lantinga 4dd9f61bfd Don't map the top keyboard row to numbers when using the one-handed DVORAK layouts (thanks @tormol!)
Fixes https://github.com/libsdl-org/SDL/pull/5127

(cherry picked from commit a2f4783e753e499c7f6660bf34e337618239a72f)
2023-05-22 11:33:47 -07:00
Sam Lantinga a6a222095e Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
Fixes https://github.com/libsdl-org/SDL/issues/7160
2023-05-20 11:14:34 -07:00
Sam Lantinga a66cad79c1 SDL_GetClosestFullscreenDisplayMode() now takes a boolean whether to include high density modes
Also changed the match to prioritize resolution over refresh rate
2023-05-18 12:15:23 -07:00
Sam Lantinga 87186a893c Integrate 8067023 and 8067041 to SDL3:
Change 8067023 by mikela:
	Add SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED to SDL_RaiseWindow

	- When set to false, this allows SDL_RaiseWindow to bring a chosen window to the top of the stack but not force input focus to it

Change 8067041 by mikela:
	Rename SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN
2023-05-18 09:21:29 -07:00
Sam Lantinga e61b5ceefe The SDL_WINDOW_ALLOW_HIGHDPI flag has been renamed SDL_WINDOW_HIGH_PIXEL_DENSITY 2023-05-18 07:34:45 -07:00
SDL Wiki Bot f9ecc841ca Sync SDL3 wiki -> header 2023-05-18 00:55:15 +00:00
Sam Lantinga cc94f600fd Officially added the concept of window pixel density
The SDL_WINDOW_ALLOW_HIGHDPI flag has been renamed SDL_WINDOW_HIGH_PIXEL_DENSITY, and added the function SDL_GetWindowPixelDensity()
2023-05-17 17:54:03 -07:00
SDL Wiki Bot 5836e057de Sync SDL3 wiki -> header 2023-05-17 19:59:14 +00:00
Sam Lantinga c699f3d1d8 Updated SDL high DPI support
We have gotten feedback that abstracting the coordinate system based on the display scale is unexpected and it is difficult to adapt existing applications to the proposed API.

The new approach is to provide the coordinate systems that people expect, but provide additional information that will help applications properly handle high DPI situations.

The concepts needed for high DPI support are documented in README-highdpi.md. An example of automatically adapting the content to display scale changes can be found in SDL_test_common.c, where auto_scale_content is checked.

Also, the SDL_WINDOW_ALLOW_HIGHDPI window flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint.

Fixes https://github.com/libsdl-org/SDL/issues/7709
2023-05-17 12:58:00 -07:00
SDL Wiki Bot e2b7b9b91c Sync SDL3 wiki -> header 2023-05-15 18:21:14 +00:00
Sam Lantinga 4de7433a9e Use the term "points" instead of "screen coordinates"
It turns out that screen coordinates were confusing people, thinking that meant pixels, when instead they are virtual coordinates; device independent units defined as pixels scaled by the display scale. We'll use the term "points" for this going forward, to reduce confusion.
2023-05-15 11:20:38 -07:00
SDL Wiki Bot 92a59333ba Sync SDL3 wiki -> header 2023-05-12 14:55:13 +00:00
Linus Probert 19adfa3ad9 wayland: Add support for images in clipboard.
Re-writes the clipboard data handling in wayland to an on demand
solution where callbacks are provided to generate/provide the clipboard
data when requested by the OS.
2023-05-12 07:54:56 -07:00