Update SDL to 3.3.4

This commit is contained in:
2025-12-15 19:32:47 +02:00
parent 3e91ba3fb2
commit 31945a53a2
48 changed files with 3222 additions and 445 deletions

View File

@@ -20,7 +20,7 @@
*/ */
/** /**
* Main include header for the SDL library, version 3.2.24 * Main include header for the SDL library, version 3.3.4
* *
* It is almost always best to include just this one header instead of * It is almost always best to include just this one header instead of
* picking out individual headers included here. There are exceptions to * picking out individual headers included here. There are exceptions to
@@ -42,6 +42,7 @@
#include <SDL3/SDL_clipboard.h> #include <SDL3/SDL_clipboard.h>
#include <SDL3/SDL_cpuinfo.h> #include <SDL3/SDL_cpuinfo.h>
#include <SDL3/SDL_dialog.h> #include <SDL3/SDL_dialog.h>
#include <SDL3/SDL_dlopennote.h>
#include <SDL3/SDL_endian.h> #include <SDL3/SDL_endian.h>
#include <SDL3/SDL_error.h> #include <SDL3/SDL_error.h>
#include <SDL3/SDL_events.h> #include <SDL3/SDL_events.h>

View File

@@ -132,14 +132,11 @@ extern "C" {
#define SDL_TriggerBreakpoint() __debugbreak() #define SDL_TriggerBreakpoint() __debugbreak()
#elif defined(_MSC_VER) && defined(_M_IX86) #elif defined(_MSC_VER) && defined(_M_IX86)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(ANDROID)
#include <assert.h>
#define SDL_TriggerBreakpoint() assert(0)
#elif SDL_HAS_BUILTIN(__builtin_debugtrap) #elif SDL_HAS_BUILTIN(__builtin_debugtrap)
#define SDL_TriggerBreakpoint() __builtin_debugtrap() #define SDL_TriggerBreakpoint() __builtin_debugtrap()
#elif SDL_HAS_BUILTIN(__builtin_trap) #elif SDL_HAS_BUILTIN(__builtin_trap)
#define SDL_TriggerBreakpoint() __builtin_trap() #define SDL_TriggerBreakpoint() __builtin_trap()
#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) #elif (defined(__GNUC__) || defined(__clang__) || defined(__TINYC__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) #elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
@@ -179,12 +176,48 @@ extern "C" {
# define SDL_FUNCTION "???" # define SDL_FUNCTION "???"
#endif #endif
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/** /**
* A macro that reports the current file being compiled. * A macro that reports the current file being compiled.
* *
* This macro is only defined if it isn't already defined, so to override it
* (perhaps with something that doesn't provide path information at all, so
* build machine information doesn't leak into public binaries), apps can
* define this macro before including SDL.h or SDL_assert.h.
*
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_FILE __FILE_NAME__
#elif !defined(SDL_FILE)
#ifdef __FILE_NAME__
#define SDL_FILE __FILE_NAME__
#else
#define SDL_FILE __FILE__ #define SDL_FILE __FILE__
#endif
#endif
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/**
* A macro that reports the current file being compiled, for use in
* assertions.
*
* This macro is only defined if it isn't already defined, so to override it
* (perhaps with something that doesn't provide path information at all, so
* build machine information doesn't leak into public binaries), apps can
* define this macro before including SDL_assert.h. For example, defining this
* to `""` will make sure no source path information is included in asserts.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_ASSERT_FILE SDL_FILE
#elif !defined(SDL_ASSERT_FILE)
#define SDL_ASSERT_FILE SDL_FILE
#endif
/** /**
* A macro that reports the current line number of the file being compiled. * A macro that reports the current line number of the file being compiled.
@@ -363,7 +396,7 @@ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *
do { \ do { \
while ( !(condition) ) { \ while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \ static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_ASSERT_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \ continue; /* go again. */ \
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \

View File

@@ -596,6 +596,24 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_SetAtomicU32(SDL_AtomicU32 *a, Uint32 v);
*/ */
extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a); extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a);
/**
* Add to an atomic variable.
*
* This function also acts as a full memory barrier.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
*
* \param a a pointer to an SDL_AtomicU32 variable to be modified.
* \param v the desired value to add or subtract.
* \returns the previous value of the atomic variable.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC Uint32 SDLCALL SDL_AddAtomicU32(SDL_AtomicU32 *a, int v);
/** /**
* Set a pointer to a new value if it is currently an old value. * Set a pointer to a new value if it is currently an old value.
* *

View File

@@ -1024,7 +1024,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream);
/** /**
* Query an audio stream for its currently-bound device. * Query an audio stream for its currently-bound device.
* *
* This reports the logical audio device that an audio stream is currently bound to. * This reports the logical audio device that an audio stream is currently
* bound to.
* *
* If not bound, or invalid, this returns zero, which is not a valid device * If not bound, or invalid, this returns zero, which is not a valid device
* ID. * ID.
@@ -1066,6 +1067,17 @@ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_Au
/** /**
* Get the properties associated with an audio stream. * Get the properties associated with an audio stream.
* *
* The application can hang any data it wants here, but the following
* properties are understood by SDL:
*
* - `SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN`: if true (the default), the
* stream be automatically cleaned up when the audio subsystem quits. If set
* to false, the streams will persist beyond that. This property is ignored
* for streams created through SDL_OpenAudioDeviceStream(), and will always
* be cleaned up. Streams that are not cleaned up will still be unbound from
* devices when the audio subsystem quits. This property was added in SDL
* 3.4.0.
*
* \param stream the SDL_AudioStream to query. * \param stream the SDL_AudioStream to query.
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -1076,6 +1088,9 @@ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_Au
*/ */
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream); extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream);
#define SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN "SDL.audiostream.auto_cleanup"
/** /**
* Query the current format of an audio stream. * Query the current format of an audio stream.
* *
@@ -1152,14 +1167,14 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStre
* *
* The frequency ratio is used to adjust the rate at which input data is * The frequency ratio is used to adjust the rate at which input data is
* consumed. Changing this effectively modifies the speed and pitch of the * consumed. Changing this effectively modifies the speed and pitch of the
* audio. A value greater than 1.0 will play the audio faster, and at a higher * audio. A value greater than 1.0f will play the audio faster, and at a
* pitch. A value less than 1.0 will play the audio slower, and at a lower * higher pitch. A value less than 1.0f will play the audio slower, and at a
* pitch. * lower pitch. 1.0f means play at normal speed.
* *
* This is applied during SDL_GetAudioStreamData, and can be continuously * This is applied during SDL_GetAudioStreamData, and can be continuously
* changed to create various effects. * changed to create various effects.
* *
* \param stream the stream the frequency ratio is being changed. * \param stream the stream on which the frequency ratio is being changed.
* \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01 * \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01
* and 100. * and 100.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
@@ -1321,7 +1336,7 @@ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioSt
* \threadsafety It is safe to call this function from any thread, as it holds * \threadsafety It is safe to call this function from any thread, as it holds
* a stream-specific mutex while running. Don't change the * a stream-specific mutex while running. Don't change the
* stream's format to have a different number of channels from a * stream's format to have a different number of channels from a
* a different thread at the same time, though! * different thread at the same time, though!
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1335,7 +1350,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStre
* Channel maps are optional; most things do not need them, instead passing * Channel maps are optional; most things do not need them, instead passing
* data in the [order that SDL expects](CategoryAudio#channel-layouts). * data in the [order that SDL expects](CategoryAudio#channel-layouts).
* *
* The output channel map reorders data that leaving a stream via * The output channel map reorders data that is leaving a stream via
* SDL_GetAudioStreamData. * SDL_GetAudioStreamData.
* *
* Each item in the array represents an input channel, and its value is the * Each item in the array represents an input channel, and its value is the
@@ -1417,6 +1432,136 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStr
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len); extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
/**
* A callback that fires for completed SDL_PutAudioStreamDataNoCopy() data.
*
* When using SDL_PutAudioStreamDataNoCopy() to provide data to an
* SDL_AudioStream, it's not safe to dispose of the data until the stream has
* completely consumed it. Often times it's difficult to know exactly when
* this has happened.
*
* This callback fires once when the stream no longer needs the buffer,
* allowing the app to easily free or reuse it.
*
* \param userdata an opaque pointer provided by the app for their personal
* use.
* \param buf the pointer provided to SDL_PutAudioStreamDataNoCopy().
* \param buflen the size of buffer, in bytes, provided to
* SDL_PutAudioStreamDataNoCopy().
*
* \threadsafety This callbacks may run from any thread, so if you need to
* protect shared data, you should use SDL_LockAudioStream to
* serialize access; this lock will be held before your callback
* is called, so your callback does not need to manage the lock
* explicitly.
*
* \since This datatype is available since SDL 3.4.0.
*
* \sa SDL_SetAudioStreamGetCallback
* \sa SDL_SetAudioStreamPutCallback
*/
typedef void (SDLCALL *SDL_AudioStreamDataCompleteCallback)(void *userdata, const void *buf, int buflen);
/**
* Add external data to an audio stream without copying it.
*
* Unlike SDL_PutAudioStreamData(), this function does not make a copy of the
* provided data, instead storing the provided pointer. This means that the
* put operation does not need to allocate and copy the data, but the original
* data must remain available until the stream is done with it, either by
* being read from the stream in its entirety, or a call to
* SDL_ClearAudioStream() or SDL_DestroyAudioStream().
*
* The data must match the format/channels/samplerate specified in the latest
* call to SDL_SetAudioStreamFormat, or the format specified when creating the
* stream if it hasn't been changed.
*
* An optional callback may be provided, which is called when the stream no
* longer needs the data. Once this callback fires, the stream will not access
* the data again. This callback will fire for any reason the data is no
* longer needed, including clearing or destroying the stream.
*
* Note that there is still an allocation to store tracking information, so
* this function is more efficient for larger blocks of data. If you're
* planning to put a few samples at a time, it will be more efficient to use
* SDL_PutAudioStreamData(), which allocates and buffers in blocks.
*
* \param stream the stream the audio data is being added to.
* \param buf a pointer to the audio data to add.
* \param len the number of bytes to add to the stream.
* \param callback the callback function to call when the data is no longer
* needed by the stream. May be NULL.
* \param userdata an opaque pointer provided to the callback for its own
* personal use.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety It is safe to call this function from any thread, but if the
* stream has a callback set, the caller might need to manage
* extra locking.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_ClearAudioStream
* \sa SDL_FlushAudioStream
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamQueued
*/
extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamDataNoCopy(SDL_AudioStream *stream, const void *buf, int len, SDL_AudioStreamDataCompleteCallback callback, void *userdata);
/**
* Add data to the stream with each channel in a separate array.
*
* This data must match the format/channels/samplerate specified in the latest
* call to SDL_SetAudioStreamFormat, or the format specified when creating the
* stream if it hasn't been changed.
*
* The data will be interleaved and queued. Note that SDL_AudioStream only
* operates on interleaved data, so this is simply a convenience function for
* easily queueing data from sources that provide separate arrays. There is no
* equivalent function to retrieve planar data.
*
* The arrays in `channel_buffers` are ordered as they are to be interleaved;
* the first array will be the first sample in the interleaved data. Any
* individual array may be NULL; in this case, silence will be interleaved for
* that channel.
*
* `num_channels` specifies how many arrays are in `channel_buffers`. This can
* be used as a safety to prevent overflow, in case the stream format has
* changed elsewhere. If more channels are specified than the current input
* spec, they are ignored. If less channels are specified, the missing arrays
* are treated as if they are NULL (silence is written to those channels). If
* the count is -1, SDL will assume the array count matches the current input
* spec.
*
* Note that `num_samples` is the number of _samples per array_. This can also
* be thought of as the number of _sample frames_ to be queued. A value of 1
* with stereo arrays will queue two samples to the stream. This is different
* than SDL_PutAudioStreamData, which wants the size of a single array in
* bytes.
*
* \param stream the stream the audio data is being added to.
* \param channel_buffers a pointer to an array of arrays, one array per
* channel.
* \param num_channels the number of arrays in `channel_buffers` or -1.
* \param num_samples the number of _samples_ per array to write to the
* stream.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety It is safe to call this function from any thread, but if the
* stream has a callback set, the caller might need to manage
* extra locking.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_ClearAudioStream
* \sa SDL_FlushAudioStream
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamQueued
*/
extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamPlanarData(SDL_AudioStream *stream, const void * const *channel_buffers, int num_channels, int num_samples);
/** /**
* Get converted/resampled data from the stream. * Get converted/resampled data from the stream.
* *
@@ -1586,8 +1731,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *str
* previously been paused. Once unpaused, any bound audio streams will begin * previously been paused. Once unpaused, any bound audio streams will begin
* to progress again, and audio can be generated. * to progress again, and audio can be generated.
* *
* Remember, SDL_OpenAudioDeviceStream opens device in a paused state, so this * SDL_OpenAudioDeviceStream opens audio devices in a paused state, so this
* function call is required for audio playback to begin on such device. * function call is required for audio playback to begin on such devices.
* *
* \param stream the audio stream associated with the audio device to resume. * \param stream the audio stream associated with the audio device to resume.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
@@ -1844,7 +1989,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream)
* Also unlike other functions, the audio device begins paused. This is to map * Also unlike other functions, the audio device begins paused. This is to map
* more closely to SDL2-style behavior, since there is no extra step here to * more closely to SDL2-style behavior, since there is no extra step here to
* bind a stream to begin audio flowing. The audio device should be resumed * bind a stream to begin audio flowing. The audio device should be resumed
* with `SDL_ResumeAudioStreamDevice(stream);` * with SDL_ResumeAudioStreamDevice().
* *
* This function works with both playback and recording devices. * This function works with both playback and recording devices.
* *

View File

@@ -261,9 +261,9 @@
* *
* On compilers without restrict support, this is defined to nothing. * On compilers without restrict support, this is defined to nothing.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.4.0.
*/ */
#define SDL_RESTRICT __restrict__ #define SDL_RESTRICT __restrict
/** /**
* Check if the compiler supports a given builtin functionality. * Check if the compiler supports a given builtin functionality.
@@ -281,9 +281,61 @@
*/ */
#define SDL_HAS_BUILTIN(x) __has_builtin(x) #define SDL_HAS_BUILTIN(x) __has_builtin(x)
/**
* A macro to specify data alignment.
*
* This informs the compiler that a given datatype or variable must be aligned
* to a specific byte count.
*
* For example:
*
* ```c
* // make sure this is struct is aligned to 16 bytes for SIMD access.
* typedef struct {
* float x, y, z, w;
* } SDL_ALIGNED(16) MySIMDAlignedData;
*
* // make sure this one field in a struct is aligned to 16 bytes for SIMD access.
* typedef struct {
* SomeStuff stuff;
* float SDL_ALIGNED(16) position[4];
* SomeOtherStuff other_stuff;
* } MyStruct;
*
* // make sure this variable is aligned to 32 bytes.
* int SDL_ALIGNED(32) myval = 0;
* ```
*
* Alignment is only guaranteed for things the compiler places: local
* variables on the stack and global/static variables. To dynamically allocate
* something that respects this alignment, use SDL_aligned_alloc() or some
* other mechanism.
*
* On compilers without alignment support, this macro is defined to an invalid
* symbol, to make it clear that the current compiler is likely to generate
* incorrect code when it sees this macro.
*
* \param x the byte count to align to, so the data's address will be a
* multiple of this value.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_ALIGNED(x) __attribute__((aligned(x)))
/* end of wiki documentation section. */ /* end of wiki documentation section. */
#endif #endif
/* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */
#ifndef SDL_RESTRICT
# if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)))
# define SDL_RESTRICT restrict
# elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__)
# define SDL_RESTRICT __restrict
# else
# define SDL_RESTRICT
# endif
#endif
#ifndef SDL_HAS_BUILTIN #ifndef SDL_HAS_BUILTIN
#ifdef __has_builtin #ifdef __has_builtin
#define SDL_HAS_BUILTIN(x) __has_builtin(x) #define SDL_HAS_BUILTIN(x) __has_builtin(x)
@@ -379,7 +431,7 @@
#endif /* SDL_INLINE not defined */ #endif /* SDL_INLINE not defined */
#ifndef SDL_FORCE_INLINE #ifndef SDL_FORCE_INLINE
#ifdef _MSC_VER #if defined(_MSC_VER) && (_MSC_VER >= 1200)
#define SDL_FORCE_INLINE __forceinline #define SDL_FORCE_INLINE __forceinline
#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
@@ -389,7 +441,7 @@
#endif /* SDL_FORCE_INLINE not defined */ #endif /* SDL_FORCE_INLINE not defined */
#ifndef SDL_NORETURN #ifndef SDL_NORETURN
#ifdef __GNUC__ #if defined(__GNUC__)
#define SDL_NORETURN __attribute__((noreturn)) #define SDL_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define SDL_NORETURN __declspec(noreturn) #define SDL_NORETURN __declspec(noreturn)
@@ -484,3 +536,18 @@
#define SDL_ALLOC_SIZE2(p1, p2) #define SDL_ALLOC_SIZE2(p1, p2)
#endif #endif
#endif /* SDL_ALLOC_SIZE2 not defined */ #endif /* SDL_ALLOC_SIZE2 not defined */
#ifndef SDL_ALIGNED
#if defined(__clang__) || defined(__GNUC__)
#define SDL_ALIGNED(x) __attribute__((aligned(x)))
#elif defined(_MSC_VER)
#define SDL_ALIGNED(x) __declspec(align(x))
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
#define SDL_ALIGNED(x) alignas(x)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_ALIGNED(x) _Alignas(x)
#else
#define SDL_ALIGNED(x) PLEASE_DEFINE_SDL_ALIGNED
#endif
#endif /* SDL_ALIGNED not defined */

View File

@@ -136,6 +136,20 @@ typedef enum SDL_CameraPosition
SDL_CAMERA_POSITION_BACK_FACING SDL_CAMERA_POSITION_BACK_FACING
} SDL_CameraPosition; } SDL_CameraPosition;
/**
* The current state of a request for camera access.
*
* \since This enum is available since SDL 3.4.0.
*
* \sa SDL_GetCameraPermissionState
*/
typedef enum SDL_CameraPermissionState
{
SDL_CAMERA_PERMISSION_STATE_DENIED = -1,
SDL_CAMERA_PERMISSION_STATE_PENDING,
SDL_CAMERA_PERMISSION_STATE_APPROVED,
} SDL_CameraPermissionState;
/** /**
* Use this function to get the number of built-in camera drivers. * Use this function to get the number of built-in camera drivers.
@@ -346,8 +360,9 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id
* on others the approval might be implicit and not alert the user at all. * on others the approval might be implicit and not alert the user at all.
* *
* This function can be used to check the status of that approval. It will * This function can be used to check the status of that approval. It will
* return 0 if still waiting for user response, 1 if the camera is approved * return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response,
* for use, and -1 if the user denied access. * SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and
* SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access.
* *
* Instead of polling with this function, you can wait for a * Instead of polling with this function, you can wait for a
* SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event
@@ -358,8 +373,9 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id
* SDL_CloseCamera() to dispose of it. * SDL_CloseCamera() to dispose of it.
* *
* \param camera the opened camera device to query. * \param camera the opened camera device to query.
* \returns -1 if user denied access to the camera, 1 if user approved access, * \returns an SDL_CameraPermissionState value indicating if access is
* 0 if no decision has been made yet. * granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision
* is still pending.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -368,7 +384,7 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id
* \sa SDL_OpenCamera * \sa SDL_OpenCamera
* \sa SDL_CloseCamera * \sa SDL_CloseCamera
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera); extern SDL_DECLSPEC SDL_CameraPermissionState SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera);
/** /**
* Get the instance ID of an opened camera. * Get the instance ID of an opened camera.

View File

@@ -198,11 +198,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
* \param mime_type the requested mime-type. * \param mime_type the requested mime-type.
* \param size a pointer filled in with the length of the returned data. * \param size a pointer filled in with the length of the returned data.
* \returns a pointer to the data for the provided mime-type. Returning NULL * \returns a pointer to the data for the provided mime-type. Returning NULL
* or setting the length to 0 will cause no data to be sent to the * or setting the length to 0 will cause zero length data to be sent
* "receiver". It is up to the receiver to handle this. Essentially * to the "receiver", which should be able to handle this. The
* returning no data is more or less undefined behavior and may cause * returned data will not be freed, so it needs to be retained and
* breakage in receiving applications. The returned data will not be * dealt with internally.
* freed, so it needs to be retained and dealt with internally.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -211,8 +210,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size); typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size);
/** /**
* Callback function that will be called when the clipboard is cleared, or when new * Callback function that will be called when the clipboard is cleared, or
* data is set. * when new data is set.
* *
* \param userdata a pointer to the provided user data. * \param userdata a pointer to the provided user data.
* *
@@ -239,7 +238,8 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
* \param cleanup a function pointer to the function that cleans up the * \param cleanup a function pointer to the function that cleans up the
* clipboard data. * clipboard data.
* \param userdata an opaque pointer that will be forwarded to the callbacks. * \param userdata an opaque pointer that will be forwarded to the callbacks.
* \param mime_types a list of mime-types that are being offered. SDL copies the given list. * \param mime_types a list of mime-types that are being offered. SDL copies
* the given list.
* \param num_mime_types the number of mime-types in the mime_types list. * \param num_mime_types the number of mime-types in the mime_types list.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.

View File

@@ -344,6 +344,27 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
*/ */
extern SDL_DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void); extern SDL_DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void);
/**
* Report the size of a page of memory.
*
* Different platforms might have different memory page sizes. In current
* times, 4 kilobytes is not unusual, but newer systems are moving to larger
* page sizes, and esoteric platforms might have any unexpected size.
*
* Note that this function can return 0, which means SDL can't determine the
* page size on this platform. It will _not_ set an error string to be
* retrieved with SDL_GetError() in this case! In this case, defaulting to
* 4096 is often a reasonable option.
*
* \returns the size of a single page of memory, in bytes, or 0 if SDL can't
* determine this information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetSystemPageSize(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -139,10 +139,12 @@ typedef void (SDLCALL *SDL_DialogFileCallback)(void *userdata, const char * cons
* it will be invoked. * it will be invoked.
* \param window the window that the dialog should be modal for, may be NULL. * \param window the window that the dialog should be modal for, may be NULL.
* Not all platforms support this option. * Not all platforms support this option.
* \param filters a list of filters, may be NULL. Not all platforms support * \param filters a list of filters, may be NULL. See the
* this option, and platforms that do support it may allow the * [`SDL_DialogFileFilter`](SDL_DialogFileFilter#code-examples)
* user to ignore the filters. If non-NULL, it must remain * documentation for examples]. Not all platforms support this
* valid at least until the callback is invoked. * option, and platforms that do support it may allow the user
* to ignore the filters. If non-NULL, it must remain valid at
* least until the callback is invoked.
* \param nfilters the number of filters. Ignored if filters is NULL. * \param nfilters the number of filters. Ignored if filters is NULL.
* \param default_location the default folder or file to start the dialog at, * \param default_location the default folder or file to start the dialog at,
* may be NULL. Not all platforms support this option. * may be NULL. Not all platforms support this option.

View File

@@ -0,0 +1,227 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* WIKI CATEGORY: DlopenNotes */
/**
* # CategoryDlopenNotes
*
* This header allows you to annotate your code so external tools know about
* dynamic shared library dependencies.
*
* If you determine that your toolchain doesn't support dlopen notes, you can
* disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use
* this CMake snippet to check for support:
*
* ```cmake
* set(CHECK_ELF_DLNOTES_SRC [==[
* #ifndef __ELF__
* ELF DL notes is only supported on ELF platforms
* #endif
* __attribute__ ((used,aligned(4),section(".note.dlopen"))) static const struct {
* struct { int a; int b; int c; } hdr; char name[4]; __attribute__((aligned(4))) char json[24];
* } dlnote = { { 4, 0x407c0c0aU, 16 }, "FDO", "[\\"a\\":{\\"a\\":\\"1\\",\\"b\\":\\"2\\"}]" };
* int main(int argc, char *argv[]) {
* return argc + dlnote.hdr.a;
* }
* ]==])
* check_c_source_compiles("${CHECK_ELF_DLNOTES_SRC}" COMPILER_SUPPORTS_ELFNOTES)
* if(NOT COMPILER_SUPPORTS_ELFNOTES)
* set(SDL_DISABLE_DLOPEN_NOTES TRUE)
* endif()
* ```
*/
#ifndef SDL_dlopennote_h
#define SDL_dlopennote_h
/**
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
* library dependency is optional.
*
* Optional functionality uses the dependency, the binary will work and the
* dependency is only needed for full-featured installations.
*
* \since This macro is available since SDL 3.4.0.
*
* \sa SDL_ELF_NOTE_DLOPEN
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
*/
#define SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested"
/**
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
* library dependency is recommended.
*
* Important functionality needs the dependency, the binary will work but in
* most cases the dependency should be provided.
*
* \since This macro is available since SDL 3.4.0.
*
* \sa SDL_ELF_NOTE_DLOPEN
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
*/
#define SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED "recommended"
/**
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
* library dependency is required.
*
* Core functionality needs the dependency, the binary will not work if it
* cannot be found.
*
* \since This macro is available since SDL 3.4.0.
*
* \sa SDL_ELF_NOTE_DLOPEN
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
*/
#define SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED "required"
#if !defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_ANDROID)
/* The dlopen note functionality isn't used on this platform */
#ifndef SDL_DISABLE_DLOPEN_NOTES
#define SDL_DISABLE_DLOPEN_NOTES
#endif
#elif defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1))
/* gcc < 3.1 too old */
#ifndef SDL_DISABLE_DLOPEN_NOTES
#define SDL_DISABLE_DLOPEN_NOTES
#endif
#endif /* SDL_PLATFORM_UNIX || SDL_PLATFORM_ANDROID */
#if defined(__ELF__) && !defined(SDL_DISABLE_DLOPEN_NOTES)
#include <SDL3/SDL_stdinc.h>
#define SDL_ELF_NOTE_DLOPEN_VENDOR "FDO"
#define SDL_ELF_NOTE_DLOPEN_TYPE 0x407c0c0aU
#define SDL_ELF_NOTE_INTERNAL2(json, variable_name) \
__attribute__((aligned(4), used, section(".note.dlopen"))) \
static const struct { \
struct { \
Uint32 n_namesz; \
Uint32 n_descsz; \
Uint32 n_type; \
} nhdr; \
char name[4]; \
__attribute__((aligned(4))) char dlopen_json[sizeof(json)]; \
} variable_name = { \
{ \
sizeof(SDL_ELF_NOTE_DLOPEN_VENDOR), \
sizeof(json), \
SDL_ELF_NOTE_DLOPEN_TYPE \
}, \
SDL_ELF_NOTE_DLOPEN_VENDOR, \
json \
}
#define SDL_ELF_NOTE_INTERNAL(json, variable_name) \
SDL_ELF_NOTE_INTERNAL2(json, variable_name)
#define SDL_SONAME_ARRAY1(N1) "[\"" N1 "\"]"
#define SDL_SONAME_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]"
#define SDL_SONAME_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]"
#define SDL_SONAME_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]"
#define SDL_SONAME_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]"
#define SDL_SONAME_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]"
#define SDL_SONAME_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]"
#define SDL_SONAME_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]"
#define SDL_SONAME_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME
#define SDL_SONAME_ARRAY(...) \
SDL_SONAME_ARRAY_GET(__VA_ARGS__, \
SDL_SONAME_ARRAY8, \
SDL_SONAME_ARRAY7, \
SDL_SONAME_ARRAY6, \
SDL_SONAME_ARRAY5, \
SDL_SONAME_ARRAY4, \
SDL_SONAME_ARRAY3, \
SDL_SONAME_ARRAY2, \
SDL_SONAME_ARRAY1 \
)(__VA_ARGS__)
/* Create "unique" variable name using __LINE__,
* so creating elf notes on the same line is not supported
*/
#define SDL_ELF_NOTE_JOIN2(A,B) A##B
#define SDL_ELF_NOTE_JOIN(A,B) SDL_ELF_NOTE_JOIN2(A,B)
#define SDL_ELF_NOTE_UNIQUE_NAME SDL_ELF_NOTE_JOIN(s_SDL_dlopen_note_, __LINE__)
/**
* Note that your application has dynamic shared library dependencies.
*
* You can do this by adding the following to the global scope:
*
* ```c
* SDL_ELF_NOTE_DLOPEN(
* "png",
* "Support for loading PNG images using libpng (required for APNG)",
* SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
* "libpng12.so.0"
* );
* ```
*
* Or if you support multiple versions of a library, you can list them:
*
* ```c
* // Our app supports SDL1, SDL2, and SDL3 by dynamically loading them
* SDL_ELF_NOTE_DLOPEN(
* "SDL",
* "Create windows through SDL video backend",
* SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
* "libSDL-1.2.so.0", "libSDL2-2.0.so.0", "libSDL3.so.0"
* );
* ```
*
* \since This macro is available since SDL 3.4.0.
*
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
*/
#define SDL_ELF_NOTE_DLOPEN(feature, description, priority, ...) \
SDL_ELF_NOTE_INTERNAL( \
"[{\"feature\":\"" feature \
"\",\"description\":\"" description \
"\",\"priority\":\"" priority \
"\",\"soname\":" SDL_SONAME_ARRAY(__VA_ARGS__) "}]", \
SDL_ELF_NOTE_UNIQUE_NAME)
#elif defined(__GNUC__) && __GNUC__ < 3
#define SDL_ELF_NOTE_DLOPEN(args...)
#elif defined(_MSC_VER) && _MSC_VER < 1400
/* Variadic macros are not supported */
#define SDL_ELF_NOTE_DLOPEN
#else
#define SDL_ELF_NOTE_DLOPEN(...)
#endif
#endif /* SDL_dlopennote_h */

View File

@@ -252,7 +252,7 @@ SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
#elif defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=abcd"(x):"0"(x));
return x; return x;
} }
#elif (defined(__powerpc__) || defined(__ppc__)) #elif (defined(__powerpc__) || defined(__ppc__))

View File

@@ -30,7 +30,7 @@
* coming and going, the system changing in some way, etc. * coming and going, the system changing in some way, etc.
* *
* An app generally takes a moment, perhaps at the start of a new frame, to * An app generally takes a moment, perhaps at the start of a new frame, to
* examine any events that have occured since the last time and process or * examine any events that have occurred since the last time and process or
* ignore them. This is generally done by calling SDL_PollEvent() in a loop * ignore them. This is generally done by calling SDL_PollEvent() in a loop
* until it returns false (or, if using the main callbacks, events are * until it returns false (or, if using the main callbacks, events are
* provided one at a time in calls to SDL_AppEvent() before the next call to * provided one at a time in calls to SDL_AppEvent() before the next call to
@@ -127,15 +127,17 @@ typedef enum SDL_EventType
SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */ SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */
SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */ SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */
SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /**< Display has changed usable bounds */
SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION, SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION,
SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED,
/* Window events */ /* Window events */
/* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */ /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
/* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */ /* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */
SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */ SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */
SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */ SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */
SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event */ SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event.
data1 is 1 for live-resize expose events, 0 otherwise. */
SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */ SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */ SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
@@ -174,6 +176,8 @@ typedef enum SDL_EventType
SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */ SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */
SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */ SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */
SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */ SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */
SDL_EVENT_SCREEN_KEYBOARD_SHOWN, /**< The on-screen keyboard has been shown */
SDL_EVENT_SCREEN_KEYBOARD_HIDDEN, /**< The on-screen keyboard has been hidden */
/* Mouse events */ /* Mouse events */
SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */ SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
@@ -214,10 +218,15 @@ typedef enum SDL_EventType
SDL_EVENT_FINGER_MOTION, SDL_EVENT_FINGER_MOTION,
SDL_EVENT_FINGER_CANCELED, SDL_EVENT_FINGER_CANCELED,
/* Pinch events */
SDL_EVENT_PINCH_BEGIN = 0x710, /**< Pinch gesture started */
SDL_EVENT_PINCH_UPDATE, /**< Pinch gesture updated */
SDL_EVENT_PINCH_END, /**< Pinch gesture ended */
/* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */ /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */
/* Clipboard events */ /* Clipboard events */
SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */ SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard changed */
/* Drag and drop events */ /* Drag and drop events */
SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */ SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */
@@ -298,7 +307,7 @@ typedef struct SDL_CommonEvent
*/ */
typedef struct SDL_DisplayEvent typedef struct SDL_DisplayEvent
{ {
SDL_EventType type; /**< SDL_DISPLAYEVENT_* */ SDL_EventType type; /**< SDL_EVENT_DISPLAY_* */
Uint32 reserved; Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_DisplayID displayID;/**< The associated display */ SDL_DisplayID displayID;/**< The associated display */
@@ -704,6 +713,10 @@ typedef struct SDL_GamepadSensorEvent
/** /**
* Audio device event structure (event.adevice.*) * Audio device event structure (event.adevice.*)
* *
* Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every
* device it discovers during initialization. After that, this event will only
* arrive when a device is hotplugged during the program's run.
*
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
*/ */
typedef struct SDL_AudioDeviceEvent typedef struct SDL_AudioDeviceEvent
@@ -781,7 +794,19 @@ typedef struct SDL_TouchFingerEvent
} SDL_TouchFingerEvent; } SDL_TouchFingerEvent;
/** /**
* Pressure-sensitive pen proximity event structure (event.pmotion.*) * Pinch event structure (event.pinch.*)
*/
typedef struct SDL_PinchFingerEvent
{
SDL_EventType type; /**< ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
float scale; /**< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". */
SDL_WindowID windowID; /**< The window underneath the finger, if any */
} SDL_PinchFingerEvent;
/**
* Pressure-sensitive pen proximity event structure (event.pproximity.*)
* *
* When a pen becomes visible to the system (it is close enough to a tablet, * When a pen becomes visible to the system (it is close enough to a tablet,
* etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's
@@ -793,6 +818,9 @@ typedef struct SDL_TouchFingerEvent
* is there." The pen touching and lifting off from the tablet while not * is there." The pen touching and lifting off from the tablet while not
* leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP. * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP.
* *
* Not all platforms have a window associated with the pen during proximity
* events. Some wait until motion/button/etc events to offer this info.
*
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
*/ */
typedef struct SDL_PenProximityEvent typedef struct SDL_PenProximityEvent
@@ -967,7 +995,7 @@ typedef struct SDL_QuitEvent
*/ */
typedef struct SDL_UserEvent typedef struct SDL_UserEvent
{ {
Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */ Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration */
Uint32 reserved; Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_WindowID windowID; /**< The associated window if any */ SDL_WindowID windowID; /**< The associated window if any */
@@ -1017,6 +1045,7 @@ typedef union SDL_Event
SDL_QuitEvent quit; /**< Quit request event data */ SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */ SDL_UserEvent user; /**< Custom event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
SDL_PinchFingerEvent pinch; /**< Pinch event data */
SDL_PenProximityEvent pproximity; /**< Pen proximity event data */ SDL_PenProximityEvent pproximity; /**< Pen proximity event data */
SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */ SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */
SDL_PenMotionEvent pmotion; /**< Pen motion event data */ SDL_PenMotionEvent pmotion; /**< Pen motion event data */
@@ -1043,7 +1072,7 @@ typedef union SDL_Event
} SDL_Event; } SDL_Event;
/* Make sure we haven't broken binary compatibility */ /* Make sure we haven't broken binary compatibility */
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding)); SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding));
/* Function prototypes */ /* Function prototypes */
@@ -1255,6 +1284,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType)
* } * }
* ``` * ```
* *
* Note that Windows (and possibly other platforms) has a quirk about how it
* handles events while dragging/resizing a window, which can cause this
* function to block for significant amounts of time. Technical explanations
* and solutions are discussed on the wiki:
*
* https://wiki.libsdl.org/SDL3/AppFreezeDuringDrag
*
* \param event the SDL_Event structure to be filled with the next event from * \param event the SDL_Event structure to be filled with the next event from
* the queue, or NULL. * the queue, or NULL.
* \returns true if this got an event or false if there are none available. * \returns true if this got an event or false if there are none available.
@@ -1391,7 +1427,10 @@ typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event);
* allows selective filtering of dynamically arriving events. * allows selective filtering of dynamically arriving events.
* *
* **WARNING**: Be very careful of what you do in the event filter function, * **WARNING**: Be very careful of what you do in the event filter function,
* as it may run in a different thread! * as it may run in a different thread! The exception is handling of
* SDL_EVENT_WINDOW_EXPOSED, which is guaranteed to be sent from the OS on the
* main thread and you are expected to redraw your window in response to this
* event.
* *
* On platforms that support it, if the quit event is generated by an * On platforms that support it, if the quit event is generated by an
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
@@ -1404,7 +1443,7 @@ typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event);
* the event filter, but events pushed onto the queue with SDL_PeepEvents() do * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
* not. * not.
* *
* \param filter an SDL_EventFilter function to call when an event happens. * \param filter a function to call when an event happens.
* \param userdata a pointer that is passed to `filter`. * \param userdata a pointer that is passed to `filter`.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
@@ -1567,6 +1606,38 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
*/ */
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event); extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event);
/**
* Generate an English description of an event.
*
* This will fill `buf` with a null-terminated string that might look
* something like this:
*
* ```
* SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
* ```
*
* The exact format of the string is not guaranteed; it is intended for
* logging purposes, to be read by a human, and not parsed by a computer.
*
* The returned value follows the same rules as SDL_snprintf(): `buf` will
* always be NULL-terminated (unless `buflen` is zero), and will be truncated
* if `buflen` is too small. The return code is the number of bytes needed for
* the complete string, not counting the NULL-terminator, whether the string
* was truncated or not. Unlike SDL_snprintf(), though, this function never
* returns -1.
*
* \param event an event to describe. May be NULL.
* \param buf the buffer to fill with the description string. May be NULL.
* \param buflen the maximum bytes that can be written to `buf`.
* \returns number of bytes needed for the full string, not counting the
* null-terminator byte.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -77,6 +77,9 @@ extern "C" {
* - `parent`: the containing directory of the bundle. For example: * - `parent`: the containing directory of the bundle. For example:
* `/Applications/SDLApp/` * `/Applications/SDLApp/`
* *
* **Android Specific Functionality**: This function returns "./", which
* allows filesystem operations to use internal storage and the asset system.
*
* **Nintendo 3DS Specific Functionality**: This function returns "romfs" * **Nintendo 3DS Specific Functionality**: This function returns "romfs"
* directory of the application as it is uncommon to store resources outside * directory of the application as it is uncommon to store resources outside
* the executable. As such it is not a writable directory. * the executable. As such it is not a writable directory.
@@ -89,6 +92,8 @@ extern "C" {
* doesn't implement this functionality, call SDL_GetError() for more * doesn't implement this functionality, call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetPrefPath * \sa SDL_GetPrefPath
@@ -134,6 +139,12 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void);
* - ...only use letters, numbers, and spaces. Avoid punctuation like "Game * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
* Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
* *
* Due to historical mistakes, `org` is allowed to be NULL or "". In such
* cases, SDL will omit the org subdirectory, including on platforms where it
* shouldn't, and including on platforms where this would make your app fail
* certification for an app store. New apps should definitely specify a real
* string for `org`.
*
* The returned path is guaranteed to end with a path separator ('\\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
@@ -144,6 +155,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void);
* etc.). This should be freed with SDL_free() when it is no longer * etc.). This should be freed with SDL_free() when it is no longer
* needed. * needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetBasePath * \sa SDL_GetBasePath
@@ -216,6 +229,8 @@ typedef enum SDL_Folder
* \returns either a null-terminated C string containing the full path to the * \returns either a null-terminated C string containing the full path to the
* folder, or NULL if an error happened. * folder, or NULL if an error happened.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder); extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder);
@@ -283,6 +298,8 @@ typedef Uint32 SDL_GlobFlags;
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path); extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path);
@@ -346,6 +363,8 @@ typedef SDL_EnumerationResult (SDLCALL *SDL_EnumerateDirectoryCallback)(void *us
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
@@ -360,6 +379,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_En
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path);
@@ -367,7 +388,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path);
/** /**
* Rename a file or directory. * Rename a file or directory.
* *
* If the file at `newpath` already exists, it will replaced. * If the file at `newpath` already exists, it will be replaced.
* *
* Note that this will not copy files across filesystems/drives/volumes, as * Note that this will not copy files across filesystems/drives/volumes, as
* that is a much more complicated (and possibly time-consuming) operation. * that is a much more complicated (and possibly time-consuming) operation.
@@ -383,6 +404,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath); extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath);
@@ -423,6 +446,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread, but this
* operation is not atomic, so the app might need to protect
* access to specific paths from other threads if appropriate.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath); extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath);
@@ -436,6 +463,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *n
* \returns true on success or false if the file doesn't exist, or another * \returns true on success or false if the file doesn't exist, or another
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info); extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info);
@@ -444,10 +473,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo
* Enumerate a directory tree, filtered by pattern, and return a list. * Enumerate a directory tree, filtered by pattern, and return a list.
* *
* Files are filtered out if they don't match the string in `pattern`, which * Files are filtered out if they don't match the string in `pattern`, which
* may contain wildcard characters '\*' (match everything) and '?' (match one * may contain wildcard characters `*` (match everything) and `?` (match one
* character). If pattern is NULL, no filtering is done and all results are * character). If pattern is NULL, no filtering is done and all results are
* returned. Subdirectories are permitted, and are specified with a path * returned. Subdirectories are permitted, and are specified with a path
* separator of '/'. Wildcard characters '\*' and '?' never match a path * separator of `/`. Wildcard characters `*` and `?` never match a path
* separator. * separator.
* *
* `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching
@@ -490,6 +519,8 @@ extern SDL_DECLSPEC char ** SDLCALL SDL_GlobDirectory(const char *path, const ch
* platform-dependent notation. NULL if there's a problem. This * platform-dependent notation. NULL if there's a problem. This
* should be freed with SDL_free() when it is no longer needed. * should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void); extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void);

View File

@@ -118,6 +118,7 @@ typedef enum SDL_GamepadType
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
SDL_GAMEPAD_TYPE_GAMECUBE,
SDL_GAMEPAD_TYPE_COUNT SDL_GAMEPAD_TYPE_COUNT
} SDL_GamepadType; } SDL_GamepadType;
@@ -127,8 +128,9 @@ typedef enum SDL_GamepadType
* For controllers that use a diamond pattern for the face buttons, the * For controllers that use a diamond pattern for the face buttons, the
* south/east/west/north buttons below correspond to the locations in the * south/east/west/north buttons below correspond to the locations in the
* diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo
* Switch controllers, this would be B/A/Y/X, for PlayStation controllers this * Switch controllers, this would be B/A/Y/X, for GameCube controllers this
* would be Cross/Circle/Square/Triangle. * would be A/X/B/Y, for PlayStation controllers this would be
* Cross/Circle/Square/Triangle.
* *
* For controllers that don't use a diamond pattern for the face buttons, the * For controllers that don't use a diamond pattern for the face buttons, the
* south/east/west/north buttons indicate the buttons labeled A, B, C, D, or * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or
@@ -163,14 +165,14 @@ typedef enum SDL_GamepadButton
SDL_GAMEPAD_BUTTON_DPAD_LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT,
SDL_GAMEPAD_BUTTON_DPAD_RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */ SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button) */
SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */ SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button) */
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button) */
SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */ SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button) */
SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */ SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */
SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */
SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */
SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */
SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */
SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */
SDL_GAMEPAD_BUTTON_COUNT SDL_GAMEPAD_BUTTON_COUNT
@@ -422,6 +424,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file)
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);
@@ -436,6 +440,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);
* single allocation that should be freed with SDL_free() when it is * single allocation that should be freed with SDL_free() when it is
* no longer needed. * no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
@@ -448,6 +454,8 @@ extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
* information. This should be freed with SDL_free() when it is no * information. This should be freed with SDL_free() when it is no
* longer needed. * longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
@@ -465,6 +473,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
* available; call SDL_GetError() for more information. This should * available; call SDL_GetError() for more information. This should
* be freed with SDL_free() when it is no longer needed. * be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_AddGamepadMapping * \sa SDL_AddGamepadMapping
@@ -485,6 +495,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_AddGamepadMapping * \sa SDL_AddGamepadMapping
@@ -497,6 +509,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_i
* *
* \returns true if a gamepad is connected, false otherwise. * \returns true if a gamepad is connected, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepads * \sa SDL_GetGamepads
@@ -512,6 +526,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void);
* call SDL_GetError() for more information. This should be freed * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed. * with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_HasGamepad * \sa SDL_HasGamepad
@@ -526,6 +542,8 @@ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
* \returns true if the given joystick is supported by the gamepad interface, * \returns true if the given joystick is supported by the gamepad interface,
* false if it isn't or it's an invalid index. * false if it isn't or it's an invalid index.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoysticks * \sa SDL_GetJoysticks
@@ -542,6 +560,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
* \returns the name of the selected gamepad. If no name can be found, this * \returns the name of the selected gamepad. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadName * \sa SDL_GetGamepadName
@@ -558,6 +578,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID
* \returns the path of the selected gamepad. If no path can be found, this * \returns the path of the selected gamepad. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadPath * \sa SDL_GetGamepadPath
@@ -573,6 +595,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the player index of a gamepad, or -1 if it's not available. * \returns the player index of a gamepad, or -1 if it's not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadPlayerIndex * \sa SDL_GetGamepadPlayerIndex
@@ -589,6 +613,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID in
* \returns the GUID of the selected gamepad. If called on an invalid index, * \returns the GUID of the selected gamepad. If called on an invalid index,
* this function returns a zero GUID. * this function returns a zero GUID.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GUIDToString * \sa SDL_GUIDToString
@@ -606,6 +632,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID inst
* \returns the USB vendor ID of the selected gamepad. If called on an invalid * \returns the USB vendor ID of the selected gamepad. If called on an invalid
* index, this function returns zero. * index, this function returns zero.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadVendor * \sa SDL_GetGamepadVendor
@@ -623,6 +651,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID inst
* \returns the USB product ID of the selected gamepad. If called on an * \returns the USB product ID of the selected gamepad. If called on an
* invalid index, this function returns zero. * invalid index, this function returns zero.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadProduct * \sa SDL_GetGamepadProduct
@@ -640,6 +670,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID ins
* \returns the product version of the selected gamepad. If called on an * \returns the product version of the selected gamepad. If called on an
* invalid index, this function returns zero. * invalid index, this function returns zero.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadProductVersion * \sa SDL_GetGamepadProductVersion
@@ -655,6 +687,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_Joystic
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the gamepad type. * \returns the gamepad type.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadType * \sa SDL_GetGamepadType
@@ -671,6 +705,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_Joystick
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the gamepad type. * \returns the gamepad type.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadTypeForID * \sa SDL_GetGamepadTypeForID
@@ -688,6 +724,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_Joys
* \returns the mapping string. Returns NULL if no mapping is available. This * \returns the mapping string. Returns NULL if no mapping is available. This
* should be freed with SDL_free() when it is no longer needed. * should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepads * \sa SDL_GetGamepads
@@ -702,6 +740,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID ins
* \returns a gamepad identifier or NULL if an error occurred; call * \returns a gamepad identifier or NULL if an error occurred; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_CloseGamepad * \sa SDL_CloseGamepad
@@ -717,6 +757,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instanc
* \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
* opened yet; call SDL_GetError() for more information. * opened yet; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id); extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);
@@ -727,6 +769,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID in
* \param player_index the player index, which different from the instance ID. * \param player_index the player index, which different from the instance ID.
* \returns the SDL_Gamepad associated with a player index. * \returns the SDL_Gamepad associated with a player index.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadPlayerIndex * \sa SDL_GetGamepadPlayerIndex
@@ -757,6 +801,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int play
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad); extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
@@ -775,6 +821,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepa
* \returns the instance ID of the specified gamepad on success or 0 on * \returns the instance ID of the specified gamepad on success or 0 on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad); extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
@@ -787,6 +835,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad
* \returns the implementation dependent name for the gamepad, or NULL if * \returns the implementation dependent name for the gamepad, or NULL if
* there is no name or the identifier passed is invalid. * there is no name or the identifier passed is invalid.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadNameForID * \sa SDL_GetGamepadNameForID
@@ -801,6 +851,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad
* \returns the implementation dependent path for the gamepad, or NULL if * \returns the implementation dependent path for the gamepad, or NULL if
* there is no path or the identifier passed is invalid. * there is no path or the identifier passed is invalid.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadPathForID * \sa SDL_GetGamepadPathForID
@@ -814,6 +866,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad
* \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
* available. * available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadTypeForID * \sa SDL_GetGamepadTypeForID
@@ -827,6 +881,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *game
* \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
* available. * available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetRealGamepadTypeForID * \sa SDL_GetRealGamepadTypeForID
@@ -841,6 +897,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the player index for gamepad, or -1 if it's not available. * \returns the player index for gamepad, or -1 if it's not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetGamepadPlayerIndex * \sa SDL_SetGamepadPlayerIndex
@@ -856,6 +914,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadPlayerIndex * \sa SDL_GetGamepadPlayerIndex
@@ -870,6 +930,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad,
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the USB vendor ID, or zero if unavailable. * \returns the USB vendor ID, or zero if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadVendorForID * \sa SDL_GetGamepadVendorForID
@@ -884,6 +946,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the USB product ID, or zero if unavailable. * \returns the USB product ID, or zero if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadProductForID * \sa SDL_GetGamepadProductForID
@@ -898,6 +962,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the USB product version, or zero if unavailable. * \returns the USB product version, or zero if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadProductVersionForID * \sa SDL_GetGamepadProductVersionForID
@@ -912,6 +978,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gam
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the gamepad firmware version, or zero if unavailable. * \returns the gamepad firmware version, or zero if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad); extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
@@ -924,6 +992,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *ga
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the serial number, or NULL if unavailable. * \returns the serial number, or NULL if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad); extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
@@ -937,6 +1007,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamep
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the gamepad handle, or 0 if unavailable. * \returns the gamepad handle, or 0 if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad); extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
@@ -949,6 +1021,8 @@ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepa
* `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad); extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);
@@ -969,6 +1043,8 @@ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnection
* battery. * battery.
* \returns the current battery state. * \returns the current battery state.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent); extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
@@ -981,6 +1057,8 @@ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *
* \returns true if the gamepad has been opened and is currently connected, or * \returns true if the gamepad has been opened and is currently connected, or
* false if not. * false if not.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
@@ -1001,6 +1079,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
* \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad); extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
@@ -1013,6 +1093,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *g
* *
* \param enabled whether to process gamepad events or not. * \param enabled whether to process gamepad events or not.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GamepadEventsEnabled * \sa SDL_GamepadEventsEnabled
@@ -1028,6 +1110,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);
* *
* \returns true if gamepad events are being processed, false otherwise. * \returns true if gamepad events are being processed, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetGamepadEventsEnabled * \sa SDL_SetGamepadEventsEnabled
@@ -1044,6 +1128,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
* single allocation that should be freed with SDL_free() when it is * single allocation that should be freed with SDL_free() when it is
* no longer needed. * no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
@@ -1055,6 +1141,8 @@ extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gam
* enabled. Under such circumstances, it will not be necessary to call this * enabled. Under such circumstances, it will not be necessary to call this
* function. * function.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
@@ -1071,6 +1159,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
* \returns the SDL_GamepadType enum corresponding to the input string, or * \returns the SDL_GamepadType enum corresponding to the input string, or
* `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found. * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadStringForType * \sa SDL_GetGamepadStringForType
@@ -1085,6 +1175,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const c
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_Gamepad mapping strings. * SDL_Gamepad mapping strings.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadTypeFromString * \sa SDL_GetGamepadTypeFromString
@@ -1107,6 +1199,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_Gamepad
* \returns the SDL_GamepadAxis enum corresponding to the input string, or * \returns the SDL_GamepadAxis enum corresponding to the input string, or
* `SDL_GAMEPAD_AXIS_INVALID` if no match was found. * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadStringForAxis * \sa SDL_GetGamepadStringForAxis
@@ -1121,6 +1215,8 @@ extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const c
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_Gamepad mapping strings. * SDL_Gamepad mapping strings.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadAxisFromString * \sa SDL_GetGamepadAxisFromString
@@ -1137,6 +1233,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_Gamepad
* \param axis an axis enum value (an SDL_GamepadAxis value). * \param axis an axis enum value (an SDL_GamepadAxis value).
* \returns true if the gamepad has this axis, false otherwise. * \returns true if the gamepad has this axis, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GamepadHasButton * \sa SDL_GamepadHasButton
@@ -1156,10 +1254,14 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_Ga
* return a negative value. Note that this differs from the value reported by * return a negative value. Note that this differs from the value reported by
* the lower-level SDL_GetJoystickAxis(), which normally uses the full range. * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
* *
* Note that for invalid gamepads or axes, this will return 0. Zero is also a
* valid value in normal operation; usually it means a centered axis.
*
* \param gamepad a gamepad. * \param gamepad a gamepad.
* \param axis an axis index (one of the SDL_GamepadAxis values). * \param axis an axis index (one of the SDL_GamepadAxis values).
* \returns axis state (including 0) on success or 0 (also) on failure; call * \returns axis state.
* SDL_GetError() for more information. *
* \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1180,6 +1282,8 @@ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_
* \returns the SDL_GamepadButton enum corresponding to the input string, or * \returns the SDL_GamepadButton enum corresponding to the input string, or
* `SDL_GAMEPAD_BUTTON_INVALID` if no match was found. * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadStringForButton * \sa SDL_GetGamepadStringForButton
@@ -1194,6 +1298,8 @@ extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(con
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_Gamepad mapping strings. * SDL_Gamepad mapping strings.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadButtonFromString * \sa SDL_GetGamepadButtonFromString
@@ -1210,6 +1316,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_Gamep
* \param button a button enum value (an SDL_GamepadButton value). * \param button a button enum value (an SDL_GamepadButton value).
* \returns true if the gamepad has this button, false otherwise. * \returns true if the gamepad has this button, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GamepadHasAxis * \sa SDL_GamepadHasAxis
@@ -1223,6 +1331,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_
* \param button a button index (one of the SDL_GamepadButton values). * \param button a button index (one of the SDL_GamepadButton values).
* \returns true if the button is pressed, false otherwise. * \returns true if the button is pressed, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GamepadHasButton * \sa SDL_GamepadHasButton
@@ -1237,6 +1347,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_
* \param button a button index (one of the SDL_GamepadButton values). * \param button a button index (one of the SDL_GamepadButton values).
* \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadButtonLabel * \sa SDL_GetGamepadButtonLabel
@@ -1250,6 +1362,8 @@ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForT
* \param button a button index (one of the SDL_GamepadButton values). * \param button a button index (one of the SDL_GamepadButton values).
* \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadButtonLabelForType * \sa SDL_GetGamepadButtonLabelForType
@@ -1262,6 +1376,8 @@ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL
* \param gamepad a gamepad. * \param gamepad a gamepad.
* \returns number of touchpads. * \returns number of touchpads.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumGamepadTouchpadFingers * \sa SDL_GetNumGamepadTouchpadFingers
@@ -1276,6 +1392,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad)
* \param touchpad a touchpad. * \param touchpad a touchpad.
* \returns number of supported simultaneous fingers. * \returns number of supported simultaneous fingers.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadTouchpadFinger * \sa SDL_GetGamepadTouchpadFinger
@@ -1299,6 +1417,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *ga
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumGamepadTouchpadFingers * \sa SDL_GetNumGamepadTouchpadFingers
@@ -1312,6 +1432,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamep
* \param type the type of sensor to query. * \param type the type of sensor to query.
* \returns true if the sensor exists, false otherwise. * \returns true if the sensor exists, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadSensorData * \sa SDL_GetGamepadSensorData
@@ -1329,6 +1451,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GamepadHasSensor * \sa SDL_GamepadHasSensor
@@ -1343,6 +1467,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepa
* \param type the type of sensor to query. * \param type the type of sensor to query.
* \returns true if the sensor is enabled, false otherwise. * \returns true if the sensor is enabled, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetGamepadSensorEnabled * \sa SDL_SetGamepadSensorEnabled
@@ -1356,6 +1482,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad,
* \param type the type of sensor to query. * \param type the type of sensor to query.
* \returns the data rate, or 0.0f if the data rate is not available. * \returns the data rate, or 0.0f if the data rate is not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type); extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
@@ -1373,6 +1501,8 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *game
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values); extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
@@ -1395,6 +1525,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@@ -1421,6 +1553,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_RumbleGamepad * \sa SDL_RumbleGamepad
@@ -1443,6 +1577,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue); extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
@@ -1456,6 +1592,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 r
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size); extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
@@ -1466,6 +1604,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, con
* \param gamepad a gamepad identifier previously returned by * \param gamepad a gamepad identifier previously returned by
* SDL_OpenGamepad(). * SDL_OpenGamepad().
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_OpenGamepad * \sa SDL_OpenGamepad
@@ -1480,6 +1620,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
* \param button a button on the gamepad. * \param button a button on the gamepad.
* \returns the sfSymbolsName or NULL if the name can't be found. * \returns the sfSymbolsName or NULL if the name can't be found.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadAppleSFSymbolsNameForAxis * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
@@ -1493,6 +1635,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButt
* \param axis an axis on the gamepad. * \param axis an axis on the gamepad.
* \returns the sfSymbolsName or NULL if the name can't be found. * \returns the sfSymbolsName or NULL if the name can't be found.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetGamepadAppleSFSymbolsNameForButton * \sa SDL_GetGamepadAppleSFSymbolsNameForButton

View File

@@ -206,14 +206,20 @@
* underlying graphics API. While it's possible that we have done something * underlying graphics API. While it's possible that we have done something
* inefficiently, it's very unlikely especially if you are relatively * inefficiently, it's very unlikely especially if you are relatively
* inexperienced with GPU rendering. Please see the performance tips above and * inexperienced with GPU rendering. Please see the performance tips above and
* make sure you are following them. Additionally, tools like RenderDoc can be * make sure you are following them. Additionally, tools like
* very helpful for diagnosing incorrect behavior and performance issues. * [RenderDoc](https://renderdoc.org/)
* can be very helpful for diagnosing incorrect behavior and performance
* issues.
* *
* ## System Requirements * ## System Requirements
* *
* **Vulkan:** Supported on Windows, Linux, Nintendo Switch, and certain * ### Vulkan
* Android devices. Requires Vulkan 1.0 with the following extensions and *
* device features: * SDL driver name: "vulkan" (for use in SDL_CreateGPUDevice() and
* SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING)
*
* Supported on Windows, Linux, Nintendo Switch, and certain Android devices.
* Requires Vulkan 1.0 with the following extensions and device features:
* *
* - `VK_KHR_swapchain` * - `VK_KHR_swapchain`
* - `VK_KHR_maintenance1` * - `VK_KHR_maintenance1`
@@ -222,13 +228,37 @@
* - `depthClamp` * - `depthClamp`
* - `shaderClipDistance` * - `shaderClipDistance`
* - `drawIndirectFirstInstance` * - `drawIndirectFirstInstance`
* - `sampleRateShading`
* *
* **D3D12:** Supported on Windows 10 or newer, Xbox One (GDK), and Xbox * You can remove some of these requirements to increase compatibility with
* Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and * Android devices by using these properties when creating the GPU device with
* SDL_CreateGPUDeviceWithProperties():
*
* - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN
* - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN
* - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN
* - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN
*
* ### D3D12
*
* SDL driver name: "direct3d12"
*
* Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S
* (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and
* Resource Binding Tier 2 or above. * Resource Binding Tier 2 or above.
* *
* **Metal:** Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware * You can remove the Tier 2 resource binding requirement to support Intel
* requirements vary by operating system: * Haswell and Broadwell GPUs by using this property when creating the GPU
* device with SDL_CreateGPUDeviceWithProperties():
*
* - SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN
*
* ### Metal
*
* SDL driver name: "metal"
*
* Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by
* operating system:
* *
* - macOS requires an Apple Silicon or * - macOS requires an Apple Silicon or
* [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc) * [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc)
@@ -236,6 +266,26 @@
* - iOS/tvOS requires an A9 GPU or newer * - iOS/tvOS requires an A9 GPU or newer
* - iOS Simulator and tvOS Simulator are unsupported * - iOS Simulator and tvOS Simulator are unsupported
* *
* ## Coordinate System
*
* The GPU API uses a left-handed coordinate system, following the convention
* of D3D12 and Metal. Specifically:
*
* - **Normalized Device Coordinates:** The lower-left corner has an x,y
* coordinate of `(-1.0, -1.0)`. The upper-right corner is `(1.0, 1.0)`. Z
* values range from `[0.0, 1.0]` where 0 is the near plane.
* - **Viewport Coordinates:** The top-left corner has an x,y coordinate of
* `(0, 0)` and extends to the bottom-right corner at `(viewportWidth,
* viewportHeight)`. +Y is down.
* - **Texture Coordinates:** The top-left corner has an x,y coordinate of
* `(0, 0)` and extends to the bottom-right corner at `(1.0, 1.0)`. +Y is
* down.
*
* If the backend driver differs from this convention (e.g. Vulkan, which has
* an NDC that assumes +Y is down), SDL will automatically convert the
* coordinate system behind the scenes, so you don't need to perform any
* coordinate flipping logic in your shaders.
*
* ## Uniform Data * ## Uniform Data
* *
* Uniforms are for passing data to shaders. The uniform data will be constant * Uniforms are for passing data to shaders. The uniform data will be constant
@@ -301,6 +351,39 @@
* unreferenced data in a bound resource without cycling, but overwriting a * unreferenced data in a bound resource without cycling, but overwriting a
* section of data that has already been referenced will produce unexpected * section of data that has already been referenced will produce unexpected
* results. * results.
*
* ## Debugging
*
* At some point of your GPU journey, you will probably encounter issues that
* are not traceable with regular debugger - for example, your code compiles
* but you get an empty screen, or your shader fails in runtime.
*
* For debugging such cases, there are tools that allow visually inspecting
* the whole GPU frame, every drawcall, every bound resource, memory buffers,
* etc. They are the following, per platform:
*
* * For Windows/Linux, use
* [RenderDoc](https://renderdoc.org/)
* * For MacOS (Metal), use Xcode built-in debugger (Open XCode, go to Debug >
* Debug Executable..., select your application, set "GPU Frame Capture" to
* "Metal" in scheme "Options" window, run your app, and click the small
* Metal icon on the bottom to capture a frame)
*
* Aside from that, you may want to enable additional debug layers to receive
* more detailed error messages, based on your GPU backend:
*
* * For D3D12, the debug layer is an optional feature that can be installed
* via "Windows Settings -> System -> Optional features" and adding the
* "Graphics Tools" optional feature.
* * For Vulkan, you will need to install Vulkan SDK on Windows, and on Linux,
* you usually have some sort of `vulkan-validation-layers` system package
* that should be installed.
* * For Metal, it should be enough just to run the application from XCode to
* receive detailed errors or warnings in the output.
*
* Don't hesitate to use tools as RenderDoc when encountering runtime issues
* or unexpected output on screen, quick GPU frame inspection can usually help
* you fix the majority of such problems.
*/ */
#ifndef SDL_gpu_h_ #ifndef SDL_gpu_h_
@@ -1310,6 +1393,17 @@ typedef struct SDL_GPUViewport
* A structure specifying parameters related to transferring data to or from a * A structure specifying parameters related to transferring data to or from a
* texture. * texture.
* *
* If either of `pixels_per_row` or `rows_per_layer` is zero, then width and
* height of passed SDL_GPUTextureRegion to SDL_UploadToGPUTexture or
* SDL_DownloadFromGPUTexture are used as default values respectively and data
* is considered to be tightly packed.
*
* **WARNING**: Direct3D 12 requires texture data row pitch to be 256 byte
* aligned, and offsets to be aligned to 512 bytes. If they are not, SDL will
* make a temporary copy of the data that is properly aligned, but this adds
* overhead to the transfer process. Apps can avoid this by aligning their
* data appropriately, or using a different GPU backend than Direct3D 12.
*
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
* \sa SDL_UploadToGPUTexture * \sa SDL_UploadToGPUTexture
@@ -1391,7 +1485,7 @@ typedef struct SDL_GPUTextureRegion
*/ */
typedef struct SDL_GPUBlitRegion typedef struct SDL_GPUBlitRegion
{ {
SDL_GPUTexture *texture; /**< The texture. */ SDL_GPUTexture *texture; /**< The texture. */
Uint32 mip_level; /**< The mip level index of the region. */ Uint32 mip_level; /**< The mip level index of the region. */
Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */
Uint32 x; /**< The left offset of the region. */ Uint32 x; /**< The left offset of the region. */
@@ -1520,8 +1614,8 @@ typedef struct SDL_GPUSamplerCreateInfo
SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */
float min_lod; /**< Clamps the minimum of the computed LOD value. */ float min_lod; /**< Clamps the minimum of the computed LOD value. */
float max_lod; /**< Clamps the maximum of the computed LOD value. */ float max_lod; /**< Clamps the maximum of the computed LOD value. */
bool enable_anisotropy; /**< true to enable anisotropic filtering. */ bool enable_anisotropy; /**< true to enable anisotropic filtering. */
bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ bool enable_compare; /**< true to enable comparison against a reference value during lookups. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
@@ -1613,6 +1707,9 @@ typedef struct SDL_GPUStencilOpState
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
* \sa SDL_GPUColorTargetDescription * \sa SDL_GPUColorTargetDescription
* \sa SDL_GPUBlendFactor
* \sa SDL_GPUBlendOp
* \sa SDL_GPUColorComponentFlags
*/ */
typedef struct SDL_GPUColorTargetBlendState typedef struct SDL_GPUColorTargetBlendState
{ {
@@ -1623,8 +1720,8 @@ typedef struct SDL_GPUColorTargetBlendState
SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */
SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */
SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */
bool enable_blend; /**< Whether blending is enabled for the color target. */ bool enable_blend; /**< Whether blending is enabled for the color target. */
bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ bool enable_color_write_mask; /**< Whether the color write mask is enabled. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
} SDL_GPUColorTargetBlendState; } SDL_GPUColorTargetBlendState;
@@ -1636,6 +1733,8 @@ typedef struct SDL_GPUColorTargetBlendState
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
* \sa SDL_CreateGPUShader * \sa SDL_CreateGPUShader
* \sa SDL_GPUShaderFormat
* \sa SDL_GPUShaderStage
*/ */
typedef struct SDL_GPUShaderCreateInfo typedef struct SDL_GPUShaderCreateInfo
{ {
@@ -1741,8 +1840,8 @@ typedef struct SDL_GPURasterizerState
float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */
float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ float depth_bias_clamp; /**< The maximum depth bias of a fragment. */
float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */
bool enable_depth_bias; /**< true to bias fragment depth values. */ bool enable_depth_bias; /**< true to bias fragment depth values. */
bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
} SDL_GPURasterizerState; } SDL_GPURasterizerState;
@@ -1759,8 +1858,8 @@ typedef struct SDL_GPUMultisampleState
{ {
SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */
Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */ Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */
bool enable_mask; /**< Reserved for future use. Must be set to false. */ bool enable_mask; /**< Reserved for future use. Must be set to false. */
Uint8 padding1; bool enable_alpha_to_coverage; /**< true enables the alpha-to-coverage feature. */
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
} SDL_GPUMultisampleState; } SDL_GPUMultisampleState;
@@ -1780,9 +1879,9 @@ typedef struct SDL_GPUDepthStencilState
SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */
Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */
Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */
bool enable_depth_test; /**< true enables the depth test. */ bool enable_depth_test; /**< true enables the depth test. */
bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */
bool enable_stencil_test; /**< true enables the stencil test. */ bool enable_stencil_test; /**< true enables the stencil test. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -1817,7 +1916,7 @@ typedef struct SDL_GPUGraphicsPipelineTargetInfo
const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */
Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */
SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */
bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -1912,6 +2011,7 @@ typedef struct SDL_GPUComputePipelineCreateInfo
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
* \sa SDL_BeginGPURenderPass * \sa SDL_BeginGPURenderPass
* \sa SDL_FColor
*/ */
typedef struct SDL_GPUColorTargetInfo typedef struct SDL_GPUColorTargetInfo
{ {
@@ -1924,8 +2024,8 @@ typedef struct SDL_GPUColorTargetInfo
SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */ SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */
Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */
Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */
bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */
bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
} SDL_GPUColorTargetInfo; } SDL_GPUColorTargetInfo;
@@ -1970,6 +2070,9 @@ typedef struct SDL_GPUColorTargetInfo
* *
* Note that depth/stencil targets do not support multisample resolves. * Note that depth/stencil targets do not support multisample resolves.
* *
* Due to ABI limitations, depth textures with more than 255 layers are not
* supported.
*
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
* \sa SDL_BeginGPURenderPass * \sa SDL_BeginGPURenderPass
@@ -1982,10 +2085,10 @@ typedef struct SDL_GPUDepthStencilTargetInfo
SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */
SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */
SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */
bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */
Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
Uint8 padding1; Uint8 mip_level; /**< The mip level to use as the depth stencil target. */
Uint8 padding2; Uint8 layer; /**< The layer index to use as the depth stencil target. */
} SDL_GPUDepthStencilTargetInfo; } SDL_GPUDepthStencilTargetInfo;
/** /**
@@ -2002,7 +2105,7 @@ typedef struct SDL_GPUBlitInfo {
SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */
SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ SDL_FlipMode flip_mode; /**< The flip mode for the source region. */
SDL_GPUFilter filter; /**< The filter mode used when blitting. */ SDL_GPUFilter filter; /**< The filter mode used when blitting. */
bool cycle; /**< true cycles the destination texture if it is already bound. */ bool cycle; /**< true cycles the destination texture if it is already bound. */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -2031,6 +2134,8 @@ typedef struct SDL_GPUBufferBinding
* *
* \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUVertexSamplers
* \sa SDL_BindGPUFragmentSamplers * \sa SDL_BindGPUFragmentSamplers
* \sa SDL_GPUTexture
* \sa SDL_GPUSampler
*/ */
typedef struct SDL_GPUTextureSamplerBinding typedef struct SDL_GPUTextureSamplerBinding
{ {
@@ -2111,6 +2216,13 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties(
/** /**
* Creates a GPU context. * Creates a GPU context.
* *
* The GPU driver name can be one of the following:
*
* - "vulkan": [Vulkan](CategoryGPU#vulkan)
* - "direct3d12": [D3D12](CategoryGPU#d3d12)
* - "metal": [Metal](CategoryGPU#metal)
* - NULL: let SDL pick the optimal driver
*
* \param format_flags a bitflag indicating which shader formats the app is * \param format_flags a bitflag indicating which shader formats the app is
* able to provide. * able to provide.
* \param debug_mode enable debug mode properties and validations. * \param debug_mode enable debug mode properties and validations.
@@ -2121,6 +2233,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties(
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_CreateGPUDeviceWithProperties
* \sa SDL_GetGPUShaderFormats * \sa SDL_GetGPUShaderFormats
* \sa SDL_GetGPUDeviceDriver * \sa SDL_GetGPUDeviceDriver
* \sa SDL_DestroyGPUDevice * \sa SDL_DestroyGPUDevice
@@ -2140,8 +2253,31 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
* properties and validations, defaults to true. * properties and validations, defaults to true.
* - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer
* energy efficiency over maximum GPU performance, defaults to false. * energy efficiency over maximum GPU performance, defaults to false.
* - `SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN`: enable to automatically log
* useful debug information on device creation, defaults to true.
* - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
* use, if a specific one is desired. * use, if a specific one is desired.
* - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN`: Enable Vulkan
* device feature shaderClipDistance. If disabled, clip distances are not
* supported in shader code: gl_ClipDistance[] built-ins of GLSL,
* SV_ClipDistance0/1 semantics of HLSL and [[clip_distance]] attribute of
* Metal. Disabling optional features allows the application to run on some
* older Android devices. Defaults to true.
* - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN`: Enable
* Vulkan device feature depthClamp. If disabled, there is no depth clamp
* support and enable_depth_clip in SDL_GPURasterizerState must always be
* set to true. Disabling optional features allows the application to run on
* some older Android devices. Defaults to true.
* - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN`:
* Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the
* argument first_instance of SDL_GPUIndirectDrawCommand must be set to
* zero. Disabling optional features allows the application to run on some
* older Android devices. Defaults to true.
* - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN`: Enable Vulkan
* device feature samplerAnisotropy. If disabled, enable_anisotropy of
* SDL_GPUSamplerCreateInfo must be set to false. Disabling optional
* features allows the application to run on some older Android devices.
* Defaults to true.
* *
* These are the current shader format properties: * These are the current shader format properties:
* *
@@ -2158,10 +2294,32 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
* - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to
* provide Metal shader libraries if applicable. * provide Metal shader libraries if applicable.
* *
* With the D3D12 renderer: * With the D3D12 backend:
* *
* - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
* use for all vertex semantics, default is "TEXCOORD". * use for all vertex semantics, default is "TEXCOORD".
* - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By
* default, Resourcing Binding Tier 2 is required for D3D12 support.
* However, an application can set this property to true to enable Tier 1
* support, if (and only if) the application uses 8 or fewer storage
* resources across all shader stages. As of writing, this property is
* useful for targeting Intel Haswell and Broadwell GPUs; other hardware
* either supports Tier 2 Resource Binding or does not support D3D12 in any
* capacity. Defaults to false.
*
* With the Vulkan backend:
*
* - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN`:
* By default, Vulkan device enumeration includes drivers of all types,
* including software renderers (for example, the Lavapipe Mesa driver).
* This can be useful if your application _requires_ SDL_GPU, but if you can
* provide your own fallback renderer (for example, an OpenGL renderer) this
* property can be set to true. Defaults to false.
* - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: a pointer to an
* SDL_GPUVulkanOptions structure to be processed during device creation.
* This allows configuring a variety of Vulkan-specific options such as
* increasing the API version and opting into extensions aside from the
* minimal set SDL requires.
* *
* \param props the properties to use. * \param props the properties to use.
* \returns a GPU context on success or NULL on failure; call SDL_GetError() * \returns a GPU context on success or NULL on failure; call SDL_GetError()
@@ -2177,16 +2335,52 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties( extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties(
SDL_PropertiesID props); SDL_PropertiesID props);
#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode" #define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode"
#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower" #define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower"
#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name" #define SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN "SDL.gpu.device.create.verbose"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private" #define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN "SDL.gpu.device.create.feature.clip_distance"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN "SDL.gpu.device.create.feature.depth_clamping"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN "SDL.gpu.device.create.feature.indirect_draw_first_instance"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN "SDL.gpu.device.create.feature.anisotropy"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration"
#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options"
/**
* A structure specifying additional options when using Vulkan.
*
* When no such structure is provided, SDL will use Vulkan API version 1.0 and
* a minimal set of features. The requested API version influences how the
* feature_list is processed by SDL. When requesting API version 1.0, the
* feature_list is ignored. Only the vulkan_10_phyisical_device_features and
* the extension lists are used. When requesting API version 1.1, the
* feature_list is scanned for feature structures introduced in Vulkan 1.1.
* When requesting Vulkan 1.2 or higher, the feature_list is additionally
* scanned for compound feature structs such as
* VkPhysicalDeviceVulkan11Features. The device and instance extension lists,
* as well as vulkan_10_physical_device_features, are always processed.
*
* \since This struct is available since SDL 3.4.0.
*/
typedef struct SDL_GPUVulkanOptions
{
Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */
void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/
void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */
Uint32 device_extension_count; /**< Number of additional device extensions to require. */
const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */
Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */
const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */
} SDL_GPUVulkanOptions;
/** /**
* Destroys a GPU context previously returned by SDL_CreateGPUDevice. * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
@@ -2250,6 +2444,116 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *d
*/ */
extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device); extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device);
/**
* Get the properties associated with a GPU device.
*
* All properties are optional and may differ between GPU backends and SDL
* versions.
*
* The following properties are provided by SDL:
*
* `SDL_PROP_GPU_DEVICE_NAME_STRING`: Contains the name of the underlying
* device as reported by the system driver. This string has no standardized
* format, is highly inconsistent between hardware devices and drivers, and is
* able to change at any time. Do not attempt to parse this string as it is
* bound to fail at some point in the future when system drivers are updated,
* new hardware devices are introduced, or when SDL adds new GPU backends or
* modifies existing ones.
*
* Strings that have been found in the wild include:
*
* - GTX 970
* - GeForce GTX 970
* - NVIDIA GeForce GTX 970
* - Microsoft Direct3D12 (NVIDIA GeForce GTX 970)
* - NVIDIA Graphics Device
* - GeForce GPU
* - P106-100
* - AMD 15D8:C9
* - AMD Custom GPU 0405
* - AMD Radeon (TM) Graphics
* - ASUS Radeon RX 470 Series
* - Intel(R) Arc(tm) A380 Graphics (DG2)
* - Virtio-GPU Venus (NVIDIA TITAN V)
* - SwiftShader Device (LLVM 16.0.0)
* - llvmpipe (LLVM 15.0.4, 256 bits)
* - Microsoft Basic Render Driver
* - unknown device
*
* The above list shows that the same device can have different formats, the
* vendor name may or may not appear in the string, the included vendor name
* may not be the vendor of the chipset on the device, some manufacturers
* include pseudo-legal marks while others don't, some devices may not use a
* marketing name in the string, the device string may be wrapped by the name
* of a translation interface, the device may be emulated in software, or the
* string may contain generic text that does not identify the device at all.
*
* `SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING`: Contains the self-reported name
* of the underlying system driver.
*
* Strings that have been found in the wild include:
*
* - Intel Corporation
* - Intel open-source Mesa driver
* - Qualcomm Technologies Inc. Adreno Vulkan Driver
* - MoltenVK
* - Mali-G715
* - venus
*
* `SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING`: Contains the self-reported
* version of the underlying system driver. This is a relatively short version
* string in an unspecified format. If SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING
* is available then that property should be preferred over this one as it may
* contain additional information that is useful for identifying the exact
* driver version used.
*
* Strings that have been found in the wild include:
*
* - 53.0.0
* - 0.405.2463
* - 32.0.15.6614
*
* `SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING`: Contains the detailed version
* information of the underlying system driver as reported by the driver. This
* is an arbitrary string with no standardized format and it may contain
* newlines. This property should be preferred over
* SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING if it is available as it usually
* contains the same information but in a format that is easier to read.
*
* Strings that have been found in the wild include:
*
* - 101.6559
* - 1.2.11
* - Mesa 21.2.2 (LLVM 12.0.1)
* - Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa)
* - v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129
*
* This string has also been observed to be a multiline string (which has a
* trailing newline):
*
* ```
* Driver Build: 85da404, I46ff5fc46f, 1606794520
* Date: 11/30/20
* Compiler Version: EV031.31.04.01
* Driver Branch: promo490_3_Google
* ```
*
* \param device a GPU context to query.
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device);
#define SDL_PROP_GPU_DEVICE_NAME_STRING "SDL.gpu.device.name"
#define SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING "SDL.gpu.device.driver_name"
#define SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING "SDL.gpu.device.driver_version"
#define SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING "SDL.gpu.device.driver_info"
/* State Creation */ /* State Creation */
/** /**
@@ -2440,7 +2744,8 @@ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader(
* Creates a texture object to be used in graphics or compute workflows. * Creates a texture object to be used in graphics or compute workflows.
* *
* The contents of this texture are undefined until data is written to the * The contents of this texture are undefined until data is written to the
* texture. * texture, either via SDL_UploadToGPUTexture or by performing a render or
* compute pass with this texture as a target.
* *
* Note that certain combinations of usage flags are invalid. For example, a * Note that certain combinations of usage flags are invalid. For example, a
* texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags. * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
@@ -2482,6 +2787,8 @@ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader(
* *
* \sa SDL_UploadToGPUTexture * \sa SDL_UploadToGPUTexture
* \sa SDL_DownloadFromGPUTexture * \sa SDL_DownloadFromGPUTexture
* \sa SDL_BeginGPURenderPass
* \sa SDL_BeginGPUComputePass
* \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUVertexSamplers
* \sa SDL_BindGPUVertexStorageTextures * \sa SDL_BindGPUVertexStorageTextures
* \sa SDL_BindGPUFragmentSamplers * \sa SDL_BindGPUFragmentSamplers
@@ -2638,6 +2945,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
* *
* Useful for debugging. * Useful for debugging.
* *
* On Direct3D 12, using SDL_InsertGPUDebugLabel requires
* WinPixEventRuntime.dll to be in your PATH or in the same directory as your
* executable. See
* [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
* for instructions on how to obtain it.
*
* \param command_buffer a command buffer. * \param command_buffer a command buffer.
* \param text a UTF-8 string constant to insert as the label. * \param text a UTF-8 string constant to insert as the label.
* *
@@ -2656,6 +2969,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
* Each call to SDL_PushGPUDebugGroup must have a corresponding call to * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
* SDL_PopGPUDebugGroup. * SDL_PopGPUDebugGroup.
* *
* On Direct3D 12, using SDL_PushGPUDebugGroup requires WinPixEventRuntime.dll
* to be in your PATH or in the same directory as your executable. See
* [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
* for instructions on how to obtain it.
*
* On some backends (e.g. Metal), pushing a debug group during a * On some backends (e.g. Metal), pushing a debug group during a
* render/blit/compute pass will create a group that is scoped to the native * render/blit/compute pass will create a group that is scoped to the native
* pass rather than the command buffer. For best results, if you push a debug * pass rather than the command buffer. For best results, if you push a debug
@@ -2675,6 +2993,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
/** /**
* Ends the most-recently pushed debug group. * Ends the most-recently pushed debug group.
* *
* On Direct3D 12, using SDL_PopGPUDebugGroup requires WinPixEventRuntime.dll
* to be in your PATH or in the same directory as your executable. See
* [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
* for instructions on how to obtain it.
*
* \param command_buffer a command buffer. * \param command_buffer a command buffer.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
@@ -2822,6 +3145,9 @@ extern SDL_DECLSPEC SDL_GPUCommandBuffer * SDLCALL SDL_AcquireGPUCommandBuffer(
* terms this means you must ensure that vec3 and vec4 fields are 16-byte * terms this means you must ensure that vec3 and vec4 fields are 16-byte
* aligned. * aligned.
* *
* For detailed information about accessing uniform data from a shader, please
* refer to SDL_CreateGPUShader.
*
* \param command_buffer a command buffer. * \param command_buffer a command buffer.
* \param slot_index the vertex uniform slot to push data to. * \param slot_index the vertex uniform slot to push data to.
* \param data client data to write. * \param data client data to write.
@@ -2892,6 +3218,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
* is called. You cannot begin another render pass, or begin a compute pass or * is called. You cannot begin another render pass, or begin a compute pass or
* copy pass until you have ended the render pass. * copy pass until you have ended the render pass.
* *
* Using SDL_GPU_LOADOP_LOAD before any contents have been written to the
* texture subresource will result in undefined behavior. SDL_GPU_LOADOP_CLEAR
* will set the contents of the texture subresource to a single value before
* any rendering is performed. It's fine to do an empty render pass using
* SDL_GPU_STOREOP_STORE to clear a texture, but in general it's better to
* think of clearing not as an independent operation but as something that's
* done as the beginning of a render pass.
*
* \param command_buffer a command buffer. * \param command_buffer a command buffer.
* \param color_target_infos an array of texture subresources with * \param color_target_infos an array of texture subresources with
* corresponding clear values and load/store ops. * corresponding clear values and load/store ops.
@@ -3514,6 +3848,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
* \returns a copy pass handle. * \returns a copy pass handle.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_EndGPUCopyPass
*/ */
extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass( extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass(
SDL_GPUCommandBuffer *command_buffer); SDL_GPUCommandBuffer *command_buffer);
@@ -3775,7 +4111,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
* supported via SDL_WindowSupportsGPUPresentMode / * supported via SDL_WindowSupportsGPUPresentMode /
* SDL_WindowSupportsGPUSwapchainComposition prior to calling this function. * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
* *
* SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always
* supported. * supported.
* *
* \param device a GPU context. * \param device a GPU context.
@@ -3849,7 +4185,9 @@ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureForma
* buffer used to acquire it. * buffer used to acquire it.
* *
* This function will fill the swapchain texture handle with NULL if too many * This function will fill the swapchain texture handle with NULL if too many
* frames are in flight. This is not an error. * frames are in flight. This is not an error. This NULL pointer should not be
* passed back into SDL. Instead, it should be considered as an indication to
* wait until the swapchain is available.
* *
* If you use this function, it is possible to create a situation where many * If you use this function, it is possible to create a situation where many
* command buffers are allocated while the rendering context waits for the GPU * command buffers are allocated while the rendering context waits for the GPU
@@ -4171,6 +4509,29 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize(
Uint32 height, Uint32 height,
Uint32 depth_or_layer_count); Uint32 depth_or_layer_count);
/**
* Get the SDL pixel format corresponding to a GPU texture format.
*
* \param format a texture format.
* \returns the corresponding pixel format, or SDL_PIXELFORMAT_UNKNOWN if
* there is no corresponding pixel format.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatFromGPUTextureFormat(SDL_GPUTextureFormat format);
/**
* Get the GPU texture format corresponding to an SDL pixel format.
*
* \param format a pixel format.
* \returns the corresponding GPU texture format, or
* SDL_GPU_TEXTUREFORMAT_INVALID if there is no corresponding GPU
* texture format.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUTextureFormatFromPixelFormat(SDL_PixelFormat format);
#ifdef SDL_PLATFORM_GDK #ifdef SDL_PLATFORM_GDK
/** /**

View File

@@ -70,7 +70,7 @@
* { * {
* SDL_Haptic *haptic; * SDL_Haptic *haptic;
* SDL_HapticEffect effect; * SDL_HapticEffect effect;
* int effect_id; * SDL_HapticEffectID effect_id;
* *
* // Open the device * // Open the device
* haptic = SDL_OpenHapticFromJoystick(joystick); * haptic = SDL_OpenHapticFromJoystick(joystick);
@@ -149,6 +149,19 @@ extern "C" {
*/ */
typedef struct SDL_Haptic SDL_Haptic; typedef struct SDL_Haptic SDL_Haptic;
/*
* Misc defines.
*/
/**
* Used to play a device an infinite number of times.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_RunHapticEffect
*/
#define SDL_HAPTIC_INFINITY 4294967295U
/** /**
* \name Haptic features * \name Haptic features
@@ -162,6 +175,11 @@ typedef struct SDL_Haptic SDL_Haptic;
*/ */
/* @{ */ /* @{ */
/**
* Type of haptic effect.
*/
typedef Uint16 SDL_HapticEffectType;
/** /**
* Constant effect supported. * Constant effect supported.
* *
@@ -383,6 +401,11 @@ typedef struct SDL_Haptic SDL_Haptic;
*/ */
/* @{ */ /* @{ */
/**
* Type of coordinates used for haptic direction.
*/
typedef Uint8 SDL_HapticDirectionType;
/** /**
* Uses polar coordinates for the direction. * Uses polar coordinates for the direction.
* *
@@ -426,18 +449,15 @@ typedef struct SDL_Haptic SDL_Haptic;
/* @} *//* Haptic features */ /* @} *//* Haptic features */
/*
* Misc defines.
*/
/** /**
* Used to play a device an infinite number of times. * ID for haptic effects.
* *
* \since This macro is available since SDL 3.2.0. * This is -1 if the ID is invalid.
* *
* \sa SDL_RunHapticEffect * \sa SDL_CreateHapticEffect
*/ */
#define SDL_HAPTIC_INFINITY 4294967295U typedef int SDL_HapticEffectID;
/** /**
@@ -545,8 +565,8 @@ typedef struct SDL_Haptic SDL_Haptic;
*/ */
typedef struct SDL_HapticDirection typedef struct SDL_HapticDirection
{ {
Uint8 type; /**< The type of encoding. */ SDL_HapticDirectionType type; /**< The type of encoding. */
Sint32 dir[3]; /**< The encoded direction. */ Sint32 dir[3]; /**< The encoded direction. */
} SDL_HapticDirection; } SDL_HapticDirection;
@@ -566,7 +586,7 @@ typedef struct SDL_HapticDirection
typedef struct SDL_HapticConstant typedef struct SDL_HapticConstant
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_CONSTANT */ SDL_HapticEffectType type; /**< SDL_HAPTIC_CONSTANT */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
/* Replay */ /* Replay */
@@ -652,9 +672,9 @@ typedef struct SDL_HapticConstant
typedef struct SDL_HapticPeriodic typedef struct SDL_HapticPeriodic
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE SDL_HapticEffectType type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE
SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
SDL_HAPTIC_SAWTOOTHDOWN */ SDL_HAPTIC_SAWTOOTHDOWN */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
/* Replay */ /* Replay */
@@ -708,8 +728,8 @@ typedef struct SDL_HapticPeriodic
typedef struct SDL_HapticCondition typedef struct SDL_HapticCondition
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, SDL_HapticEffectType type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
/* Replay */ /* Replay */
@@ -747,7 +767,7 @@ typedef struct SDL_HapticCondition
typedef struct SDL_HapticRamp typedef struct SDL_HapticRamp
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_RAMP */ SDL_HapticEffectType type; /**< SDL_HAPTIC_RAMP */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
/* Replay */ /* Replay */
@@ -786,7 +806,7 @@ typedef struct SDL_HapticRamp
typedef struct SDL_HapticLeftRight typedef struct SDL_HapticLeftRight
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_LEFTRIGHT */ SDL_HapticEffectType type; /**< SDL_HAPTIC_LEFTRIGHT */
/* Replay */ /* Replay */
Uint32 length; /**< Duration of the effect in milliseconds. */ Uint32 length; /**< Duration of the effect in milliseconds. */
@@ -816,7 +836,7 @@ typedef struct SDL_HapticLeftRight
typedef struct SDL_HapticCustom typedef struct SDL_HapticCustom
{ {
/* Header */ /* Header */
Uint16 type; /**< SDL_HAPTIC_CUSTOM */ SDL_HapticEffectType type; /**< SDL_HAPTIC_CUSTOM */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
/* Replay */ /* Replay */
@@ -915,7 +935,7 @@ typedef struct SDL_HapticCustom
typedef union SDL_HapticEffect typedef union SDL_HapticEffect
{ {
/* Common for all force feedback effects */ /* Common for all force feedback effects */
Uint16 type; /**< Effect type. */ SDL_HapticEffectType type; /**< Effect type. */
SDL_HapticConstant constant; /**< Constant effect. */ SDL_HapticConstant constant; /**< Constant effect. */
SDL_HapticPeriodic periodic; /**< Periodic effect. */ SDL_HapticPeriodic periodic; /**< Periodic effect. */
SDL_HapticCondition condition; /**< Condition effect. */ SDL_HapticCondition condition; /**< Condition effect. */
@@ -1193,7 +1213,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, c
* \sa SDL_RunHapticEffect * \sa SDL_RunHapticEffect
* \sa SDL_UpdateHapticEffect * \sa SDL_UpdateHapticEffect
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect); extern SDL_DECLSPEC SDL_HapticEffectID SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect);
/** /**
* Update the properties of an effect. * Update the properties of an effect.
@@ -1215,7 +1235,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const
* \sa SDL_CreateHapticEffect * \sa SDL_CreateHapticEffect
* \sa SDL_RunHapticEffect * \sa SDL_RunHapticEffect
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffect *data); extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, const SDL_HapticEffect *data);
/** /**
* Run the haptic effect on its associated haptic device. * Run the haptic effect on its associated haptic device.
@@ -1239,7 +1259,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int
* \sa SDL_StopHapticEffect * \sa SDL_StopHapticEffect
* \sa SDL_StopHapticEffects * \sa SDL_StopHapticEffects
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations); extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, Uint32 iterations);
/** /**
* Stop the haptic effect on its associated haptic device. * Stop the haptic effect on its associated haptic device.
@@ -1254,7 +1274,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int eff
* \sa SDL_RunHapticEffect * \sa SDL_RunHapticEffect
* \sa SDL_StopHapticEffects * \sa SDL_StopHapticEffects
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int effect); extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect);
/** /**
* Destroy a haptic effect on the device. * Destroy a haptic effect on the device.
@@ -1269,7 +1289,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int ef
* *
* \sa SDL_CreateHapticEffect * \sa SDL_CreateHapticEffect
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int effect); extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect);
/** /**
* Get the status of the current effect on the specified haptic device. * Get the status of the current effect on the specified haptic device.
@@ -1285,7 +1305,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int
* *
* \sa SDL_GetHapticFeatures * \sa SDL_GetHapticFeatures
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect); extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, SDL_HapticEffectID effect);
/** /**
* Set the global gain of the specified haptic device. * Set the global gain of the specified haptic device.

View File

@@ -55,6 +55,7 @@
#include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h> #include <SDL3/SDL_error.h>
#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_begin_code.h> #include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@@ -283,6 +284,24 @@ extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_
*/ */
extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path); extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path);
/**
* Get the properties associated with an SDL_hid_device.
*
* The following read-only properties are provided by SDL:
*
* - `SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER`: the libusb_device_handle
* associated with the device, if it was opened using libusb.
*
* \param dev a device handle returned from SDL_hid_open().
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_hid_get_properties(SDL_hid_device *dev);
#define SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER "SDL.hidapi.libusb.device.handle"
/** /**
* Write an Output report to a HID device. * Write an Output report to a HID device.
* *

View File

@@ -391,12 +391,46 @@ extern "C" {
* concept, so it applies to a physical audio device in this case, and not an * concept, so it applies to a physical audio device in this case, and not an
* SDL_AudioStream, nor an SDL logical audio device. * SDL_AudioStream, nor an SDL logical audio device.
* *
* For Windows WASAPI audio, the following roles are supported, and map to
* `AUDIO_STREAM_CATEGORY`:
*
* - "Other" (default)
* - "Communications" - Real-time communications, such as VOIP or chat
* - "Game" - Game audio
* - "GameChat" - Game chat audio, similar to "Communications" except that
* this will not attenuate other audio streams
* - "Movie" - Music or sound with dialog
* - "Media" - Music or sound without dialog
*
* If your application applies its own echo cancellation, gain control, and
* noise reduction it should also set SDL_HINT_AUDIO_DEVICE_RAW_STREAM.
*
* This hint should be set before an audio device is opened. * This hint should be set before an audio device is opened.
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
*/ */
#define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" #define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE"
/**
* Specify whether this audio device should do audio processing.
*
* Some operating systems perform echo cancellation, gain control, and noise
* reduction as needed. If your application already handles these, you can set
* this hint to prevent the OS from doing additional audio processing.
*
* This corresponds to the WASAPI audio option `AUDCLNT_STREAMOPTIONS_RAW`.
*
* The variable can be set to the following values:
*
* - "0": audio processing can be done by the OS. (default)
* - "1": audio processing is done by the application.
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_AUDIO_DEVICE_RAW_STREAM "SDL_AUDIO_DEVICE_RAW_STREAM"
/** /**
* Specify the input file when recording audio using the disk audio driver. * Specify the input file when recording audio using the disk audio driver.
* *
@@ -685,6 +719,21 @@ extern "C" {
*/ */
#define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" #define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS"
/**
* Set the level of checking for invalid parameters passed to SDL functions.
*
* The variable can be set to the following values:
*
* - "1": Enable fast parameter error checking, e.g. quick NULL checks, etc.
* - "2": Enable full parameter error checking, e.g. validating objects are
* the correct type, etc. (default)
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_INVALID_PARAM_CHECKS "SDL_INVALID_PARAM_CHECKS"
/** /**
* Disable giving back control to the browser automatically when running with * Disable giving back control to the browser automatically when running with
* asyncify. * asyncify.
@@ -711,8 +760,6 @@ extern "C" {
* *
* This hint only applies to the emscripten platform. * This hint only applies to the emscripten platform.
* *
* The default value is "#canvas"
*
* This hint should be set before creating a window. * This hint should be set before creating a window.
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
@@ -726,7 +773,7 @@ extern "C" {
* *
* The variable can be one of: * The variable can be one of:
* *
* - "#window": the javascript window object (default) * - "#window": the javascript window object
* - "#document": the javascript document object * - "#document": the javascript document object
* - "#screen": the javascript window.screen object * - "#screen": the javascript window.screen object
* - "#canvas": the WebGL canvas element * - "#canvas": the WebGL canvas element
@@ -740,6 +787,32 @@ extern "C" {
*/ */
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
/**
* Dictate that windows on Emscripten will fill the whole browser window.
*
* When enabled, the canvas element fills the entire document. Resize events
* will be generated as the browser window is resized, as that will adjust the
* canvas size as well. The canvas will cover anything else on the page,
* including any controls provided by Emscripten in its generated HTML file
* (in fact, any elements on the page that aren't the canvas will be moved
* into a hidden `div` element).
*
* Often times this is desirable for a browser-based game, but it means
* several things that we expect of an SDL window on other platforms might not
* work as expected, such as minimum window sizes and aspect ratios.
*
* This hint overrides SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_FILL_DOCUMENT_BOOLEAN
* properties when creating an SDL window.
*
* This hint only applies to the Emscripten platform.
*
* This hint can be set at any time (before creating the window, or to toggle
* its state later). Only one window can fill the document at a time.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_EMSCRIPTEN_FILL_DOCUMENT "SDL_EMSCRIPTEN_FILL_DOCUMENT"
/** /**
* A variable that controls whether the on-screen keyboard should be shown * A variable that controls whether the on-screen keyboard should be shown
* when text input is active. * when text input is active.
@@ -1143,8 +1216,8 @@ extern "C" {
#define SDL_HINT_IME_IMPLEMENTED_UI "SDL_IME_IMPLEMENTED_UI" #define SDL_HINT_IME_IMPLEMENTED_UI "SDL_IME_IMPLEMENTED_UI"
/** /**
* A variable controlling whether the home indicator bar on iPhone X should be * A variable controlling whether the home indicator bar on iPhone X and later
* hidden. * should be hidden.
* *
* The variable can be set to the following values: * The variable can be set to the following values:
* *
@@ -1723,6 +1796,69 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI" #define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI"
/**
* A variable controlling whether the HIDAPI driver for some Logitech wheels
* should be used.
*
* This variable can be set to the following values:
*
* - "0": HIDAPI driver is not used
* - "1": HIDAPI driver is used
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_LG4FF "SDL_JOYSTICK_HIDAPI_LG4FF"
/**
* A variable controlling whether the HIDAPI driver for 8BitDo controllers
* should be used.
*
* This variable can be set to the following values:
*
* "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_8BITDO "SDL_JOYSTICK_HIDAPI_8BITDO"
/**
* A variable controlling whether the HIDAPI driver for SInput controllers
* should be used.
*
* More info - https://github.com/HandHeldLegend/SInput-HID
*
* This variable can be set to the following values:
*
* "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_SINPUT "SDL_JOYSTICK_HIDAPI_SINPUT"
/**
* A variable controlling whether the HIDAPI driver for ZUIKI controllers
* should be used.
*
* This variable can be set to the following values:
*
* "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_ZUIKI "SDL_JOYSTICK_HIDAPI_ZUIKI"
/**
* A variable controlling whether the HIDAPI driver for Flydigi controllers
* should be used.
*
* This variable can be set to the following values:
*
* "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/
#define SDL_HINT_JOYSTICK_HIDAPI_FLYDIGI "SDL_JOYSTICK_HIDAPI_FLYDIGI"
/** /**
* A variable controlling whether the HIDAPI driver for Nintendo Switch * A variable controlling whether the HIDAPI driver for Nintendo Switch
* controllers should be used. * controllers should be used.
@@ -1774,6 +1910,23 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED" #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED"
/**
* A variable controlling whether the HIDAPI driver for Nintendo Switch 2
* controllers should be used.
*
* The variable can be set to the following values:
*
* - "0": HIDAPI driver is not used.
* - "1": HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI.
*
* This hint should be set before initializing joysticks and gamepads.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH2 "SDL_JOYSTICK_HIDAPI_SWITCH2"
/** /**
* A variable controlling whether Nintendo Switch Joy-Con controllers will be * A variable controlling whether Nintendo Switch Joy-Con controllers will be
* in vertical mode when using the HIDAPI driver. * in vertical mode when using the HIDAPI driver.
@@ -1926,6 +2079,41 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED"
/**
* A variable controlling whether the new HIDAPI driver for wired Xbox One
* (GIP) controllers should be used.
*
* The variable can be set to the following values:
*
* - "0": HIDAPI driver is not used.
* - "1": HIDAPI driver is used.
*
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE.
*
* This hint should be set before initializing joysticks and gamepads.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_GIP "SDL_JOYSTICK_HIDAPI_GIP"
/**
* A variable controlling whether the new HIDAPI driver for wired Xbox One
* (GIP) controllers should reset the controller if it can't get the metadata
* from the controller.
*
* The variable can be set to the following values:
*
* - "0": Assume this is a generic controller.
* - "1": Reset the controller to get metadata.
*
* By default the controller is not reset.
*
* This hint should be set before initializing joysticks and gamepads.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA"
/** /**
* A variable controlling whether IOKit should be used for controller * A variable controlling whether IOKit should be used for controller
* handling. * handling.
@@ -2228,9 +2416,9 @@ extern "C" {
* pressing the 1 key would yield the keycode SDLK_1, or '1', instead of * pressing the 1 key would yield the keycode SDLK_1, or '1', instead of
* SDLK_AMPERSAND, or '&' * SDLK_AMPERSAND, or '&'
* - "latin_letters": For keyboards using non-Latin letters, such as Russian * - "latin_letters": For keyboards using non-Latin letters, such as Russian
* or Thai, the letter keys generate keycodes as though it had an en_US * or Thai, the letter keys generate keycodes as though it had an English
* layout. e.g. pressing the key associated with SDL_SCANCODE_A on a Russian * QWERTY layout. e.g. pressing the key associated with SDL_SCANCODE_A on a
* keyboard would yield 'a' instead of a Cyrillic letter. * Russian keyboard would yield 'a' instead of a Cyrillic letter.
* *
* The default value for this hint is "french_numbers,latin_letters" * The default value for this hint is "french_numbers,latin_letters"
* *
@@ -2289,6 +2477,27 @@ extern "C" {
*/ */
#define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER" #define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER"
/**
* A variable that controls whether KMSDRM will use "atomic" functionality.
*
* The KMSDRM backend can use atomic commits, if both DRM_CLIENT_CAP_ATOMIC
* and DRM_CLIENT_CAP_UNIVERSAL_PLANES is supported by the system. As of SDL
* 3.4.0, it will favor this functionality, but in case this doesn't work well
* on a given system or other surprises, this hint can be used to disable it.
*
* This hint can not enable the functionality if it isn't available.
*
* The variable can be set to the following values:
*
* - "0": SDL will not use the KMSDRM "atomic" functionality.
* - "1": SDL will allow usage of the KMSDRM "atomic" functionality. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_KMSDRM_ATOMIC "SDL_KMSDRM_ATOMIC"
/** /**
* A variable controlling the default SDL log levels. * A variable controlling the default SDL log levels.
* *
@@ -2309,6 +2518,11 @@ extern "C" {
* *
* `app=info,assert=warn,test=verbose,*=error` * `app=info,assert=warn,test=verbose,*=error`
* *
* If the `DEBUG_INVOCATION` environment variable is set to "1", the default
* log levels are equivalent to:
*
* `assert=warn,test=verbose,*=debug`
*
* This hint can be set anytime. * This hint can be set anytime.
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
@@ -2410,6 +2624,21 @@ extern "C" {
*/ */
#define SDL_HINT_MAC_SCROLL_MOMENTUM "SDL_MAC_SCROLL_MOMENTUM" #define SDL_HINT_MAC_SCROLL_MOMENTUM "SDL_MAC_SCROLL_MOMENTUM"
/**
* A variable controlling whether holding down a key will repeat the pressed
* key or open the accents menu on macOS.
*
* The variable can be set to the following values:
*
* - "0": Holding a key will open the accents menu for that key.
* - "1": Holding a key will repeat the pressed key. (default)
*
* This hint needs to be set before SDL_Init().
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_MAC_PRESS_AND_HOLD "SDL_MAC_PRESS_AND_HOLD"
/** /**
* Request SDL_AppIterate() be called at a specific rate. * Request SDL_AppIterate() be called at a specific rate.
* *
@@ -2430,6 +2659,10 @@ extern "C" {
* This defaults to 0, and specifying NULL for the hint's value will restore * This defaults to 0, and specifying NULL for the hint's value will restore
* the default. * the default.
* *
* This doesn't have to be an integer value. For example, "59.94" won't be
* rounded to an integer rate; the digits after the decimal are actually
* respected.
*
* This hint can be set anytime. * This hint can be set anytime.
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
@@ -2493,7 +2726,7 @@ extern "C" {
* the window center occur within a short time period, SDL will emulate mouse * the window center occur within a short time period, SDL will emulate mouse
* warps using relative mouse mode. This can provide smoother and more * warps using relative mouse mode. This can provide smoother and more
* reliable mouse motion for some older games, which continuously calculate * reliable mouse motion for some older games, which continuously calculate
* the distance travelled by the mouse pointer and warp it back to the center * the distance traveled by the mouse pointer and warp it back to the center
* of the window, rather than using relative mouse motion. * of the window, rather than using relative mouse motion.
* *
* Note that relative mouse mode may have different mouse acceleration * Note that relative mouse mode may have different mouse acceleration
@@ -2859,6 +3092,24 @@ extern "C" {
*/ */
#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" #define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG"
/**
* A variable controlling whether to use the Direct3D 11 WARP software
* rasterizer.
*
* For more information, see:
* https://learn.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp
*
* The variable can be set to the following values:
*
* - "0": Disable WARP rasterizer. (default)
* - "1": Enable WARP rasterizer.
*
* This hint should be set before creating a renderer.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_RENDER_DIRECT3D11_WARP "SDL_RENDER_DIRECT3D11_WARP"
/** /**
* A variable controlling whether to enable Vulkan Validation Layers. * A variable controlling whether to enable Vulkan Validation Layers.
* *
@@ -3041,6 +3292,37 @@ extern "C" {
*/ */
#define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED" #define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED"
/**
* Variable controlling the width of the PS2's framebuffer in pixels
*
* By default, this variable is "640"
*/
#define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH"
/**
* Variable controlling the height of the PS2's framebuffer in pixels
*
* By default, this variable is "448"
*/
#define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT"
/**
* Variable controlling whether the signal is interlaced or progressive
*
* - "0": Image is interlaced. (default)
* - "1": Image is progressive
*/
#define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE"
/**
* Variable controlling the video mode of the console
*
* - "": Console-native. (default)
* - "NTSC": 60hz region
* - "PAL": 50hz region
*/
#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE"
/** /**
* A variable controlling which Dispmanx layer to use on a Raspberry PI. * A variable controlling which Dispmanx layer to use on a Raspberry PI.
* *
@@ -3407,6 +3689,43 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY" #define SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY"
/**
* A variable indicating whether the metal layer drawable size should be
* updated for the SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event on macOS.
*
* The variable can be set to the following values:
*
* - "0": the metal layer drawable size will not be updated on the
* SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
* - "1": the metal layer drawable size will be updated on the
* SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. (default)
*
* This hint should be set before SDL_Metal_CreateView called.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_VIDEO_METAL_AUTO_RESIZE_DRAWABLE "SDL_VIDEO_METAL_AUTO_RESIZE_DRAWABLE"
/**
* A variable controlling whether SDL will attempt to automatically set the
* destination display to a mode most closely matching that of the previous
* display if an exclusive fullscreen window is moved onto it.
*
* The variable can be set to the following values:
*
* - "0": SDL will not attempt to automatically set a matching mode on the
* destination display. If an exclusive fullscreen window is moved to a new
* display, the window will become fullscreen desktop.
* - "1": SDL will attempt to automatically set a mode on the destination
* display that most closely matches the mode of the display that the
* exclusive fullscreen window was previously on. (default)
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE "SDL_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE"
/** /**
* A variable controlling whether fullscreen windows are minimized when they * A variable controlling whether fullscreen windows are minimized when they
* lose focus. * lose focus.
@@ -4061,15 +4380,14 @@ extern "C" {
* *
* The variable can be set to the following values: * The variable can be set to the following values:
* *
* - "0": GameInput is not used for raw keyboard and mouse events. * - "0": GameInput is not used for raw keyboard and mouse events. (default)
* - "1": GameInput is used for raw keyboard and mouse events, if available. * - "1": GameInput is used for raw keyboard and mouse events, if available.
* (default)
* *
* This hint should be set before SDL is initialized. * This hint should be set before SDL is initialized.
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
*/ */
#define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT" #define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT"
/** /**
* A variable controlling whether raw keyboard events are used on Windows. * A variable controlling whether raw keyboard events are used on Windows.
@@ -4085,6 +4403,28 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" #define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD"
/**
* A variable controlling whether or not the RIDEV_NOHOTKEYS flag is set when
* enabling Windows raw keyboard events.
*
* This blocks any hotkeys that have been registered by applications from
* having any effect beyond generating raw WM_INPUT events.
*
* This flag does not affect system-hotkeys like ALT-TAB or CTRL-ALT-DEL, but
* does affect the Windows Logo key since it is a userland hotkey registered
* by explorer.exe.
*
* The variable can be set to the following values:
*
* - "0": Hotkeys are not excluded. (default)
* - "1": Hotkeys are excluded.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.4.0.
*/
#define SDL_HINT_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS "SDL_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS"
/** /**
* A variable controlling whether SDL uses Kernel Semaphores on Windows. * A variable controlling whether SDL uses Kernel Semaphores on Windows.
* *
@@ -4114,7 +4454,7 @@ extern "C" {
* *
* \since This hint is available since SDL 3.2.0. * \since This hint is available since SDL 3.2.0.
*/ */
#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" #define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON"
/** /**
* A variable to specify custom icon resource id from RC file on Windows * A variable to specify custom icon resource id from RC file on Windows
@@ -4287,7 +4627,6 @@ extern "C" {
*/ */
#define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS" #define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS"
/** /**
* An enumeration of hint priorities. * An enumeration of hint priorities.
* *
@@ -4386,19 +4725,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetHints(void);
* \param name the hint to query. * \param name the hint to query.
* \returns the string value of a hint or NULL if the hint isn't set. * \returns the string value of a hint or NULL if the hint isn't set.
* *
* \threadsafety It is safe to call this function from any thread, however the * \threadsafety It is safe to call this function from any thread.
* return value only remains valid until the hint is changed; if
* another thread might do so, the app should supply locks
* and/or make a copy of the string. Note that using a hint
* callback instead is always thread-safe, as SDL holds a lock
* on the thread subsystem during the callback.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetHint * \sa SDL_SetHint
* \sa SDL_SetHintWithPriority * \sa SDL_SetHintWithPriority
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); extern SDL_DECLSPEC const char *SDLCALL SDL_GetHint(const char *name);
/** /**
* Get the boolean value of a hint variable. * Get the boolean value of a hint variable.
@@ -4474,8 +4808,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintC
* \sa SDL_AddHintCallback * \sa SDL_AddHintCallback
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_RemoveHintCallback(const char *name, extern SDL_DECLSPEC void SDLCALL SDL_RemoveHintCallback(const char *name,
SDL_HintCallback callback, SDL_HintCallback callback,
void *userdata); void *userdata);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -101,7 +101,7 @@ typedef Uint32 SDL_InitFlags;
* to run. * to run.
* *
* See * See
* [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README/main-functions#main-callbacks-in-sdl3) * [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README-main-functions#main-callbacks-in-sdl3)
* for complete details. * for complete details.
* *
* \since This enum is available since SDL 3.2.0. * \since This enum is available since SDL 3.2.0.

View File

@@ -268,6 +268,7 @@ _m_prefetch(void *__P)
#endif /* compiler version */ #endif /* compiler version */
#ifdef SDL_WIKI_DOCUMENTATION_SECTION #ifdef SDL_WIKI_DOCUMENTATION_SECTION
/** /**
* A macro to decide if the compiler supports `__attribute__((target))`. * A macro to decide if the compiler supports `__attribute__((target))`.
* *
@@ -280,12 +281,14 @@ _m_prefetch(void *__P)
* \sa SDL_TARGETING * \sa SDL_TARGETING
*/ */
#define SDL_HAS_TARGET_ATTRIBS #define SDL_HAS_TARGET_ATTRIBS
#elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15)
/* LoongArch requires GCC 15+ for target attribute support */
# define SDL_HAS_TARGET_ATTRIBS
#elif defined(__clang__) && defined(__has_attribute) #elif defined(__clang__) && defined(__has_attribute)
# if __has_attribute(target) # if __has_attribute(target)
# define SDL_HAS_TARGET_ATTRIBS # define SDL_HAS_TARGET_ATTRIBS
# endif # endif
#elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */ #elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
# define SDL_HAS_TARGET_ATTRIBS # define SDL_HAS_TARGET_ATTRIBS
#elif defined(__ICC) && __ICC >= 1600 #elif defined(__ICC) && __ICC >= 1600
# define SDL_HAS_TARGET_ATTRIBS # define SDL_HAS_TARGET_ATTRIBS

View File

@@ -111,7 +111,7 @@ typedef struct SDL_IOStreamInterface
/** /**
* Read up to `size` bytes from the data stream to the area pointed * Read up to `size` bytes from the data stream to the area pointed
* at by `ptr`. * at by `ptr`. `size` will always be > 0.
* *
* On an incomplete read, you should set `*status` to a value from the * On an incomplete read, you should set `*status` to a value from the
* SDL_IOStatus enum. You do not have to explicitly set this on * SDL_IOStatus enum. You do not have to explicitly set this on
@@ -123,7 +123,7 @@ typedef struct SDL_IOStreamInterface
/** /**
* Write exactly `size` bytes from the area pointed at by `ptr` * Write exactly `size` bytes from the area pointed at by `ptr`
* to data stream. * to data stream. `size` will always be > 0.
* *
* On an incomplete write, you should set `*status` to a value from the * On an incomplete write, you should set `*status` to a value from the
* SDL_IOStatus enum. You do not have to explicitly set this on * SDL_IOStatus enum. You do not have to explicitly set this on
@@ -203,6 +203,8 @@ typedef struct SDL_IOStream SDL_IOStream;
* - "w": Create an empty file for writing. If a file with the same name * - "w": Create an empty file for writing. If a file with the same name
* already exists its content is erased and the file is treated as a new * already exists its content is erased and the file is treated as a new
* empty file. * empty file.
* - "wx": Create an empty file for writing. If a file with the same name
* already exists, the call fails.
* - "a": Append to a file. Writing operations append data at the end of the * - "a": Append to a file. Writing operations append data at the end of the
* file. The file is created if it does not exist. * file. The file is created if it does not exist.
* - "r+": Open a file for update both reading and writing. The file must * - "r+": Open a file for update both reading and writing. The file must
@@ -210,6 +212,8 @@ typedef struct SDL_IOStream SDL_IOStream;
* - "w+": Create an empty file for both reading and writing. If a file with * - "w+": Create an empty file for both reading and writing. If a file with
* the same name already exists its content is erased and the file is * the same name already exists its content is erased and the file is
* treated as a new empty file. * treated as a new empty file.
* - "w+x": Create an empty file for both reading and writing. If a file with
* the same name already exists, the call fails.
* - "a+": Open a file for reading and appending. All writing operations are * - "a+": Open a file for reading and appending. All writing operations are
* performed at the end of the file, protecting the previous content to be * performed at the end of the file, protecting the previous content to be
* overwritten. You can reposition (fseek, rewind) the internal pointer to * overwritten. You can reposition (fseek, rewind) the internal pointer to
@@ -260,7 +264,7 @@ typedef struct SDL_IOStream SDL_IOStream;
* \returns a pointer to the SDL_IOStream structure that is created or NULL on * \returns a pointer to the SDL_IOStream structure that is created or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -286,8 +290,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons
* certain size, for both read and write access. * certain size, for both read and write access.
* *
* This memory buffer is not copied by the SDL_IOStream; the pointer you * This memory buffer is not copied by the SDL_IOStream; the pointer you
* provide must remain valid until you close the stream. Closing the stream * provide must remain valid until you close the stream.
* will not free the original buffer.
* *
* If you need to make sure the SDL_IOStream never writes to the memory * If you need to make sure the SDL_IOStream never writes to the memory
* buffer, you should use SDL_IOFromConstMem() with a read-only buffer of * buffer, you should use SDL_IOFromConstMem() with a read-only buffer of
@@ -300,6 +303,13 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons
* - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter
* that was passed to this function. * that was passed to this function.
* *
* Additionally, the following properties are recognized:
*
* - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to
* a non-NULL value it will be interpreted as a function of SDL_free_func
* type and called with the passed `mem` pointer when closing the stream. By
* default it is unset, i.e., the memory will not be freed.
*
* \param mem a pointer to a buffer to feed an SDL_IOStream stream. * \param mem a pointer to a buffer to feed an SDL_IOStream stream.
* \param size the buffer size, in bytes. * \param size the buffer size, in bytes.
* \returns a pointer to a new SDL_IOStream structure or NULL on failure; call * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call
@@ -321,6 +331,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size)
#define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base" #define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base"
#define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size" #define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size"
#define SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER "SDL.iostream.memory.free"
/** /**
* Use this function to prepare a read-only memory buffer for use with * Use this function to prepare a read-only memory buffer for use with
@@ -333,8 +344,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size)
* without writing to the memory buffer. * without writing to the memory buffer.
* *
* This memory buffer is not copied by the SDL_IOStream; the pointer you * This memory buffer is not copied by the SDL_IOStream; the pointer you
* provide must remain valid until you close the stream. Closing the stream * provide must remain valid until you close the stream.
* will not free the original buffer.
* *
* If you need to write to a memory buffer, you should use SDL_IOFromMem() * If you need to write to a memory buffer, you should use SDL_IOFromMem()
* with a writable buffer of memory instead. * with a writable buffer of memory instead.
@@ -346,6 +356,13 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size)
* - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter
* that was passed to this function. * that was passed to this function.
* *
* Additionally, the following properties are recognized:
*
* - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to
* a non-NULL value it will be interpreted as a function of SDL_free_func
* type and called with the passed `mem` pointer when closing the stream. By
* default it is unset, i.e., the memory will not be freed.
*
* \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream. * \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream.
* \param size the buffer size, in bytes. * \param size the buffer size, in bytes.
* \returns a pointer to a new SDL_IOStream structure or NULL on failure; call * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call
@@ -452,7 +469,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterfac
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -467,7 +484,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context);
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -487,7 +504,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *c
* \param context the SDL_IOStream to query. * \param context the SDL_IOStream to query.
* \returns an SDL_IOStatus enum with the current state. * \returns an SDL_IOStatus enum with the current state.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -501,7 +518,7 @@ extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context);
* negative error code on failure; call SDL_GetError() for more * negative error code on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -528,7 +545,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
* \returns the final offset in the data stream after the seek or -1 on * \returns the final offset in the data stream after the seek or -1 on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -548,7 +565,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offs
* \returns the current offset in the stream, or -1 if the information can not * \returns the current offset in the stream, or -1 if the information can not
* be determined. * be determined.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -567,13 +584,17 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context);
* the stream is not at EOF, SDL_GetIOStatus() will return a different error * the stream is not at EOF, SDL_GetIOStatus() will return a different error
* value and SDL_GetError() will offer a human-readable message. * value and SDL_GetError() will offer a human-readable message.
* *
* A request for zero bytes on a valid stream will return zero immediately
* without accessing the stream, so the stream status (EOF, err, etc) will not
* change.
*
* \param context a pointer to an SDL_IOStream structure. * \param context a pointer to an SDL_IOStream structure.
* \param ptr a pointer to a buffer to read data into. * \param ptr a pointer to a buffer to read data into.
* \param size the number of bytes to read from the data source. * \param size the number of bytes to read from the data source.
* \returns the number of bytes read, or 0 on end of file or other failure; * \returns the number of bytes read, or 0 on end of file or other failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -596,13 +617,17 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr,
* recoverable, such as a non-blocking write that can simply be retried later, * recoverable, such as a non-blocking write that can simply be retried later,
* or a fatal error. * or a fatal error.
* *
* A request for zero bytes on a valid stream will return zero immediately
* without accessing the stream, so the stream status (EOF, err, etc) will not
* change.
*
* \param context a pointer to an SDL_IOStream structure. * \param context a pointer to an SDL_IOStream structure.
* \param ptr a pointer to a buffer containing data to write. * \param ptr a pointer to a buffer containing data to write.
* \param size the number of bytes to write. * \param size the number of bytes to write.
* \returns the number of bytes written, which will be less than `size` on * \returns the number of bytes written, which will be less than `size` on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -626,7 +651,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void
* \returns the number of bytes written or 0 on failure; call SDL_GetError() * \returns the number of bytes written or 0 on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -646,7 +671,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINT
* \returns the number of bytes written or 0 on failure; call SDL_GetError() * \returns the number of bytes written or 0 on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -666,7 +691,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRIN
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -692,7 +717,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context);
* \returns the data or NULL on failure; call SDL_GetError() for more * \returns the data or NULL on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -715,7 +740,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *da
* \returns the data or NULL on failure; call SDL_GetError() for more * \returns the data or NULL on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -736,7 +761,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasi
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -755,7 +780,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile_IO(SDL_IOStream *src, const void *
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -784,7 +809,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile(const char *file, const void *data
* \returns true on success or false on failure or EOF; call SDL_GetError() * \returns true on success or false on failure or EOF; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -803,7 +828,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -823,10 +848,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value);
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -846,10 +871,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -869,10 +894,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -892,10 +917,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -915,10 +940,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -938,10 +963,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -961,10 +986,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -984,10 +1009,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1007,10 +1032,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1030,10 +1055,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1053,10 +1078,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1076,10 +1101,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value)
* *
* \param src the stream from which to read data. * \param src the stream from which to read data.
* \param value a pointer filled in with the data read. * \param value a pointer filled in with the data read.
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful read or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1101,7 +1126,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1115,7 +1140,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value);
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1134,7 +1159,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value);
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1153,7 +1178,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1171,7 +1196,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1189,7 +1214,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1208,7 +1233,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1227,7 +1252,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1245,7 +1270,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1263,7 +1288,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1282,7 +1307,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1301,7 +1326,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1319,7 +1344,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1337,7 +1362,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value)
* \returns true on successful write or false on failure; call SDL_GetError() * \returns true on successful write or false on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety Do not use the same SDL_IOStream from two threads at once.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */

View File

@@ -29,8 +29,8 @@
* instead. * instead.
* *
* The term "instance_id" is the current instantiation of a joystick device in * The term "instance_id" is the current instantiation of a joystick device in
* the system, if the joystick is removed and then re-inserted then it will * the system. If the joystick is removed and then re-inserted then it will
* get a new instance_id, instance_id's are monotonically increasing * get a new instance_id. instance_id's are monotonically increasing
* identifiers of a joystick plugged in. * identifiers of a joystick plugged in.
* *
* The term "player_index" is the number assigned to a player on a specific * The term "player_index" is the number assigned to a player on a specific
@@ -48,6 +48,14 @@
* If you would like to receive joystick updates while the application is in * If you would like to receive joystick updates while the application is in
* the background, you should set the following hint before calling * the background, you should set the following hint before calling
* SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
*
* SDL can provide virtual joysticks as well: the app defines an imaginary
* controller with SDL_AttachVirtualJoystick(), and then can provide inputs
* for it via SDL_SetJoystickVirtualAxis(), SDL_SetJoystickVirtualButton(),
* etc. As this data is supplied, it will look like a normal joystick to SDL,
* just not backed by a hardware driver. This has been used to make unusual
* devices, like VR headset controllers, look like normal joysticks, or
* provide recording/playback of game inputs, etc.
*/ */
#ifndef SDL_joystick_h_ #ifndef SDL_joystick_h_
@@ -107,6 +115,10 @@ typedef Uint32 SDL_JoystickID;
* This is by no means a complete list of everything that can be plugged into * This is by no means a complete list of everything that can be plugged into
* a computer. * a computer.
* *
* You may refer to
* [XInput Controller Types](https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes)
* table for a general understanding of each joystick type.
*
* \since This enum is available since SDL 3.2.0. * \since This enum is available since SDL 3.2.0.
*/ */
typedef enum SDL_JoystickType typedef enum SDL_JoystickType
@@ -170,6 +182,8 @@ typedef enum SDL_JoystickConnectionState
* joysticks while processing to guarantee that the joystick list won't change * joysticks while processing to guarantee that the joystick list won't change
* and joystick and gamepad events will not be delivered. * and joystick and gamepad events will not be delivered.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock); extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
@@ -177,6 +191,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystic
/** /**
* Unlocking for atomic access to the joystick API. * Unlocking for atomic access to the joystick API.
* *
* \threadsafety This should be called from the same thread that called
* SDL_LockJoysticks().
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock); extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
@@ -186,6 +203,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joyst
* *
* \returns true if a joystick is connected, false otherwise. * \returns true if a joystick is connected, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoysticks * \sa SDL_GetJoysticks
@@ -201,6 +220,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasJoystick(void);
* call SDL_GetError() for more information. This should be freed * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed. * with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_HasJoystick * \sa SDL_HasJoystick
@@ -217,6 +238,8 @@ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count);
* \returns the name of the selected joystick. If no name can be found, this * \returns the name of the selected joystick. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickName * \sa SDL_GetJoystickName
@@ -233,6 +256,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickPath * \sa SDL_GetJoystickPath
@@ -248,6 +273,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPathForID(SDL_JoystickID
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the player index of a joystick, or -1 if it's not available. * \returns the player index of a joystick, or -1 if it's not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickPlayerIndex * \sa SDL_GetJoystickPlayerIndex
@@ -264,6 +291,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID i
* \returns the GUID of the selected joystick. If called with an invalid * \returns the GUID of the selected joystick. If called with an invalid
* instance_id, this function returns a zero GUID. * instance_id, this function returns a zero GUID.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickGUID * \sa SDL_GetJoystickGUID
@@ -281,6 +310,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID ins
* \returns the USB vendor ID of the selected joystick. If called with an * \returns the USB vendor ID of the selected joystick. If called with an
* invalid instance_id, this function returns 0. * invalid instance_id, this function returns 0.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickVendor * \sa SDL_GetJoystickVendor
@@ -298,6 +329,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendorForID(SDL_JoystickID ins
* \returns the USB product ID of the selected joystick. If called with an * \returns the USB product ID of the selected joystick. If called with an
* invalid instance_id, this function returns 0. * invalid instance_id, this function returns 0.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickProduct * \sa SDL_GetJoystickProduct
@@ -315,6 +348,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductForID(SDL_JoystickID in
* \returns the product version of the selected joystick. If called with an * \returns the product version of the selected joystick. If called with an
* invalid instance_id, this function returns 0. * invalid instance_id, this function returns 0.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickProductVersion * \sa SDL_GetJoystickProductVersion
@@ -332,6 +367,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersionForID(SDL_Joysti
* invalid instance_id, this function returns * invalid instance_id, this function returns
* `SDL_JOYSTICK_TYPE_UNKNOWN`. * `SDL_JOYSTICK_TYPE_UNKNOWN`.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickType * \sa SDL_GetJoystickType
@@ -349,6 +386,8 @@ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickTypeForID(SDL_Joysti
* \returns a joystick identifier or NULL on failure; call SDL_GetError() for * \returns a joystick identifier or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_CloseJoystick * \sa SDL_CloseJoystick
@@ -362,6 +401,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_OpenJoystick(SDL_JoystickID insta
* \returns an SDL_Joystick on success or NULL on failure or if it hasn't been * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been
* opened yet; call SDL_GetError() for more information. * opened yet; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id); extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id);
@@ -373,6 +414,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickPlayerIndex * \sa SDL_GetJoystickPlayerIndex
@@ -465,13 +508,33 @@ SDL_COMPILE_TIME_ASSERT(SDL_VirtualJoystickDesc_SIZE,
/** /**
* Attach a new virtual joystick. * Attach a new virtual joystick.
* *
* Apps can create virtual joysticks, that exist without hardware directly
* backing them, and have program-supplied inputs. Once attached, a virtual
* joystick looks like any other joystick that SDL can access. These can be
* used to make other things look like joysticks, or provide pre-recorded
* input, etc.
*
* Once attached, the app can send joystick inputs to the new virtual joystick
* using SDL_SetJoystickVirtualAxis(), etc.
*
* When no longer needed, the virtual joystick can be removed by calling
* SDL_DetachVirtualJoystick().
*
* \param desc joystick description, initialized using SDL_INIT_INTERFACE(). * \param desc joystick description, initialized using SDL_INIT_INTERFACE().
* \returns the joystick instance ID, or 0 on failure; call SDL_GetError() for * \returns the joystick instance ID, or 0 on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_DetachVirtualJoystick * \sa SDL_DetachVirtualJoystick
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualTouchpad
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc); extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc);
@@ -483,6 +546,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_V
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_AttachVirtualJoystick * \sa SDL_AttachVirtualJoystick
@@ -495,6 +560,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instan
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns true if the joystick is virtual, false otherwise. * \returns true if the joystick is virtual, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id); extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id);
@@ -518,7 +585,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_i
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualTouchpad
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
@@ -538,7 +613,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joysti
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualTouchpad
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel);
@@ -557,7 +640,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joysti
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualTouchpad
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, bool down); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, bool down);
@@ -576,7 +667,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joys
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualTouchpad
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
@@ -602,7 +701,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystic
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualSensorData
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure);
@@ -624,7 +731,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *jo
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_SetJoystickVirtualAxis
* \sa SDL_SetJoystickVirtualButton
* \sa SDL_SetJoystickVirtualBall
* \sa SDL_SetJoystickVirtualHat
* \sa SDL_SetJoystickVirtualTouchpad
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
@@ -648,6 +763,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick); extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
@@ -665,6 +782,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joyst
* \returns the name of the selected joystick. If no name can be found, this * \returns the name of the selected joystick. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickNameForID * \sa SDL_GetJoystickNameForID
@@ -678,6 +797,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joyst
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickPathForID * \sa SDL_GetJoystickPathForID
@@ -693,6 +814,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPath(SDL_Joystick *joyst
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the player index, or -1 if it's not available. * \returns the player index, or -1 if it's not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetJoystickPlayerIndex * \sa SDL_SetJoystickPlayerIndex
@@ -708,6 +831,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystic
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickPlayerIndex * \sa SDL_GetJoystickPlayerIndex
@@ -724,6 +849,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joysti
* this function returns a zero GUID; call SDL_GetError() for more * this function returns a zero GUID; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
@@ -739,6 +866,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick)
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the USB vendor ID of the selected joystick, or 0 if unavailable. * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickVendorForID * \sa SDL_GetJoystickVendorForID
@@ -753,6 +882,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick)
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the USB product ID of the selected joystick, or 0 if unavailable. * \returns the USB product ID of the selected joystick, or 0 if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickProductForID * \sa SDL_GetJoystickProductForID
@@ -767,6 +898,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the product version of the selected joystick, or 0 if unavailable. * \returns the product version of the selected joystick, or 0 if unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickProductVersionForID * \sa SDL_GetJoystickProductVersionForID
@@ -782,6 +915,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *j
* \returns the firmware version of the selected joystick, or 0 if * \returns the firmware version of the selected joystick, or 0 if
* unavailable. * unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick); extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick);
@@ -795,6 +930,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *
* \returns the serial number of the selected joystick, or NULL if * \returns the serial number of the selected joystick, or NULL if
* unavailable. * unavailable.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick); extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick);
@@ -805,6 +942,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joy
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the SDL_JoystickType of the selected joystick. * \returns the SDL_JoystickType of the selected joystick.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickTypeForID * \sa SDL_GetJoystickTypeForID
@@ -824,6 +963,8 @@ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *j
* \param crc16 a pointer filled in with a CRC used to distinguish different * \param crc16 a pointer filled in with a CRC used to distinguish different
* products with the same VID/PID, or 0 if not available. * products with the same VID/PID, or 0 if not available.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
@@ -837,6 +978,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 *
* \returns true if the joystick has been opened, false if it has not; call * \returns true if the joystick has been opened, false if it has not; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick); extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
@@ -848,6 +991,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
* \returns the instance ID of the specified joystick on success or 0 on * \returns the instance ID of the specified joystick on success or 0 on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joystick); extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joystick);
@@ -863,6 +1008,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joyst
* \returns the number of axis controls/number of axes on success or -1 on * \returns the number of axis controls/number of axes on success or -1 on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickAxis * \sa SDL_GetJoystickAxis
@@ -884,6 +1031,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
* \returns the number of trackballs on success or -1 on failure; call * \returns the number of trackballs on success or -1 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickBall * \sa SDL_GetJoystickBall
@@ -900,6 +1049,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
* \returns the number of POV hats on success or -1 on failure; call * \returns the number of POV hats on success or -1 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickHat * \sa SDL_GetJoystickHat
@@ -916,6 +1067,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
* \returns the number of buttons on success or -1 on failure; call * \returns the number of buttons on success or -1 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetJoystickButton * \sa SDL_GetJoystickButton
@@ -934,6 +1087,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick
* *
* \param enabled whether to process joystick events or not. * \param enabled whether to process joystick events or not.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_JoystickEventsEnabled * \sa SDL_JoystickEventsEnabled
@@ -950,6 +1105,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(bool enabled);
* *
* \returns true if joystick events are being processed, false otherwise. * \returns true if joystick events are being processed, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_SetJoystickEventsEnabled * \sa SDL_SetJoystickEventsEnabled
@@ -962,6 +1119,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickEventsEnabled(void);
* This is called automatically by the event loop if any joystick events are * This is called automatically by the event loop if any joystick events are
* enabled. * enabled.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void); extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
@@ -984,6 +1143,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
* \returns a 16-bit signed integer representing the current position of the * \returns a 16-bit signed integer representing the current position of the
* axis or 0 on failure; call SDL_GetError() for more information. * axis or 0 on failure; call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumJoystickAxes * \sa SDL_GetNumJoystickAxes
@@ -1002,6 +1163,8 @@ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, i
* \param state upon return, the initial value is supplied here. * \param state upon return, the initial value is supplied here.
* \returns true if this axis has any initial value, or false if not. * \returns true if this axis has any initial value, or false if not.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state); extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
@@ -1021,6 +1184,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *j
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumJoystickBalls * \sa SDL_GetNumJoystickBalls
@@ -1036,6 +1201,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int
* \param hat the hat index to get the state from; indices start at index 0. * \param hat the hat index to get the state from; indices start at index 0.
* \returns the current hat position. * \returns the current hat position.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumJoystickHats * \sa SDL_GetNumJoystickHats
@@ -1060,6 +1227,8 @@ extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int
* index 0. * index 0.
* \returns true if the button is pressed, false otherwise. * \returns true if the button is pressed, false otherwise.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GetNumJoystickButtons * \sa SDL_GetNumJoystickButtons
@@ -1083,6 +1252,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, i
* \param duration_ms the duration of the rumble effect, in milliseconds. * \param duration_ms the duration of the rumble effect, in milliseconds.
* \returns true, or false if rumble isn't supported on this joystick. * \returns true, or false if rumble isn't supported on this joystick.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@@ -1110,6 +1281,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_RumbleJoystick * \sa SDL_RumbleJoystick
@@ -1132,6 +1305,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joysti
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
@@ -1145,6 +1320,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size); extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
@@ -1154,6 +1331,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick,
* *
* \param joystick the joystick device to close. * \param joystick the joystick device to close.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_OpenJoystick * \sa SDL_OpenJoystick
@@ -1168,6 +1347,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
* `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick); extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick);
@@ -1189,6 +1370,8 @@ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectio
* \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent); extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent);

View File

@@ -174,8 +174,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetKeyboard(void);
/** /**
* Get the current key modifier state for the keyboard. * Get the current key modifier state for the keyboard.
* *
* \returns an OR'd combination of the modifier keys for the keyboard. See * \returns an OR'd combination of the modifier keys for the keyboard.
* SDL_Keymod for details.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *

View File

@@ -45,12 +45,16 @@
* `SDLK_*` constant for those keys that do not generate characters. * `SDLK_*` constant for those keys that do not generate characters.
* *
* A special exception is the number keys at the top of the keyboard which map * A special exception is the number keys at the top of the keyboard which map
* to SDLK_0...SDLK_9 on AZERTY layouts. * by default to SDLK_0...SDLK_9 on AZERTY layouts.
* *
* Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or * Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or
* unicode code point. * unicode code point.
* *
* Many common keycodes are listed below, but this list is not exhaustive.
*
* \since This datatype is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_HINT_KEYCODE_OPTIONS
*/ */
typedef Uint32 SDL_Keycode; typedef Uint32 SDL_Keycode;

View File

@@ -206,6 +206,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
* SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. * SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g.
* "WARNING: ". * "WARNING: ".
* *
* This function makes a copy of its string argument, **prefix**, so it is not
* necessary to keep the value of **prefix** alive after the call returns.
*
* \param priority the SDL_LogPriority to modify. * \param priority the SDL_LogPriority to modify.
* \param prefix the prefix to use for that log priority, or NULL to use no * \param prefix the prefix to use for that log priority, or NULL to use no
* prefix. * prefix.
@@ -263,7 +266,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fm
* \sa SDL_LogInfo * \sa SDL_LogInfo
* \sa SDL_LogMessage * \sa SDL_LogMessage
* \sa SDL_LogMessageV * \sa SDL_LogMessageV
* \sa SDL_LogTrace
* \sa SDL_LogVerbose * \sa SDL_LogVerbose
* \sa SDL_LogWarn * \sa SDL_LogWarn
*/ */

View File

@@ -47,7 +47,7 @@
* *
* For more information, see: * For more information, see:
* *
* https://wiki.libsdl.org/SDL3/README/main-functions * https://wiki.libsdl.org/SDL3/README-main-functions
*/ */
#ifndef SDL_main_h_ #ifndef SDL_main_h_
@@ -68,7 +68,7 @@
* proper entry point for the platform, and all the other magic details * proper entry point for the platform, and all the other magic details
* needed, like manually calling SDL_SetMainReady. * needed, like manually calling SDL_SetMainReady.
* *
* Please see [README/main-functions](README/main-functions), (or * Please see [README-main-functions](README-main-functions), (or
* docs/README-main-functions.md in the source tree) for a more detailed * docs/README-main-functions.md in the source tree) for a more detailed
* explanation. * explanation.
* *
@@ -85,7 +85,7 @@
* SDL_AppQuit. The app should not provide a `main` function in this case, and * SDL_AppQuit. The app should not provide a `main` function in this case, and
* doing so will likely cause the build to fail. * doing so will likely cause the build to fail.
* *
* Please see [README/main-functions](README/main-functions), (or * Please see [README-main-functions](README-main-functions), (or
* docs/README-main-functions.md in the source tree) for a more detailed * docs/README-main-functions.md in the source tree) for a more detailed
* explanation. * explanation.
* *
@@ -110,7 +110,8 @@
* Even if available, an app can define SDL_MAIN_HANDLED and provide their * Even if available, an app can define SDL_MAIN_HANDLED and provide their
* own, if they know what they're doing. * own, if they know what they're doing.
* *
* This macro is used internally by SDL, and apps probably shouldn't rely on it. * This macro is used internally by SDL, and apps probably shouldn't rely on
* it.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
@@ -125,10 +126,11 @@
* This macro is defined by `SDL_main.h`, which is not automatically included * This macro is defined by `SDL_main.h`, which is not automatically included
* by `SDL.h`. * by `SDL.h`.
* *
* Even if required, an app can define SDL_MAIN_HANDLED and provide their * Even if required, an app can define SDL_MAIN_HANDLED and provide their own,
* own, if they know what they're doing. * if they know what they're doing.
* *
* This macro is used internally by SDL, and apps probably shouldn't rely on it. * This macro is used internally by SDL, and apps probably shouldn't rely on
* it.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
@@ -165,12 +167,10 @@
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(SDL_PLATFORM_IOS) #elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
/* On iOS SDL provides a main function that creates an application delegate /* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop.
and starts the iOS application run loop.
To use it, just #include SDL_main.h in the source file that contains your To use it, just #include <SDL3/SDL_main.h> in the source file that contains your main() function.
main() function.
See src/video/uikit/SDL_uikitappdelegate.m for more details. See src/video/uikit/SDL_uikitappdelegate.m for more details.
*/ */
@@ -347,10 +347,10 @@ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int a
* Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
* standard "main" function, you should not supply this. * standard "main" function, you should not supply this.
* *
* This function is called repeatedly by SDL after SDL_AppInit returns 0. The * This function is called repeatedly by SDL after SDL_AppInit returns
* function should operate as a single iteration the program's primary loop; * SDL_APP_CONTINUE. The function should operate as a single iteration the
* it should update whatever state it needs and draw a new frame of video, * program's primary loop; it should update whatever state it needs and draw a
* usually. * new frame of video, usually.
* *
* On some platforms, this function will be called at the refresh rate of the * On some platforms, this function will be called at the refresh rate of the
* display (which might change during the life of your app!). There are no * display (which might change during the life of your app!). There are no
@@ -449,8 +449,8 @@ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_E
* *
* This function is called once by SDL before terminating the program. * This function is called once by SDL before terminating the program.
* *
* This function will be called no matter what, even if SDL_AppInit requests * This function will be called in all cases, even if SDL_AppInit requests
* termination. * termination at startup.
* *
* This function should not go into an infinite mainloop; it should * This function should not go into an infinite mainloop; it should
* deinitialize any resources necessary, perform whatever shutdown activities, * deinitialize any resources necessary, perform whatever shutdown activities,
@@ -512,7 +512,7 @@ typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]);
* SDL_MAIN_USE_CALLBACKS. * SDL_MAIN_USE_CALLBACKS.
* *
* Program startup is a surprisingly complex topic. Please see * Program startup is a surprisingly complex topic. Please see
* [README/main-functions](README/main-functions), (or * [README-main-functions](README-main-functions), (or
* docs/README-main-functions.md in the source tree) for a more detailed * docs/README-main-functions.md in the source tree) for a more detailed
* explanation. * explanation.
* *
@@ -553,6 +553,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void);
* using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do
* *not* need SDL_SetMainReady(). * *not* need SDL_SetMainReady().
* *
* If `argv` is NULL, SDL will provide command line arguments, either by
* querying the OS for them if possible, or supplying a filler array if not.
*
* \param argc the argc parameter from the application's main() function, or 0 * \param argc the argc parameter from the application's main() function, or 0
* if the platform's main-equivalent has no argc. * if the platform's main-equivalent has no argc.
* \param argv the argv parameter from the application's main() function, or * \param argv the argv parameter from the application's main() function, or
@@ -615,11 +618,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[]
* Most applications do not need to, and should not, call this directly; SDL * Most applications do not need to, and should not, call this directly; SDL
* will call it when initializing the video subsystem. * will call it when initializing the video subsystem.
* *
* If `name` is NULL, SDL currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` for
* the style, regardless of what is specified here.
*
* \param name the window class name, in UTF-8 encoding. If NULL, SDL * \param name the window class name, in UTF-8 encoding. If NULL, SDL
* currently uses "SDL_app" but this isn't guaranteed. * currently uses "SDL_app" but this isn't guaranteed.
* \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL * \param style the value to use in WNDCLASSEX::style.
* currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
* what is specified here.
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
* will use `GetModuleHandle(NULL)` instead. * will use `GetModuleHandle(NULL)` instead.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more

View File

@@ -130,6 +130,17 @@ typedef enum SDL_MouseWheelDirection
SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
} SDL_MouseWheelDirection; } SDL_MouseWheelDirection;
/**
* Animated cursor frame info.
*
* \since This struct is available since SDL 3.4.0.
*/
typedef struct SDL_CursorFrameInfo
{
SDL_Surface *surface; /**< The surface data for this frame */
Uint32 duration; /**< The frame duration in milliseconds (a duration of 0 is infinite) */
} SDL_CursorFrameInfo;
/** /**
* A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc. * A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc.
* *
@@ -160,6 +171,44 @@ typedef Uint32 SDL_MouseButtonFlags;
#define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1) #define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1)
#define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2) #define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2)
/**
* A callback used to transform mouse motion delta from raw values.
*
* This is called during SDL's handling of platform mouse events to scale the
* values of the resulting motion delta.
*
* \param userdata what was passed as `userdata` to
* SDL_SetRelativeMouseTransform().
* \param timestamp the associated time at which this mouse motion event was
* received.
* \param window the associated window to which this mouse motion event was
* addressed.
* \param mouseID the associated mouse from which this mouse motion event was
* emitted.
* \param x pointer to a variable that will be treated as the resulting x-axis
* motion.
* \param y pointer to a variable that will be treated as the resulting y-axis
* motion.
*
* \threadsafety This callback is called by SDL's internal mouse input
* processing procedure, which may be a thread separate from the
* main event loop that is run at realtime priority. Stalling
* this thread with too much work in the callback can therefore
* potentially freeze the entire system. Care should be taken
* with proper synchronization practices when adding other side
* effects beyond mutation of the x and y values.
*
* \since This datatype is available since SDL 3.4.0.
*
* \sa SDL_SetRelativeMouseTransform
*/
typedef void (SDLCALL *SDL_MouseMotionTransformCallback)(
void *userdata,
Uint64 timestamp,
SDL_Window *window,
SDL_MouseID mouseID,
float *x, float *y
);
/* Function prototypes */ /* Function prototypes */
@@ -380,6 +429,24 @@ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window *window,
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y); extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
/**
* Set a user-defined function by which to transform relative mouse inputs.
*
* This overrides the relative system scale and relative speed scale hints.
* Should be called prior to enabling relative mouse mode, fails otherwise.
*
* \param callback a callback used to transform relative mouse motion, or NULL
* for default behavior.
* \param userdata a pointer that will be passed to `callback`.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata);
/** /**
* Set relative mouse mode for a window. * Set relative mouse mode for a window.
* *
@@ -509,6 +576,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_CreateAnimatedCursor
* \sa SDL_CreateColorCursor * \sa SDL_CreateColorCursor
* \sa SDL_CreateSystemCursor * \sa SDL_CreateSystemCursor
* \sa SDL_DestroyCursor * \sa SDL_DestroyCursor
@@ -522,15 +590,16 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data,
/** /**
* Create a color cursor. * Create a color cursor.
* *
* If this function is passed a surface with alternate representations, the * If this function is passed a surface with alternate representations added
* surface will be interpreted as the content to be used for 100% display * with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the
* scale, and the alternate representations will be used for high DPI * content to be used for 100% display scale, and the alternate
* situations. For example, if the original surface is 32x32, then on a 2x * representations will be used for high DPI situations. For example, if the
* macOS display or 200% display scale on Windows, a 64x64 version of the * original surface is 32x32, then on a 2x macOS display or 200% display scale
* image will be used, if available. If a matching version of the image isn't * on Windows, a 64x64 version of the image will be used, if available. If a
* available, the closest larger size image will be downscaled to the * matching version of the image isn't available, the closest larger size
* appropriate size and be used instead, if available. Otherwise, the closest * image will be downscaled to the appropriate size and be used instead, if
* smaller image will be upscaled and be used instead. * available. Otherwise, the closest smaller image will be upscaled and be
* used instead.
* *
* \param surface an SDL_Surface structure representing the cursor image. * \param surface an SDL_Surface structure representing the cursor image.
* \param hot_x the x position of the cursor hot spot. * \param hot_x the x position of the cursor hot spot.
@@ -542,6 +611,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data,
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_AddSurfaceAlternateImage
* \sa SDL_CreateAnimatedCursor
* \sa SDL_CreateCursor * \sa SDL_CreateCursor
* \sa SDL_CreateSystemCursor * \sa SDL_CreateSystemCursor
* \sa SDL_DestroyCursor * \sa SDL_DestroyCursor
@@ -551,6 +622,57 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surf
int hot_x, int hot_x,
int hot_y); int hot_y);
/**
* Create an animated color cursor.
*
* Animated cursors are composed of a sequential array of frames, specified as
* surfaces and durations in an array of SDL_CursorFrameInfo structs. The hot
* spot coordinates are universal to all frames, and all frames must have the
* same dimensions.
*
* Frame durations are specified in milliseconds. A duration of 0 implies an
* infinite frame time, and the animation will stop on that frame. To create a
* one-shot animation, set the duration of the last frame in the sequence to
* 0.
*
* If this function is passed surfaces with alternate representations added
* with SDL_AddSurfaceAlternateImage(), the surfaces will be interpreted as
* the content to be used for 100% display scale, and the alternate
* representations will be used for high DPI situations. For example, if the
* original surfaces are 32x32, then on a 2x macOS display or 200% display
* scale on Windows, a 64x64 version of the image will be used, if available.
* If a matching version of the image isn't available, the closest larger size
* image will be downscaled to the appropriate size and be used instead, if
* available. Otherwise, the closest smaller image will be upscaled and be
* used instead.
*
* If the underlying platform does not support animated cursors, this function
* will fall back to creating a static color cursor using the first frame in
* the sequence.
*
* \param frames an array of cursor images composing the animation.
* \param frame_count the number of frames in the sequence.
* \param hot_x the x position of the cursor hot spot.
* \param hot_y the y position of the cursor hot spot.
* \returns the new cursor on success or NULL on failure; call SDL_GetError()
* for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_AddSurfaceAlternateImage
* \sa SDL_CreateCursor
* \sa SDL_CreateColorCursor
* \sa SDL_CreateSystemCursor
* \sa SDL_DestroyCursor
* \sa SDL_SetCursor
*/
extern SDL_DECLSPEC SDL_Cursor *SDLCALL SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames,
int frame_count,
int hot_x,
int hot_y);
/** /**
* Create a system cursor. * Create a system cursor.
* *
@@ -629,6 +751,7 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_CreateAnimatedCursor
* \sa SDL_CreateColorCursor * \sa SDL_CreateColorCursor
* \sa SDL_CreateCursor * \sa SDL_CreateCursor
* \sa SDL_CreateSystemCursor * \sa SDL_CreateSystemCursor

View File

@@ -360,7 +360,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mut
* \sa SDL_LockMutex * \sa SDL_LockMutex
* \sa SDL_UnlockMutex * \sa SDL_UnlockMutex
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex); extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex);
/** /**
* Unlock the mutex. * Unlock the mutex.
@@ -559,7 +559,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
* \sa SDL_TryLockRWLockForWriting * \sa SDL_TryLockRWLockForWriting
* \sa SDL_UnlockRWLock * \sa SDL_UnlockRWLock
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock); extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock);
/** /**
* Try to lock a read/write lock _for writing_ without blocking. * Try to lock a read/write lock _for writing_ without blocking.
@@ -589,7 +589,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
* \sa SDL_TryLockRWLockForReading * \sa SDL_TryLockRWLockForReading
* \sa SDL_UnlockRWLock * \sa SDL_UnlockRWLock
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock); extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock);
/** /**
* Unlock the read/write lock. * Unlock the read/write lock.
@@ -942,7 +942,7 @@ typedef enum SDL_InitStatus
* Here is an example of using this: * Here is an example of using this:
* *
* ```c * ```c
* static SDL_AtomicInitState init; * static SDL_InitState init;
* *
* bool InitSystem(void) * bool InitSystem(void)
* { * {

View File

@@ -28,12 +28,37 @@
* handling, e.g., for input and drawing tablets or suitably equipped mobile / * handling, e.g., for input and drawing tablets or suitably equipped mobile /
* tablet devices. * tablet devices.
* *
* To get started with pens, simply handle SDL_EVENT_PEN_* events. When a pen * To get started with pens, simply handle pen events:
* starts providing input, SDL will assign it a unique SDL_PenID, which will *
* remain for the life of the process, as long as the pen stays connected. * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT
* (SDL_PenProximityEvent)
* - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent)
* - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent)
* - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent)
* - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent)
* *
* Pens may provide more than simple touch input; they might have other axes, * Pens may provide more than simple touch input; they might have other axes,
* such as pressure, tilt, rotation, etc. * such as pressure, tilt, rotation, etc.
*
* When a pen starts providing input, SDL will assign it a unique SDL_PenID,
* which will remain for the life of the process, as long as the pen stays
* connected. A pen leaving proximity (being taken far enough away from the
* digitizer tablet that it no longer reponds) and then coming back should
* fire proximity events, but the SDL_PenID should remain consistent.
* Unplugging the digitizer and reconnecting may cause future input to have a
* new SDL_PenID, as SDL may not know that this is the same hardware.
*
* Please note that various platforms vary wildly in how (and how well) they
* support pen input. If your pen supports some piece of functionality but SDL
* doesn't seem to, it might actually be the operating system's fault. For
* example, some platforms can manage multiple devices at the same time, but
* others will make any connected pens look like a single logical device, much
* how all USB mice connected to a computer will move the same system cursor.
* cursor. Other platforms might not support pen buttons, or the distance
* axis, etc. Very few platforms can even report _what_ functionality the pen
* supports in the first place, so best practices is to either build UI to let
* the user configure their pens, or be prepared to handle new functionality
* for a pen the first time an event is reported.
*/ */
#ifndef SDL_pen_h_ #ifndef SDL_pen_h_
@@ -43,6 +68,7 @@
#include <SDL3/SDL_mouse.h> #include <SDL3/SDL_mouse.h>
#include <SDL3/SDL_touch.h> #include <SDL3/SDL_touch.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -55,7 +81,12 @@ extern "C" {
* *
* These show up in pen events when SDL sees input from them. They remain * These show up in pen events when SDL sees input from them. They remain
* consistent as long as SDL can recognize a tool to be the same pen; but if a * consistent as long as SDL can recognize a tool to be the same pen; but if a
* pen physically leaves the area and returns, it might get a new ID. * pen's digitizer table is physically detached from the computer, it might
* get a new ID when reconnected, as SDL won't know it's the same device.
*
* These IDs are only stable within a single run of a program; the next time a
* program is run, the pen's ID will likely be different, even if the hardware
* hasn't been disconnected, etc.
* *
* \since This datatype is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
*/ */
@@ -75,7 +106,6 @@ typedef Uint32 SDL_PenID;
*/ */
#define SDL_PEN_TOUCHID ((SDL_TouchID)-2) #define SDL_PEN_TOUCHID ((SDL_TouchID)-2)
/** /**
* Pen input flags, as reported by various pen events' `pen_state` field. * Pen input flags, as reported by various pen events' `pen_state` field.
* *
@@ -83,13 +113,14 @@ typedef Uint32 SDL_PenID;
*/ */
typedef Uint32 SDL_PenInputFlags; typedef Uint32 SDL_PenInputFlags;
#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ #define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */
#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ #define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */
#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ #define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */
#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ #define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */
#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ #define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */
#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ #define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */
#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ #define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */
#define SDL_PEN_INPUT_IN_PROXIMITY (1u << 31) /**< pen is in proximity (since SDL 3.4.0) */
/** /**
* Pen axis indices. * Pen axis indices.
@@ -118,10 +149,50 @@ typedef enum SDL_PenAxis
SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */
} SDL_PenAxis; } SDL_PenAxis;
/**
* An enum that describes the type of a pen device.
*
* A "direct" device is a pen that touches a graphic display (like an Apple
* Pencil on an iPad's screen). "Indirect" devices touch an external tablet
* surface that is connected to the machine but is not a display (like a
* lower-end Wacom tablet connected over USB).
*
* Apps may use this information to decide if they should draw a cursor; if
* the pen is touching the screen directly, a cursor doesn't make sense and
* can be in the way, but becomes necessary for indirect devices to know where
* on the display they are interacting.
*
* \since This enum is available since SDL 3.4.0.
*/
typedef enum SDL_PenDeviceType
{
SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */
SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */
SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */
SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */
} SDL_PenDeviceType;
/**
* Get the device type of the given pen.
*
* Many platforms do not supply this information, so an app must always be
* prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result.
*
* \param instance_id the pen instance ID.
* \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID
* on failure; call SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_PenDeviceType SDLCALL SDL_GetPenDeviceType(SDL_PenID instance_id);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include <SDL3/SDL_close_code.h>
#endif /* SDL_pen_h_ */ #endif /* SDL_pen_h_ */

View File

@@ -451,7 +451,7 @@ typedef enum SDL_PackedLayout
* expressions with side-effects here. * expressions with side-effects here.
* *
* \param format an SDL_PixelFormat to check. * \param format an SDL_PixelFormat to check.
* \returns true if the format is 10-bit, false otherwise. * \returns true if the format is a floating point, false otherwise.
* *
* \threadsafety It is safe to call this macro from any thread. * \threadsafety It is safe to call this macro from any thread.
* *
@@ -1096,7 +1096,7 @@ typedef enum SDL_Colorspace
SDL_CHROMA_LOCATION_LEFT), */ SDL_CHROMA_LOCATION_LEFT), */
SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */
SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG /**< The default colorspace for YUV surfaces if no colorspace is specified */ SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED /**< The default colorspace for YUV surfaces if no colorspace is specified */
} SDL_Colorspace; } SDL_Colorspace;
/** /**
@@ -1379,7 +1379,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *for
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
* *
* \param pixel a pixel value. * \param pixelvalue a pixel value.
* \param format a pointer to SDL_PixelFormatDetails describing the pixel * \param format a pointer to SDL_PixelFormatDetails describing the pixel
* format. * format.
* \param palette an optional palette for indexed formats, may be NULL. * \param palette an optional palette for indexed formats, may be NULL.
@@ -1397,7 +1397,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *for
* \sa SDL_MapRGB * \sa SDL_MapRGB
* \sa SDL_MapRGBA * \sa SDL_MapRGBA
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b); extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b);
/** /**
* Get RGBA values from a pixel in the specified format. * Get RGBA values from a pixel in the specified format.
@@ -1410,7 +1410,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatD
* If the surface has no alpha component, the alpha will be returned as 0xff * If the surface has no alpha component, the alpha will be returned as 0xff
* (100% opaque). * (100% opaque).
* *
* \param pixel a pixel value. * \param pixelvalue a pixel value.
* \param format a pointer to SDL_PixelFormatDetails describing the pixel * \param format a pointer to SDL_PixelFormatDetails describing the pixel
* format. * format.
* \param palette an optional palette for indexed formats, may be NULL. * \param palette an optional palette for indexed formats, may be NULL.
@@ -1429,7 +1429,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatD
* \sa SDL_MapRGB * \sa SDL_MapRGB
* \sa SDL_MapRGBA * \sa SDL_MapRGBA
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */

View File

@@ -190,7 +190,7 @@
#if TARGET_OS_VISION #if TARGET_OS_VISION
/** /**
* A preprocessor macro that is only defined if compiling for VisionOS. * A preprocessor macro that is only defined if compiling for visionOS.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
* *
@@ -202,7 +202,7 @@
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
/** /**
* A preprocessor macro that is only defined if compiling for iOS. * A preprocessor macro that is only defined if compiling for iOS or visionOS.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
* *
@@ -317,7 +317,7 @@
#define SDL_PLATFORM_CYGWIN 1 #define SDL_PLATFORM_CYGWIN 1
#endif #endif
#if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) #if (defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(__NGAGE__)
/** /**
* A preprocessor macro that is only defined if compiling for Windows. * A preprocessor macro that is only defined if compiling for Windows.
@@ -473,4 +473,25 @@
#define SDL_PLATFORM_3DS 1 #define SDL_PLATFORM_3DS 1
#endif #endif
#ifdef __NGAGE__
/**
* A preprocessor macro that is only defined if compiling for the Nokia
* N-Gage.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_PLATFORM_NGAGE 1
#endif
#ifdef __GNU__
/**
* A preprocessor macro that is only defined if compiling for GNU/Hurd.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_PLATFORM_HURD 1
#endif
#endif /* SDL_platform_defines_h_ */ #endif /* SDL_platform_defines_h_ */

View File

@@ -88,8 +88,8 @@ typedef enum SDL_PowerState
* can't determine a value or there is no battery. * can't determine a value or there is no battery.
* \param percent a pointer filled in with the percentage of battery life * \param percent a pointer filled in with the percentage of battery life
* left, between 0 and 100, or NULL to ignore. This will be * left, between 0 and 100, or NULL to ignore. This will be
* filled in with -1 we can't determine a value or there is no * filled in with -1 when we can't determine a value or there
* battery. * is no battery.
* \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *

View File

@@ -166,6 +166,9 @@ typedef enum SDL_ProcessIO
* - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment * - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment
* pointer. If this property is set, it will be the entire environment for * pointer. If this property is set, it will be the entire environment for
* the process, otherwise the current environment is used. * the process, otherwise the current environment is used.
* - `SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING`: a UTF-8 encoded
* string representing the working directory for the process, defaults to
* the current working directory.
* - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing * - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing
* where standard input for the process comes from, defaults to * where standard input for the process comes from, defaults to
* `SDL_PROCESS_STDIO_NULL`. * `SDL_PROCESS_STDIO_NULL`.
@@ -192,6 +195,12 @@ typedef enum SDL_ProcessIO
* run in the background. In this case the default input and output is * run in the background. In this case the default input and output is
* `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not * `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not
* available, and will always be 0. * available, and will always be 0.
* - `SDL_PROP_PROCESS_CREATE_CMDLINE_STRING`: a string containing the program
* to run and any parameters. This string is passed directly to
* `CreateProcess` on Windows, and does nothing on other platforms. This
* property is only important if you want to start programs that does
* non-standard command-line processing, and in most cases using
* `SDL_PROP_PROCESS_CREATE_ARGS_POINTER` is sufficient.
* *
* On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and * On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and
* SIGCHLD should not be ignored or handled because those would prevent SDL * SIGCHLD should not be ignored or handled because those would prevent SDL
@@ -219,6 +228,7 @@ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_Pr
#define SDL_PROP_PROCESS_CREATE_ARGS_POINTER "SDL.process.create.args" #define SDL_PROP_PROCESS_CREATE_ARGS_POINTER "SDL.process.create.args"
#define SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER "SDL.process.create.environment" #define SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER "SDL.process.create.environment"
#define SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING "SDL.process.create.working_directory"
#define SDL_PROP_PROCESS_CREATE_STDIN_NUMBER "SDL.process.create.stdin_option" #define SDL_PROP_PROCESS_CREATE_STDIN_NUMBER "SDL.process.create.stdin_option"
#define SDL_PROP_PROCESS_CREATE_STDIN_POINTER "SDL.process.create.stdin_source" #define SDL_PROP_PROCESS_CREATE_STDIN_POINTER "SDL.process.create.stdin_source"
#define SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER "SDL.process.create.stdout_option" #define SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER "SDL.process.create.stdout_option"
@@ -227,6 +237,7 @@ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_Pr
#define SDL_PROP_PROCESS_CREATE_STDERR_POINTER "SDL.process.create.stderr_source" #define SDL_PROP_PROCESS_CREATE_STDERR_POINTER "SDL.process.create.stderr_source"
#define SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN "SDL.process.create.stderr_to_stdout" #define SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN "SDL.process.create.stderr_to_stdout"
#define SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN "SDL.process.create.background" #define SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN "SDL.process.create.background"
#define SDL_PROP_PROCESS_CREATE_CMDLINE_STRING "SDL.process.create.cmdline"
/** /**
* Get the properties associated with a process. * Get the properties associated with a process.

View File

@@ -59,7 +59,7 @@ extern "C" {
#endif #endif
/** /**
* SDL properties ID * An ID that represents a properties set.
* *
* \since This datatype is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
*/ */
@@ -80,6 +80,31 @@ typedef enum SDL_PropertyType
SDL_PROPERTY_TYPE_BOOLEAN SDL_PROPERTY_TYPE_BOOLEAN
} SDL_PropertyType; } SDL_PropertyType;
/**
* A generic property for naming things.
*
* This property is intended to be added to any SDL_PropertiesID that needs a
* generic name associated with the property set. It is not guaranteed that
* any property set will include this key, but it is convenient to have a
* standard key that any piece of code could reasonably agree to use.
*
* For example, the properties associated with an SDL_Texture might have a
* name string of "player sprites", or an SDL_AudioStream might have
* "background music", etc. This might also be useful for an SDL_IOStream to
* list the path to its asset.
*
* There is no format for the value set with this key; it is expected to be
* human-readable and informational in nature, possibly for logging or
* debugging purposes.
*
* SDL does not currently set this property on any objects it creates, but
* this may change in later versions; it is currently expected that apps and
* external libraries will take advantage of it, when appropriate.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_PROP_NAME_STRING "SDL.name"
/** /**
* Get the global SDL properties. * Get the global SDL properties.
* *
@@ -119,7 +144,9 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread. This
* function acquires simultaneous mutex locks on both the source
* and destination property sets.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */

View File

@@ -88,8 +88,11 @@ typedef struct SDL_Rect
/** /**
* A rectangle, with the origin at the upper left (using floating point * A rectangle stored using floating point values.
* values). *
* The origin of the coordinate space is in the top-left, with increasing
* values moving down and right. The properties `x` and `y` represent the
* coordinates of the top-left corner of the rectangle.
* *
* \since This struct is available since SDL 3.2.0. * \since This struct is available since SDL 3.2.0.
* *
@@ -125,10 +128,10 @@ typedef struct SDL_FRect
*/ */
SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect) SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect)
{ {
frect->x = (float)rect->x; frect->x = SDL_static_cast(float, rect->x);
frect->y = (float)rect->y; frect->y = SDL_static_cast(float, rect->y);
frect->w = (float)rect->w; frect->w = SDL_static_cast(float, rect->w);
frect->h = (float)rect->h; frect->h = SDL_static_cast(float, rect->h);
} }
/** /**
@@ -324,7 +327,7 @@ SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect
} }
/** /**
* Determine whether a floating point rectangle can contain any point. * Determine whether a floating point rectangle takes no space.
* *
* A rectangle is considered "empty" for this function if `r` is NULL, or if * A rectangle is considered "empty" for this function if `r` is NULL, or if
* `r`'s width and/or height are < 0.0f. * `r`'s width and/or height are < 0.0f.

View File

@@ -39,9 +39,9 @@
* may also be stretched with linear interpolation. * may also be stretched with linear interpolation.
* *
* This API is designed to accelerate simple 2D operations. You may want more * This API is designed to accelerate simple 2D operations. You may want more
* functionality such as polygons and particle effects and in that case you * functionality such as 3D polygons and particle effects, and in that case
* should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the * you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of
* many good 3D engines. * the many good 3D engines.
* *
* These functions must be called from the main thread. See this bug for * These functions must be called from the main thread. See this bug for
* details: https://github.com/libsdl-org/SDL/issues/986 * details: https://github.com/libsdl-org/SDL/issues/986
@@ -59,6 +59,7 @@
#include <SDL3/SDL_rect.h> #include <SDL3/SDL_rect.h>
#include <SDL3/SDL_surface.h> #include <SDL3/SDL_surface.h>
#include <SDL3/SDL_video.h> #include <SDL3/SDL_video.h>
#include <SDL3/SDL_gpu.h>
#include <SDL3/SDL_begin_code.h> #include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@@ -73,6 +74,13 @@ extern "C" {
*/ */
#define SDL_SOFTWARE_RENDERER "software" #define SDL_SOFTWARE_RENDERER "software"
/**
* The name of the GPU renderer.
*
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_GPU_RENDERER "gpu"
/** /**
* Vertex structure. * Vertex structure.
* *
@@ -97,6 +105,25 @@ typedef enum SDL_TextureAccess
SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
} SDL_TextureAccess; } SDL_TextureAccess;
/**
* The addressing mode for a texture when used in SDL_RenderGeometry().
*
* This affects how texture coordinates are interpreted outside of [0, 1]
*
* Texture wrapping is always supported for power of two texture sizes, and is
* supported for other texture sizes if
* SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN is set to true.
*
* \since This enum is available since SDL 3.4.0.
*/
typedef enum SDL_TextureAddressMode
{
SDL_TEXTURE_ADDRESS_INVALID = -1,
SDL_TEXTURE_ADDRESS_AUTO, /**< Wrapping is enabled if texture coordinates are outside [0, 1], this is the default */
SDL_TEXTURE_ADDRESS_CLAMP, /**< Texture coordinates are clamped to the [0, 1] range */
SDL_TEXTURE_ADDRESS_WRAP /**< The texture is repeated (tiled) */
} SDL_TextureAddressMode;
/** /**
* How the logical size is mapped to the output. * How the logical size is mapped to the output.
* *
@@ -106,7 +133,7 @@ typedef enum SDL_RendererLogicalPresentation
{ {
SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */ SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */ SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */ SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color */
SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */ SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */ SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */
} SDL_RendererLogicalPresentation; } SDL_RendererLogicalPresentation;
@@ -267,6 +294,17 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window
* present synchronized with the refresh rate. This property can take any * present synchronized with the refresh rate. This property can take any
* value that is supported by SDL_SetRenderVSync() for the renderer. * value that is supported by SDL_SetRenderVSync() for the renderer.
* *
* With the SDL GPU renderer (since SDL 3.4.0):
*
* - `SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER`: the device to use with the
* renderer, optional.
* - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN`: the app is able to
* provide SPIR-V shaders to SDL_GPURenderState, optional.
* - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN`: the app is able to
* provide DXIL shaders to SDL_GPURenderState, optional.
* - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN`: the app is able to
* provide MSL shaders to SDL_GPURenderState, optional.
*
* With the vulkan renderer: * With the vulkan renderer:
* *
* - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use
@@ -303,6 +341,10 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_
#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface" #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface"
#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace" #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace"
#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync" #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync"
#define SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER "SDL.renderer.create.gpu.device"
#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN "SDL.renderer.create.gpu.shaders_spirv"
#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN "SDL.renderer.create.gpu.shaders_dxil"
#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN "SDL.renderer.create.gpu.shaders_msl"
#define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance" #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance"
#define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface" #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface"
#define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device" #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device"
@@ -310,6 +352,53 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_
#define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index" #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index"
#define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index" #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index"
/**
* Create a 2D GPU rendering context.
*
* The GPU device to use is passed in as a parameter. If this is NULL, then a
* device will be created normally and can be retrieved using
* SDL_GetGPURendererDevice().
*
* The window to use is passed in as a parameter. If this is NULL, then this
* will become an offscreen renderer. In that case, you should call
* SDL_SetRenderTarget() to setup rendering to a texture, and then call
* SDL_RenderPresent() normally to complete drawing a frame.
*
* \param device the GPU device to use with the renderer, or NULL to create a
* device.
* \param window the window where rendering is displayed, or NULL to create an
* offscreen renderer.
* \returns a valid rendering context or NULL if there was an error; call
* SDL_GetError() for more information.
*
* \threadsafety If this function is called with a valid GPU device, it should
* be called on the thread that created the device. If this
* function is called with a valid window, it should be called
* on the thread that created the window.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_CreateRendererWithProperties
* \sa SDL_GetGPURendererDevice
* \sa SDL_CreateGPUShader
* \sa SDL_CreateGPURenderState
* \sa SDL_SetGPURenderState
*/
extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_GPUDevice *device, SDL_Window *window);
/**
* Return the GPU device used by a renderer.
*
* \param renderer the rendering context.
* \returns the GPU device used by the renderer, or NULL if the renderer is
* not a GPU renderer; call SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_GetGPURendererDevice(SDL_Renderer *renderer);
/** /**
* Create a 2D software rendering context for a surface. * Create a 2D software rendering context for a surface.
* *
@@ -323,7 +412,7 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_
* \returns a valid rendering context or NULL if there was an error; call * \returns a valid rendering context or NULL if there was an error; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety This function should only be called on the main thread. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -389,6 +478,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *rende
* - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *)
* array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN, * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
* representing the available texture formats for this renderer. * representing the available texture formats for this renderer.
* - `SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`: true if the renderer
* supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures.
* - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value
* describing the colorspace for output to the display, defaults to * describing the colorspace for output to the display, defaults to
* SDL_COLORSPACE_SRGB. * SDL_COLORSPACE_SRGB.
@@ -465,6 +556,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Rende
#define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync" #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"
#define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size" #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"
#define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats" #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats"
#define SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN "SDL.renderer.texture_wrapping"
#define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace" #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
#define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled" #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"
#define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point" #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"
@@ -601,6 +693,9 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende
* pixels, required * pixels, required
* - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
* pixels, required * pixels, required
* - `SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER`: an SDL_Palette to use with
* palettized texture formats. This can be set later with
* SDL_SetTexturePalette()
* - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating
* point textures, this defines the value of 100% diffuse white, with higher * point textures, this defines the value of 100% diffuse white, with higher
* values being displayed in the High Dynamic Range headroom. This defaults * values being displayed in the High Dynamic Range headroom. This defaults
@@ -677,6 +772,20 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if
* you want to wrap an existing texture. * you want to wrap an existing texture.
* *
* With the GPU renderer:
*
* - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture
* associated with the texture, if you want to wrap an existing texture.
* - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture
* associated with the UV plane of an NV12 texture, if you want to wrap an
* existing texture.
* - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture
* associated with the U plane of a YUV texture, if you want to wrap an
* existing texture.
* - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture
* associated with the V plane of a YUV texture, if you want to wrap an
* existing texture.
*
* \param renderer the rendering context. * \param renderer the rendering context.
* \param props the properties to use. * \param props the properties to use.
* \returns the created texture or NULL on failure; call SDL_GetError() for * \returns the created texture or NULL on failure; call SDL_GetError() for
@@ -695,29 +804,34 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende
*/ */
extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props); extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" #define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette"
#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture"
#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv"
#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u"
#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v"
/** /**
* Get the properties associated with a texture. * Get the properties associated with a texture.
@@ -797,6 +911,17 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Re
* - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
* texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc) * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
* *
* With the gpu renderer:
*
* - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated
* with the texture
* - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated
* with the UV plane of an NV12 texture
* - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated
* with the U plane of a YUV texture
* - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated
* with the V plane of a YUV texture
*
* \param texture the texture to query. * \param texture the texture to query.
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -833,6 +958,10 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Textur
#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
#define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture" #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
#define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture"
#define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv"
#define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u"
#define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v"
/** /**
* Get the renderer that created an SDL_Texture. * Get the renderer that created an SDL_Texture.
@@ -864,6 +993,43 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Textur
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h); extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
/**
* Set the palette used by a texture.
*
* Setting the palette keeps an internal reference to the palette, which can
* be safely destroyed afterwards.
*
* A single palette can be shared with many textures.
*
* \param texture the texture to update.
* \param palette the SDL_Palette structure to use.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_CreatePalette
* \sa SDL_GetTexturePalette
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette);
/**
* Get the palette used by a texture.
*
* \param texture the texture to query.
* \returns a pointer to the palette used by the texture, or NULL if there is
* no palette used.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_SetTexturePalette
*/
extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture);
/** /**
* Set an additional color value multiplied into render copy operations. * Set an additional color value multiplied into render copy operations.
* *
@@ -1386,14 +1552,6 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *rend
* specific dimensions but to make fonts look sharp, the app turns off logical * specific dimensions but to make fonts look sharp, the app turns off logical
* presentation while drawing text, for example. * presentation while drawing text, for example.
* *
* For the renderer's window, letterboxing is drawn into the framebuffer if
* logical presentation is enabled during SDL_RenderPresent; be sure to
* reenable it before presenting if you were toggling it, otherwise the
* letterbox areas might have artifacts from previous frames (or artifacts
* from external overlays, etc). Letterboxing is never drawn into texture
* render targets; be sure to call SDL_RenderClear() before drawing into the
* texture so the letterboxing areas are cleared, if appropriate.
*
* You can convert coordinates in an event into rendering coordinates using * You can convert coordinates in an event into rendering coordinates using
* SDL_ConvertEventToRenderCoordinates(). * SDL_ConvertEventToRenderCoordinates().
* *
@@ -1418,15 +1576,16 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *
* Get device independent resolution and presentation mode for rendering. * Get device independent resolution and presentation mode for rendering.
* *
* This function gets the width and height of the logical rendering output, or * This function gets the width and height of the logical rendering output, or
* the output size in pixels if a logical resolution is not enabled. * 0 if a logical resolution is not enabled.
* *
* Each render target has its own logical presentation state. This function * Each render target has its own logical presentation state. This function
* gets the state for the current render target. * gets the state for the current render target.
* *
* \param renderer the rendering context. * \param renderer the rendering context.
* \param w an int to be filled with the width. * \param w an int filled with the logical presentation width.
* \param h an int to be filled with the height. * \param h an int filled with the logical presentation height.
* \param mode the presentation mode used. * \param mode a variable filled with the logical presentation mode being
* used.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
@@ -1545,8 +1704,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *ren
* *
* \param renderer the rendering context. * \param renderer the rendering context.
* \param event the event to modify. * \param event the event to modify.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true if the event is converted or doesn't need conversion, or
* information. * false on failure; call SDL_GetError() for more information.
* *
* \threadsafety This function should only be called on the main thread. * \threadsafety This function should only be called on the main thread.
* *
@@ -2231,9 +2390,48 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer,
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_RenderTexture * \sa SDL_RenderTexture
* \sa SDL_RenderTexture9GridTiled
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect); extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect);
/**
* Perform a scaled copy using the 9-grid algorithm to the current rendering
* target at subpixel precision.
*
* The pixels in the texture are split into a 3x3 grid, using the different
* corner sizes for each corner, and the sides and center making up the
* remaining pixels. The corners are then scaled using `scale` and fit into
* the corners of the destination rectangle. The sides and center are then
* tiled into place to cover the remaining destination rectangle.
*
* \param renderer the renderer which should copy parts of a texture.
* \param texture the source texture.
* \param srcrect the SDL_Rect structure representing the rectangle to be used
* for the 9-grid, or NULL to use the entire texture.
* \param left_width the width, in pixels, of the left corners in `srcrect`.
* \param right_width the width, in pixels, of the right corners in `srcrect`.
* \param top_height the height, in pixels, of the top corners in `srcrect`.
* \param bottom_height the height, in pixels, of the bottom corners in
* `srcrect`.
* \param scale the scale used to transform the corner of `srcrect` into the
* corner of `dstrect`, or 0.0f for an unscaled copy.
* \param dstrect a pointer to the destination rectangle, or NULL for the
* entire rendering target.
* \param tileScale the scale used to transform the borders and center of
* `srcrect` into the borders and middle of `dstrect`, or
* 1.0f for an unscaled copy.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_RenderTexture
* \sa SDL_RenderTexture9Grid
*/
extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect, float tileScale);
/** /**
* Render a list of triangles, optionally using a texture and indices into the * Render a list of triangles, optionally using a texture and indices into the
* vertex array Color and alpha modulation is done per vertex * vertex array Color and alpha modulation is done per vertex
@@ -2255,6 +2453,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer,
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_RenderGeometryRaw * \sa SDL_RenderGeometryRaw
* \sa SDL_SetRenderTextureAddressMode
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
SDL_Texture *texture, SDL_Texture *texture,
@@ -2287,6 +2486,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_RenderGeometry * \sa SDL_RenderGeometry
* \sa SDL_SetRenderTextureAddressMode
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
SDL_Texture *texture, SDL_Texture *texture,
@@ -2296,6 +2496,44 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
int num_vertices, int num_vertices,
const void *indices, int num_indices, int size_indices); const void *indices, int num_indices, int size_indices);
/**
* Set the texture addressing mode used in SDL_RenderGeometry().
*
* \param renderer the rendering context.
* \param u_mode the SDL_TextureAddressMode to use for horizontal texture
* coordinates in SDL_RenderGeometry().
* \param v_mode the SDL_TextureAddressMode to use for vertical texture
* coordinates in SDL_RenderGeometry().
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_RenderGeometry
* \sa SDL_RenderGeometryRaw
* \sa SDL_GetRenderTextureAddressMode
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode u_mode, SDL_TextureAddressMode v_mode);
/**
* Get the texture addressing mode used in SDL_RenderGeometry().
*
* \param renderer the rendering context.
* \param u_mode a pointer filled in with the SDL_TextureAddressMode to use
* for horizontal texture coordinates in SDL_RenderGeometry(),
* may be NULL.
* \param v_mode a pointer filled in with the SDL_TextureAddressMode to use
* for vertical texture coordinates in SDL_RenderGeometry(), may
* be NULL.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_SetRenderTextureAddressMode
*/
extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode *u_mode, SDL_TextureAddressMode *v_mode);
/** /**
* Read pixels from the current rendering target. * Read pixels from the current rendering target.
* *
@@ -2347,8 +2585,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *ren
* should not be done; you are only required to change back the rendering * should not be done; you are only required to change back the rendering
* target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
* textures by themselves do not have a concept of backbuffers. Calling * textures by themselves do not have a concept of backbuffers. Calling
* SDL_RenderPresent while rendering to a texture will still update the screen * SDL_RenderPresent while rendering to a texture will fail.
* with any current drawing that has been done _to the window itself_.
* *
* \param renderer the rendering context. * \param renderer the rendering context.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
@@ -2577,8 +2814,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int
* Among these limitations: * Among these limitations:
* *
* - It accepts UTF-8 strings, but will only renders ASCII characters. * - It accepts UTF-8 strings, but will only renders ASCII characters.
* - It has a single, tiny size (8x8 pixels). One can use logical presentation * - It has a single, tiny size (8x8 pixels). You can use logical presentation
* or scaling to adjust it, but it will be blurry. * or SDL_SetRenderScale() to adjust it.
* - It uses a simple, hardcoded bitmap font. It does not allow different font * - It uses a simple, hardcoded bitmap font. It does not allow different font
* selections and it does not support truetype, for proper scaling. * selections and it does not support truetype, for proper scaling.
* - It does no word-wrapping and does not treat newline characters as a line * - It does no word-wrapping and does not treat newline characters as a line
@@ -2636,6 +2873,148 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, flo
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4); extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4);
/**
* Set default scale mode for new textures for given renderer.
*
* When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
*
* \param renderer the renderer to update.
* \param scale_mode the scale mode to change to for new textures.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_GetDefaultTextureScaleMode
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode);
/**
* Get default texture scale mode of the given renderer.
*
* \param renderer the renderer to get data from.
* \param scale_mode a SDL_ScaleMode filled with current default scale mode.
* See SDL_SetDefaultTextureScaleMode() for the meaning of
* the value.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_SetDefaultTextureScaleMode
*/
extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode);
/**
* A structure specifying the parameters of a GPU render state.
*
* \since This struct is available since SDL 3.4.0.
*
* \sa SDL_CreateGPURenderState
*/
typedef struct SDL_GPURenderStateCreateInfo
{
SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */
Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */
const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */
Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */
SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */
Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */
SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */
SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
} SDL_GPURenderStateCreateInfo;
/**
* A custom GPU render state.
*
* \since This struct is available since SDL 3.4.0.
*
* \sa SDL_CreateGPURenderState
* \sa SDL_SetGPURenderStateFragmentUniforms
* \sa SDL_SetGPURenderState
* \sa SDL_DestroyGPURenderState
*/
typedef struct SDL_GPURenderState SDL_GPURenderState;
/**
* Create custom GPU render state.
*
* \param renderer the renderer to use.
* \param createinfo a struct describing the GPU render state to create.
* \returns a custom GPU render state or NULL on failure; call SDL_GetError()
* for more information.
*
* \threadsafety This function should be called on the thread that created the
* renderer.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_SetGPURenderStateFragmentUniforms
* \sa SDL_SetGPURenderState
* \sa SDL_DestroyGPURenderState
*/
extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, SDL_GPURenderStateCreateInfo *createinfo);
/**
* Set fragment shader uniform variables in a custom GPU render state.
*
* The data is copied and will be pushed using
* SDL_PushGPUFragmentUniformData() during draw call execution.
*
* \param state the state to modify.
* \param slot_index the fragment uniform slot to push data to.
* \param data client data to write.
* \param length the length of the data to write.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should be called on the thread that created the
* renderer.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length);
/**
* Set custom GPU render state.
*
* This function sets custom GPU render state for subsequent draw calls. This
* allows using custom shaders with the GPU renderer.
*
* \param renderer the renderer to use.
* \param state the state to to use, or NULL to clear custom GPU render state.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should be called on the thread that created the
* renderer.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state);
/**
* Destroy custom GPU render state.
*
* \param state the state to destroy.
*
* \threadsafety This function should be called on the thread that created the
* renderer.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_CreateGPURenderState
*/
extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -31,9 +31,9 @@
/* #undef SDL_VENDOR_INFO */ /* #undef SDL_VENDOR_INFO */
#ifdef SDL_VENDOR_INFO #ifdef SDL_VENDOR_INFO
#define SDL_REVISION "SDL-3.2.24-release-3.2.24 (" SDL_VENDOR_INFO ")" #define SDL_REVISION "SDL-3.3.4-prerelease-3.3.4 (" SDL_VENDOR_INFO ")"
#else #else
#define SDL_REVISION "SDL-3.2.24-release-3.2.24" #define SDL_REVISION "SDL-3.3.4-prerelease-3.3.4"
#endif #endif
#endif /* SDL_revision_h_ */ #endif /* SDL_revision_h_ */

View File

@@ -49,10 +49,37 @@
#include <SDL3/SDL_platform_defines.h> #include <SDL3/SDL_platform_defines.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef int intptr_t;
#endif
#endif
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
defined(SDL_INCLUDE_INTTYPES_H) defined(SDL_INCLUDE_INTTYPES_H)
#include <inttypes.h> #include <inttypes.h>
@@ -492,7 +519,7 @@ typedef uint64_t Uint64;
* and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with * and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with
* SDL_TimeToWindows() and SDL_TimeFromWindows(). * SDL_TimeToWindows() and SDL_TimeFromWindows().
* *
* \since This macro is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
* *
* \sa SDL_MAX_SINT64 * \sa SDL_MAX_SINT64
* \sa SDL_MIN_SINT64 * \sa SDL_MIN_SINT64
@@ -1164,7 +1191,7 @@ typedef struct SDL_alignment_test
void *b; void *b;
} SDL_alignment_test; } SDL_alignment_test;
SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *))); SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *)));
SDL_COMPILE_TIME_ASSERT(two_s_complement, (int)~(int)0 == (int)(-1)); SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1));
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
/** \endcond */ /** \endcond */
@@ -2119,7 +2146,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_abs(int x);
* *
* \param x the first value to compare. * \param x the first value to compare.
* \param y the second value to compare. * \param y the second value to compare.
* \returns the lesser of `x` and `y`. * \returns the greater of `x` and `y`.
* *
* \threadsafety It is safe to call this macro from any thread. * \threadsafety It is safe to call this macro from any thread.
* *
@@ -2640,7 +2667,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwo
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
* *
* \sa SDL_zero * \sa SDL_zero
* \sa SDL_zeroa * \sa SDL_zerop
*/ */
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
@@ -4722,7 +4749,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
/** /**
* Compute the ceiling of `x`. * Compute the ceiling of `x`.
* *
* The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x` * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x`
* rounded up to the nearest integer. * rounded up to the nearest integer.
* *
* Domain: `-INF <= x <= INF` * Domain: `-INF <= x <= INF`
@@ -4750,7 +4777,7 @@ extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x);
/** /**
* Compute the ceiling of `x`. * Compute the ceiling of `x`.
* *
* The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x` * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x`
* rounded up to the nearest integer. * rounded up to the nearest integer.
* *
* Domain: `-INF <= x <= INF` * Domain: `-INF <= x <= INF`
@@ -4992,7 +5019,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x);
/** /**
* Compute the floor of `x`. * Compute the floor of `x`.
* *
* The floor of `x` is the largest integer `y` such that `y > x`, i.e `x` * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x`
* rounded down to the nearest integer. * rounded down to the nearest integer.
* *
* Domain: `-INF <= x <= INF` * Domain: `-INF <= x <= INF`
@@ -5020,7 +5047,7 @@ extern SDL_DECLSPEC double SDLCALL SDL_floor(double x);
/** /**
* Compute the floor of `x`. * Compute the floor of `x`.
* *
* The floor of `x` is the largest integer `y` such that `y > x`, i.e `x` * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x`
* rounded down to the nearest integer. * rounded down to the nearest integer.
* *
* Domain: `-INF <= x <= INF` * Domain: `-INF <= x <= INF`
@@ -5921,7 +5948,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1))
/** /**
* Convert a UTF-8 string to UCS-4. * Convert a UTF-8 string to UCS-4.
@@ -5935,7 +5962,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1))
/** /**
* Convert a wchar_t string to UTF-8. * Convert a wchar_t string to UTF-8.
@@ -5949,7 +5976,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t)) #define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t))
/* force builds using Clang's static analysis tools to use literal C runtime /* force builds using Clang's static analysis tools to use literal C runtime
@@ -5974,6 +6001,10 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
#endif #endif
#if !defined(HAVE_STRTOK_R) && !defined(strtok_r)
char *strtok_r(char *str, const char *delim, char **saveptr);
#endif
#ifndef _WIN32 #ifndef _WIN32
/* strdup is not ANSI but POSIX, and its prototype might be hidden... */ /* strdup is not ANSI but POSIX, and its prototype might be hidden... */
/* not for windows: might conflict with string.h where strdup may have /* not for windows: might conflict with string.h where strdup may have

View File

@@ -334,6 +334,10 @@ typedef struct SDL_Storage SDL_Storage;
/** /**
* Opens up a read-only container for the application's filesystem. * Opens up a read-only container for the application's filesystem.
* *
* By default, SDL_OpenTitleStorage uses the generic storage implementation.
* When the path override is not provided, the generic implementation will use
* the output of SDL_GetBasePath as the base path.
*
* \param override a path to override the backend's default title root. * \param override a path to override the backend's default title root.
* \param props a property list that may contain backend-specific information. * \param props a property list that may contain backend-specific information.
* \returns a title storage container on success or NULL on failure; call * \returns a title storage container on success or NULL on failure; call

View File

@@ -29,12 +29,16 @@
* provides a reasonable toolbox for transforming the data, including copying * provides a reasonable toolbox for transforming the data, including copying
* between surfaces, filling rectangles in the image data, etc. * between surfaces, filling rectangles in the image data, etc.
* *
* There is also a simple .bmp loader, SDL_LoadBMP(). SDL itself does not * There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png
* provide loaders for various other file formats, but there are several * loader, SDL_LoadPNG(). SDL itself does not provide loaders for other file
* excellent external libraries that do, including its own satellite library, * formats, but there are several excellent external libraries that do,
* SDL_image: * including its own satellite library,
* [SDL_image](https://wiki.libsdl.org/SDL3_image)
* .
* *
* https://github.com/libsdl-org/SDL_image * In general these functions are thread-safe in that they can be called on
* different threads with different surfaces. You should not try to modify any
* surface from two threads simultaneously.
*/ */
#ifndef SDL_surface_h_ #ifndef SDL_surface_h_
@@ -83,8 +87,9 @@ typedef Uint32 SDL_SurfaceFlags;
typedef enum SDL_ScaleMode typedef enum SDL_ScaleMode
{ {
SDL_SCALEMODE_INVALID = -1, SDL_SCALEMODE_INVALID = -1,
SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */ SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
SDL_SCALEMODE_LINEAR /**< linear filtering */ SDL_SCALEMODE_LINEAR, /**< linear filtering */
SDL_SCALEMODE_PIXELART /**< nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 */
} SDL_ScaleMode; } SDL_ScaleMode;
/** /**
@@ -94,9 +99,10 @@ typedef enum SDL_ScaleMode
*/ */
typedef enum SDL_FlipMode typedef enum SDL_FlipMode
{ {
SDL_FLIP_NONE, /**< Do not flip */ SDL_FLIP_NONE, /**< Do not flip */
SDL_FLIP_HORIZONTAL, /**< flip horizontally */ SDL_FLIP_HORIZONTAL, /**< flip horizontally */
SDL_FLIP_VERTICAL /**< flip vertically */ SDL_FLIP_VERTICAL, /**< flip vertically */
SDL_FLIP_HORIZONTAL_AND_VERTICAL = (SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL) /**< flip horizontally and vertically (not a diagonal flip) */
} SDL_FlipMode; } SDL_FlipMode;
#ifndef SDL_INTERNAL #ifndef SDL_INTERNAL
@@ -235,6 +241,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
* left edge of the image, if this surface is being used as a cursor. * left edge of the image, if this surface is being used as a cursor.
* - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the * - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the
* top edge of the image, if this surface is being used as a cursor. * top edge of the image, if this surface is being used as a cursor.
* - `SDL_PROP_SURFACE_ROTATION_NUMBER`: the number of degrees a surface's
* data is meant to be rotated clockwise to make the image right-side up.
* Default 0. This is used by the camera API, if a mobile device is oriented
* differently than what its camera provides (i.e. - the camera always
* provides portrait images but the phone is being held in landscape
* orientation). Since SDL 3.4.0.
* *
* \param surface the SDL_Surface structure to query. * \param surface the SDL_Surface structure to query.
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
@@ -251,6 +263,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac
#define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap" #define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap"
#define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x" #define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x"
#define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y" #define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y"
#define SDL_PROP_SURFACE_ROTATION_NUMBER "SDL.surface.rotation"
/** /**
* Set the colorspace used by a surface. * Set the colorspace used by a surface.
@@ -264,7 +277,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -283,7 +297,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface,
* \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if
* the surface is NULL. * the surface is NULL.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -313,7 +328,8 @@ extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface
* the surface didn't have an index format); call SDL_GetError() for * the surface didn't have an index format); call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -324,6 +340,9 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *
/** /**
* Set the palette used by a surface. * Set the palette used by a surface.
* *
* Setting the palette keeps an internal reference to the palette, which can
* be safely destroyed afterwards.
*
* A single palette can be shared with many surfaces. * A single palette can be shared with many surfaces.
* *
* \param surface the SDL_Surface structure to update. * \param surface the SDL_Surface structure to update.
@@ -331,7 +350,8 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -372,7 +392,8 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *sur
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -415,7 +436,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surf
* failure; call SDL_GetError() for more information. This should be * failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed. * freed with SDL_free() when it is no longer needed.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -433,7 +455,8 @@ extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *sur
* *
* \param surface the SDL_Surface structure to update. * \param surface the SDL_Surface structure to update.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -459,9 +482,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *s
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. The locking referred to by * \threadsafety This function can be called on different threads with
* this function is making the pixels available for direct * different surfaces. The locking referred to by this function
* access, not thread-safe locking. * is making the pixels available for direct access, not
* thread-safe locking.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -485,6 +509,46 @@ extern SDL_DECLSPEC bool SDLCALL SDL_LockSurface(SDL_Surface *surface);
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
/**
* Load a BMP or PNG image from a seekable SDL data stream.
*
* The new surface should be freed with SDL_DestroySurface(). Not doing so
* will result in a memory leak.
*
* \param src the data stream for the surface.
* \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
* in the case of an error.
* \returns a pointer to a new SDL_Surface structure or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_DestroySurface
* \sa SDL_LoadSurface
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface_IO(SDL_IOStream *src, bool closeio);
/**
* Load a BMP or PNG image from a file.
*
* The new surface should be freed with SDL_DestroySurface(). Not doing so
* will result in a memory leak.
*
* \param file the file to load.
* \returns a pointer to a new SDL_Surface structure or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_DestroySurface
* \sa SDL_LoadSurface_IO
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface(const char *file);
/** /**
* Load a BMP image from a seekable SDL data stream. * Load a BMP image from a seekable SDL data stream.
* *
@@ -543,7 +607,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -553,7 +618,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);
/** /**
* Save a surface to a file. * Save a surface to a file in BMP format.
* *
* Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
* BMP directly. Other RGB formats with 8-bit or higher get converted to a * BMP directly. Other RGB formats with 8-bit or higher get converted to a
@@ -566,7 +631,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStre
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -575,6 +641,94 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStre
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file); extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
/**
* Load a PNG image from a seekable SDL data stream.
*
* This is intended as a convenience function for loading images from trusted
* sources. If you want to load arbitrary images you should use libpng or
* another image loading library designed with security in mind.
*
* The new surface should be freed with SDL_DestroySurface(). Not doing so
* will result in a memory leak.
*
* \param src the data stream for the surface.
* \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
* in the case of an error.
* \returns a pointer to a new SDL_Surface structure or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_DestroySurface
* \sa SDL_LoadPNG
* \sa SDL_SavePNG_IO
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG_IO(SDL_IOStream *src, bool closeio);
/**
* Load a PNG image from a file.
*
* This is intended as a convenience function for loading images from trusted
* sources. If you want to load arbitrary images you should use libpng or
* another image loading library designed with security in mind.
*
* The new surface should be freed with SDL_DestroySurface(). Not doing so
* will result in a memory leak.
*
* \param file the PNG file to load.
* \returns a pointer to a new SDL_Surface structure or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_DestroySurface
* \sa SDL_LoadPNG_IO
* \sa SDL_SavePNG
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file);
/**
* Save a surface to a seekable SDL data stream in PNG format.
*
* \param surface the SDL_Surface structure containing the image to be saved.
* \param dst a data stream to save to.
* \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even
* in the case of an error.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function can be called on different threads with
* different surfaces.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_LoadPNG_IO
* \sa SDL_SavePNG
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);
/**
* Save a surface to a file in PNG format.
*
* \param surface the SDL_Surface structure containing the image to be saved.
* \param file a file to save to.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function can be called on different threads with
* different surfaces.
*
* \since This function is available since SDL 3.4.0.
*
* \sa SDL_LoadPNG
* \sa SDL_SavePNG_IO
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *file);
/** /**
* Set the RLE acceleration hint for a surface. * Set the RLE acceleration hint for a surface.
* *
@@ -586,7 +740,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *f
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -628,7 +783,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -693,7 +849,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -713,7 +870,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -735,7 +893,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -773,7 +932,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -812,7 +972,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, S
* \returns true if the rectangle intersects the surface, otherwise false and * \returns true if the rectangle intersects the surface, otherwise false and
* blits will be completely clipped. * blits will be completely clipped.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -833,7 +994,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, co
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -849,12 +1011,34 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SD
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip); extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
/**
* Return a copy of a surface rotated clockwise a number of degrees.
*
* The angle of rotation can be negative for counter-clockwise rotation.
*
* When the rotation isn't a multiple of 90 degrees, the resulting surface is
* larger than the original, with the background filled in with the colorkey,
* if available, or RGBA 255/255/255/0 if not.
*
* \param surface the surface to rotate.
* \param angle the rotation angle, in degrees.
* \returns a rotated copy of the surface or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function can be called on different threads with
* different surfaces.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface, float angle);
/** /**
* Creates a new surface identical to the existing surface. * Creates a new surface identical to the existing surface.
* *
@@ -867,7 +1051,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipM
* \returns a copy of the surface or NULL on failure; call SDL_GetError() for * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -888,7 +1073,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surf
* \returns a copy of the surface or NULL on failure; call SDL_GetError() for * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -915,7 +1101,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface,
* \returns the new SDL_Surface structure that is created or NULL on failure; * \returns the new SDL_Surface structure that is created or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -943,7 +1130,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surfac
* \returns the new SDL_Surface structure that is created or NULL on failure; * \returns the new SDL_Surface structure that is created or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1046,7 +1234,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1068,7 +1257,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surfac
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1093,7 +1283,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1120,7 +1311,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1411,7 +1603,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SD
* \param b the blue component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255.
* \returns a pixel value. * \returns a pixel value.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1444,7 +1637,8 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8
* \param a the alpha component of the pixel in the range 0-255. * \param a the alpha component of the pixel in the range 0-255.
* \returns a pixel value. * \returns a pixel value.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1475,7 +1669,8 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1501,7 +1696,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1526,7 +1722,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1548,7 +1745,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with
* different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */

View File

@@ -247,14 +247,14 @@ typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata);
* *
* For more information see: * For more information see:
* *
* https://wiki.libsdl.org/SDL3/README/ios * https://wiki.libsdl.org/SDL3/README-ios
* *
* Note that if you use the "main callbacks" instead of a standard C `main` * Note that if you use the "main callbacks" instead of a standard C `main`
* function, you don't have to use this API, as SDL will manage this for you. * function, you don't have to use this API, as SDL will manage this for you.
* *
* Details on main callbacks are here: * Details on main callbacks are here:
* *
* https://wiki.libsdl.org/SDL3/README/main-functions * https://wiki.libsdl.org/SDL3/README-main-functions
* *
* \param window the window for which the animation callback should be set. * \param window the window for which the animation callback should be set.
* \param interval the number of frames after which **callback** will be * \param interval the number of frames after which **callback** will be

View File

@@ -153,6 +153,10 @@ typedef struct
SDL_Rect confine; SDL_Rect confine;
bool hide_cursor; bool hide_cursor;
/* Misc. */
int quit_after_ms_interval;
SDL_TimerID quit_after_ms_timer;
/* Options info */ /* Options info */
SDLTest_ArgumentParser common_argparser; SDLTest_ArgumentParser common_argparser;
SDLTest_ArgumentParser video_argparser; SDLTest_ArgumentParser video_argparser;

View File

@@ -52,6 +52,7 @@ extern "C" {
* \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.
*/ */
int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error);
int SDLCALL SDLTest_CompareSurfacesIgnoreTransparentPixels(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error);
/** /**
* Compares 2 memory blocks for equality * Compares 2 memory blocks for equality

View File

@@ -37,7 +37,8 @@
* will report failure without doing anything. * will report failure without doing anything.
* *
* If you're going to work with threads, you almost certainly need to have a * If you're going to work with threads, you almost certainly need to have a
* good understanding of [CategoryMutex](CategoryMutex) as well. * good understanding of thread safety measures: locking and synchronization
* mechanisms are handled by the functions in SDL_mutex.h.
*/ */
#include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_stdinc.h>

View File

@@ -34,7 +34,7 @@
* This category covers measuring time elapsed (SDL_GetTicks(), * This category covers measuring time elapsed (SDL_GetTicks(),
* SDL_GetPerformanceCounter()), putting a thread to sleep for a certain * SDL_GetPerformanceCounter()), putting a thread to sleep for a certain
* amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing * amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing
* a callback function after a certain amount of time has elasped * a callback function after a certain amount of time has elapsed
* (SDL_AddTimer(), etc). * (SDL_AddTimer(), etc).
* *
* There are also useful macros to convert between time units, like * There are also useful macros to convert between time units, like
@@ -185,14 +185,18 @@ extern "C" {
#define SDL_NS_TO_US(NS) ((NS) / SDL_NS_PER_US) #define SDL_NS_TO_US(NS) ((NS) / SDL_NS_PER_US)
/** /**
* Get the number of milliseconds since SDL library initialization. * Get the number of milliseconds that have elapsed since the SDL library
* initialization.
* *
* \returns an unsigned 64-bit value representing the number of milliseconds * \returns an unsigned 64bit integer that represents the number of
* since the SDL library initialized. * milliseconds that have elapsed since the SDL library was
* initialized (typically via a call to SDL_Init).
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetTicksNS
*/ */
extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicks(void); extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicks(void);

View File

@@ -53,7 +53,7 @@ extern "C" {
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_MINOR_VERSION 2 #define SDL_MINOR_VERSION 3
/** /**
* The current micro (or patchlevel) version of the SDL headers. * The current micro (or patchlevel) version of the SDL headers.
@@ -62,7 +62,7 @@ extern "C" {
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_MICRO_VERSION 24 #define SDL_MICRO_VERSION 4
/** /**
* This macro turns the version numbers into a numeric value. * This macro turns the version numbers into a numeric value.
@@ -148,13 +148,14 @@ extern "C" {
extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void); extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void);
/** /**
* Get the code revision of SDL that is linked against your program. * Get the code revision of the SDL library that is linked against your
* program.
* *
* This value is the revision of the code you are linked with and may be * This value is the revision of the code you are linking against and may be
* different from the code you are compiling with, which is found in the * different from the code you are compiling with, which is found in the
* constant SDL_REVISION. * constant SDL_REVISION if you explicitly include SDL_revision.h
* *
* The revision is arbitrary string (a hash value) uniquely identifying the * The revision is an arbitrary string (a hash value) uniquely identifying the
* exact revision of the SDL library in use, and is only useful in comparing * exact revision of the SDL library in use, and is only useful in comparing
* against other revisions. It is NOT an incrementing number. * against other revisions. It is NOT an incrementing number.
* *

View File

@@ -97,6 +97,8 @@ typedef Uint32 SDL_WindowID;
* uninitialized will either return the user provided value, if one was set * uninitialized will either return the user provided value, if one was set
* prior to initialization, or NULL. See docs/README-wayland.md for more * prior to initialization, or NULL. See docs/README-wayland.md for more
* information. * information.
*
* \since This macro is available since SDL 3.2.0.
*/ */
#define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display" #define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display"
@@ -180,6 +182,12 @@ typedef struct SDL_Window SDL_Window;
* changed on existing windows by the app, and some of it might be altered by * changed on existing windows by the app, and some of it might be altered by
* the user or system outside of the app's control. * the user or system outside of the app's control.
* *
* When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain
* resizable windows to the dimensions recommended by the compositor to fit it
* within the usable desktop space, although some compositors will do this
* automatically without intervention as well. Use `SDL_SetWindowResizable`
* after creation instead if you wish to create a window with a specific size.
*
* \since This datatype is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
* *
* \sa SDL_GetWindowFlags * \sa SDL_GetWindowFlags
@@ -220,6 +228,8 @@ typedef Uint64 SDL_WindowFlags;
* SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY. * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
@@ -232,6 +242,8 @@ typedef Uint64 SDL_WindowFlags;
* \param X the SDL_DisplayID of the display to use. * \param X the SDL_DisplayID of the display to use.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
@@ -241,6 +253,8 @@ typedef Uint64 SDL_WindowFlags;
* This always uses the primary display. * This always uses the primary display.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
@@ -250,6 +264,8 @@ typedef Uint64 SDL_WindowFlags;
* \param X the window position value. * \param X the window position value.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) #define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
@@ -260,6 +276,8 @@ typedef Uint64 SDL_WindowFlags;
* SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY. * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
@@ -272,6 +290,8 @@ typedef Uint64 SDL_WindowFlags;
* \param X the SDL_DisplayID of the display to use. * \param X the SDL_DisplayID of the display to use.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
@@ -281,6 +301,8 @@ typedef Uint64 SDL_WindowFlags;
* This always uses the primary display. * This always uses the primary display.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/ */
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
@@ -290,6 +312,8 @@ typedef Uint64 SDL_WindowFlags;
* \param X the window position value. * \param X the window position value.
* *
* \since This macro is available since SDL 3.2.0. * \since This macro is available since SDL 3.2.0.
*
* \sa SDL_GetWindowPosition
*/ */
#define SDL_WINDOWPOS_ISCENTERED(X) \ #define SDL_WINDOWPOS_ISCENTERED(X) \
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
@@ -307,12 +331,30 @@ typedef enum SDL_FlashOperation
SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */ SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
} SDL_FlashOperation; } SDL_FlashOperation;
/**
* Window progress state
*
* \since This enum is available since SDL 3.2.8.
*/
typedef enum SDL_ProgressState
{
SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */
SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */
SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */
SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */
SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */
SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */
} SDL_ProgressState;
/** /**
* An opaque handle to an OpenGL context. * An opaque handle to an OpenGL context.
* *
* \since This datatype is available since SDL 3.2.0. * \since This datatype is available since SDL 3.2.0.
* *
* \sa SDL_GL_CreateContext * \sa SDL_GL_CreateContext
* \sa SDL_GL_SetAttribute
* \sa SDL_GL_MakeCurrent
* \sa SDL_GL_DestroyContext
*/ */
typedef struct SDL_GLContextState *SDL_GLContext; typedef struct SDL_GLContextState *SDL_GLContext;
@@ -448,7 +490,7 @@ typedef enum SDL_GLAttr
SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */ SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */
SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */ SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */
SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. */ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply! */
SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */ SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */
SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */ SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */
SDL_GL_CONTEXT_NO_ERROR, SDL_GL_CONTEXT_NO_ERROR,
@@ -530,7 +572,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
* to be proper names. * to be proper names.
* *
* \param index the index of a video driver. * \param index the index of a video driver.
* \returns the name of the video driver with the given **index**. * \returns the name of the video driver with the given **index**, or NULL if
* index is out of bounds.
* *
* \threadsafety This function should only be called on the main thread. * \threadsafety This function should only be called on the main thread.
* *
@@ -617,6 +660,16 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
* responsible for any coordinate transformations needed to conform to the * responsible for any coordinate transformations needed to conform to the
* requested display orientation. * requested display orientation.
* *
* On Wayland:
*
* - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated
* with the display
*
* On Windows:
*
* - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle
* (HMONITOR) associated with the display
*
* \param displayID the instance ID of the display to query. * \param displayID the instance ID of the display to query.
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -629,6 +682,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled" #define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation" #define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor"
/** /**
* Get the name of a display in UTF-8 encoding. * Get the name of a display in UTF-8 encoding.
@@ -1049,8 +1104,6 @@ extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count);
* *
* - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution
* - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
* - `SDL_WINDOW_OCCLUDED`: window partially or completely obscured by another
* window
* - `SDL_WINDOW_HIDDEN`: window is not visible * - `SDL_WINDOW_HIDDEN`: window is not visible
* - `SDL_WINDOW_BORDERLESS`: no window decoration * - `SDL_WINDOW_BORDERLESS`: no window decoration
* - `SDL_WINDOW_RESIZABLE`: window can be resized * - `SDL_WINDOW_RESIZABLE`: window can be resized
@@ -1078,7 +1131,8 @@ extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count);
* - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer
* - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable
* *
* The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set. * The SDL_Window will be shown if SDL_WINDOW_HIDDEN is not set. If hidden at
* creation time, SDL_ShowWindow() can be used to show it later.
* *
* On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
* property to YES, otherwise you will not receive a High-DPI OpenGL canvas. * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
@@ -1167,14 +1221,15 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int
* Popup windows implicitly do not have a border/decorations and do not appear * Popup windows implicitly do not have a border/decorations and do not appear
* on the taskbar/dock or in lists of windows such as alt-tab menus. * on the taskbar/dock or in lists of windows such as alt-tab menus.
* *
* By default, popup window positions will automatically be constrained to keep * By default, popup window positions will automatically be constrained to
* the entire window within display bounds. This can be overridden with the * keep the entire window within display bounds. This can be overridden with
* `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property. * the `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property.
* *
* By default, popup menus will automatically grab keyboard focus from the parent * By default, popup menus will automatically grab keyboard focus from the
* when shown. This behavior can be overridden by setting the `SDL_WINDOW_NOT_FOCUSABLE` * parent when shown. This behavior can be overridden by setting the
* flag, setting the `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or * `SDL_WINDOW_NOT_FOCUSABLE` flag, setting the
* toggling it after creation via the `SDL_SetWindowFocusable()` function. * `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or toggling
* it after creation via the `SDL_SetWindowFocusable()` function.
* *
* If a parent window is hidden or destroyed, any child popup windows will be * If a parent window is hidden or destroyed, any child popup windows will be
* recursively hidden or destroyed as well. Child popup windows not explicitly * recursively hidden or destroyed as well. Child popup windows not explicitly
@@ -1216,9 +1271,10 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
* be always on top * be always on top
* - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no
* window decoration * window decoration
* - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip" and * - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip"
* "menu" window types should be automatically constrained to be entirely within * and "menu" window types should be automatically constrained to be
* display bounds (default), false if no constraints on the position are desired. * entirely within display bounds (default), false if no constraints on the
* position are desired.
* - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the
* window will be used with an externally managed graphics context. * window will be used with an externally managed graphics context.
* - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should
@@ -1275,12 +1331,18 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
* - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)` * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)`
* NSView associated with the window, defaults to `[window contentView]` * NSView associated with the window, defaults to `[window contentView]`
* *
* These are additional supported properties on iOS, tvOS, and visionOS:
*
* - `SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER`: the `(__unsafe_unretained)`
* UIWindowScene associated with the window, defaults to the active window
* scene.
*
* These are additional supported properties on Wayland: * These are additional supported properties on Wayland:
* *
* - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if
* the application wants to use the Wayland surface for a custom role and * the application wants to use the Wayland surface for a custom role and
* does not want it attached to an XDG toplevel window. See * does not want it attached to an XDG toplevel window. See
* [README/wayland](README/wayland) for more information on using custom * [README-wayland](README-wayland) for more information on using custom
* surfaces. * surfaces.
* - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the
* application wants an associated `wl_egl_window` object to be created and * application wants an associated `wl_egl_window` object to be created and
@@ -1288,7 +1350,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
* property or `SDL_WINDOW_OPENGL` flag set. * property or `SDL_WINDOW_OPENGL` flag set.
* - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface
* associated with the window, if you want to wrap an existing window. See * associated with the window, if you want to wrap an existing window. See
* [README/wayland](README/wayland) for more information. * [README-wayland](README-wayland) for more information.
* *
* These are additional supported properties on Windows: * These are additional supported properties on Windows:
* *
@@ -1304,8 +1366,31 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren
* *
* The window is implicitly shown if the "hidden" property is not set. * The window is implicitly shown if the "hidden" property is not set.
* *
* Windows with the "tooltip" and "menu" properties are popup windows and have * These are additional supported properties with Emscripten:
* the behaviors and guidelines outlined in SDL_CreatePopupWindow(). *
* - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING`: the id given to the
* canvas element. This should start with a '#' sign
* - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_FILL_DOCUMENT_BOOLEAN`: true to make
* the canvas element fill the entire document. Resize events will be
* generated as the browser window is resized, as that will adjust the
* canvas size as well. The canvas will cover anything else on the page,
* including any controls provided by Emscripten in its generated HTML file.
* Often times this is desirable for a browser-based game, but it means
* several things that we expect of an SDL window on other platforms might
* not work as expected, such as minimum window sizes and aspect ratios.
* Default false.
* - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: override the
* binding element for keyboard inputs for this canvas. The variable can be
* one of:
* - "#window": the javascript window object (default)
* - "#document": the javascript document object
* - "#screen": the javascript window.screen object
* - "#canvas": the WebGL canvas element
* - "#none": Don't bind anything at all
* - any other string without a leading # sign applies to the element on the
* page with that ID. Windows with the "tooltip" and "menu" properties are
* popup windows and have the behaviors and guidelines outlined in
* SDL_CreatePopupWindow().
* *
* If this window is being created to be used with an SDL_Renderer, you should * If this window is being created to be used with an SDL_Renderer, you should
* not add a graphics API specific property * not add a graphics API specific property
@@ -1360,12 +1445,16 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_Prop
#define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y" #define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y"
#define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window" #define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window"
#define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view" #define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view"
#define SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER "SDL.window.create.uikit.windowscene"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom" #define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window" #define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface" #define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface"
#define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd" #define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd"
#define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd" #define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd"
#define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window" #define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window"
#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.create.emscripten.canvas_id"
#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_FILL_DOCUMENT_BOOLEAN "SDL.window.create.emscripten.fill_document"
#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.create.emscripten.keyboard_element"
/** /**
* Get the numeric ID of a window. * Get the numeric ID of a window.
@@ -1477,8 +1566,8 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
* *
* On OpenVR: * On OpenVR:
* *
* - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID`: the OpenVR Overlay Handle ID for the * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER`: the OpenVR Overlay Handle ID
* associated overlay window. * for the associated overlay window.
* *
* On Vivante: * On Vivante:
* *
@@ -1530,6 +1619,16 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
* - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the
* window * window
* *
* On Emscripten:
*
* - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING`: the id the canvas element
* will have
* - `SDL_PROP_WINDOW_EMSCRIPTEN_FILL_DOCUMENT_BOOLEAN`: true if the canvas is
* set to consume the entire browser window, bypassing some SDL window
* functionality.
* - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: the keyboard
* element that associates keyboard events to this window
*
* \param window the window to query. * \param window the window to query.
* \returns a valid property ID on success or 0 on failure; call * \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -1556,7 +1655,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window
#define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev" #define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev"
#define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window" #define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window"
#define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag" #define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag"
#define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID "SDL.window.openvr.overlay_id" #define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER "SDL.window.openvr.overlay_id"
#define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display" #define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display"
#define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window" #define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window"
#define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface" #define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface"
@@ -1575,6 +1674,9 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window
#define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display" #define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display"
#define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen" #define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen"
#define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window" #define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window"
#define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.emscripten.canvas_id"
#define SDL_PROP_WINDOW_EMSCRIPTEN_FILL_DOCUMENT_BOOLEAN "SDL.window.emscripten.fill_document"
#define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.emscripten.keyboard_element"
/** /**
* Get the window flags. * Get the window flags.
@@ -1632,15 +1734,16 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
/** /**
* Set the icon for a window. * Set the icon for a window.
* *
* If this function is passed a surface with alternate representations, the * If this function is passed a surface with alternate representations added
* surface will be interpreted as the content to be used for 100% display * using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as
* scale, and the alternate representations will be used for high DPI * the content to be used for 100% display scale, and the alternate
* situations. For example, if the original surface is 32x32, then on a 2x * representations will be used for high DPI situations. For example, if the
* macOS display or 200% display scale on Windows, a 64x64 version of the * original surface is 32x32, then on a 2x macOS display or 200% display scale
* image will be used, if available. If a matching version of the image isn't * on Windows, a 64x64 version of the image will be used, if available. If a
* available, the closest larger size image will be downscaled to the * matching version of the image isn't available, the closest larger size
* appropriate size and be used instead, if available. Otherwise, the closest * image will be downscaled to the appropriate size and be used instead, if
* smaller image will be upscaled and be used instead. * available. Otherwise, the closest smaller image will be upscaled and be
* used instead.
* *
* \param window the window to change. * \param window the window to change.
* \param icon an SDL_Surface structure containing the icon for the window. * \param icon an SDL_Surface structure containing the icon for the window.
@@ -1650,6 +1753,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
* \threadsafety This function should only be called on the main thread. * \threadsafety This function should only be called on the main thread.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*
* \sa SDL_AddSurfaceAlternateImage
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon); extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
@@ -1776,6 +1881,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, in
* \sa SDL_GetRenderOutputSize * \sa SDL_GetRenderOutputSize
* \sa SDL_GetWindowSizeInPixels * \sa SDL_GetWindowSizeInPixels
* \sa SDL_SetWindowSize * \sa SDL_SetWindowSize
* \sa SDL_EVENT_WINDOW_RESIZED
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h); extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
@@ -1843,7 +1949,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_R
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect); extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
/** /**
* Get the size of a window's client area. * Get the aspect ratio of a window's client area.
* *
* \param window the window to query the width and height from. * \param window the window to query the width and height from.
* \param min_aspect a pointer filled in with the minimum aspect ratio of the * \param min_aspect a pointer filled in with the minimum aspect ratio of the
@@ -2470,7 +2576,6 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, b
* *
* \sa SDL_GetWindowMouseRect * \sa SDL_GetWindowMouseRect
* \sa SDL_SetWindowMouseRect * \sa SDL_SetWindowMouseRect
* \sa SDL_SetWindowMouseGrab
* \sa SDL_SetWindowKeyboardGrab * \sa SDL_SetWindowKeyboardGrab
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed); extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed);
@@ -2815,6 +2920,62 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surf
*/ */
extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation); extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
/**
* Sets the state of the progress bar for the given windows taskbar icon.
*
* \param window the window whose progress state is to be modified.
* \param state the progress state. `SDL_PROGRESS_STATE_NONE` stops displaying
* the progress bar.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state);
/**
* Get the state of the progress bar for the given windows taskbar icon.
*
* \param window the window to get the current progress state from.
* \returns the progress state, or `SDL_PROGRESS_STATE_INVALID` on failure;
* call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window);
/**
* Sets the value of the progress bar for the given windows taskbar icon.
*
* \param window the window whose progress value is to be modified.
* \param value the progress value in the range of [0.0f - 1.0f]. If the value
* is outside the valid range, it gets clamped.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value);
/**
* Get the value of the progress bar for the given windows taskbar icon.
*
* \param window the window to get the current progress value from.
* \returns the progress value in the range of [0.0f - 1.0f], or -1.0f on
* failure; call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window);
/** /**
* Destroy a window. * Destroy a window.
* *
@@ -3050,8 +3211,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
* SDL_GL_GetAttribute() to check the values after creating the OpenGL * SDL_GL_GetAttribute() to check the values after creating the OpenGL
* context, since the values obtained can differ from the requested ones. * context, since the values obtained can differ from the requested ones.
* *
* \param attr an SDL_GLAttr enum value specifying the OpenGL attribute to * \param attr an enum value specifying the OpenGL attribute to set.
* set.
* \param value the desired value for the attribute. * \param value the desired value for the attribute.
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
@@ -3060,6 +3220,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
* \sa SDL_GL_CreateContext
* \sa SDL_GL_GetAttribute * \sa SDL_GL_GetAttribute
* \sa SDL_GL_ResetAttributes * \sa SDL_GL_ResetAttributes
*/ */
@@ -3086,6 +3247,12 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetAttribute(SDL_GLAttr attr, int *value
/** /**
* Create an OpenGL context for an OpenGL window, and make it current. * Create an OpenGL context for an OpenGL window, and make it current.
* *
* The OpenGL context will be created with the current states set through
* SDL_GL_SetAttribute().
*
* The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL
* flag, or context creation will fail.
*
* Windows users new to OpenGL should note that, for historical reasons, GL * Windows users new to OpenGL should note that, for historical reasons, GL
* functions added after OpenGL version 1.1 are not available by default. * functions added after OpenGL version 1.1 are not available by default.
* Those functions must be loaded at run-time, either with an OpenGL * Those functions must be loaded at run-time, either with an OpenGL

View File

@@ -51,6 +51,7 @@ namespace Flax.Deps.Dependencies
bool buildStatic = true; bool buildStatic = true;
var configs = new string[] var configs = new string[]
{ {
"-DSDL_TESTS=OFF",
"-DSDL_TEST_LIBRARY=OFF", "-DSDL_TEST_LIBRARY=OFF",
"-DSDL_CAMERA=OFF", "-DSDL_CAMERA=OFF",
"-DSDL_DIALOG=OFF", "-DSDL_DIALOG=OFF",
@@ -90,7 +91,7 @@ namespace Flax.Deps.Dependencies
CloneGitRepo(root, "https://github.com/libsdl-org/SDL"); CloneGitRepo(root, "https://github.com/libsdl-org/SDL");
GitFetch(root); GitFetch(root);
GitResetToCommit(root, "a8589a84226a6202831a3d49ff4edda4acab9acd"); // 3.2.24 GitResetToCommit(root, "f173fd28f04cb64ae054d6a97edb5d33925f539b"); // 3.3.4 preview
foreach (var platform in options.Platforms) foreach (var platform in options.Platforms)
{ {