dep: Update SDL2 to 2.24.2

This commit is contained in:
Connor McLaughlin 2022-11-10 18:55:32 +10:00
parent a6a52b31ad
commit fd807b14aa
97 changed files with 6507 additions and 1056 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -41,7 +41,9 @@
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_filesystem.h" #include "SDL_filesystem.h"
#include "SDL_gamecontroller.h" #include "SDL_gamecontroller.h"
#include "SDL_guid.h"
#include "SDL_haptic.h" #include "SDL_haptic.h"
#include "SDL_hidapi.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "SDL_loadso.h" #include "SDL_loadso.h"
@ -132,6 +134,8 @@ extern "C" {
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_InitSubSystem * \sa SDL_InitSubSystem
* \sa SDL_Quit * \sa SDL_Quit
* \sa SDL_SetMainReady * \sa SDL_SetMainReady
@ -148,6 +152,8 @@ extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init * \sa SDL_Init
* \sa SDL_Quit * \sa SDL_Quit
* \sa SDL_QuitSubSystem * \sa SDL_QuitSubSystem
@ -169,6 +175,8 @@ extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
* *
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details. * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_InitSubSystem * \sa SDL_InitSubSystem
* \sa SDL_Quit * \sa SDL_Quit
*/ */
@ -183,6 +191,8 @@ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
* *
* The return value does not include SDL_INIT_NOPARACHUTE. * The return value does not include SDL_INIT_NOPARACHUTE.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init * \sa SDL_Init
* \sa SDL_InitSubSystem * \sa SDL_InitSubSystem
*/ */
@ -205,6 +215,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
* application is shutdown, but it is not wise to do this from a library or * application is shutdown, but it is not wise to do this from a library or
* other dynamically loaded code. * other dynamically loaded code.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init * \sa SDL_Init
* \sa SDL_QuitSubSystem * \sa SDL_QuitSubSystem
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -22,7 +22,7 @@
#ifndef SDL_assert_h_ #ifndef SDL_assert_h_
#define SDL_assert_h_ #define SDL_assert_h_
#include "SDL_config.h" #include "SDL_stdinc.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -51,6 +51,8 @@ assert can have unique static variables associated with it.
/* Don't include intrin.h here because it contains C++ code */ /* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void); extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak() #define SDL_TriggerBreakpoint() __debugbreak()
#elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
#define SDL_TriggerBreakpoint() __builtin_debugtrap()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (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(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
@ -69,7 +71,7 @@ assert can have unique static variables associated with it.
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__ # define SDL_FUNCTION __func__
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__)) #elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__ # define SDL_FUNCTION __FUNCTION__
#else #else
# define SDL_FUNCTION "???" # define SDL_FUNCTION "???"
@ -217,6 +219,8 @@ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
* fails or NULL for the default handler * fails or NULL for the default handler
* \param userdata a pointer that is passed to `handler` * \param userdata a pointer that is passed to `handler`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAssertionHandler * \sa SDL_GetAssertionHandler
*/ */
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
@ -285,6 +289,8 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
* \returns a list of all failed assertions or NULL if the list is empty. This * \returns a list of all failed assertions or NULL if the list is empty. This
* memory should not be modified or freed by the application. * memory should not be modified or freed by the application.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ResetAssertionReport * \sa SDL_ResetAssertionReport
*/ */
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
@ -297,6 +303,8 @@ extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
* no items. In addition, any previously-triggered assertions will be reset to * no items. In addition, any previously-triggered assertions will be reset to
* a trigger_count of zero, and their always_ignore state will be false. * a trigger_count of zero, and their always_ignore state will be false.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAssertionReport * \sa SDL_GetAssertionReport
*/ */
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -98,6 +98,8 @@ typedef int SDL_SpinLock;
* \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already * \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already
* held. * held.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicLock * \sa SDL_AtomicLock
* \sa SDL_AtomicUnlock * \sa SDL_AtomicUnlock
*/ */
@ -111,6 +113,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
* *
* \param lock a pointer to a lock variable * \param lock a pointer to a lock variable
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicTryLock * \sa SDL_AtomicTryLock
* \sa SDL_AtomicUnlock * \sa SDL_AtomicUnlock
*/ */
@ -148,7 +152,7 @@ void _ReadWriteBarrier(void);
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
extern _inline void SDL_CompilerBarrier (void); extern __inline void SDL_CompilerBarrier(void);
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; #pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
#else #else
#define SDL_CompilerBarrier() \ #define SDL_CompilerBarrier() \
@ -173,6 +177,8 @@ extern _inline void SDL_CompilerBarrier (void);
* *
* For more information on these semantics, take a look at the blog post: * For more information on these semantics, take a look at the blog post:
* http://preshing.com/20120913/acquire-and-release-semantics * http://preshing.com/20120913/acquire-and-release-semantics
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
@ -231,6 +237,26 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
#endif #endif
#endif #endif
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
#elif (defined(__powerpc__) || defined(__powerpc64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
#define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
#define SDL_CPUPauseInstruction() __yield()
#elif defined(__WATCOMC__) && defined(__386__)
/* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */
extern __inline void SDL_CPUPauseInstruction(void);
#pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h"
#else
#define SDL_CPUPauseInstruction()
#endif
/** /**
* \brief A type representing an atomic integer value. It is a struct * \brief A type representing an atomic integer value. It is a struct
* so people don't accidentally use numeric operations on it. * so people don't accidentally use numeric operations on it.
@ -268,6 +294,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int
* \param v the desired value * \param v the desired value
* \returns the previous value of the atomic variable. * \returns the previous value of the atomic variable.
* *
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicGet * \sa SDL_AtomicGet
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
@ -281,6 +309,8 @@ extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
* \param a a pointer to an SDL_atomic_t variable * \param a a pointer to an SDL_atomic_t variable
* \returns the current value of an atomic variable. * \returns the current value of an atomic variable.
* *
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicSet * \sa SDL_AtomicSet
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
@ -297,6 +327,8 @@ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
* \param v the desired value to add * \param v the desired value to add
* \returns the previous value of the atomic variable. * \returns the previous value of the atomic variable.
* *
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicDecRef * \sa SDL_AtomicDecRef
* \sa SDL_AtomicIncRef * \sa SDL_AtomicIncRef
*/ */
@ -348,6 +380,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *
* \param v the desired pointer value * \param v the desired pointer value
* \returns the previous value of the pointer. * \returns the previous value of the pointer.
* *
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicCASPtr * \sa SDL_AtomicCASPtr
* \sa SDL_AtomicGetPtr * \sa SDL_AtomicGetPtr
*/ */
@ -362,6 +396,8 @@ extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
* \param a a pointer to a pointer * \param a a pointer to a pointer
* \returns the current value of a pointer. * \returns the current value of a pointer.
* *
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicCASPtr * \sa SDL_AtomicCASPtr
* \sa SDL_AtomicSetPtr * \sa SDL_AtomicSetPtr
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -172,7 +172,7 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
* 2: FL FR (stereo) * 2: FL FR (stereo)
* 3: FL FR LFE (2.1 surround) * 3: FL FR LFE (2.1 surround)
* 4: FL FR BL BR (quad) * 4: FL FR BL BR (quad)
* 5: FL FR FC BL BR (quad + center) * 5: FL FR LFE BL BR (4.1 surround)
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
* 7: FL FR FC LFE BC SL SR (6.1 surround) * 7: FL FR FC LFE BC SL SR (6.1 surround)
* 8: FL FR FC LFE BL BR SL SR (7.1 surround) * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
@ -253,7 +253,48 @@ typedef struct SDL_AudioCVT
* order that they are normally initialized by default. * order that they are normally initialized by default.
*/ */
/* @{ */ /* @{ */
/**
* Use this function to get the number of built-in audio drivers.
*
* This function returns a hardcoded number. This never returns a negative
* value; if there are no drivers compiled into this build of SDL, this
* function returns zero. The presence of a driver in this list does not mean
* it will function, it just means SDL is capable of interacting with that
* interface. For example, a build of SDL might have esound support, but if
* there's no esound server available, SDL's esound driver would fail if used.
*
* By default, SDL tries all drivers, in its preferred order, until one is
* found to be usable.
*
* \returns the number of built-in audio drivers.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioDriver
*/
extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
/**
* Use this function to get the name of a built in audio driver.
*
* The list of audio drivers is given in the order that they are normally
* initialized by default; the drivers that seem more reasonable to choose
* first (as far as the SDL developers believe) are earlier in the list.
*
* The names of drivers are all simple, low-ASCII identifiers, like "alsa",
* "coreaudio" or "xaudio2". These never have Unicode characters, and are not
* meant to be proper names.
*
* \param index the index of the audio driver; the value ranges from 0 to
* SDL_GetNumAudioDrivers() - 1
* \returns the name of the audio driver at the requested index, or NULL if an
* invalid index was specified.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumAudioDrivers
*/
extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
/* @} */ /* @} */
@ -265,7 +306,36 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
* use. You should normally use SDL_Init() or SDL_InitSubSystem(). * use. You should normally use SDL_Init() or SDL_InitSubSystem().
*/ */
/* @{ */ /* @{ */
/**
* Use this function to initialize a particular audio driver.
*
* This function is used internally, and should not be used unless you have a
* specific need to designate the audio driver you want to use. You should
* normally use SDL_Init() or SDL_InitSubSystem().
*
* \param driver_name the name of the desired audio driver
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AudioQuit
*/
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
/**
* Use this function to shut down audio if you initialized it with
* SDL_AudioInit().
*
* This function is used internally, and should not be used unless you have a
* specific need to specify the audio driver you want to use. You should
* normally use SDL_Quit() or SDL_QuitSubSystem().
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AudioInit
*/
extern DECLSPEC void SDLCALL SDL_AudioQuit(void); extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
/* @} */ /* @} */
@ -296,7 +366,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
* *
* This function is roughly equivalent to: * This function is roughly equivalent to:
* *
* ```c++ * ```c
* SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); * SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
* ``` * ```
* *
@ -327,6 +397,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
* audio device or failure to set up the audio thread; call * audio device or failure to set up the audio thread; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CloseAudio * \sa SDL_CloseAudio
* \sa SDL_LockAudio * \sa SDL_LockAudio
* \sa SDL_PauseAudio * \sa SDL_PauseAudio
@ -370,7 +442,7 @@ typedef Uint32 SDL_AudioDeviceID;
* should not be called for each iteration of a loop, but rather once at the * should not be called for each iteration of a loop, but rather once at the
* start of a loop: * start of a loop:
* *
* ```c++ * ```c
* // Don't do this: * // Don't do this:
* for (int i = 0; i < SDL_GetNumAudioDevices(0); i++) * for (int i = 0; i < SDL_GetNumAudioDevices(0); i++)
* *
@ -412,7 +484,10 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
* \returns the name of the audio device at the requested index, or NULL on * \returns the name of the audio device at the requested index, or NULL on
* error. * error.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumAudioDevices * \sa SDL_GetNumAudioDevices
* \sa SDL_GetDefaultAudioInfo
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
int iscapture); int iscapture);
@ -426,9 +501,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
* hardware. * hardware.
* *
* `spec` will be filled with the sample rate, sample format, and channel * `spec` will be filled with the sample rate, sample format, and channel
* count. All other values in the structure are filled with 0. When the * count.
* supported struct members are 0, SDL was unable to get the property from the
* backend.
* *
* \param index the index of the audio device; valid values range from 0 to * \param index the index of the audio device; valid values range from 0 to
* SDL_GetNumAudioDevices() - 1 * SDL_GetNumAudioDevices() - 1
@ -437,13 +510,51 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
* \param spec The SDL_AudioSpec to be initialized by this function. * \param spec The SDL_AudioSpec to be initialized by this function.
* \returns 0 on success, nonzero on error * \returns 0 on success, nonzero on error
* *
* \since This function is available since SDL 2.0.16.
*
* \sa SDL_GetNumAudioDevices * \sa SDL_GetNumAudioDevices
* \sa SDL_GetDefaultAudioInfo
*/ */
extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index, extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
int iscapture, int iscapture,
SDL_AudioSpec *spec); SDL_AudioSpec *spec);
/**
* Get the name and preferred format of the default audio device.
*
* Some (but not all!) platforms have an isolated mechanism to get information
* about the "default" device. This can actually be a completely different
* device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
* even be a network address! (This is discussed in SDL_OpenAudioDevice().)
*
* As a result, this call is not guaranteed to be performant, as it can query
* the sound server directly every time, unlike the other query functions. You
* should call this function sparingly!
*
* `spec` will be filled with the sample rate, sample format, and channel
* count, if a default device exists on the system. If `name` is provided,
* will be filled with either a dynamically-allocated UTF-8 string or NULL.
*
* \param name A pointer to be filled with the name of the default device (can
* be NULL). Please call SDL_free() when you are done with this
* pointer!
* \param spec The SDL_AudioSpec to be initialized by this function.
* \param iscapture non-zero to query the default recording device, zero to
* query the default output device.
* \returns 0 on success, nonzero on error
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetAudioDeviceName
* \sa SDL_GetAudioDeviceSpec
* \sa SDL_OpenAudioDevice
*/
extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
SDL_AudioSpec *spec,
int iscapture);
/** /**
* Open a specific audio device. * Open a specific audio device.
* *
@ -462,6 +573,19 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
* hostname/IP address for a remote audio server, or a filename in the * hostname/IP address for a remote audio server, or a filename in the
* diskaudio driver. * diskaudio driver.
* *
* An opened audio device starts out paused, and should be enabled for playing
* by calling SDL_PauseAudioDevice(devid, 0) when you are ready for your audio
* callback function to be called. Since the audio driver may modify the
* requested size of the audio buffer, you should allocate any local mixing
* buffers after you open the audio device.
*
* The audio callback runs in a separate thread in most cases; you can prevent
* race conditions between your callback and other threads without fully
* pausing playback with SDL_LockAudioDevice(). For more information about the
* callback, see SDL_AudioSpec.
*
* Managing the audio spec via 'desired' and 'obtained':
*
* When filling in the desired audio spec structure: * When filling in the desired audio spec structure:
* *
* - `desired->freq` should be the frequency in sample-frames-per-second (Hz). * - `desired->freq` should be the frequency in sample-frames-per-second (Hz).
@ -497,6 +621,7 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
* - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE` * - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
* - `SDL_AUDIO_ALLOW_FORMAT_CHANGE` * - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
* - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE` * - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
* - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
* - `SDL_AUDIO_ALLOW_ANY_CHANGE` * - `SDL_AUDIO_ALLOW_ANY_CHANGE`
* *
* These flags specify how SDL should behave when a device cannot offer a * These flags specify how SDL should behave when a device cannot offer a
@ -510,20 +635,12 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
* callback's float32 audio to int16 before feeding it to the hardware and * callback's float32 audio to int16 before feeding it to the hardware and
* will keep the originally requested format in the `obtained` structure. * will keep the originally requested format in the `obtained` structure.
* *
* The resulting audio specs, varying depending on hardware and on what
* changes were allowed, will then be written back to `obtained`.
*
* If your application can only handle one specific data format, pass a zero * If your application can only handle one specific data format, pass a zero
* for `allowed_changes` and let SDL transparently handle any differences. * for `allowed_changes` and let SDL transparently handle any differences.
* *
* An opened audio device starts out paused, and should be enabled for playing
* by calling SDL_PauseAudioDevice(devid, 0) when you are ready for your audio
* callback function to be called. Since the audio driver may modify the
* requested size of the audio buffer, you should allocate any local mixing
* buffers after you open the audio device.
*
* The audio callback runs in a separate thread in most cases; you can prevent
* race conditions between your callback and other threads without fully
* pausing playback with SDL_LockAudioDevice(). For more information about the
* callback, see SDL_AudioSpec.
*
* \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a * \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a
* driver-specific name as appropriate. NULL requests the most * driver-specific name as appropriate. NULL requests the most
* reasonable default device. * reasonable default device.
@ -570,7 +687,38 @@ typedef enum
SDL_AUDIO_PLAYING, SDL_AUDIO_PLAYING,
SDL_AUDIO_PAUSED SDL_AUDIO_PAUSED
} SDL_AudioStatus; } SDL_AudioStatus;
/**
* This function is a legacy means of querying the audio device.
*
* New programs might want to use SDL_GetAudioDeviceStatus() instead. This
* function is equivalent to calling...
*
* ```c
* SDL_GetAudioDeviceStatus(1);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \returns the SDL_AudioStatus of the audio device opened by SDL_OpenAudio().
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioDeviceStatus
*/
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
/**
* Use this function to get the current audio state of an audio device.
*
* \param dev the ID of an audio device previously opened with
* SDL_OpenAudioDevice()
* \returns the SDL_AudioStatus of the specified audio device.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PauseAudioDevice
*/
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
/* @} *//* Audio State */ /* @} *//* Audio State */
@ -584,7 +732,56 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDevice
* Silence will be written to the audio device during the pause. * Silence will be written to the audio device during the pause.
*/ */
/* @{ */ /* @{ */
/**
* This function is a legacy means of pausing the audio device.
*
* New programs might want to use SDL_PauseAudioDevice() instead. This
* function is equivalent to calling...
*
* ```c
* SDL_PauseAudioDevice(1, pause_on);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \param pause_on non-zero to pause, 0 to unpause
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioStatus
* \sa SDL_PauseAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
/**
* Use this function to pause and unpause audio playback on a specified
* device.
*
* This function pauses and unpauses the audio callback processing for a given
* device. Newly-opened audio devices start in the paused state, so you must
* call this function with **pause_on**=0 after opening the specified audio
* device to start playing sound. This allows you to safely initialize data
* for your callback function after opening the audio device. Silence will be
* written to the audio device while paused, and the audio callback is
* guaranteed to not be called. Pausing one device does not prevent other
* unpaused devices from running their callbacks.
*
* Pausing state does not stack; even if you pause a device several times, a
* single unpause will start the device playing again, and vice versa. This is
* different from how SDL_LockAudioDevice() works.
*
* If you just need to protect a few variables from race conditions vs your
* callback, you shouldn't pause the audio device, as it will lead to dropouts
* in the audio playback. Instead, you should use SDL_LockAudioDevice().
*
* \param dev a device opened by SDL_OpenAudioDevice()
* \param pause_on non-zero to pause, 0 to unpause
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
int pause_on); int pause_on);
/* @} *//* Pause audio functions */ /* @} *//* Pause audio functions */
@ -633,14 +830,14 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
* *
* Example: * Example:
* *
* ```c++ * ```c
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len); * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len);
* ``` * ```
* *
* Note that the SDL_LoadWAV macro does this same thing for you, but in a less * Note that the SDL_LoadWAV macro does this same thing for you, but in a less
* messy way: * messy way:
* *
* ```c++ * ```c
* SDL_LoadWAV("sample.wav", &spec, &buf, &len); * SDL_LoadWAV("sample.wav", &spec, &buf, &len);
* ``` * ```
* *
@ -665,6 +862,8 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
* When the application is done with the data returned in * When the application is done with the data returned in
* `audio_buf`, it should call SDL_FreeWAV() to dispose of it. * `audio_buf`, it should call SDL_FreeWAV() to dispose of it.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeWAV * \sa SDL_FreeWAV
* \sa SDL_LoadWAV * \sa SDL_LoadWAV
*/ */
@ -691,6 +890,8 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
* \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or * \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
* SDL_LoadWAV_RW() * SDL_LoadWAV_RW()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadWAV * \sa SDL_LoadWAV
* \sa SDL_LoadWAV_RW * \sa SDL_LoadWAV_RW
*/ */
@ -724,6 +925,8 @@ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
* or a negative error code on failure; call SDL_GetError() for more * or a negative error code on failure; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ConvertAudio * \sa SDL_ConvertAudio
*/ */
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
@ -768,6 +971,8 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
* \returns 0 if the conversion was completed successfully or a negative error * \returns 0 if the conversion was completed successfully or a negative error
* code on failure; call SDL_GetError() for more information. * code on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BuildAudioCVT * \sa SDL_BuildAudioCVT
*/ */
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
@ -794,6 +999,8 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
* \param dst_rate The sampling rate of the desired audio output * \param dst_rate The sampling rate of the desired audio output
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamAvailable
@ -816,6 +1023,8 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm
* \param len The number of bytes to write to the stream * \param len The number of bytes to write to the stream
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamAvailable
@ -833,6 +1042,8 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const vo
* \param len The maximum number of bytes to fill * \param len The maximum number of bytes to fill
* \returns the number of bytes read from the stream, or -1 on error * \returns the number of bytes read from the stream, or -1 on error
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamAvailable
@ -849,6 +1060,8 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *bu
* resample correctly, so this number might be lower than what you expect, or * resample correctly, so this number might be lower than what you expect, or
* even be zero. Add more data or flush the stream if you need the data now. * even be zero. Add more data or flush the stream if you need the data now.
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
@ -866,6 +1079,8 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
* audio gaps in the output. Generally this is intended to signal the end of * audio gaps in the output. Generally this is intended to signal the end of
* input, so the complete output becomes available. * input, so the complete output becomes available.
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
@ -878,6 +1093,8 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
/** /**
* Clear any pending data in the stream without converting it * Clear any pending data in the stream without converting it
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
@ -890,6 +1107,8 @@ extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
/** /**
* Free an audio stream * Free an audio stream
* *
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
@ -900,17 +1119,18 @@ extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
#define SDL_MIX_MAXVOLUME 128 #define SDL_MIX_MAXVOLUME 128
/** /**
* This function is a legacy means of mixing audio. * This function is a legacy means of mixing audio.
* *
* This function is equivalent to calling * This function is equivalent to calling...
* *
* ```c++ * ```c
* SDL_MixAudioFormat(dst, src, format, len, volume); * SDL_MixAudioFormat(dst, src, format, len, volume);
* ``` * ```
* *
* where `format` is the obtained format of the audio device from the legacy * ...where `format` is the obtained format of the audio device from the
* SDL_OpenAudio() function. * legacy SDL_OpenAudio() function.
* *
* \param dst the destination for the mixed audio * \param dst the destination for the mixed audio
* \param src the source audio buffer to be mixed * \param src the source audio buffer to be mixed
@ -918,6 +1138,8 @@ extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume * for full audio volume
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MixAudioFormat * \sa SDL_MixAudioFormat
*/ */
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
@ -950,6 +1172,8 @@ extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
* \param len the length of the audio buffer in bytes * \param len the length of the audio buffer in bytes
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume * for full audio volume
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
const Uint8 * src, const Uint8 * src,
@ -987,10 +1211,9 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
* You should not call SDL_LockAudio() on the device before queueing; SDL * You should not call SDL_LockAudio() on the device before queueing; SDL
* handles locking internally for this function. * handles locking internally for this function.
* *
* Note that SDL2 * Note that SDL2 does not support planar audio. You will need to resample
* [https://discourse.libsdl.org/t/sdl2-support-for-planar-audio/31263/3 does * from planar audio formats into a non-planar one (see SDL_AudioFormat)
* not support planar audio]. You will need to resample from planar audio * before queuing audio.
* formats into a non-planar one (see SDL_AudioFormat) before queuing audio.
* *
* \param dev the device ID to which we will queue audio * \param dev the device ID to which we will queue audio
* \param data the data to queue to the device for later playback * \param data the data to queue to the device for later playback
@ -1131,22 +1354,112 @@ extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
* function or you will cause deadlock. * function or you will cause deadlock.
*/ */
/* @{ */ /* @{ */
/**
* This function is a legacy means of locking the audio device.
*
* New programs might want to use SDL_LockAudioDevice() instead. This function
* is equivalent to calling...
*
* ```c
* SDL_LockAudioDevice(1);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockAudioDevice
* \sa SDL_UnlockAudio
* \sa SDL_UnlockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_LockAudio(void); extern DECLSPEC void SDLCALL SDL_LockAudio(void);
/**
* Use this function to lock out the audio callback function for a specified
* device.
*
* The lock manipulated by these functions protects the audio callback
* function specified in SDL_OpenAudioDevice(). During a
* SDL_LockAudioDevice()/SDL_UnlockAudioDevice() pair, you can be guaranteed
* that the callback function for that device is not running, even if the
* device is not paused. While a device is locked, any other unpaused,
* unlocked devices may still run their callbacks.
*
* Calling this function from inside your audio callback is unnecessary. SDL
* obtains this lock before calling your function, and releases it when the
* function returns.
*
* You should not hold the lock longer than absolutely necessary. If you hold
* it too long, you'll experience dropouts in your audio playback. Ideally,
* your application locks the device, sets a few variables and unlocks again.
* Do not do heavy work while holding the lock for a device.
*
* It is safe to lock the audio device multiple times, as long as you unlock
* it an equivalent number of times. The callback will not run until the
* device has been unlocked completely in this way. If your application fails
* to unlock the device appropriately, your callback will never run, you might
* hear repeating bursts of audio, and SDL_CloseAudioDevice() will probably
* deadlock.
*
* Internally, the audio device lock is a mutex; if you lock from two threads
* at once, not only will you block the audio callback, you'll block the other
* thread.
*
* \param dev the ID of the device to be locked
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_UnlockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
/**
* This function is a legacy means of unlocking the audio device.
*
* New programs might want to use SDL_UnlockAudioDevice() instead. This
* function is equivalent to calling...
*
* ```c
* SDL_UnlockAudioDevice(1);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockAudio
* \sa SDL_UnlockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
/**
* Use this function to unlock the audio callback function for a specified
* device.
*
* This function should be paired with a previous SDL_LockAudioDevice() call.
*
* \param dev the ID of the device to be unlocked
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
/* @} *//* Audio lock functions */ /* @} *//* Audio lock functions */
/** /**
* This function is a legacy means of closing the audio device. * This function is a legacy means of closing the audio device.
* *
* This function is equivalent to calling * This function is equivalent to calling...
* *
* ```c++ * ```c
* SDL_CloseAudioDevice(1); * SDL_CloseAudioDevice(1);
* ``` * ```
* *
* and is only useful if you used the legacy SDL_OpenAudio() function. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \since This function is available since SDL 2.0.0.
* *
* \sa SDL_OpenAudio * \sa SDL_OpenAudio
*/ */
@ -1170,6 +1483,8 @@ extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
* *
* \param dev an audio device previously opened with SDL_OpenAudioDevice() * \param dev an audio device previously opened with SDL_OpenAudioDevice()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_OpenAudioDevice * \sa SDL_OpenAudioDevice
*/ */
extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -48,7 +48,7 @@ extern "C" {
* \return the index of the most significant bit, or -1 if the value is 0. * \return the index of the most significant bit, or -1 if the value is 0.
*/ */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_bsr_watcom (Uint32); extern __inline int _SDL_bsr_watcom(Uint32);
#pragma aux _SDL_bsr_watcom = \ #pragma aux _SDL_bsr_watcom = \
"bsr eax, eax" \ "bsr eax, eax" \
parm [eax] nomemory \ parm [eax] nomemory \

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -67,9 +67,8 @@ typedef enum
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D9, D3D11 */
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D9, D3D11 */
} SDL_BlendOperation; } SDL_BlendOperation;
/** /**
@ -87,7 +86,6 @@ typedef enum
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
} SDL_BlendFactor; } SDL_BlendFactor;
/** /**
@ -135,10 +133,10 @@ typedef enum
* SDL 2.0.6. All renderers support the four blend modes listed in the * SDL 2.0.6. All renderers support the four blend modes listed in the
* SDL_BlendMode enumeration. * SDL_BlendMode enumeration.
* *
* - **direct3d**: Supports `SDL_BLENDOPERATION_ADD` with all factors. * - **direct3d**: Supports all operations with all factors. However, some
* - **direct3d11**: Supports all operations with all factors. However, some
* factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and * factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and
* `SDL_BLENDOPERATION_MAXIMUM`. * `SDL_BLENDOPERATION_MAXIMUM`.
* - **direct3d11**: Same as Direct3D 9.
* - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all * - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
* factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL * factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL
* 2.0.6. * 2.0.6.
@ -175,7 +173,7 @@ typedef enum
* \returns an SDL_BlendMode that represents the chosen factors and * \returns an SDL_BlendMode that represents the chosen factors and
* operations. * operations.
* *
* \since This function is available in SDL 2.0.6. * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_SetRenderDrawBlendMode * \sa SDL_SetRenderDrawBlendMode
* \sa SDL_GetRenderDrawBlendMode * \sa SDL_GetRenderDrawBlendMode

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -45,6 +45,8 @@ extern "C" {
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetClipboardText * \sa SDL_GetClipboardText
* \sa SDL_HasClipboardText * \sa SDL_HasClipboardText
*/ */
@ -53,12 +55,15 @@ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
/** /**
* Get UTF-8 text from the clipboard, which must be freed with SDL_free(). * Get UTF-8 text from the clipboard, which must be freed with SDL_free().
* *
* This functions returns NULL if there was not enough memory left for a copy * This functions returns empty string if there was not enough memory left for
* of the clipboard's content. * a copy of the clipboard's content.
* *
* \returns the clipboard text on success or NULL on failure; call * \returns the clipboard text on success or an empty string on failure; call
* SDL_GetError() for more information. Caller must call SDL_free() * SDL_GetError() for more information. Caller must call SDL_free()
* on the returned pointer when done with it. * on the returned pointer when done with it (even if there was an
* error).
*
* \since This function is available since SDL 2.0.0.
* *
* \sa SDL_HasClipboardText * \sa SDL_HasClipboardText
* \sa SDL_SetClipboardText * \sa SDL_SetClipboardText

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -33,16 +33,22 @@
#include "SDL_config_windows.h" #include "SDL_config_windows.h"
#elif defined(__WINRT__) #elif defined(__WINRT__)
#include "SDL_config_winrt.h" #include "SDL_config_winrt.h"
#elif defined(__WINGDK__)
#include "SDL_config_wingdk.h"
#elif defined(__XBOXONE__) || defined(__XBOXSERIES__)
#include "SDL_config_xbox.h"
#elif defined(__MACOSX__) #elif defined(__MACOSX__)
#include "SDL_config_macosx.h" #include "SDL_config_macosx.h"
#elif defined(__IPHONEOS__) #elif defined(__IPHONEOS__)
#include "SDL_config_iphoneos.h" #include "SDL_config_iphoneos.h"
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
#include "SDL_config_android.h" #include "SDL_config_android.h"
#elif defined(__PSP__)
#include "SDL_config_psp.h"
#elif defined(__OS2__) #elif defined(__OS2__)
#include "SDL_config_os2.h" #include "SDL_config_os2.h"
#elif defined(__EMSCRIPTEN__)
#include "SDL_config_emscripten.h"
#elif defined(__NGAGE__)
#include "SDL_config_ngage.h"
#else #else
/* This is a minimal configuration just to get SDL running on new platforms. */ /* This is a minimal configuration just to get SDL running on new platforms. */
#include "SDL_config_minimal.h" #include "SDL_config_minimal.h"

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -48,6 +48,7 @@
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
/* C library functions */ /* C library functions */
#define HAVE_DLOPEN 1
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
@ -59,6 +60,7 @@
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
@ -142,7 +144,7 @@
/* Enable various audio drivers */ /* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_ANDROID 1 #define SDL_AUDIO_DRIVER_ANDROID 1
#define SDL_AUDIO_DRIVER_OPENSLES 1 #define SDL_AUDIO_DRIVER_OPENSLES 1
#define SDL_AUDIO_DRIVER_AAUDIO 0 #define SDL_AUDIO_DRIVER_AAUDIO 1
#define SDL_AUDIO_DRIVER_DUMMY 1 #define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */ /* Enable various input drivers */

View file

@ -0,0 +1,218 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
#ifndef _SDL_config_emscripten_h_
#define _SDL_config_emscripten_h_
#include "SDL_platform.h"
/**
* \file SDL_config_emscripten.h
*
* This is a configuration that can be used to build SDL for Emscripten.
*/
#ifdef __LP64__
#define SIZEOF_VOIDP 8
#else
#define SIZEOF_VOIDP 4
#endif
#define HAVE_GCC_ATOMICS 1
/* Useful headers */
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_ICONV_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MATH_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_WCHAR_H 1
/* C library functions */
#define HAVE_DLOPEN 1
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_WCSLEN 1
#define HAVE_WCSDUP 1
#define HAVE_WCSSTR 1
#define HAVE_WCSCMP 1
#define HAVE_WCSNCMP 1
#define HAVE_WCSCASECMP 1
#define HAVE_WCSNCASECMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOK_R 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_SSCANF 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#define HAVE_FSEEKO 1
#define HAVE_FSEEKO64 1
#define HAVE_SIGACTION 1
#define HAVE_SA_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1
#define HAVE_CLOCK_GETTIME 1
/* #undef HAVE_GETPAGESIZE */
#define HAVE_MPROTECT 1
#define HAVE_ICONV 1
/* SDL internal assertion support */
/* #undef SDL_DEFAULT_ASSERT_LEVEL */
#define SDL_CPUINFO_DISABLED 1
#define SDL_HAPTIC_DISABLED 1
#define SDL_HIDAPI_DISABLED 1
#ifndef __EMSCRIPTEN_PTHREADS__
#define SDL_THREADS_DISABLED 1
#endif
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1
/* Enable various input drivers */
#define SDL_JOYSTICK_EMSCRIPTEN 1
/* Enable various sensor drivers */
#define SDL_SENSOR_DUMMY 1
/* Enable various shared object loading systems */
#define SDL_LOADSO_DLOPEN 1
/* Enable various threading systems */
#ifdef __EMSCRIPTEN_PTHREADS__
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
#endif
/* Enable various timer systems */
#define SDL_TIMER_UNIX 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1
#define SDL_VIDEO_RENDER_OGL_ES2 1
/* Enable OpenGL support */
/* #undef SDL_VIDEO_OPENGL */
/* #undef SDL_VIDEO_OPENGL_ES */
#define SDL_VIDEO_OPENGL_ES2 1
/* #undef SDL_VIDEO_OPENGL_BGL */
/* #undef SDL_VIDEO_OPENGL_CGL */
/* #undef SDL_VIDEO_OPENGL_GLX */
/* #undef SDL_VIDEO_OPENGL_WGL */
#define SDL_VIDEO_OPENGL_EGL 1
/* #undef SDL_VIDEO_OPENGL_OSMESA */
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
/* Enable system power support */
#define SDL_POWER_EMSCRIPTEN 1
/* Enable system filesystem support */
#define SDL_FILESYSTEM_EMSCRIPTEN 1
#endif /* _SDL_config_emscripten_h_ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -48,6 +48,7 @@
/* #undef HAVE_LIBUNWIND_H */ /* #undef HAVE_LIBUNWIND_H */
/* C library functions */ /* C library functions */
#define HAVE_DLOPEN 1
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
@ -59,6 +60,7 @@
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
@ -116,7 +118,7 @@
#define HAVE_LROUNDF 1 #define HAVE_LROUNDF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1 #define HAVE_POWF 1
#define HAVE_ROUND 1 #define HAVE_ROUND 1
#define HAVE_ROUNDF 1 #define HAVE_ROUNDF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1 #define HAVE_SCALBNF 1
@ -133,6 +135,7 @@
#define HAVE_NANOSLEEP 1 #define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1 #define HAVE_SYSCONF 1
#define HAVE_SYSCTLBYNAME 1 #define HAVE_SYSCTLBYNAME 1
#define HAVE_O_CLOEXEC 1
/* enable iPhone version of Core Audio driver */ /* enable iPhone version of Core Audio driver */
#define SDL_AUDIO_DRIVER_COREAUDIO 1 #define SDL_AUDIO_DRIVER_COREAUDIO 1

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -52,6 +52,7 @@
#define HAVE_LIBUNWIND_H 1 #define HAVE_LIBUNWIND_H 1
/* C library functions */ /* C library functions */
#define HAVE_DLOPEN 1
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
@ -62,6 +63,7 @@
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
@ -119,7 +121,7 @@
#define HAVE_LROUNDF 1 #define HAVE_LROUNDF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1 #define HAVE_POWF 1
#define HAVE_ROUND 1 #define HAVE_ROUND 1
#define HAVE_ROUNDF 1 #define HAVE_ROUNDF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1 #define HAVE_SCALBNF 1
@ -143,6 +145,10 @@
# endif # endif
#endif #endif
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
#define HAVE_O_CLOEXEC 1
#endif
#define HAVE_GCC_ATOMICS 1 #define HAVE_GCC_ATOMICS 1
/* Enable various audio drivers */ /* Enable various audio drivers */
@ -180,17 +186,13 @@
#undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/opt/X11/lib/libX11.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/opt/X11/lib/libX11.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/opt/X11/lib/libXext.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/opt/X11/lib/libXext.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/opt/X11/lib/libXinerama.1.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/opt/X11/lib/libXi.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/opt/X11/lib/libXi.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/opt/X11/lib/libXrandr.2.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/opt/X11/lib/libXrandr.2.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/opt/X11/lib/libXss.1.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/opt/X11/lib/libXss.1.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/opt/X11/lib/libXxf86vm.1.dylib"
#define SDL_VIDEO_DRIVER_X11_XDBE 1 #define SDL_VIDEO_DRIVER_X11_XDBE 1
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
#define SDL_VIDEO_DRIVER_X11_XRANDR 1 #define SDL_VIDEO_DRIVER_X11_XRANDR 1
#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 #define SDL_VIDEO_DRIVER_X11_XSHAPE 1
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
#ifdef MAC_OS_X_VERSION_10_8 #ifdef MAC_OS_X_VERSION_10_8
@ -201,7 +203,6 @@
*/ */
#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 #define SDL_VIDEO_DRIVER_X11_XINPUT2 1
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
#endif #endif
#ifndef SDL_VIDEO_RENDER_OGL #ifndef SDL_VIDEO_RENDER_OGL
@ -268,7 +269,6 @@
#define SDL_FILESYSTEM_COCOA 1 #define SDL_FILESYSTEM_COCOA 1
/* Enable assembly routines */ /* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
#ifdef __ppc__ #ifdef __ppc__
#define SDL_ALTIVEC_BLITTERS 1 #define SDL_ALTIVEC_BLITTERS 1
#endif #endif

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -49,6 +49,7 @@ typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t; typedef unsigned long uintptr_t;
#else #else
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#define HAVE_INTTYPES_H 1
#endif /* Visual Studio 2008 */ #endif /* Visual Studio 2008 */
#ifdef __GNUC__ #ifdef __GNUC__
@ -64,6 +65,9 @@ typedef unsigned long uintptr_t;
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1 #define SDL_HAPTIC_DISABLED 1
/* Enable the stub HIDAPI */
#define SDL_HIDAPI_DISABLED 1
/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ /* Enable the stub sensor driver (src/sensor/dummy/\*.c) */
#define SDL_SENSOR_DISABLED 1 #define SDL_SENSOR_DISABLED 1

View file

@ -0,0 +1,89 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
#ifndef SDL_config_ngage_h_
#define SDL_config_ngage_h_
#define SDL_config_h_
#include "SDL_platform.h"
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t;
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_MATH_H 1
#define HAVE_CEIL 1
#define HAVE_COPYSIGN 1
#define HAVE_COS 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_SCALBN 1
#define HAVE_SIN 1
#define HAVE_SQRT 1
#define HAVE_TAN 1
#define HAVE_MALLOC 1
#define SDL_MAIN_NEEDED 1
#define LACKS_SYS_MMAN_H 1
/* Enable the N-Gage thread support (src/thread/ngage/\*.c) */
#define SDL_THREAD_NGAGE 1
/* Enable the N-Gage timer support (src/timer/ngage/\*.c) */
#define SDL_TIMER_NGAGE 1
/* Enable the N-Gage video driver (src/video/ngage/\*.c) */
#define SDL_VIDEO_DRIVER_NGAGE 1
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
#define SDL_JOYSTICK_DISABLED 1
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
/* Enable the stub HIDAPI */
#define SDL_HIDAPI_DISABLED 1
/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */
#define SDL_SENSOR_DISABLED 1
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
#define SDL_FILESYSTEM_DUMMY 1
#endif /* SDL_config_ngage_h_ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -33,14 +33,21 @@
#define SDL_POWER_DISABLED 1 #define SDL_POWER_DISABLED 1
#define SDL_HAPTIC_DISABLED 1 #define SDL_HAPTIC_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1
/*#undef SDL_JOYSTICK_OS2 */
/*#undef SDL_JOYSTICK_HIDAPI */
/*#undef SDL_JOYSTICK_VIRTUAL */
#define SDL_SENSOR_DUMMY 1 #define SDL_SENSOR_DUMMY 1
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_OS2 1 #define SDL_VIDEO_DRIVER_OS2 1
#define SDL_JOYSTICK_OS2 1
#ifndef HAVE_LIBUSB_H /* see Makefile */
#define SDL_HIDAPI_DISABLED 1
/*#undef SDL_JOYSTICK_HIDAPI */
#else
#define SDL_JOYSTICK_HIDAPI 1
#define HAVE_LIBUSB 1
/* dynamically loaded libusb-1.0 dll: */
#define SDL_LIBUSB_DYNAMIC "usb100.dll"
#endif
/*#undef SDL_JOYSTICK_VIRTUAL */
/* Enable OpenGL support */ /* Enable OpenGL support */
/* #undef SDL_VIDEO_OPENGL */ /* #undef SDL_VIDEO_OPENGL */
@ -50,9 +57,6 @@
#define SDL_TIMER_OS2 1 #define SDL_TIMER_OS2 1
#define SDL_FILESYSTEM_OS2 1 #define SDL_FILESYSTEM_OS2 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
/* use libsamplerate for audio rate conversion. */ /* use libsamplerate for audio rate conversion. */
/*#define HAVE_LIBSAMPLERATE_H 1 */ /*#define HAVE_LIBSAMPLERATE_H 1 */
@ -61,25 +65,32 @@
#define HAVE_LIBC 1 #define HAVE_LIBC 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#define HAVE_STDIO_H 1 #define HAVE_STDIO_H 1
#define STDC_HEADERS 1 #define STDC_HEADERS 1
#define HAVE_STDLIB_H 1 #define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_MALLOC_H 1 #define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1 #define HAVE_STRINGS_H 1
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
#define HAVE_INTTYPES_H 1 #define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
#define HAVE_CTYPE_H 1 #define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
#define HAVE_FLOAT_H 1 #define HAVE_FLOAT_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#if 0 /* see Makefile */
#define HAVE_ICONV 1
#define HAVE_ICONV_H 1
#endif
/* #undef HAVE_DLOPEN */
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
@ -92,7 +103,11 @@
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
/* OpenWatcom requires specific calling conventions for qsort and bsearch */
#ifndef __WATCOMC__
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#endif
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -54,6 +54,7 @@
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#define HAVE_DLOPEN 1
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
@ -64,6 +65,7 @@
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1

View file

@ -1,165 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 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.
*/
#ifndef SDL_config_psp_h_
#define SDL_config_psp_h_
#define SDL_config_h_
#include "SDL_platform.h"
#ifdef __GNUC__
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
#endif
#define HAVE_GCC_ATOMICS 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_SETENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE_STRLCPY 1
#define HAVE_STRLCAT 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
/* #define HAVE_SYSCONF 1 */
/* #define HAVE_SIGACTION 1 */
/* PSP isn't that sophisticated */
#define LACKS_SYS_MMAN_H 1
/* Enable the PSP thread support (src/thread/psp/\*.c) */
#define SDL_THREAD_PSP 1
/* Enable the PSP timer support (src/timer/psp/\*.c) */
#define SDL_TIMERS_PSP 1
/* Enable the PSP joystick driver (src/joystick/psp/\*.c) */
#define SDL_JOYSTICK_PSP 1
#define SDL_JOYSTICK_VIRTUAL 1
/* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1
/* Enable the PSP audio driver (src/audio/psp/\*.c) */
#define SDL_AUDIO_DRIVER_PSP 1
/* PSP video driver */
#define SDL_VIDEO_DRIVER_PSP 1
/* PSP render driver */
#define SDL_VIDEO_RENDER_PSP 1
#define SDL_POWER_PSP 1
/* !!! FIXME: what does PSP do for filesystem stuff? */
#define SDL_FILESYSTEM_DUMMY 1
/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
/* PSP can't load shared object (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
#endif /* SDL_config_psp_h_ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -25,10 +25,35 @@
#include "SDL_platform.h" #include "SDL_platform.h"
/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK,
* but out of caution we'll only use it if the compiler supports __has_include() to confirm its presence.
* If your compiler doesn't support __has_include() but you have winsdkver.h, define HAVE_WINSDKVER_H. */
#if !defined(HAVE_WINSDKVER_H) && defined(__has_include)
#if __has_include(<winsdkver.h>)
#define HAVE_WINSDKVER_H 1
#endif
#endif
#ifdef HAVE_WINSDKVER_H
#include <winsdkver.h>
#endif
/* sdkddkver.h defines more specific SDK version numbers. This is needed because older versions of the
* Windows 10 SDK have broken declarations for the C API for DirectX 12. */
#if !defined(HAVE_SDKDDKVER_H) && defined(__has_include)
#if __has_include(<sdkddkver.h>)
#define HAVE_SDKDDKVER_H 1
#endif
#endif
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__clang__) #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__clang__) || defined(__BORLANDC__) || defined(__CODEGEARC__)
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;
@ -77,14 +102,34 @@ typedef unsigned int uintptr_t;
# define SIZEOF_VOIDP 4 # define SIZEOF_VOIDP 4
#endif #endif
#ifdef __clang__
# define HAVE_GCC_ATOMICS 1
#endif
#define HAVE_DDRAW_H 1 #define HAVE_DDRAW_H 1
#define HAVE_DINPUT_H 1 #define HAVE_DINPUT_H 1
#define HAVE_DSOUND_H 1 #define HAVE_DSOUND_H 1
#ifndef __WATCOMC__
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1 #define HAVE_XINPUT_H 1
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
#define HAVE_WINDOWS_GAMING_INPUT_H 1
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0602 /* Windows 8 SDK */
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
#endif
#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */
#define HAVE_D3D12_H 1
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
#define HAVE_SHELLSCALINGAPI_H 1
#endif
#define HAVE_MMDEVICEAPI_H 1 #define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1 #define HAVE_AUDIOCLIENT_H 1
#define HAVE_TPCSHRD_H 1
#define HAVE_SENSORSAPI_H 1 #define HAVE_SENSORSAPI_H 1
#endif
#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600) #if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600)
#define HAVE_IMMINTRIN_H 1 #define HAVE_IMMINTRIN_H 1
#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64)) #elif defined(__has_include) && (defined(__i386__) || defined(__x86_64))
@ -111,7 +156,11 @@ typedef unsigned int uintptr_t;
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1 #define HAVE_ALLOCA 1
/* OpenWatcom requires specific calling conventions for qsort and bsearch */
#ifndef __WATCOMC__
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#endif
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
#define HAVE_MEMCPY 1 #define HAVE_MEMCPY 1
@ -142,37 +191,40 @@ typedef unsigned int uintptr_t;
#define HAVE__WCSNICMP 1 #define HAVE__WCSNICMP 1
#define HAVE__WCSDUP 1 #define HAVE__WCSDUP 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1 #define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1 #define HAVE_ATAN2 1
#define HAVE_CEIL 1
#define HAVE_COS 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_FMOD 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_POW 1
#define HAVE_SIN 1
#define HAVE_SQRT 1
#define HAVE_TAN 1
#ifndef __WATCOMC__
#define HAVE_ACOSF 1
#define HAVE_ASINF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1 #define HAVE_ATAN2F 1
#define HAVE_CEILF 1 #define HAVE_CEILF 1
#define HAVE__COPYSIGN 1 #define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1 #define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1 #define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1 #define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1 #define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1 #define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1 #define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1 #define HAVE_POWF 1
#define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1 #define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1 #define HAVE_TANF 1
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */ /* These functions were added with the VC++ 2013 C runtime library */
#if _MSC_VER >= 1800 #if _MSC_VER >= 1800
@ -192,8 +244,18 @@ typedef unsigned int uintptr_t;
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
#define HAVE__FSEEKI64 1 #define HAVE__FSEEKI64 1
#endif #endif
#ifdef _USE_MATH_DEFINES
#define HAVE_M_PI 1
#endif #endif
#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) #elif defined(__WATCOMC__)
#define HAVE__FSEEKI64 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_VSSCANF 1
#define HAVE_ROUND 1
#define HAVE_SCALBN 1
#define HAVE_TRUNC 1
#else
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#endif #endif
#else #else
@ -201,22 +263,10 @@ typedef unsigned int uintptr_t;
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#endif #endif
/* Check to see if we have Windows 10 build environment */
#if defined(_MSC_VER) && (_MSC_VER >= 1911) /* Visual Studio 15.3 */
#include <sdkddkver.h>
#if _WIN32_WINNT >= 0x0601 /* Windows 7 */
#define SDL_WINDOWS7_SDK
#endif
#if _WIN32_WINNT >= 0x0602 /* Windows 8 */
#define SDL_WINDOWS8_SDK
#endif
#if _WIN32_WINNT >= 0x0A00 /* Windows 10 */
#define SDL_WINDOWS10_SDK
#endif
#endif /* _MSC_VER >= 1911 */
/* Enable various audio drivers */ /* Enable various audio drivers */
#if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)
#define SDL_AUDIO_DRIVER_WASAPI 1 #define SDL_AUDIO_DRIVER_WASAPI 1
#endif
#define SDL_AUDIO_DRIVER_DSOUND 1 #define SDL_AUDIO_DRIVER_DSOUND 1
#define SDL_AUDIO_DRIVER_WINMM 1 #define SDL_AUDIO_DRIVER_WINMM 1
#define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DISK 1
@ -229,7 +279,7 @@ typedef unsigned int uintptr_t;
#define SDL_JOYSTICK_RAWINPUT 1 #define SDL_JOYSTICK_RAWINPUT 1
#endif #endif
#define SDL_JOYSTICK_VIRTUAL 1 #define SDL_JOYSTICK_VIRTUAL 1
#ifdef SDL_WINDOWS10_SDK #ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_WGI 1 #define SDL_JOYSTICK_WGI 1
#endif #endif
#define SDL_JOYSTICK_XINPUT 1 #define SDL_JOYSTICK_XINPUT 1
@ -237,7 +287,11 @@ typedef unsigned int uintptr_t;
#define SDL_HAPTIC_XINPUT 1 #define SDL_HAPTIC_XINPUT 1
/* Enable the sensor driver */ /* Enable the sensor driver */
#ifdef HAVE_SENSORSAPI_H
#define SDL_SENSOR_WINDOWS 1 #define SDL_SENSOR_WINDOWS 1
#else
#define SDL_SENSOR_DUMMY 1
#endif
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1 #define SDL_LOADSO_WINDOWS 1
@ -256,9 +310,12 @@ typedef unsigned int uintptr_t;
#ifndef SDL_VIDEO_RENDER_D3D #ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1 #define SDL_VIDEO_RENDER_D3D 1
#endif #endif
#ifdef SDL_WINDOWS7_SDK #if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1 #define SDL_VIDEO_RENDER_D3D11 1
#endif #endif
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
#define SDL_VIDEO_RENDER_D3D12 1
#endif
/* Enable OpenGL support */ /* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL #ifndef SDL_VIDEO_OPENGL
@ -289,11 +346,6 @@ typedef unsigned int uintptr_t;
/* Enable filesystem support */ /* Enable filesystem support */
#define SDL_FILESYSTEM_WINDOWS 1 #define SDL_FILESYSTEM_WINDOWS 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* SDL_config_windows_h_ */ #endif /* SDL_config_windows_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,285 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
#ifndef SDL_config_wingdk_h_
#define SDL_config_wingdk_h_
#define SDL_config_h_
#include "SDL_platform.h"
/* Windows GDK does not need Windows SDK version checks because it requires
* a recent version of the Windows 10 SDK. */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
/* At this time, only recent MSVC or clang are supported by Windows GDK */
#if defined(__clang__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
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 _UINTPTR_T_DEFINED
typedef unsigned __int64 uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
#else /* !__clang__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __clang__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
/* GDK only supports 64-bit */
# define SIZEOF_VOIDP 8
#ifdef __clang__
# define HAVE_GCC_ATOMICS 1
#endif
#define HAVE_DDRAW_H 1
#define HAVE_DINPUT_H 1
#define HAVE_DSOUND_H 1
/* No SDK version checks needed for these because the SDK has to be new. */
#define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1
#define HAVE_WINDOWS_GAMING_INPUT_H 1
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
#define HAVE_D3D12_H 1
#define HAVE_SHELLSCALINGAPI_H 1
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_TPCSHRD_H 1
#define HAVE_SENSORSAPI_H 1
#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600)
#define HAVE_IMMINTRIN_H 1
#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64))
# if __has_include(<immintrin.h>)
# define HAVE_IMMINTRIN_H 1
# endif
#endif
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
#ifdef HAVE_LIBC
/* Useful headers */
#define STDC_HEADERS 1
#define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__STRUPR */
/* #undef HAVE__STRLWR */
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
/* #undef HAVE_STRTOK_R */
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__LTOA */
/* #undef HAVE__ULTOA */
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE__WCSICMP 1
#define HAVE__WCSNICMP 1
#define HAVE__WCSDUP 1
#define HAVE_ACOS 1
#define HAVE_ASIN 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_CEIL 1
#define HAVE_COS 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_FMOD 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_POW 1
#define HAVE_SIN 1
#define HAVE_SQRT 1
#define HAVE_TAN 1
#define HAVE_ACOSF 1
#define HAVE_ASINF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1
#define HAVE_COSF 1
#define HAVE_EXPF 1
#define HAVE_FABSF 1
#define HAVE_FLOORF 1
#define HAVE_FMODF 1
#define HAVE_LOGF 1
#define HAVE_LOG10F 1
#define HAVE_POWF 1
#define HAVE_SINF 1
#define HAVE_SQRTF 1
#define HAVE_TANF 1
#if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_VSSCANF 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#define HAVE__FSEEKI64 1
#ifdef _USE_MATH_DEFINES
#define HAVE_M_PI 1
#endif
#else
#define HAVE_M_PI 1
#endif
#else
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#endif
/* Enable various audio drivers */
#if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)
#define SDL_AUDIO_DRIVER_WASAPI 1
#endif
#define SDL_AUDIO_DRIVER_DSOUND 1
#define SDL_AUDIO_DRIVER_WINMM 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
#define SDL_JOYSTICK_DINPUT 1
#define SDL_JOYSTICK_HIDAPI 1
#define SDL_JOYSTICK_RAWINPUT 1
#define SDL_JOYSTICK_VIRTUAL 1
#ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_WGI 1
#endif
#define SDL_JOYSTICK_XINPUT 1
#define SDL_HAPTIC_DINPUT 1
#define SDL_HAPTIC_XINPUT 1
/* Enable the sensor driver */
#ifdef HAVE_SENSORSAPI_H
#define SDL_SENSOR_WINDOWS 1
#else
#define SDL_SENSOR_DUMMY 1
#endif
/* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */
#define SDL_THREAD_GENERIC_COND_SUFFIX 1
#define SDL_THREAD_WINDOWS 1
/* Enable various timer systems */
#define SDL_TIMER_WINDOWS 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDOWS 1
#ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1
#endif
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
#define SDL_VIDEO_RENDER_D3D12 1
#endif
/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_WGL
#define SDL_VIDEO_OPENGL_WGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
#ifndef SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_OPENGL_ES2 1
#endif
#ifndef SDL_VIDEO_OPENGL_EGL
#define SDL_VIDEO_OPENGL_EGL 1
#endif
/* Enable Vulkan support */
#define SDL_VIDEO_VULKAN 1
/* Enable system power support */
#define SDL_POWER_WINDOWS 1
/* Enable filesystem support */
#define SDL_FILESYSTEM_WINDOWS 1
#endif /* SDL_config_wingdk_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -92,6 +92,10 @@ typedef unsigned int uintptr_t;
# define SIZEOF_VOIDP 4 # define SIZEOF_VOIDP 4
#endif #endif
#ifdef __clang__
# define HAVE_GCC_ATOMICS 1
#endif
/* Useful headers */ /* Useful headers */
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
@ -100,6 +104,7 @@ typedef unsigned int uintptr_t;
#define HAVE_MMDEVICEAPI_H 1 #define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1 #define HAVE_AUDIOCLIENT_H 1
#define HAVE_TPCSHRD_H 1
#define HAVE_LIBC 1 #define HAVE_LIBC 1
#define STDC_HEADERS 1 #define STDC_HEADERS 1
@ -118,6 +123,7 @@ typedef unsigned int uintptr_t;
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1 #define HAVE_ALLOCA 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
#define HAVE_MEMCPY 1 #define HAVE_MEMCPY 1
@ -190,6 +196,8 @@ typedef unsigned int uintptr_t;
#define HAVE_TRUNCF 1 #define HAVE_TRUNCF 1
#define HAVE__FSEEKI64 1 #define HAVE__FSEEKI64 1
#define HAVE_ROAPI_H 1
/* Enable various audio drivers */ /* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_WASAPI 1 #define SDL_AUDIO_DRIVER_WASAPI 1
#define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DISK 1
@ -201,10 +209,18 @@ typedef unsigned int uintptr_t;
#define SDL_HAPTIC_DISABLED 1 #define SDL_HAPTIC_DISABLED 1
#else #else
#define SDL_JOYSTICK_VIRTUAL 1 #define SDL_JOYSTICK_VIRTUAL 1
#if (NTDDI_VERSION >= NTDDI_WIN10)
#define SDL_JOYSTICK_WGI 1
#define SDL_HAPTIC_DISABLED 1
#else
#define SDL_JOYSTICK_XINPUT 1 #define SDL_JOYSTICK_XINPUT 1
#define SDL_HAPTIC_XINPUT 1 #define SDL_HAPTIC_XINPUT 1
#endif /* WIN10 */
#endif #endif
/* WinRT doesn't have HIDAPI available */
#define SDL_HIDAPI_DISABLED 1
/* Enable the dummy sensor driver */ /* Enable the dummy sensor driver */
#define SDL_SENSOR_DUMMY 1 #define SDL_SENSOR_DUMMY 1
@ -234,6 +250,9 @@ typedef unsigned int uintptr_t;
/* Enable appropriate renderer(s) */ /* Enable appropriate renderer(s) */
#define SDL_VIDEO_RENDER_D3D11 1 #define SDL_VIDEO_RENDER_D3D11 1
/* Disable D3D12 as it's not implemented for WinRT */
#define SDL_VIDEO_RENDER_D3D12 0
#if SDL_VIDEO_OPENGL_ES2 #if SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1 #define SDL_VIDEO_RENDER_OGL_ES2 1
#endif #endif
@ -241,9 +260,4 @@ typedef unsigned int uintptr_t;
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_WINRT 1 #define SDL_POWER_WINRT 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* SDL_config_winrt_h_ */ #endif /* SDL_config_winrt_h_ */

View file

@ -1,153 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 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.
*/
#ifndef SDL_config_wiz_h_
#define SDL_config_wiz_h_
#define SDL_config_h_
/* This is a set of defines to configure the SDL features */
/* General platform specific identifiers */
#include "SDL_platform.h"
#define SDL_BYTEORDER 1234
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1
#define HAVE_ICONV_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MATH_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_STRLEN 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOK_R 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#define HAVE_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
#define HAVE_POW 1
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_OSS 1
#define SDL_INPUT_LINUXEV 1
#define SDL_JOYSTICK_LINUX 1
#define SDL_JOYSTICK_VIRTUAL 1
#define SDL_HAPTIC_LINUX 1
#define SDL_SENSOR_DUMMY 1
#define SDL_LOADSO_DLOPEN 1
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
#define SDL_TIMER_UNIX 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_PANDORA 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_OPENGL_ES 1
#endif /* SDL_config_wiz_h_ */

View file

@ -0,0 +1,267 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
#ifndef SDL_config_wingdk_h_
#define SDL_config_wingdk_h_
#define SDL_config_h_
#include "SDL_platform.h"
/* Windows GDK does not need Windows SDK version checks because it requires
* a recent version of the Windows 10 SDK. */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
/* At this time, only recent MSVC or clang are supported by Windows GDK */
#if defined(__clang__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
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 _UINTPTR_T_DEFINED
typedef unsigned __int64 uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
#else /* !__clang__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __clang__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
/* GDK only supports 64-bit */
# define SIZEOF_VOIDP 8
#ifdef __clang__
# define HAVE_GCC_ATOMICS 1
#endif
/*#define HAVE_DDRAW_H 1*/
/*#define HAVE_DINPUT_H 1*/
/*#define HAVE_DSOUND_H 1*/
/* No SDK version checks needed for these because the SDK has to be new. */
/* #define HAVE_DXGI_H 1 */
#define HAVE_XINPUT_H 1
/*#define HAVE_WINDOWS_GAMING_INPUT_H 1*/
/*#define HAVE_D3D11_H 1*/
/*#define HAVE_ROAPI_H 1*/
#define HAVE_D3D12_H 1
/*#define HAVE_SHELLSCALINGAPI_H 1*/
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
/*#define HAVE_TPCSHRD_H 1*/
/*#define HAVE_SENSORSAPI_H 1*/
#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600)
#define HAVE_IMMINTRIN_H 1
#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64))
# if __has_include(<immintrin.h>)
# define HAVE_IMMINTRIN_H 1
# endif
#endif
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
#ifdef HAVE_LIBC
/* Useful headers */
#define STDC_HEADERS 1
#define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDIO_H 1
#define HAVE_STRING_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__STRUPR */
/* #undef HAVE__STRLWR */
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
/* #undef HAVE_STRTOK_R */
/* These functions have security warnings, so we won't use them */
/* #undef HAVE__LTOA */
/* #undef HAVE__ULTOA */
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE__WCSICMP 1
#define HAVE__WCSNICMP 1
#define HAVE__WCSDUP 1
#define HAVE_ACOS 1
#define HAVE_ASIN 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_CEIL 1
#define HAVE_COS 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_FMOD 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_POW 1
#define HAVE_SIN 1
#define HAVE_SQRT 1
#define HAVE_TAN 1
#define HAVE_ACOSF 1
#define HAVE_ASINF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1
#define HAVE_COSF 1
#define HAVE_EXPF 1
#define HAVE_FABSF 1
#define HAVE_FLOORF 1
#define HAVE_FMODF 1
#define HAVE_LOGF 1
#define HAVE_LOG10F 1
#define HAVE_POWF 1
#define HAVE_SINF 1
#define HAVE_SQRTF 1
#define HAVE_TANF 1
#if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_VSSCANF 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#define HAVE__FSEEKI64 1
#ifdef _USE_MATH_DEFINES
#define HAVE_M_PI 1
#endif
#else
#define HAVE_M_PI 1
#endif
#else
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#endif
/* Enable various audio drivers */
#if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)
#define SDL_AUDIO_DRIVER_WASAPI 1
#endif
/*#define SDL_AUDIO_DRIVER_DSOUND 1*/
/*#define SDL_AUDIO_DRIVER_WINMM 1*/
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various input drivers */
/*#define SDL_JOYSTICK_DINPUT 1*/
/*#define SDL_JOYSTICK_HIDAPI 1*/
/*#define SDL_JOYSTICK_RAWINPUT 1*/
#define SDL_JOYSTICK_VIRTUAL 1
#ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_WGI 1
#endif
#define SDL_JOYSTICK_XINPUT 1
/*#define SDL_HAPTIC_DINPUT 1*/
#define SDL_HAPTIC_XINPUT 1
/* Enable the sensor driver */
#ifdef HAVE_SENSORSAPI_H
#define SDL_SENSOR_WINDOWS 1
#else
#define SDL_SENSOR_DUMMY 1
#endif
/* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */
#define SDL_THREAD_GENERIC_COND_SUFFIX 1
#define SDL_THREAD_WINDOWS 1
/* Enable various timer systems */
#define SDL_TIMER_WINDOWS 1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDOWS 1
/* #ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1
#endif*/
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
#define SDL_VIDEO_RENDER_D3D12 1
#endif
/* Enable system power support */
/*#define SDL_POWER_WINDOWS 1*/
#define SDL_POWER_HARDWIRED 1
/* Enable filesystem support */
/* #define SDL_FILESYSTEM_WINDOWS 1*/
#define SDL_FILESYSTEM_XBOX 1
/* Disable IME as not supported yet (TODO: Xbox IME?) */
#define SDL_DISABLE_WINDOWS_IME 1
#endif /* SDL_config_wingdk_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -63,6 +63,9 @@ _m_prefetch(void *__P)
#ifndef __SSE2__ #ifndef __SSE2__
#define __SSE2__ #define __SSE2__
#endif #endif
#ifndef __SSE3__
#define __SSE3__
#endif
#elif defined(__MINGW64_VERSION_MAJOR) #elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h> #include <intrin.h>
#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON) #if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
@ -76,7 +79,7 @@ _m_prefetch(void *__P)
#if !defined(SDL_DISABLE_ARM_NEON_H) #if !defined(SDL_DISABLE_ARM_NEON_H)
# if defined(__ARM_NEON) # if defined(__ARM_NEON)
# include <arm_neon.h> # include <arm_neon.h>
# elif defined(__WINDOWS__) || defined(__WINRT__) # elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
# if defined(_M_ARM) # if defined(_M_ARM)
# include <armintr.h> # include <armintr.h>
@ -95,6 +98,14 @@ _m_prefetch(void *__P)
#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
#include <mm3dnow.h> #include <mm3dnow.h>
#endif #endif
#if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
#include <lsxintrin.h>
#define __LSX__
#endif
#if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX_H)
#include <lasxintrin.h>
#define __LASX__
#endif
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) #if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
#include <immintrin.h> #include <immintrin.h>
#else #else
@ -155,6 +166,8 @@ extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
* *
* \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -176,6 +189,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
* *
* \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAVX * \sa SDL_HasAVX
* \sa SDL_HasAVX2 * \sa SDL_HasAVX2
@ -196,6 +211,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
* *
* \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -216,6 +233,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
* *
* \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
* \sa SDL_HasAVX2 * \sa SDL_HasAVX2
@ -236,6 +255,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
* *
* \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -256,6 +277,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
* *
* \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -276,6 +299,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
* *
* \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -296,6 +321,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
* *
* \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -316,6 +343,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
* *
* \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow * \sa SDL_Has3DNow
* \sa SDL_HasAltiVec * \sa SDL_HasAltiVec
* \sa SDL_HasAVX * \sa SDL_HasAVX
@ -380,6 +409,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
* *
* \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_HasAVX * \sa SDL_HasAVX
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
@ -393,6 +424,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
* *
* \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_HasNEON * \sa SDL_HasNEON
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
@ -403,13 +436,41 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
* This always returns false on CPUs that aren't using ARM instruction sets. * This always returns false on CPUs that aren't using ARM instruction sets.
* *
* \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not. * \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
/**
* Determine whether the CPU has LSX (LOONGARCH SIMD) features.
*
* This always returns false on CPUs that aren't using LOONGARCH instruction
* sets.
*
* \returns SDL_TRUE if the CPU has LOONGARCH LSX features or SDL_FALSE if
* not.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasLSX(void);
/**
* Determine whether the CPU has LASX (LOONGARCH SIMD) features.
*
* This always returns false on CPUs that aren't using LOONGARCH instruction
* sets.
*
* \returns SDL_TRUE if the CPU has LOONGARCH LASX features or SDL_FALSE if
* not.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasLASX(void);
/** /**
* Get the amount of RAM configured in the system. * Get the amount of RAM configured in the system.
* *
* \returns the amount of RAM configured in the system in MB. * \returns the amount of RAM configured in the system in MiB.
* *
* \since This function is available since SDL 2.0.1. * \since This function is available since SDL 2.0.1.
*/ */
@ -429,6 +490,8 @@ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
* *
* \returns the alignment in bytes needed for available, known SIMD * \returns the alignment in bytes needed for available, known SIMD
* instructions. * instructions.
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
@ -461,9 +524,11 @@ extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
* *
* \param len The length, in bytes, of the block to allocate. The actual * \param len The length, in bytes, of the block to allocate. The actual
* allocated block might be larger due to padding, etc. * allocated block might be larger due to padding, etc.
* \returns a pointer to thenewly-allocated block, NULL if out of memory. * \returns a pointer to the newly-allocated block, NULL if out of memory.
* *
* \sa SDL_SIMDAlignment * \since This function is available since SDL 2.0.10.
*
* \sa SDL_SIMDGetAlignment
* \sa SDL_SIMDRealloc * \sa SDL_SIMDRealloc
* \sa SDL_SIMDFree * \sa SDL_SIMDFree
*/ */
@ -485,7 +550,9 @@ extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
* memory. * memory.
* \returns a pointer to the newly-reallocated block, NULL if out of memory. * \returns a pointer to the newly-reallocated block, NULL if out of memory.
* *
* \sa SDL_SIMDAlignment * \since This function is available since SDL 2.0.14.
*
* \sa SDL_SIMDGetAlignment
* \sa SDL_SIMDAlloc * \sa SDL_SIMDAlloc
* \sa SDL_SIMDFree * \sa SDL_SIMDFree
*/ */
@ -508,6 +575,8 @@ extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
* \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, to * \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, to
* deallocate. NULL is a legal no-op. * deallocate. NULL is a legal no-op.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_SIMDAlloc * \sa SDL_SIMDAlloc
* \sa SDL_SIMDRealloc * \sa SDL_SIMDRealloc
*/ */

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -30,20 +30,17 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && (_MSC_VER >= 1400)
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
#ifdef __clang__ #ifdef __clang__
#ifndef __PRFCHWINTRIN_H #ifndef __PRFCHWINTRIN_H
#define __PRFCHWINTRIN_H #define __PRFCHWINTRIN_H
static __inline__ void __attribute__((__always_inline__, __nodebug__)) static __inline__ void __attribute__((__always_inline__, __nodebug__))
_m_prefetch(void *__P) _m_prefetch(void *__P)
{ {
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); __builtin_prefetch(__P, 0, 3 /* _MM_HINT_T0 */);
} }
#endif /* __PRFCHWINTRIN_H */ #endif /* __PRFCHWINTRIN_H */
#endif /* __clang__ */ #endif /* __clang__ */
@ -62,17 +59,26 @@ _m_prefetch(void *__P)
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER __BYTE_ORDER #define SDL_BYTEORDER __BYTE_ORDER
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__) || defined(__DragonFly__)
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER BYTE_ORDER #define SDL_BYTEORDER BYTE_ORDER
#elif defined(__FreeBSD__) || defined(__NetBSD__) #elif defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/endian.h> #include <sys/endian.h>
#define SDL_BYTEORDER BYTE_ORDER #define SDL_BYTEORDER BYTE_ORDER
/* predefs from newer gcc and clang versions: */
#elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__)
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#else
#error Unsupported endianness
#endif /**/
#else #else
#if defined(__hppa__) || \ #if defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
(defined(__MIPS__) && defined(__MIPSEB__)) || \ (defined(__MIPS__) && defined(__MIPSEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \
defined(__sparc__) defined(__sparc__)
#define SDL_BYTEORDER SDL_BIG_ENDIAN #define SDL_BYTEORDER SDL_BIG_ENDIAN
#else #else
@ -81,6 +87,28 @@ _m_prefetch(void *__P)
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* !SDL_BYTEORDER */ #endif /* !SDL_BYTEORDER */
#ifndef SDL_FLOATWORDORDER /* Not defined in SDL_config.h? */
/* predefs from newer gcc versions: */
#if defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__)
#if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
#elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
#else
#error Unsupported endianness
#endif /**/
#elif defined(__MAVERICK__)
/* For Maverick, float words are always little-endian. */
#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
#elif (defined(__arm__) || defined(__thumb__)) && !defined(__VFP_FP__) && !defined(__ARM_EABI__)
/* For FPA, float words are always big-endian. */
#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
#else
/* By default, assume that floats words follow the memory system mode. */
#define SDL_FLOATWORDORDER SDL_BYTEORDER
#endif /* __FLOAT_WORD_ORDER__ */
#endif /* !SDL_FLOATWORDORDER */
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -91,25 +119,45 @@ extern "C" {
/** /**
* \file SDL_endian.h * \file SDL_endian.h
*/ */
#if (defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) || \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) /* various modern compilers may have builtin swap */
#if defined(__GNUC__) || defined(__clang__)
# define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
# define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
/* this one is broken */
# define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)
#else
# define HAS_BUILTIN_BSWAP16 0
# define HAS_BUILTIN_BSWAP32 0
# define HAS_BUILTIN_BSWAP64 0
# define HAS_BROKEN_BSWAP 0
#endif
#if HAS_BUILTIN_BSWAP16
#define SDL_Swap16(x) __builtin_bswap16(x) #define SDL_Swap16(x) __builtin_bswap16(x)
#elif defined(__GNUC__) && defined(__i386__) && \ #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) #pragma intrinsic(_byteswap_ushort)
#define SDL_Swap16(x) _byteswap_ushort(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
@ -118,25 +166,15 @@ SDL_Swap16(Uint16 x)
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
return (Uint16)result; return (Uint16)result;
} }
#elif defined(__GNUC__) && defined(__aarch64__) #elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x)
{
__asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x));
return x;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
return x; return x;
} }
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_ushort)
#define SDL_Swap16(x) _byteswap_ushort(x)
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint16 SDL_Swap16(Uint16); extern __inline Uint16 SDL_Swap16(Uint16);
#pragma aux SDL_Swap16 = \ #pragma aux SDL_Swap16 = \
"xchg al, ah" \ "xchg al, ah" \
parm [ax] \ parm [ax] \
@ -149,25 +187,26 @@ SDL_Swap16(Uint16 x)
} }
#endif #endif
#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \ #if HAS_BUILTIN_BSWAP32
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_Swap32(x) __builtin_bswap32(x) #define SDL_Swap32(x) __builtin_bswap32(x)
#elif defined(__GNUC__) && defined(__i386__) && \ #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) #pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswap %0": "=r"(x):"0"(x)); __asm__("bswap %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswapl %0": "=r"(x):"0"(x)); __asm__("bswapl %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
@ -178,14 +217,7 @@ SDL_Swap32(Uint32 x)
__asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x)); __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x));
return result; return result;
} }
#elif defined(__GNUC__) && defined(__aarch64__) #elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x)
{
__asm__("rev %w1, %w0": "=r"(x):"r"(x));
return x;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
@ -193,14 +225,11 @@ SDL_Swap32(Uint32 x)
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint32 SDL_Swap32(Uint32); extern __inline Uint32 SDL_Swap32(Uint32);
#pragma aux SDL_Swap32 = \ #pragma aux SDL_Swap32 = \
"bswap eax" \ "bswap eax" \
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x)
#else #else
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
@ -210,11 +239,12 @@ SDL_Swap32(Uint32 x)
} }
#endif #endif
#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \ #if HAS_BUILTIN_BSWAP64
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_Swap64(x) __builtin_bswap64(x) #define SDL_Swap64(x) __builtin_bswap64(x)
#elif defined(__GNUC__) && defined(__i386__) && \ #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) #pragma intrinsic(_byteswap_uint64)
#define SDL_Swap64(x) _byteswap_uint64(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
@ -230,7 +260,7 @@ SDL_Swap64(Uint64 x)
: "0" (v.s.a), "1"(v.s.b)); : "0" (v.s.a), "1"(v.s.b));
return v.u; return v.u;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
@ -238,16 +268,13 @@ SDL_Swap64(Uint64 x)
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint64 SDL_Swap64(Uint64); extern __inline Uint64 SDL_Swap64(Uint64);
#pragma aux SDL_Swap64 = \ #pragma aux SDL_Swap64 = \
"bswap eax" \ "bswap eax" \
"bswap edx" \ "bswap edx" \
"xchg eax,edx" \ "xchg eax,edx" \
parm [eax edx] \ parm [eax edx] \
modify [eax edx]; modify [eax edx];
#elif defined(_MSC_VER)
#pragma intrinsic(_byteswap_uint64)
#define SDL_Swap64(x) _byteswap_uint64(x)
#else #else
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
@ -278,6 +305,11 @@ SDL_SwapFloat(float x)
return swapper.f; return swapper.f;
} }
/* remove extra macros */
#undef HAS_BROKEN_BSWAP
#undef HAS_BUILTIN_BSWAP16
#undef HAS_BUILTIN_BSWAP32
#undef HAS_BUILTIN_BSWAP64
/** /**
* \name Swap to native * \name Swap to native

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -58,6 +58,8 @@ extern "C" {
* any * any
* \returns always -1. * \returns always -1.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ClearError * \sa SDL_ClearError
* \sa SDL_GetError * \sa SDL_GetError
*/ */
@ -72,11 +74,11 @@ extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fm
* *
* The message is only applicable when an SDL function has signaled an error. * The message is only applicable when an SDL function has signaled an error.
* You must check the return values of SDL function calls to determine when to * You must check the return values of SDL function calls to determine when to
* appropriately call SDL_GetError(). You should _not_ use the results of * appropriately call SDL_GetError(). You should *not* use the results of
* SDL_GetError() to decide if an error has occurred! Sometimes SDL will set * SDL_GetError() to decide if an error has occurred! Sometimes SDL will set
* an error string even when reporting success. * an error string even when reporting success.
* *
* SDL will _not_ clear the error string for successful API calls. You _must_ * SDL will *not* clear the error string for successful API calls. You *must*
* check return values for failure cases before you can assume the error * check return values for failure cases before you can assume the error
* string applies. * string applies.
* *
@ -93,6 +95,8 @@ extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fm
* return values of SDL function calls to determine when to * return values of SDL function calls to determine when to
* appropriately call SDL_GetError(). * appropriately call SDL_GetError().
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ClearError * \sa SDL_ClearError
* \sa SDL_SetError * \sa SDL_SetError
*/ */
@ -109,6 +113,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetError(void);
* \param maxlen The size of the buffer pointed to by the errstr parameter * \param maxlen The size of the buffer pointed to by the errstr parameter
* \returns the pointer passed in as the `errstr` parameter. * \returns the pointer passed in as the `errstr` parameter.
* *
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_GetError * \sa SDL_GetError
*/ */
extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen); extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
@ -116,6 +122,8 @@ extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
/** /**
* Clear any previous error message for this thread. * Clear any previous error message for this thread.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetError * \sa SDL_GetError
* \sa SDL_SetError * \sa SDL_SetError
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -102,6 +102,7 @@ typedef enum
SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
input language or keyboard layout change. input language or keyboard layout change.
*/ */
SDL_TEXTEDITING_EXT, /**< Extended keyboard text editing (composition) */
/* Mouse events */ /* Mouse events */
SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
@ -117,6 +118,7 @@ typedef enum
SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_JOYBUTTONUP, /**< Joystick button released */
SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
SDL_JOYBATTERYUPDATED, /**< Joystick battery level change */
/* Game controller events */ /* Game controller events */
SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
@ -160,6 +162,9 @@ typedef enum
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
/* Internal events */
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
* and should be allocated with SDL_RegisterEvents() * and should be allocated with SDL_RegisterEvents()
*/ */
@ -240,6 +245,19 @@ typedef struct SDL_TextEditingEvent
Sint32 length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingEvent; } SDL_TextEditingEvent;
/**
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
* truncated if stored in the text buffer SDL_TextEditingEvent
*/
typedef struct SDL_TextEditingExtEvent
{
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
Sint32 start; /**< The start cursor of selected editing text */
Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingExtEvent;
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
/** /**
@ -298,6 +316,8 @@ typedef struct SDL_MouseWheelEvent
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
} SDL_MouseWheelEvent; } SDL_MouseWheelEvent;
/** /**
@ -376,6 +396,16 @@ typedef struct SDL_JoyDeviceEvent
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
} SDL_JoyDeviceEvent; } SDL_JoyDeviceEvent;
/**
* \brief Joysick battery level change event structure (event.jbattery.*)
*/
typedef struct SDL_JoyBatteryEvent
{
Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
SDL_JoystickPowerLevel level; /**< The joystick battery level */
} SDL_JoyBatteryEvent;
/** /**
* \brief Game controller axis motion event structure (event.caxis.*) * \brief Game controller axis motion event structure (event.caxis.*)
@ -596,6 +626,7 @@ typedef union SDL_Event
SDL_WindowEvent window; /**< Window event data */ SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */ SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */ SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextEditingExtEvent editExt; /**< Extended text editing event data */
SDL_TextInputEvent text; /**< Text input event data */ SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */ SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */ SDL_MouseButtonEvent button; /**< Mouse button event data */
@ -605,6 +636,7 @@ typedef union SDL_Event
SDL_JoyHatEvent jhat; /**< Joystick hat event data */ SDL_JoyHatEvent jhat; /**< Joystick hat event data */
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
@ -659,6 +691,8 @@ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NUL
* polling or waiting for events (e.g. you are filtering them), then you must * polling or waiting for events (e.g. you are filtering them), then you must
* call SDL_PumpEvents() to force an event queue update. * call SDL_PumpEvents() to force an event queue update.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent * \sa SDL_PollEvent
* \sa SDL_WaitEvent * \sa SDL_WaitEvent
*/ */
@ -704,6 +738,8 @@ typedef enum
* \returns the number of events actually stored or a negative error code on * \returns the number of events actually stored or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent * \sa SDL_PollEvent
* \sa SDL_PumpEvents * \sa SDL_PumpEvents
* \sa SDL_PushEvent * \sa SDL_PushEvent
@ -723,6 +759,8 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
* \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
* events matching `type` are not present. * events matching `type` are not present.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasEvents * \sa SDL_HasEvents
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
@ -740,6 +778,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
* \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
* present, or SDL_FALSE if not. * present, or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasEvents * \sa SDL_HasEvents
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
@ -760,6 +800,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
* *
* \param type the type of event to be cleared; see SDL_EventType for details * \param type the type of event to be cleared; see SDL_EventType for details
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FlushEvents * \sa SDL_FlushEvents
*/ */
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
@ -783,6 +825,8 @@ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
* \param maxType the high end of event type to be cleared, inclusive; see * \param maxType the high end of event type to be cleared, inclusive; see
* SDL_EventType for details * SDL_EventType for details
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FlushEvent * \sa SDL_FlushEvent
*/ */
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
@ -798,8 +842,8 @@ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
* If `event` is NULL, it simply returns 1 if there is an event in the queue, * If `event` is NULL, it simply returns 1 if there is an event in the queue,
* but will not remove it from the queue. * but will not remove it from the queue.
* *
* As this function implicitly calls SDL_PumpEvents(), you can only call this * As this function may implicitly call SDL_PumpEvents(), you can only call
* function in the thread that set the video mode. * this function in the thread that set the video mode.
* *
* SDL_PollEvent() is the favored way of receiving system events since it can * SDL_PollEvent() is the favored way of receiving system events since it can
* be done from the main loop and does not suspend the main loop while waiting * be done from the main loop and does not suspend the main loop while waiting
@ -823,6 +867,8 @@ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
* the queue, or NULL * the queue, or NULL
* \returns 1 if there is a pending event or 0 if there are none available. * \returns 1 if there is a pending event or 0 if there are none available.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetEventFilter * \sa SDL_GetEventFilter
* \sa SDL_PeepEvents * \sa SDL_PeepEvents
* \sa SDL_PushEvent * \sa SDL_PushEvent
@ -838,14 +884,16 @@ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
* If `event` is not NULL, the next event is removed from the queue and stored * If `event` is not NULL, the next event is removed from the queue and stored
* in the SDL_Event structure pointed to by `event`. * in the SDL_Event structure pointed to by `event`.
* *
* As this function implicitly calls SDL_PumpEvents(), you can only call this * As this function may implicitly call SDL_PumpEvents(), you can only call
* function in the thread that initialized the video subsystem. * this function in the thread that initialized the video subsystem.
* *
* \param event the SDL_Event structure to be filled in with the next event * \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL * from the queue, or NULL
* \returns 1 on success or 0 if there was an error while waiting for events; * \returns 1 on success or 0 if there was an error while waiting for events;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent * \sa SDL_PollEvent
* \sa SDL_PumpEvents * \sa SDL_PumpEvents
* \sa SDL_WaitEventTimeout * \sa SDL_WaitEventTimeout
@ -859,8 +907,8 @@ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
* If `event` is not NULL, the next event is removed from the queue and stored * If `event` is not NULL, the next event is removed from the queue and stored
* in the SDL_Event structure pointed to by `event`. * in the SDL_Event structure pointed to by `event`.
* *
* As this function implicitly calls SDL_PumpEvents(), you can only call this * As this function may implicitly call SDL_PumpEvents(), you can only call
* function in the thread that initialized the video subsystem. * this function in the thread that initialized the video subsystem.
* *
* \param event the SDL_Event structure to be filled in with the next event * \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL * from the queue, or NULL
@ -870,6 +918,8 @@ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
* call SDL_GetError() for more information. This also returns 0 if * call SDL_GetError() for more information. This also returns 0 if
* the timeout elapsed without an event arriving. * the timeout elapsed without an event arriving.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent * \sa SDL_PollEvent
* \sa SDL_PumpEvents * \sa SDL_PumpEvents
* \sa SDL_WaitEvent * \sa SDL_WaitEvent
@ -903,6 +953,8 @@ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
* code on failure; call SDL_GetError() for more information. A * code on failure; call SDL_GetError() for more information. A
* common reason for error is the event queue being full. * common reason for error is the event queue being full.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PeepEvents * \sa SDL_PeepEvents
* \sa SDL_PollEvent * \sa SDL_PollEvent
* \sa SDL_RegisterEvents * \sa SDL_RegisterEvents
@ -957,6 +1009,8 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
* \param filter An SDL_EventFilter function to call when an event happens * \param filter An SDL_EventFilter 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`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AddEventWatch * \sa SDL_AddEventWatch
* \sa SDL_EventState * \sa SDL_EventState
* \sa SDL_GetEventFilter * \sa SDL_GetEventFilter
@ -977,6 +1031,8 @@ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
* be stored here * be stored here
* \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set. * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetEventFilter * \sa SDL_SetEventFilter
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
@ -1003,6 +1059,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
* \param filter an SDL_EventFilter function to call when an event happens. * \param filter an SDL_EventFilter 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`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_DelEventWatch * \sa SDL_DelEventWatch
* \sa SDL_SetEventFilter * \sa SDL_SetEventFilter
*/ */
@ -1018,6 +1076,8 @@ extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
* \param filter the function originally passed to SDL_AddEventWatch() * \param filter the function originally passed to SDL_AddEventWatch()
* \param userdata the pointer originally passed to SDL_AddEventWatch() * \param userdata the pointer originally passed to SDL_AddEventWatch()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AddEventWatch * \sa SDL_AddEventWatch
*/ */
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
@ -1034,6 +1094,8 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
* \param filter the SDL_EventFilter function to call when an event happens * \param filter the SDL_EventFilter 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`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetEventFilter * \sa SDL_GetEventFilter
* \sa SDL_SetEventFilter * \sa SDL_SetEventFilter
*/ */
@ -1061,6 +1123,8 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
* \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
* of the event before this function makes any changes to it. * of the event before this function makes any changes to it.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetEventState * \sa SDL_GetEventState
*/ */
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -55,7 +55,7 @@ extern "C" {
* *
* - `resource`: bundle resource directory (the default). For example: * - `resource`: bundle resource directory (the default). For example:
* `/Applications/SDLApp/MyApp.app/Contents/Resources` * `/Applications/SDLApp/MyApp.app/Contents/Resources`
* - `bundle`: the Bundle directory. Fpr example: * - `bundle`: the Bundle directory. For example:
* `/Applications/SDLApp/MyApp.app/` * `/Applications/SDLApp/MyApp.app/`
* - `parent`: the containing directory of the bundle. For example: * - `parent`: the containing directory of the bundle. For example:
* `/Applications/SDLApp/` * `/Applications/SDLApp/`
@ -92,7 +92,7 @@ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
* *
* `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\` * `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\`
* *
* On Linux, the string might look like" * On Linux, the string might look like:
* *
* `/home/bob/.local/share/My Program Name/` * `/home/bob/.local/share/My Program Name/`
* *

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -69,7 +69,11 @@ typedef enum
SDL_CONTROLLER_TYPE_VIRTUAL, SDL_CONTROLLER_TYPE_VIRTUAL,
SDL_CONTROLLER_TYPE_PS5, SDL_CONTROLLER_TYPE_PS5,
SDL_CONTROLLER_TYPE_AMAZON_LUNA, SDL_CONTROLLER_TYPE_AMAZON_LUNA,
SDL_CONTROLLER_TYPE_GOOGLE_STADIA SDL_CONTROLLER_TYPE_GOOGLE_STADIA,
SDL_CONTROLLER_TYPE_NVIDIA_SHIELD,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
} SDL_GameControllerType; } SDL_GameControllerType;
typedef enum typedef enum
@ -189,6 +193,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated, * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
* -1 on error; call SDL_GetError() for more information. * -1 on error; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerMapping * \sa SDL_GameControllerMapping
* \sa SDL_GameControllerMappingForGUID * \sa SDL_GameControllerMappingForGUID
*/ */
@ -198,6 +204,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingStri
* Get the number of mappings installed. * Get the number of mappings installed.
* *
* \returns the number of mappings. * \returns the number of mappings.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void); extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
@ -206,6 +214,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
* *
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* the index is out of range. * the index is out of range.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index); extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
@ -218,6 +228,8 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_ind
* \returns a mapping string or NULL on error; call SDL_GetError() for more * \returns a mapping string or NULL on error; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetDeviceGUID * \sa SDL_JoystickGetDeviceGUID
* \sa SDL_JoystickGetGUID * \sa SDL_JoystickGetGUID
*/ */
@ -281,6 +293,25 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
*/ */
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
/**
* Get the implementation dependent path for the game controller.
*
* This function can be called before any controllers are opened.
*
* `joystick_index` is the same as the `device_index` passed to
* SDL_JoystickOpen().
*
* \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1
* \returns the implementation-dependent path for the game controller, or NULL
* if there is no path or the index is invalid.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GameControllerPath
*/
extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_index);
/** /**
* Get the type of a game controller. * Get the type of a game controller.
* *
@ -289,6 +320,8 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_
* \param joystick_index the device_index of a device, from zero to * \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1
* \returns the controller type. * \returns the controller type.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index); extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
@ -301,6 +334,8 @@ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(in
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* no mapping is available. * no mapping is available.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
@ -349,6 +384,8 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL
* instance id! * instance id!
* \returns the SDL_GameController associated with a player index. * \returns the SDL_GameController associated with a player index.
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_GameControllerGetPlayerIndex * \sa SDL_GameControllerGetPlayerIndex
* \sa SDL_GameControllerSetPlayerIndex * \sa SDL_GameControllerSetPlayerIndex
*/ */
@ -372,6 +409,23 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(in
*/ */
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
/**
* Get the implementation-dependent path for an opened game controller.
*
* This is the same path as returned by SDL_GameControllerNameForIndex(), but
* it takes a controller identifier instead of the (unstable) device index.
*
* \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen()
* \returns the implementation dependent path for the game controller, or NULL
* if there is no path or the identifier passed is invalid.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GameControllerPathForIndex
*/
extern DECLSPEC const char *SDLCALL SDL_GameControllerPath(SDL_GameController *gamecontroller);
/** /**
* Get the type of this currently opened controller * Get the type of this currently opened controller
* *
@ -380,6 +434,8 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *g
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \returns the controller type. * \returns the controller type.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller); extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
@ -390,6 +446,8 @@ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_Gam
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \returns the player index for controller, or -1 if it's not available. * \returns the player index for controller, or -1 if it's not available.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
@ -397,7 +455,10 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController
* Set the player index of an opened game controller. * Set the player index of an opened game controller.
* *
* \param gamecontroller the game controller object to adjust. * \param gamecontroller the game controller object to adjust.
* \param player_index Player index to assign to this controller. * \param player_index Player index to assign to this controller, or -1 to
* clear the player index and turn off player LEDs.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index); extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
@ -408,6 +469,8 @@ extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \return the USB vendor ID, or zero if unavailable. * \return the USB vendor ID, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller); extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
@ -418,6 +481,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *g
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \return the USB product ID, or zero if unavailable. * \return the USB product ID, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller); extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
@ -428,9 +493,23 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \return the USB product version, or zero if unavailable. * \return the USB product version, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller); extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
/**
* Get the firmware version of an opened controller, if available.
*
* If the firmware version isn't available this function returns 0.
*
* \param gamecontroller the game controller object to query.
* \return the controller firmware version, or zero if unavailable.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller);
/** /**
* Get the serial number of an opened controller, if available. * Get the serial number of an opened controller, if available.
* *
@ -439,6 +518,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameContr
* *
* \param gamecontroller the game controller object to query. * \param gamecontroller the game controller object to query.
* \return the serial number, or NULL if unavailable. * \return the serial number, or NULL if unavailable.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller); extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
@ -450,6 +531,8 @@ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameControl
* \returns SDL_TRUE if the controller has been opened and is currently * \returns SDL_TRUE if the controller has been opened and is currently
* connected, or SDL_FALSE if not. * connected, or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerClose * \sa SDL_GameControllerClose
* \sa SDL_GameControllerOpen * \sa SDL_GameControllerOpen
*/ */
@ -471,6 +554,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameControlle
* \param gamecontroller the game controller object that you want to get a * \param gamecontroller the game controller object that you want to get a
* joystick from * joystick from
* \returns a SDL_Joystick object; call SDL_GetError() for more information. * \returns a SDL_Joystick object; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
@ -500,6 +585,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
* This function is called automatically by the event loop if events are * This function is called automatically by the event loop if events are
* 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.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
@ -541,6 +628,8 @@ typedef enum
* \returns the SDL_GameControllerAxis enum corresponding to the input string, * \returns the SDL_GameControllerAxis enum corresponding to the input string,
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. * or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetStringForAxis * \sa SDL_GameControllerGetStringForAxis
*/ */
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str); extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
@ -555,6 +644,8 @@ extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromStri
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_GameController mapping strings. * SDL_GameController mapping strings.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetAxisFromString * \sa SDL_GameControllerGetAxisFromString
*/ */
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
@ -585,6 +676,8 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
* \param gamecontroller a game controller * \param gamecontroller a game controller
* \param axis an axis enum value (an SDL_GameControllerAxis value) * \param axis an axis enum value (an SDL_GameControllerAxis value)
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise. * \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL extern DECLSPEC SDL_bool SDLCALL
SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
@ -650,6 +743,8 @@ typedef enum
* \param str string representing a SDL_GameController axis * \param str string representing a SDL_GameController axis
* \returns the SDL_GameControllerButton enum corresponding to the input * \returns the SDL_GameControllerButton enum corresponding to the input
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. * string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str); extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str);
@ -695,6 +790,8 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
* \param gamecontroller a game controller * \param gamecontroller a game controller
* \param button a button enum value (an SDL_GameControllerButton value) * \param button a button enum value (an SDL_GameControllerButton value)
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise. * \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller, extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button); SDL_GameControllerButton button);
@ -716,17 +813,23 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
/** /**
* Get the number of touchpads on a game controller. * Get the number of touchpads on a game controller.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller); extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
/** /**
* Get the number of supported simultaneous fingers on a touchpad on a game * Get the number of supported simultaneous fingers on a touchpad on a game
* controller. * controller.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad); extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
/** /**
* Get the current state of a finger on a touchpad on a game controller. * Get the current state of a finger on a touchpad on a game controller.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure); extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
@ -736,6 +839,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameControll
* \param gamecontroller The controller to query * \param gamecontroller The controller to query
* \param type The type of sensor to query * \param type The type of sensor to query
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise. * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type); extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
@ -746,6 +851,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController
* \param type The type of sensor to enable/disable * \param type The type of sensor to enable/disable
* \param enabled Whether data reporting should be enabled * \param enabled Whether data reporting should be enabled
* \returns 0 or -1 if an error occurred. * \returns 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled); extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
@ -755,6 +862,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameControlle
* \param gamecontroller The controller to query * \param gamecontroller The controller to query
* \param type The type of sensor to query * \param type The type of sensor to query
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise. * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type); extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
@ -765,6 +874,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameContr
* \param gamecontroller The controller to query * \param gamecontroller The controller to query
* \param type The type of sensor to query * \param type The type of sensor to query
* \return the data rate, or 0.0f if the data rate is not available. * \return the data rate, or 0.0f if the data rate is not available.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type); extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
@ -779,6 +890,8 @@ extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameContro
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data * \param num_values The number of values to write to data
* \return 0 or -1 if an error occurred. * \return 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values); extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
@ -795,6 +908,10 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if rumble isn't supported on this controller * \returns 0, or -1 if rumble isn't supported on this controller
*
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_GameControllerHasRumble
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@ -805,8 +922,9 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecon
* calling it with 0 intensity stops any rumbling. * calling it with 0 intensity stops any rumbling.
* *
* Note that this is rumbling of the _triggers_ and not the game controller as * Note that this is rumbling of the _triggers_ and not the game controller as
* a whole. The first controller to offer this feature was the PlayStation 5's * a whole. This is currently only supported on Xbox One controllers. If you
* DualShock 5. * want the (more common) whole-controller rumble, use
* SDL_GameControllerRumble() instead.
* *
* \param gamecontroller The controller to vibrate * \param gamecontroller The controller to vibrate
* \param left_rumble The intensity of the left trigger rumble motor, from 0 * \param left_rumble The intensity of the left trigger rumble motor, from 0
@ -815,6 +933,10 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecon
* to 0xFFFF * to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if trigger rumble isn't supported on this controller * \returns 0, or -1 if trigger rumble isn't supported on this controller
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_GameControllerHasRumbleTriggers
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
@ -824,9 +946,37 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController
* \param gamecontroller The controller to query * \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a * \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
* modifiable LED * modifiable LED
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller); extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
/**
* Query whether a game controller has rumble support.
*
* \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
* support
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerRumble
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
/**
* Query whether a game controller has rumble support on triggers.
*
* \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
* rumble support
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerRumbleTriggers
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
/** /**
* Update a game controller's LED color. * Update a game controller's LED color.
* *
@ -835,6 +985,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *ga
* \param green The intensity of the green LED * \param green The intensity of the green LED
* \param blue The intensity of the blue LED * \param blue The intensity of the blue LED
* \returns 0, or -1 if this controller does not have a modifiable LED * \returns 0, or -1 if this controller does not have a modifiable LED
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue); extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
@ -846,6 +998,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecon
* \param size The size of the data to send to the controller * \param size The size of the data to send to the controller
* \returns 0, or -1 if this controller or driver doesn't support effect * \returns 0, or -1 if this controller or driver doesn't support effect
* packets * packets
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size); extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
@ -855,10 +1009,41 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gam
* \param gamecontroller a game controller identifier previously returned by * \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen() * SDL_GameControllerOpen()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerOpen * \sa SDL_GameControllerOpen
*/ */
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
/**
* Return the sfSymbolsName for a given button on a game controller on Apple
* platforms.
*
* \param gamecontroller the controller to query
* \param button a button on the game controller
* \returns the sfSymbolsName or NULL if the name can't be found
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerGetAppleSFSymbolsNameForAxis
*/
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
/**
* Return the sfSymbolsName for a given axis on a game controller on Apple
* platforms.
*
* \param gamecontroller the controller to query
* \param axis an axis on the game controller
* \returns the sfSymbolsName or NULL if the name can't be found
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerGetAppleSFSymbolsNameForButton
*/
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -0,0 +1,100 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
/**
* \file SDL_guid.h
*
* Include file for handling ::SDL_GUID values.
*/
#ifndef SDL_guid_h_
#define SDL_guid_h_
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* An SDL_GUID is a 128-bit identifier for an input device that
* identifies that device across runs of SDL programs on the same
* platform. If the device is detached and then re-attached to a
* different port, or if the base system is rebooted, the device
* should still report the same GUID.
*
* GUIDs are as precise as possible but are not guaranteed to
* distinguish physically distinct but equivalent devices. For
* example, two game controllers from the same vendor with the same
* product ID and revision may have the same GUID.
*
* GUIDs may be platform-dependent (i.e., the same device may report
* different GUIDs on different operating systems).
*/
typedef struct {
Uint8 data[16];
} SDL_GUID;
/* Function prototypes */
/**
* Get an ASCII string representation for a given ::SDL_GUID.
*
* You should supply at least 33 bytes for pszGUID.
*
* \param guid the ::SDL_GUID you wish to convert to string
* \param pszGUID buffer in which to write the ASCII string
* \param cbGUID the size of pszGUID
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GUIDFromString
*/
extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
/**
* Convert a GUID string into a ::SDL_GUID structure.
*
* Performs no error checking. If this function is given a string containing
* an invalid GUID, the function will silently succeed, but the GUID generated
* will not be useful.
*
* \param pchGUID string containing an ASCII representation of a GUID
* \returns a ::SDL_GUID structure.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GUIDToString
*/
extern DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_guid_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -76,7 +76,7 @@
* } * }
* *
* // Create the effect * // Create the effect
* memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default * SDL_memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
* effect.type = SDL_HAPTIC_SINE; * effect.type = SDL_HAPTIC_SINE;
* effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
* effect.periodic.direction.dir[0] = 18000; // Force comes from south * effect.periodic.direction.dir[0] = 18000; // Force comes from south
@ -820,6 +820,7 @@ typedef union SDL_HapticEffect
/* Function prototypes */ /* Function prototypes */
/** /**
* Count the number of haptic devices attached to the system. * Count the number of haptic devices attached to the system.
* *
@ -970,6 +971,8 @@ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *
* *
* \param haptic the SDL_Haptic device to close * \param haptic the SDL_Haptic device to close
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticOpen * \sa SDL_HapticOpen
*/ */
extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
@ -1033,6 +1036,8 @@ extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
* \param haptic the SDL_Haptic device to query * \param haptic the SDL_Haptic device to query
* \returns the number of axes on success or a negative error code on failure; * \returns the number of axes on success or a negative error code on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
@ -1063,6 +1068,8 @@ extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic,
* \returns the ID of the effect on success or a negative error code on * \returns the ID of the effect on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticDestroyEffect * \sa SDL_HapticDestroyEffect
* \sa SDL_HapticRunEffect * \sa SDL_HapticRunEffect
* \sa SDL_HapticUpdateEffect * \sa SDL_HapticUpdateEffect
@ -1207,6 +1214,8 @@ extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticQuery * \sa SDL_HapticQuery
*/ */
extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
@ -1225,6 +1234,8 @@ extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticUnpause * \sa SDL_HapticUnpause
*/ */
extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
@ -1238,6 +1249,8 @@ extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticPause * \sa SDL_HapticPause
*/ */
extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
@ -1248,6 +1261,8 @@ extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
* \param haptic the SDL_Haptic device to stop * \param haptic the SDL_Haptic device to stop
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
@ -1259,6 +1274,8 @@ extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
* negative error code on failure; call SDL_GetError() for more * negative error code on failure; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticRumbleInit * \sa SDL_HapticRumbleInit
* \sa SDL_HapticRumblePlay * \sa SDL_HapticRumblePlay
* \sa SDL_HapticRumbleStop * \sa SDL_HapticRumbleStop
@ -1290,6 +1307,8 @@ extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticRumbleInit * \sa SDL_HapticRumbleInit
* \sa SDL_HapticRumbleStop * \sa SDL_HapticRumbleStop
* \sa SDL_HapticRumbleSupported * \sa SDL_HapticRumbleSupported
@ -1303,6 +1322,8 @@ extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float stre
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HapticRumbleInit * \sa SDL_HapticRumbleInit
* \sa SDL_HapticRumblePlay * \sa SDL_HapticRumblePlay
* \sa SDL_HapticRumbleSupported * \sa SDL_HapticRumbleSupported

View file

@ -0,0 +1,451 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 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.
*/
/**
* \file SDL_hidapi.h
*
* Header file for SDL HIDAPI functions.
*
* This is an adaptation of the original HIDAPI interface by Alan Ott,
* and includes source code licensed under the following BSD license:
*
Copyright (c) 2010, Alan Ott, Signal 11 Software
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Signal 11 Software nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*
* If you would like a version of SDL without this code, you can build SDL
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for example
* on iOS or tvOS to avoid a dependency on the CoreBluetooth framework.
*/
#ifndef SDL_hidapi_h_
#define SDL_hidapi_h_
#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief A handle representing an open HID device
*/
struct SDL_hid_device_;
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
/** hidapi info structure */
/**
* \brief Information about a connected HID device
*/
typedef struct SDL_hid_device_info
{
/** Platform-specific device path */
char *path;
/** Device Vendor ID */
unsigned short vendor_id;
/** Device Product ID */
unsigned short product_id;
/** Serial Number */
wchar_t *serial_number;
/** Device Release Number in binary-coded decimal,
also known as Device Version Number */
unsigned short release_number;
/** Manufacturer String */
wchar_t *manufacturer_string;
/** Product string */
wchar_t *product_string;
/** Usage Page for this Device/Interface
(Windows/Mac only). */
unsigned short usage_page;
/** Usage for this Device/Interface
(Windows/Mac only).*/
unsigned short usage;
/** The USB interface which this logical device
represents.
* Valid on both Linux implementations in all cases.
* Valid on the Windows implementation only if the device
contains more than one interface. */
int interface_number;
/** Additional information about the USB interface.
Valid on libusb and Android implementations. */
int interface_class;
int interface_subclass;
int interface_protocol;
/** Pointer to the next device */
struct SDL_hid_device_info *next;
} SDL_hid_device_info;
/**
* Initialize the HIDAPI library.
*
* This function initializes the HIDAPI library. Calling it is not strictly
* necessary, as it will be called automatically by SDL_hid_enumerate() and
* any of the SDL_hid_open_*() functions if it is needed. This function should
* be called at the beginning of execution however, if there is a chance of
* HIDAPI handles being opened by different threads simultaneously.
*
* Each call to this function should have a matching call to SDL_hid_exit()
*
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_hid_exit
*/
extern DECLSPEC int SDLCALL SDL_hid_init(void);
/**
* Finalize the HIDAPI library.
*
* This function frees all of the static data associated with HIDAPI. It
* should be called at the end of execution to avoid memory leaks.
*
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_hid_init
*/
extern DECLSPEC int SDLCALL SDL_hid_exit(void);
/**
* Check to see if devices may have been added or removed.
*
* Enumerating the HID devices is an expensive operation, so you can call this
* to see if there have been any system device changes since the last call to
* this function. A change in the counter returned doesn't necessarily mean
* that anything has changed, but you can call SDL_hid_enumerate() to get an
* updated device list.
*
* Calling this function for the first time may cause a thread or other system
* resource to be allocated to track device change notifications.
*
* \returns a change counter that is incremented with each potential device
* change, or 0 if device change detection isn't available.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_hid_enumerate
*/
extern DECLSPEC Uint32 SDLCALL SDL_hid_device_change_count(void);
/**
* Enumerate the HID Devices.
*
* This function returns a linked list of all the HID devices attached to the
* system which match vendor_id and product_id. If `vendor_id` is set to 0
* then any vendor matches. If `product_id` is set to 0 then any product
* matches. If `vendor_id` and `product_id` are both set to 0, then all HID
* devices will be returned.
*
* \param vendor_id The Vendor ID (VID) of the types of device to open.
* \param product_id The Product ID (PID) of the types of device to open.
* \returns a pointer to a linked list of type SDL_hid_device_info, containing
* information about the HID devices attached to the system, or NULL
* in the case of failure. Free this linked list by calling
* SDL_hid_free_enumeration().
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_hid_device_change_count
*/
extern DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id);
/**
* Free an enumeration Linked List
*
* This function frees a linked list created by SDL_hid_enumerate().
*
* \param devs Pointer to a list of struct_device returned from
* SDL_hid_enumerate().
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC void SDLCALL SDL_hid_free_enumeration(SDL_hid_device_info *devs);
/**
* Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally
* a serial number.
*
* If `serial_number` is NULL, the first device with the specified VID and PID
* is opened.
*
* \param vendor_id The Vendor ID (VID) of the device to open.
* \param product_id The Product ID (PID) of the device to open.
* \param serial_number The Serial Number of the device to open (Optionally
* NULL).
* \returns a pointer to a SDL_hid_device object on success or NULL on
* failure.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number);
/**
* Open a HID device by its path name.
*
* The path name be determined by calling SDL_hid_enumerate(), or a
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
*
* \param path The path name of the device to open
* \returns a pointer to a SDL_hid_device object on success or NULL on
* failure.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */);
/**
* Write an Output report to a HID device.
*
* The first byte of `data` must contain the Report ID. For devices which only
* support a single report, this must be set to 0x0. The remaining bytes
* contain the report data. Since the Report ID is mandatory, calls to
* SDL_hid_write() will always contain one more byte than the report contains.
* For example, if a hid report is 16 bytes long, 17 bytes must be passed to
* SDL_hid_write(), the Report ID (or 0x0, for devices with a single report),
* followed by the report data (16 bytes). In this example, the length passed
* in would be 17.
*
* SDL_hid_write() will send the data on the first OUT endpoint, if one
* exists. If it does not, it will send the data through the Control Endpoint
* (Endpoint 0).
*
* \param dev A device handle returned from SDL_hid_open().
* \param data The data to send, including the report number as the first
* byte.
* \param length The length in bytes of the data to send.
* \returns the actual number of bytes written and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_write(SDL_hid_device *dev, const unsigned char *data, size_t length);
/**
* Read an Input report from a HID device with timeout.
*
* Input reports are returned to the host through the INTERRUPT IN endpoint.
* The first byte will contain the Report number if the device uses numbered
* reports.
*
* \param dev A device handle returned from SDL_hid_open().
* \param data A buffer to put the read data into.
* \param length The number of bytes to read. For devices with multiple
* reports, make sure to read an extra byte for the report
* number.
* \param milliseconds timeout in milliseconds or -1 for blocking wait.
* \returns the actual number of bytes read and -1 on error. If no packet was
* available to be read within the timeout period, this function
* returns 0.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_read_timeout(SDL_hid_device *dev, unsigned char *data, size_t length, int milliseconds);
/**
* Read an Input report from a HID device.
*
* Input reports are returned to the host through the INTERRUPT IN endpoint.
* The first byte will contain the Report number if the device uses numbered
* reports.
*
* \param dev A device handle returned from SDL_hid_open().
* \param data A buffer to put the read data into.
* \param length The number of bytes to read. For devices with multiple
* reports, make sure to read an extra byte for the report
* number.
* \returns the actual number of bytes read and -1 on error. If no packet was
* available to be read and the handle is in non-blocking mode, this
* function returns 0.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_read(SDL_hid_device *dev, unsigned char *data, size_t length);
/**
* Set the device handle to be non-blocking.
*
* In non-blocking mode calls to SDL_hid_read() will return immediately with a
* value of 0 if there is no data to be read. In blocking mode, SDL_hid_read()
* will wait (block) until there is data to read before returning.
*
* Nonblocking can be turned on and off at any time.
*
* \param dev A device handle returned from SDL_hid_open().
* \param nonblock enable or not the nonblocking reads - 1 to enable
* nonblocking - 0 to disable nonblocking.
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_set_nonblocking(SDL_hid_device *dev, int nonblock);
/**
* Send a Feature report to the device.
*
* Feature reports are sent over the Control endpoint as a Set_Report
* transfer. The first byte of `data` must contain the Report ID. For devices
* which only support a single report, this must be set to 0x0. The remaining
* bytes contain the report data. Since the Report ID is mandatory, calls to
* SDL_hid_send_feature_report() will always contain one more byte than the
* report contains. For example, if a hid report is 16 bytes long, 17 bytes
* must be passed to SDL_hid_send_feature_report(): the Report ID (or 0x0, for
* devices which do not use numbered reports), followed by the report data (16
* bytes). In this example, the length passed in would be 17.
*
* \param dev A device handle returned from SDL_hid_open().
* \param data The data to send, including the report number as the first
* byte.
* \param length The length in bytes of the data to send, including the report
* number.
* \returns the actual number of bytes written and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_send_feature_report(SDL_hid_device *dev, const unsigned char *data, size_t length);
/**
* Get a feature report from a HID device.
*
* Set the first byte of `data` to the Report ID of the report to be read.
* Make sure to allow space for this extra byte in `data`. Upon return, the
* first byte will still contain the Report ID, and the report data will start
* in data[1].
*
* \param dev A device handle returned from SDL_hid_open().
* \param data A buffer to put the read data into, including the Report ID.
* Set the first byte of `data` to the Report ID of the report to
* be read, or set it to zero if your device does not use numbered
* reports.
* \param length The number of bytes to read, including an extra byte for the
* report ID. The buffer can be longer than the actual report.
* \returns the number of bytes read plus one for the report ID (which is
* still in the first byte), or -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsigned char *data, size_t length);
/**
* Close a HID device.
*
* \param dev A device handle returned from SDL_hid_open().
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC void SDLCALL SDL_hid_close(SDL_hid_device *dev);
/**
* Get The Manufacturer String from a HID device.
*
* \param dev A device handle returned from SDL_hid_open().
* \param string A wide string buffer to put the data into.
* \param maxlen The length of the buffer in multiples of wchar_t.
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_get_manufacturer_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
/**
* Get The Product String from a HID device.
*
* \param dev A device handle returned from SDL_hid_open().
* \param string A wide string buffer to put the data into.
* \param maxlen The length of the buffer in multiples of wchar_t.
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_get_product_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
/**
* Get The Serial Number String from a HID device.
*
* \param dev A device handle returned from SDL_hid_open().
* \param string A wide string buffer to put the data into.
* \param maxlen The length of the buffer in multiples of wchar_t.
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_get_serial_number_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen);
/**
* Get a string from a HID device, based on its string index.
*
* \param dev A device handle returned from SDL_hid_open().
* \param string_index The index of the string to get.
* \param string A wide string buffer to put the data into.
* \param maxlen The length of the buffer in multiples of wchar_t.
* \returns 0 on success and -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int string_index, wchar_t *string, size_t maxlen);
/**
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers
*
* \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC void SDLCALL SDL_hid_ble_scan(SDL_bool active);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_hidapi_h_ */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -145,6 +145,26 @@ extern "C" {
*/ */
#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" #define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON"
/**
* \brief Specify an application name.
*
* This hint lets you specify the application name sent to the OS when
* required. For example, this will often appear in volume control applets for
* audio streams, and in lists of applications which are inhibiting the
* screensaver. You should use a string that describes your program ("My Game
* 2: The Revenge")
*
* Setting this to "" or leaving it unset will have SDL use a reasonable
* default: probably the application's name or "SDL Application" if SDL
* doesn't have any better information.
*
* Note that, for audio streams, this can be overridden with
* SDL_HINT_AUDIO_DEVICE_APP_NAME.
*
* On targets where this is not supported, this hint does nothing.
*/
#define SDL_HINT_APP_NAME "SDL_APP_NAME"
/** /**
* \brief A variable controlling whether controllers used with the Apple TV * \brief A variable controlling whether controllers used with the Apple TV
* generate UI events. * generate UI events.
@ -199,8 +219,9 @@ extern "C" {
* that describes your program ("My Game 2: The Revenge") * that describes your program ("My Game 2: The Revenge")
* *
* Setting this to "" or leaving it unset will have SDL use a reasonable * Setting this to "" or leaving it unset will have SDL use a reasonable
* default: probably the application's name or "SDL Application" if SDL * default: this will be the name set with SDL_HINT_APP_NAME, if that hint is
* doesn't have any better information. * set. Otherwise, it'll probably the application's name or "SDL Application"
* if SDL doesn't have any better information.
* *
* On targets where this is not supported, this hint does nothing. * On targets where this is not supported, this hint does nothing.
*/ */
@ -371,13 +392,14 @@ extern "C" {
#define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS" #define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS"
/** /**
* \brief A variable controlling whether SDL logs all events pushed onto its internal queue. * \brief A variable controlling verbosity of the logging of SDL events pushed onto the internal queue.
* *
* This variable can be set to the following values: * This variable can be set to the following values, from least to most verbose:
* *
* "0" - Don't log any events (default) * "0" - Don't log any events (default)
* "1" - Log all events except mouse and finger motion, which are pretty spammy. * "1" - Log most events (other than the really spammy ones).
* "2" - Log all events. * "2" - Include mouse and finger motion events.
* "3" - Include SDL_SysWMEvent events.
* *
* This is generally meant to be used to debug SDL itself, but can be useful * This is generally meant to be used to debug SDL itself, but can be useful
* for application developers that need better visibility into what is going * for application developers that need better visibility into what is going
@ -391,6 +413,19 @@ extern "C" {
*/ */
#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" #define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING"
/**
* \brief A variable controlling whether raising the window should be done more forcefully
*
* This variable can be set to the following values:
* "0" - No forcing (the default)
* "1" - Extra level of forcing
*
* At present, this is only an issue under MS Windows, which makes it nearly impossible to
* programmatically move a window to the foreground, for "security" reasons. See
* http://stackoverflow.com/a/34414846 for a discussion.
*/
#define SDL_HINT_FORCE_RAISEWINDOW "SDL_HINT_FORCE_RAISEWINDOW"
/** /**
* \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface.
* *
@ -536,6 +571,26 @@ extern "C" {
*/ */
#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
/**
* \brief A variable to control whether certain IMEs should show native UI components (such as the Candidate List) instead of suppressing them.
*
* The variable can be set to the following values:
* "0" - Native UI components are not display. (default)
* "1" - Native UI components are displayed.
*/
#define SDL_HINT_IME_SHOW_UI "SDL_IME_SHOW_UI"
/**
* \brief A variable to control if extended IME text support is enabled.
* If enabled then SDL_TextEditingExtEvent will be issued if the text would be truncated otherwise.
* Additionally SDL_TextInputEvent will be dispatched multiple times so that it is not truncated.
*
* The variable can be set to the following values:
* "0" - Legacy behavior. Text can be truncated, no heap allocations. (default)
* "1" - Modern behavior.
*/
#define SDL_HINT_IME_SUPPORT_EXTENDED_TEXT "SDL_IME_SUPPORT_EXTENDED_TEXT"
/** /**
* \brief A variable controlling whether the home indicator bar on iPhone X * \brief A variable controlling whether the home indicator bar on iPhone X
* should be hidden. * should be hidden.
@ -582,18 +637,42 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE" #define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE"
/** /**
* \brief A variable controlling whether Switch Joy-Cons should be treated the same as Switch Pro Controllers when using the HIDAPI driver. * \brief A variable controlling whether "low_frequency_rumble" and "high_frequency_rumble" is used to implement
* the GameCube controller's 3 rumble modes, Stop(0), Rumble(1), and StopHard(2)
* this is useful for applications that need full compatibility for things like ADSR envelopes.
* Stop is implemented by setting "low_frequency_rumble" to "0" and "high_frequency_rumble" ">0"
* Rumble is both at any arbitrary value,
* StopHard is implemented by setting both "low_frequency_rumble" and "high_frequency_rumble" to "0"
*
* This variable can be set to the following values:
* "0" - Normal rumble behavior is behavior is used (default)
* "1" - Proper GameCube controller rumble behavior is used
*
*/
#define SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE "SDL_JOYSTICK_GAMECUBE_RUMBLE_BRAKE"
/**
* \brief A variable controlling whether the HIDAPI driver for Nintendo Switch Joy-Cons should be used.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - basic Joy-Con support with no analog input (the default) * "0" - HIDAPI driver is not used
* "1" - Joy-Cons treated as half full Pro Controllers with analog inputs and sensors * "1" - HIDAPI driver is used
* *
* This does not combine Joy-Cons into a single controller. That's up to the user. * The default is the value of SDL_HINT_JOYSTICK_HIDAPI
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS "SDL_JOYSTICK_HIDAPI_JOY_CONS" #define SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS "SDL_JOYSTICK_HIDAPI_JOY_CONS"
/** /**
* \brief A variable controlling whether Nintendo Switch Joy-Con controllers will be combined into a single Pro-like controller when using the HIDAPI driver
*
* This variable can be set to the following values:
* "0" - Left and right Joy-Con controllers will not be combined and each will be a mini-gamepad
* "1" - Left and right Joy-Con controllers will be combined into a single controller (the default)
*/
#define SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS "SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS"
/**
* \brief A variable controlling whether the HIDAPI driver for Amazon Luna controllers connected via Bluetooth should be used. * \brief A variable controlling whether the HIDAPI driver for Amazon Luna controllers connected via Bluetooth should be used.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
@ -604,6 +683,28 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_LUNA "SDL_JOYSTICK_HIDAPI_LUNA" #define SDL_HINT_JOYSTICK_HIDAPI_LUNA "SDL_JOYSTICK_HIDAPI_LUNA"
/**
* \brief A variable controlling whether the HIDAPI driver for Nintendo Online classic 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_NINTENDO_CLASSIC "SDL_JOYSTICK_HIDAPI_NINTENDO_CLASSIC"
/**
* \brief A variable controlling whether the HIDAPI driver for NVIDIA SHIELD 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_SHIELD "SDL_JOYSTICK_HIDAPI_SHIELD"
/** /**
* \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used. * \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used.
* *
@ -690,9 +791,10 @@ extern "C" {
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - HIDAPI driver is not used * "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used * "1" - HIDAPI driver is used for Steam Controllers, which requires Bluetooth access
* and may prompt the user for permission on iOS and Android.
* *
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI * The default is "0"
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" #define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM"
@ -708,14 +810,36 @@ extern "C" {
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH"
/** /**
* \brief A variable controlling whether the Home button LED should be turned on when a Nintendo Switch controller is opened * \brief A variable controlling whether the Home button LED should be turned on when a Nintendo Switch Pro controller is opened
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - home button LED is left off * "0" - home button LED is turned off
* "1" - home button LED is turned on (the default) * "1" - home button LED is turned on
*
* By default the Home button LED state is not changed. This hint can also be set to a floating point value between 0.0 and 1.0 which controls the brightness of the Home button LED.
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED" #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED"
/**
* \brief A variable controlling whether the Home button LED should be turned on when a Nintendo Switch Joy-Con controller is opened
*
* This variable can be set to the following values:
* "0" - home button LED is turned off
* "1" - home button LED is turned on
*
* By default the Home button LED state is not changed. This hint can also be set to a floating point value between 0.0 and 1.0 which controls the brightness of the Home button LED.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED "SDL_JOYSTICK_HIDAPI_JOYCON_HOME_LED"
/**
* \brief A variable controlling whether the player LEDs should be lit to indicate which player is associated with a Nintendo Switch controller.
*
* This variable can be set to the following values:
* "0" - player LEDs are not enabled
* "1" - player LEDs are enabled (the default)
*/
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED"
/** /**
* \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used. * \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used.
* *
@ -727,17 +851,16 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX" #define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX"
/** /**
* \brief A variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices. * \brief A variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - RAWINPUT drivers are not used * "0" - RAWINPUT drivers are not used
* "1" - RAWINPUT drivers are used (the default) * "1" - RAWINPUT drivers are used (the default)
*
*/ */
#define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT" #define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT"
/** /**
* \brief A variable controlling whether the RAWINPUT driver should pull correlated data from XInput. * \brief A variable controlling whether the RAWINPUT driver should pull correlated data from XInput.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
@ -750,7 +873,16 @@ extern "C" {
*/ */
#define SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT "SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT" #define SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT "SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT"
/** /**
* \brief A variable controlling whether the ROG Chakram mice should show up as joysticks
*
* This variable can be set to the following values:
* "0" - ROG Chakram mice do not show up as joysticks (the default)
* "1" - ROG Chakram mice show up as joysticks
*/
#define SDL_HINT_JOYSTICK_ROG_CHAKRAM "SDL_JOYSTICK_ROG_CHAKRAM"
/**
* \brief A variable controlling whether a separate thread should be used * \brief A variable controlling whether a separate thread should be used
* for handling joystick detection and raw input messages on Windows * for handling joystick detection and raw input messages on Windows
* *
@ -784,7 +916,43 @@ 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"
/** /**
* \brief A comma separated list of devices to open as joysticks
*
* This variable is currently only used by the Linux joystick driver.
*/
#define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE"
/**
* \brief A variable controlling whether joysticks on Linux will always treat 'hat' axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking whether they may be analog.
*
* This variable can be set to the following values:
* "0" - Only map hat axis inputs to digital hat outputs if the input axes appear to actually be digital (the default)
* "1" - Always handle the input axes numbered ABS_HAT0X to ABS_HAT3Y as digital hats
*/
#define SDL_HINT_LINUX_DIGITAL_HATS "SDL_LINUX_DIGITAL_HATS"
/**
* \brief A variable controlling whether digital hats on Linux will apply deadzones to their underlying input axes or use unfiltered values.
*
* This variable can be set to the following values:
* "0" - Return digital hat values based on unfiltered input axis values
* "1" - Return digital hat values with deadzones on the input axes taken into account (the default)
*/
#define SDL_HINT_LINUX_HAT_DEADZONES "SDL_LINUX_HAT_DEADZONES"
/**
* \brief A variable controlling whether to use the classic /dev/input/js* joystick interface or the newer /dev/input/event* joystick interface on Linux
*
* This variable can be set to the following values:
* "0" - Use /dev/input/event*
* "1" - Use /dev/input/js*
*
* By default the /dev/input/event* interfaces are used
*/
#define SDL_HINT_LINUX_JOYSTICK_CLASSIC "SDL_LINUX_JOYSTICK_CLASSIC"
/**
* \brief A variable controlling whether joysticks on Linux adhere to their HID-defined deadzones or return unfiltered values. * \brief A variable controlling whether joysticks on Linux adhere to their HID-defined deadzones or return unfiltered values.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
@ -809,6 +977,24 @@ extern "C" {
*/ */
#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" #define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK"
/**
* \brief A variable controlling whether dispatching OpenGL context updates should block the dispatching thread until the main thread finishes processing
*
* This variable can be set to the following values:
* "0" - Dispatching OpenGL context updates will block the dispatching thread until the main thread finishes processing (default).
* "1" - Dispatching OpenGL context updates will allow the dispatching thread to continue execution.
*
* Generally you want the default, but if you have OpenGL code in a background thread on a Mac, and the main thread
* hangs because it's waiting for that background thread, but that background thread is also hanging because it's
* waiting for the main thread to do an update, this might fix your issue.
*
* This hint only applies to macOS.
*
* This hint is available since SDL 2.24.0.
*
*/
#define SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH "SDL_MAC_OPENGL_ASYNC_DISPATCH"
/** /**
* \brief A variable setting the double click radius, in pixels. * \brief A variable setting the double click radius, in pixels.
*/ */
@ -835,6 +1021,22 @@ extern "C" {
*/ */
#define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE" #define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE"
/**
* \brief A variable controlling whether relative mouse mode constrains the mouse to the center of the window
*
* This variable can be set to the following values:
* "0" - Relative mouse mode constrains the mouse to the window
* "1" - Relative mouse mode constrains the mouse to the center of the window
*
* Constraining to the center of the window works better for FPS games and when the
* application is running over RDP. Constraining to the whole window works better
* for 2D games and increases the chance that the mouse will be in the correct
* position when using high DPI mice.
*
* By default SDL will constrain the mouse to the center of the window
*/
#define SDL_HINT_MOUSE_RELATIVE_MODE_CENTER "SDL_MOUSE_RELATIVE_MODE_CENTER"
/** /**
* \brief A variable controlling whether relative mouse mode is implemented using mouse warping * \brief A variable controlling whether relative mouse mode is implemented using mouse warping
* *
@ -862,6 +1064,17 @@ extern "C" {
*/ */
#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE" #define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE"
/**
* \brief A variable controlling whether a motion event should be generated for mouse warping in relative mode.
*
* This variable can be set to the following values:
* "0" - Warping the mouse will not generate a motion event in relative mode
* "1" - Warping the mouse will generate a motion event in relative mode
*
* By default warping the mouse will not generate motion events in relative mode. This avoids the application having to filter out large relative motion due to warping.
*/
#define SDL_HINT_MOUSE_RELATIVE_WARP_MOTION "SDL_MOUSE_RELATIVE_WARP_MOTION"
/** /**
* \brief A variable controlling whether mouse events should generate synthetic touch events * \brief A variable controlling whether mouse events should generate synthetic touch events
* *
@ -871,6 +1084,19 @@ extern "C" {
*/ */
#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" #define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS"
/**
* \brief A variable controlling whether the mouse is captured while mouse buttons are pressed
*
* This variable can be set to the following values:
* "0" - The mouse is not captured while mouse buttons are pressed
* "1" - The mouse is captured while mouse buttons are pressed
*
* By default the mouse is captured while mouse buttons are pressed so if the mouse is dragged
* outside the window, the application continues to receive mouse events until the button is
* released.
*/
#define SDL_HINT_MOUSE_AUTO_CAPTURE "SDL_MOUSE_AUTO_CAPTURE"
/** /**
* \brief Tell SDL not to catch the SIGINT or SIGTERM signals. * \brief Tell SDL not to catch the SIGINT or SIGTERM signals.
* *
@ -926,6 +1152,22 @@ extern "C" {
*/ */
#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" #define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
/**
* \brief A variable controlling the use of a sentinel event when polling the event queue
*
* This variable can be set to the following values:
* "0" - Disable poll sentinels
* "1" - Enable poll sentinels
*
* When polling for events, SDL_PumpEvents is used to gather new events from devices.
* If a device keeps producing new events between calls to SDL_PumpEvents, a poll loop will
* become stuck until the new events stop.
* This is most noticable when moving a high frequency mouse.
*
* By default, poll sentinels are enabled.
*/
#define SDL_HINT_POLL_SENTINEL "SDL_POLL_SENTINEL"
/** /**
* \brief Override for SDL_GetPreferredLocales() * \brief Override for SDL_GetPreferredLocales()
* *
@ -992,6 +1234,19 @@ extern "C" {
*/ */
#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" #define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING"
/**
* \brief A variable controlling how the 2D render API renders lines
*
* This variable can be set to the following values:
* "0" - Use the default line drawing method (Bresenham's line algorithm as of SDL 2.0.20)
* "1" - Use the driver point API using Bresenham's line algorithm (correct, draws many points)
* "2" - Use the driver line API (occasionally misses line endpoints based on hardware driver quirks, was the default before 2.0.20)
* "3" - Use the driver geometry API (correct, draws thicker diagonal lines)
*
* This variable should be set when the renderer is created.
*/
#define SDL_HINT_RENDER_LINE_METHOD "SDL_RENDER_LINE_METHOD"
/** /**
* \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer.
* *
@ -1025,6 +1280,8 @@ extern "C" {
* *
* This variable is case insensitive and can be set to the following values: * This variable is case insensitive and can be set to the following values:
* "direct3d" * "direct3d"
* "direct3d11"
* "direct3d12"
* "opengl" * "opengl"
* "opengles2" * "opengles2"
* "opengles" * "opengles"
@ -1081,7 +1338,7 @@ extern "C" {
*/ */
#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC"
/** /**
* \brief A variable to control whether the return key on the soft keyboard * \brief A variable to control whether the return key on the soft keyboard
* should hide the soft keyboard on Android and iOS. * should hide the soft keyboard on Android and iOS.
* *
@ -1101,6 +1358,26 @@ extern "C" {
*/ */
#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" #define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER"
/**
* \brief Specify an "activity name" for screensaver inhibition.
*
* Some platforms, notably Linux desktops, list the applications which are
* inhibiting the screensaver or other power-saving features.
*
* This hint lets you specify the "activity name" sent to the OS when
* SDL_DisableScreenSaver() is used (or the screensaver is automatically
* disabled). The contents of this hint are used when the screensaver is
* disabled. You should use a string that describes what your program is doing
* (and, therefore, why the screensaver is disabled). For example, "Playing a
* game" or "Watching a video".
*
* Setting this to "" or leaving it unset will have SDL use a reasonable
* default: "Playing a game" or something similar.
*
* On targets where this is not supported, this hint does nothing.
*/
#define SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME "SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME"
/** /**
* \brief Specifies whether SDL_THREAD_PRIORITY_TIME_CRITICAL should be treated as realtime. * \brief Specifies whether SDL_THREAD_PRIORITY_TIME_CRITICAL should be treated as realtime.
* *
@ -1178,6 +1455,18 @@ extern "C" {
*/ */
#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" #define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS"
/**
* \brief A variable controlling which touchpad should generate synthetic mouse events
*
* This variable can be set to the following values:
* "0" - Only front touchpad should generate mouse events. Default
* "1" - Only back touchpad should generate mouse events.
* "2" - Both touchpads should generate mouse events.
*
* By default SDL will generate mouse events for all touch devices
*/
#define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_HINT_VITA_TOUCH_MOUSE_DEVICE"
/** /**
* \brief A variable controlling whether the Android / tvOS remotes * \brief A variable controlling whether the Android / tvOS remotes
* should be listed as joystick devices, instead of sending keyboard events. * should be listed as joystick devices, instead of sending keyboard events.
@ -1218,6 +1507,17 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" #define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER"
/**
* \brief A variable controlling whether the EGL window is allowed to be
* composited as transparent, rather than opaque.
*
* Most window systems will always render windows opaque, even if the surface
* format has an alpha channel. This is not always true, however, so by default
* SDL will try to enforce opaque composition. To override this behavior, you
* can set this hint to "1".
*/
#define SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY"
/** /**
* \brief A variable controlling whether the graphics context is externally managed. * \brief A variable controlling whether the graphics context is externally managed.
* *
@ -1251,9 +1551,7 @@ extern "C" {
* SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen"
* button on their titlebars). * button on their titlebars).
* *
* The default value is "1". Spaces are disabled regardless of this hint if * The default value is "1". This hint must be set before any windows are created.
* the OS isn't at least Mac OS X Lion (10.7). This hint must be set before
* any windows are created.
*/ */
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" #define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
@ -1276,6 +1574,35 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR" #define SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR"
/**
* \brief A variable controlling whether the libdecor Wayland backend is preferred over native decrations.
*
* When this hint is set, libdecor will be used to provide window decorations, even if xdg-decoration is
* available. (Note that, by default, libdecor will use xdg-decoration itself if available).
*
* This variable can be set to the following values:
* "0" - libdecor is enabled only if server-side decorations are unavailable.
* "1" - libdecor is always enabled if available.
*
* libdecor is used over xdg-shell when xdg-decoration protocol is unavailable.
*/
#define SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR "SDL_VIDEO_WAYLAND_PREFER_LIBDECOR"
/**
* \brief A variable controlling whether video mode emulation is enabled under Wayland.
*
* When this hint is set, a standard set of emulated CVT video modes will be exposed for use by the application.
* If it is disabled, the only modes exposed will be the logical desktop size and, in the case of a scaled
* desktop, the native display resolution.
*
* This variable can be set to the following values:
* "0" - Video mode emulation is disabled.
* "1" - Video mode emulation is enabled.
*
* By default video mode emulation is enabled.
*/
#define SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION "SDL_VIDEO_WAYLAND_MODE_EMULATION"
/** /**
* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). * \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
* *
@ -1295,6 +1622,28 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" #define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
/**
* \brief When calling SDL_CreateWindowFrom(), make the window compatible with OpenGL.
*
* This variable can be set to the following values:
* "0" - Don't add any graphics flags to the SDL_WindowFlags
* "1" - Add SDL_WINDOW_OPENGL to the SDL_WindowFlags
*
* By default SDL will not make the foreign window compatible with OpenGL.
*/
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL "SDL_VIDEO_FOREIGN_WINDOW_OPENGL"
/**
* \brief When calling SDL_CreateWindowFrom(), make the window compatible with Vulkan.
*
* This variable can be set to the following values:
* "0" - Don't add any graphics flags to the SDL_WindowFlags
* "1" - Add SDL_WINDOW_VULKAN to the SDL_WindowFlags
*
* By default SDL will not make the foreign window compatible with Vulkan.
*/
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN "SDL_VIDEO_FOREIGN_WINDOW_VULKAN"
/** /**
* \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries * \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries
* *
@ -1355,13 +1704,11 @@ extern "C" {
#define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID" #define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID"
/** /**
* \brief A variable controlling whether the X11 Xinerama extension should be used. * \brief A no-longer-used variable controlling whether the X11 Xinerama extension should be used.
* *
* This variable can be set to the following values: * Before SDL 2.0.24, this would let apps and users disable Xinerama support on X11.
* "0" - Disable Xinerama * Now SDL never uses Xinerama, and does not check for this hint at all.
* "1" - Enable Xinerama * The preprocessor define is left here for source compatibility.
*
* By default SDL will use Xinerama if it is available.
*/ */
#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" #define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA"
@ -1372,18 +1719,16 @@ extern "C" {
* "0" - Disable XRandR * "0" - Disable XRandR
* "1" - Enable XRandR * "1" - Enable XRandR
* *
* By default SDL will not use XRandR because of window manager issues. * By default SDL will use XRandR.
*/ */
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" #define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"
/** /**
* \brief A variable controlling whether the X11 VidMode extension should be used. * \brief A no-longer-used variable controlling whether the X11 VidMode extension should be used.
* *
* This variable can be set to the following values: * Before SDL 2.0.24, this would let apps and users disable XVidMode support on X11.
* "0" - Disable XVidMode * Now SDL never uses XVidMode, and does not check for this hint at all.
* "1" - Enable XVidMode * The preprocessor define is left here for source compatibility.
*
* By default SDL will use XVidMode if it is available.
*/ */
#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" #define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE"
@ -1484,9 +1829,6 @@ extern "C" {
* They offer better performance, allocate no kernel ressources and * They offer better performance, allocate no kernel ressources and
* use less memory. SDL will fall back to Critical Sections on older * use less memory. SDL will fall back to Critical Sections on older
* OS versions or if forced to by this hint. * OS versions or if forced to by this hint.
* This also affects Condition Variables. When SRW mutexes are used,
* SDL will use Windows Condition Variables as well. Else, a generic
* SDL_cond implementation will be used that works with all mutexes.
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - Use SRW Locks when available. If not, fall back to Critical Sections. (default) * "0" - Use SRW Locks when available. If not, fall back to Critical Sections. (default)
@ -1546,6 +1888,57 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX" #define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX"
/**
* \brief Controls whether SDL will declare the process to be DPI aware.
*
* This hint must be set before initializing the video subsystem.
*
* The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
* a DPI scale factor.
*
* This hint is equivalent to requesting DPI awareness via external means (e.g. calling SetProcessDpiAwarenessContext)
* and does not cause SDL to use a virtualized coordinate system, so it will generally give you 1 SDL coordinate = 1 pixel
* even on high-DPI displays.
*
* For more information, see:
* https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
*
* This variable can be set to the following values:
* "" - Do not change the DPI awareness (default).
* "unaware" - Declare the process as DPI unaware. (Windows 8.1 and later).
* "system" - Request system DPI awareness. (Vista and later).
* "permonitor" - Request per-monitor DPI awareness. (Windows 8.1 and later).
* "permonitorv2" - Request per-monitor V2 DPI awareness. (Windows 10, version 1607 and later).
* The most visible difference from "permonitor" is that window title bar will be scaled
* to the visually correct size when dragging between monitors with different scale factors.
* This is the preferred DPI awareness level.
*
* If the requested DPI awareness is not available on the currently running OS, SDL will try to request the best
* available match.
*/
#define SDL_HINT_WINDOWS_DPI_AWARENESS "SDL_WINDOWS_DPI_AWARENESS"
/**
* \brief Uses DPI-scaled points as the SDL coordinate system on Windows.
*
* This changes the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere.
* This means windows will be appropriately sized, even when created on high-DPI displays with scaling.
*
* e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings,
* will create a window with an 800x600 client area (in pixels).
*
* Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
* and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
*
* This variable can be set to the following values:
* "0" - SDL coordinates equal Windows coordinates. No automatic window resizing when dragging
* between monitors with different scale factors (unless this is performed by
* Windows itself, which is the case when the process is DPI unaware).
* "1" - SDL coordinates are in DPI-scaled points. Automatically resize windows as needed on
* displays with non-100% scale factors.
*/
#define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING"
/** /**
* \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
* *
@ -1557,6 +1950,17 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" #define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"
/**
* \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called
*
* This variable can be set to the following values:
* "0" - The window is activated when the SDL_ShowWindow function is called
* "1" - The window is not activated when the SDL_ShowWindow function is called
*
* By default SDL will activate the window when the SDL_ShowWindow function is called
*/
#define SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN "SDL_WINDOW_NO_ACTIVATION_WHEN_SHOWN"
/** \brief Allows back-button-press events on Windows Phone to be marked as handled /** \brief Allows back-button-press events on Windows Phone to be marked as handled
* *
* Windows Phone devices typically feature a Back button. When pressed, * Windows Phone devices typically feature a Back button. When pressed,
@ -1677,6 +2081,15 @@ extern "C" {
*/ */
#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" #define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED"
/**
* \brief A variable that lets you disable the detection and use of DirectInput gamepad devices
*
* The variable can be set to the following values:
* "0" - Disable DirectInput detection (only uses XInput)
* "1" - Enable DirectInput detection (the default)
*/
#define SDL_HINT_DIRECTINPUT_ENABLED "SDL_DIRECTINPUT_ENABLED"
/** /**
* \brief A variable that causes SDL to use the old axis and button mapping for XInput devices. * \brief A variable that causes SDL to use the old axis and button mapping for XInput devices.
* *
@ -1705,6 +2118,133 @@ extern "C" {
*/ */
#define SDL_HINT_AUDIO_INCLUDE_MONITORS "SDL_AUDIO_INCLUDE_MONITORS" #define SDL_HINT_AUDIO_INCLUDE_MONITORS "SDL_AUDIO_INCLUDE_MONITORS"
/**
* \brief A variable that forces X11 windows to create as a custom type.
*
* This is currently only used for X11 and ignored elsewhere.
*
* During SDL_CreateWindow, SDL uses the _NET_WM_WINDOW_TYPE X11 property
* to report to the window manager the type of window it wants to create.
* This might be set to various things if SDL_WINDOW_TOOLTIP or
* SDL_WINDOW_POPUP_MENU, etc, were specified. For "normal" windows that
* haven't set a specific type, this hint can be used to specify a custom
* type. For example, a dock window might set this to
* "_NET_WM_WINDOW_TYPE_DOCK".
*
* If not set or set to "", this hint is ignored. This hint must be set
* before the SDL_CreateWindow() call that it is intended to affect.
*
* This hint is available since SDL 2.0.22.
*/
#define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE"
/**
* \brief A variable that decides whether to send SDL_QUIT when closing the final window.
*
* By default, SDL sends an SDL_QUIT event when there is only one window
* and it receives an SDL_WINDOWEVENT_CLOSE event, under the assumption most
* apps would also take the loss of this window as a signal to terminate the
* program.
*
* However, it's not unreasonable in some cases to have the program continue
* to live on, perhaps to create new windows later.
*
* Changing this hint to "0" will cause SDL to not send an SDL_QUIT event
* when the final window is requesting to close. Note that in this case,
* there are still other legitimate reasons one might get an SDL_QUIT
* event: choosing "Quit" from the macOS menu bar, sending a SIGINT (ctrl-c)
* on Unix, etc.
*
* The default value is "1". This hint can be changed at any time.
*
* This hint is available since SDL 2.0.22. Before then, you always get
* an SDL_QUIT event when closing the final window.
*/
#define SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE "SDL_QUIT_ON_LAST_WINDOW_CLOSE"
/**
* \brief A variable that decides what video backend to use.
*
* By default, SDL will try all available video backends in a reasonable
* order until it finds one that can work, but this hint allows the app
* or user to force a specific target, such as "x11" if, say, you are
* on Wayland but want to try talking to the X server instead.
*
* This functionality has existed since SDL 2.0.0 (indeed, before that)
* but before 2.0.22 this was an environment variable only. In 2.0.22,
* it was upgraded to a full SDL hint, so you can set the environment
* variable as usual or programatically set the hint with SDL_SetHint,
* which won't propagate to child processes.
*
* The default value is unset, in which case SDL will try to figure out
* the best video backend on your behalf. This hint needs to be set
* before SDL_Init() is called to be useful.
*
* This hint is available since SDL 2.0.22. Before then, you could set
* the environment variable to get the same effect.
*/
#define SDL_HINT_VIDEODRIVER "SDL_VIDEODRIVER"
/**
* \brief A variable that decides what audio backend to use.
*
* By default, SDL will try all available audio backends in a reasonable
* order until it finds one that can work, but this hint allows the app
* or user to force a specific target, such as "alsa" if, say, you are
* on PulseAudio but want to try talking to the lower level instead.
*
* This functionality has existed since SDL 2.0.0 (indeed, before that)
* but before 2.0.22 this was an environment variable only. In 2.0.22,
* it was upgraded to a full SDL hint, so you can set the environment
* variable as usual or programatically set the hint with SDL_SetHint,
* which won't propagate to child processes.
*
* The default value is unset, in which case SDL will try to figure out
* the best audio backend on your behalf. This hint needs to be set
* before SDL_Init() is called to be useful.
*
* This hint is available since SDL 2.0.22. Before then, you could set
* the environment variable to get the same effect.
*/
#define SDL_HINT_AUDIODRIVER "SDL_AUDIODRIVER"
/**
* \brief A variable that decides what KMSDRM device to use.
*
* Internally, SDL might open something like "/dev/dri/cardNN" to
* access KMSDRM functionality, where "NN" is a device index number.
*
* SDL makes a guess at the best index to use (usually zero), but the
* app or user can set this hint to a number between 0 and 99 to
* force selection.
*
* This hint is available since SDL 2.24.0.
*/
#define SDL_HINT_KMSDRM_DEVICE_INDEX "SDL_KMSDRM_DEVICE_INDEX"
/**
* \brief A variable that treats trackpads as touch devices.
*
* On macOS (and possibly other platforms in the future), SDL will report
* touches on a trackpad as mouse input, which is generally what users
* expect from this device; however, these are often actually full
* multitouch-capable touch devices, so it might be preferable to some apps
* to treat them as such.
*
* Setting this hint to true will make the trackpad input report as a
* multitouch device instead of a mouse. The default is false.
*
* Note that most platforms don't support this hint. As of 2.24.0, it
* only supports MacBooks' trackpads on macOS. Others may follow later.
*
* This hint is checked during SDL_Init and can not be changed after.
*
* This hint is available since SDL 2.24.0.
*/
#define SDL_HINT_TRACKPAD_IS_TOUCH_ONLY "SDL_TRACKPAD_IS_TOUCH_ONLY"
/** /**
* \brief An enumeration of hint priorities * \brief An enumeration of hint priorities
@ -1729,6 +2269,8 @@ typedef enum
* \param priority the SDL_HintPriority level for the hint * \param priority the SDL_HintPriority level for the hint
* \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise. * \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetHint * \sa SDL_GetHint
* \sa SDL_SetHint * \sa SDL_SetHint
*/ */
@ -1747,18 +2289,39 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
* \param value the value of the hint variable * \param value the value of the hint variable
* \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise. * \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetHint * \sa SDL_GetHint
* \sa SDL_SetHintWithPriority * \sa SDL_SetHintWithPriority
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name,
const char *value); const char *value);
/**
* Reset a hint to the default value.
*
* This will reset a hint to the value of the environment variable, or NULL if
* the environment isn't set. Callbacks will be called normally with this
* change.
*
* \param name the hint to set
* \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetHint
* \sa SDL_SetHint
*/
extern DECLSPEC SDL_bool SDLCALL SDL_ResetHint(const char *name);
/** /**
* Get the value of a hint. * Get the value of a hint.
* *
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetHint * \sa SDL_SetHint
* \sa SDL_SetHintWithPriority * \sa SDL_SetHintWithPriority
*/ */
@ -1825,6 +2388,8 @@ extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name,
* Clear all hints. * Clear all hints.
* *
* This function is automatically called during SDL_Quit(). * This function is automatically called during SDL_Quit().
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_ClearHints(void); extern DECLSPEC void SDLCALL SDL_ClearHints(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -43,6 +43,7 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_guid.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -69,9 +70,7 @@ struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick;
/* A structure that encodes the stable unique id for a joystick device */ /* A structure that encodes the stable unique id for a joystick device */
typedef struct { typedef SDL_GUID SDL_JoystickGUID;
Uint8 data[16];
} SDL_JoystickGUID;
/** /**
* This is a unique ID for a joystick for the time it is connected to the system, * This is a unique ID for a joystick for the time it is connected to the system,
@ -124,6 +123,8 @@ typedef enum
* In particular, you are guaranteed that the joystick list won't change, so * In particular, you are guaranteed that the joystick list won't change, so
* the API functions that take a joystick index will be valid, and joystick * the API functions that take a joystick index will be valid, and joystick
* and game controller events will not be delivered. * and game controller events will not be delivered.
*
* \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
@ -137,6 +138,8 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
* In particular, you are guaranteed that the joystick list won't change, so * In particular, you are guaranteed that the joystick list won't change, so
* the API functions that take a joystick index will be valid, and joystick * the API functions that take a joystick index will be valid, and joystick
* and game controller events will not be delivered. * and game controller events will not be delivered.
*
* \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
@ -146,7 +149,10 @@ extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
* \returns the number of attached joysticks on success or a negative error * \returns the number of attached joysticks on success or a negative error
* code on failure; call SDL_GetError() for more information. * code on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickName * \sa SDL_JoystickName
* \sa SDL_JoystickPath
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
@ -161,14 +167,35 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickName * \sa SDL_JoystickName
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
/**
* Get the implementation dependent path of a joystick.
*
* This can be called before any joysticks are opened.
*
* \param device_index the index of the joystick to query (the N'th joystick
* on the system)
* \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_JoystickPath
* \sa SDL_JoystickOpen
*/
extern DECLSPEC const char *SDLCALL SDL_JoystickPathForIndex(int device_index);
/** /**
* Get the player index of a joystick, or -1 if it's not available This can be * Get the player index of a joystick, or -1 if it's not available This can be
* called before any joysticks are opened. * called before any joysticks are opened.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index); extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
@ -183,6 +210,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
* \returns the GUID of the selected joystick. If called on an invalid index, * \returns the GUID of the selected joystick. If called on an invalid index,
* this function returns a zero GUID * this function returns a zero GUID
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetGUID * \sa SDL_JoystickGetGUID
* \sa SDL_JoystickGetGUIDString * \sa SDL_JoystickGetGUIDString
*/ */
@ -198,6 +227,8 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_in
* on the system * on the system
* \returns the USB vendor ID of the selected joystick. If called on an * \returns the USB vendor ID of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
@ -211,6 +242,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
* on the system * on the system
* \returns the USB product ID of the selected joystick. If called on an * \returns the USB product ID of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
@ -224,6 +257,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
* on the system * on the system
* \returns the product version of the selected joystick. If called on an * \returns the product version of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
@ -236,6 +271,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_in
* on the system * on the system
* \returns the SDL_JoystickType of the selected joystick. If called on an * \returns the SDL_JoystickType of the selected joystick. If called on an
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN` * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index); extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index);
@ -249,6 +286,8 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
* on the system * on the system
* \returns the instance id of the selected joystick. If called on an invalid * \returns the instance id of the selected joystick. If called on an invalid
* index, this function returns zero * index, this function returns zero
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index); extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index);
@ -267,6 +306,8 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int devic
* \returns a joystick identifier or NULL if an error occurred; call * \returns a joystick identifier or NULL if an error occurred; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickClose * \sa SDL_JoystickClose
* \sa SDL_JoystickInstanceID * \sa SDL_JoystickInstanceID
*/ */
@ -289,6 +330,8 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
* \param player_index the player index to get the SDL_Joystick for * \param player_index the player index to get the SDL_Joystick for
* \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.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index); extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index);
@ -296,18 +339,70 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_ind
* Attach a new virtual joystick. * Attach a new virtual joystick.
* *
* \returns the joystick's device index, or -1 if an error occurred. * \returns the joystick's device index, or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
int naxes, int naxes,
int nbuttons, int nbuttons,
int nhats); int nhats);
/**
* The structure that defines an extended virtual joystick description
*
* The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
* All other elements of this structure are optional and can be left 0.
*
* \sa SDL_JoystickAttachVirtualEx
*/
typedef struct SDL_VirtualJoystickDesc
{
Uint16 version; /**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` */
Uint16 type; /**< `SDL_JoystickType` */
Uint16 naxes; /**< the number of axes on this joystick */
Uint16 nbuttons; /**< the number of buttons on this joystick */
Uint16 nhats; /**< the number of hats on this joystick */
Uint16 vendor_id; /**< the USB vendor ID of this joystick */
Uint16 product_id; /**< the USB product ID of this joystick */
Uint16 padding; /**< unused */
Uint32 button_mask; /**< A mask of which buttons are valid for this controller
e.g. (1 << SDL_CONTROLLER_BUTTON_A) */
Uint32 axis_mask; /**< A mask of which axes are valid for this controller
e.g. (1 << SDL_CONTROLLER_AXIS_LEFTX) */
const char *name; /**< the name of the joystick */
void *userdata; /**< User data pointer passed to callbacks */
void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_JoystickRumble() */
int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_JoystickRumbleTriggers() */
int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_JoystickSetLED() */
int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_JoystickSendEffect() */
} SDL_VirtualJoystickDesc;
/**
* \brief The current version of the SDL_VirtualJoystickDesc structure
*/
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
/**
* Attach a new virtual joystick with extended properties.
*
* \returns the joystick's device index, or -1 if an error occurred.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc);
/** /**
* Detach a virtual joystick. * Detach a virtual joystick.
* *
* \param device_index a value previously returned from * \param device_index a value previously returned from
* SDL_JoystickAttachVirtual() * SDL_JoystickAttachVirtual()
* \returns 0 on success, or -1 if an error occurred. * \returns 0 on success, or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index); extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);
@ -316,6 +411,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);
* *
* \param device_index a joystick device index. * \param device_index a joystick device index.
* \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise. * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index); extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
@ -332,6 +429,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
* \param axis the specific axis on the virtual joystick to set. * \param axis the specific axis on the virtual joystick to set.
* \param value the new value for the specified axis. * \param value the new value for the specified axis.
* \returns 0 on success, -1 on error. * \returns 0 on success, -1 on error.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
@ -348,6 +447,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, i
* \param button the specific button on the virtual joystick to set. * \param button the specific button on the virtual joystick to set.
* \param value the new value for the specified button. * \param value the new value for the specified button.
* \returns 0 on success, -1 on error. * \returns 0 on success, -1 on error.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
@ -364,6 +465,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick,
* \param hat the specific hat on the virtual joystick to set. * \param hat the specific hat on the virtual joystick to set.
* \param value the new value for the specified hat. * \param value the new value for the specified hat.
* \returns 0 on success, -1 on error. * \returns 0 on success, -1 on error.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
@ -381,6 +484,19 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, in
*/ */
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick); extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
/**
* Get the implementation dependent path of a joystick.
*
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_JoystickPathForIndex
*/
extern DECLSPEC const char *SDLCALL SDL_JoystickPath(SDL_Joystick *joystick);
/** /**
* Get the player index of an opened joystick. * Get the player index of an opened joystick.
* *
@ -389,6 +505,8 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the player index, or -1 if it's not available. * \returns the player index, or -1 if it's not available.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick); extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
@ -396,7 +514,10 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
* Set the player index of an opened joystick. * Set the player index of an opened joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \param player_index the player index to set. * \param player_index Player index to assign to this joystick, or -1 to clear
* the player index and turn off player LEDs.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index); extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index);
@ -410,6 +531,8 @@ extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick,
* this function returns a zero GUID; call SDL_GetError() for more * this function returns a zero GUID; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetDeviceGUID * \sa SDL_JoystickGetDeviceGUID
* \sa SDL_JoystickGetGUIDString * \sa SDL_JoystickGetGUIDString
*/ */
@ -422,6 +545,8 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joyst
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \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.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
@ -432,6 +557,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \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.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
@ -442,9 +569,24 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the product version of the selected joystick, or 0 if unavailable. * \returns the product version of the selected joystick, or 0 if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick); extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick);
/**
* Get the firmware version of an opened joystick, if available.
*
* If the firmware version isn't available this function returns 0.
*
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the firmware version of the selected joystick, or 0 if
* unavailable.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetFirmwareVersion(SDL_Joystick *joystick);
/** /**
* Get the serial number of an opened joystick, if available. * Get the serial number of an opened joystick, if available.
* *
@ -453,6 +595,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joyst
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the serial number of the selected joystick, or NULL if * \returns the serial number of the selected joystick, or NULL if
* unavailable. * unavailable.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick); extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick);
@ -461,6 +605,8 @@ extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystic
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
* \returns the SDL_JoystickType of the selected joystick. * \returns the SDL_JoystickType of the selected joystick.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick); extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick);
@ -473,6 +619,8 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joyst
* \param pszGUID buffer in which to write the ASCII string * \param pszGUID buffer in which to write the ASCII string
* \param cbGUID the size of pszGUID * \param cbGUID the size of pszGUID
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetDeviceGUID * \sa SDL_JoystickGetDeviceGUID
* \sa SDL_JoystickGetGUID * \sa SDL_JoystickGetGUID
* \sa SDL_JoystickGetGUIDFromString * \sa SDL_JoystickGetGUIDFromString
@ -489,6 +637,8 @@ extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, ch
* \param pchGUID string containing an ASCII representation of a GUID * \param pchGUID string containing an ASCII representation of a GUID
* \returns a SDL_JoystickGUID structure. * \returns a SDL_JoystickGUID structure.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetGUIDString * \sa SDL_JoystickGetGUIDString
*/ */
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
@ -500,6 +650,8 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const cha
* \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not; * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickClose * \sa SDL_JoystickClose
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
@ -512,6 +664,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick)
* \returns the instance ID of the specified joystick on success or a negative * \returns the instance ID of the specified joystick on success or a negative
* error code on failure; call SDL_GetError() for more information. * error code on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick); extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick);
@ -528,6 +682,8 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joys
* negative error code on failure; call SDL_GetError() for more * negative error code on failure; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetAxis * \sa SDL_JoystickGetAxis
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
@ -545,6 +701,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
* \returns the number of trackballs on success or a negative error code on * \returns the number of trackballs on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetBall * \sa SDL_JoystickGetBall
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
@ -556,6 +714,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
* \returns the number of POV hats on success or a negative error code on * \returns the number of POV hats on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetHat * \sa SDL_JoystickGetHat
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
@ -568,6 +728,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
* \returns the number of buttons on success or a negative error code on * \returns the number of buttons on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetButton * \sa SDL_JoystickGetButton
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
@ -579,6 +741,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
* 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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickEventState * \sa SDL_JoystickEventState
*/ */
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
@ -602,12 +766,15 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
* If `state` is `SDL_QUERY` then the current state is returned, * If `state` is `SDL_QUERY` then the current state is returned,
* otherwise the new processing state is returned. * otherwise the new processing state is returned.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerEventState * \sa SDL_GameControllerEventState
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
#define SDL_JOYSTICK_AXIS_MAX 32767 #define SDL_JOYSTICK_AXIS_MAX 32767
#define SDL_JOYSTICK_AXIS_MIN -32768 #define SDL_JOYSTICK_AXIS_MIN -32768
/** /**
* Get the current state of an axis control on a joystick. * Get the current state of an axis control on a joystick.
* *
@ -626,6 +793,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickNumAxes * \sa SDL_JoystickNumAxes
*/ */
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
@ -642,6 +811,8 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
* \param axis the axis to query; the axis indices start at index 0 * \param axis the axis to query; the axis indices start at index 0
* \param state Upon return, the initial value is supplied here. * \param state Upon return, the initial value is supplied here.
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick, extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick,
int axis, Sint16 *state); int axis, Sint16 *state);
@ -680,6 +851,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *j
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickNumHats * \sa SDL_JoystickNumHats
*/ */
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
@ -700,6 +873,8 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickNumBalls * \sa SDL_JoystickNumBalls
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
@ -713,6 +888,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
* index 0 * index 0
* \returns 1 if the specified button is pressed, 0 otherwise. * \returns 1 if the specified button is pressed, 0 otherwise.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickNumButtons * \sa SDL_JoystickNumButtons
*/ */
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
@ -731,6 +908,10 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if rumble isn't supported on this joystick * \returns 0, or -1 if rumble isn't supported on this joystick
*
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_JoystickHasRumble
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@ -740,9 +921,9 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 lo
* Each call to this function cancels any previous trigger rumble effect, and * Each call to this function cancels any previous trigger rumble effect, and
* calling it with 0 intensity stops any rumbling. * calling it with 0 intensity stops any rumbling.
* *
* Note that this function is for _trigger_ rumble; the first joystick to * Note that this is rumbling of the _triggers_ and not the game controller as
* support this was the PlayStation 5's DualShock 5 controller. If you want * a whole. This is currently only supported on Xbox One controllers. If you
* the (more common) whole-controller rumble, use SDL_JoystickRumble() * want the (more common) whole-controller rumble, use SDL_JoystickRumble()
* instead. * instead.
* *
* \param joystick The joystick to vibrate * \param joystick The joystick to vibrate
@ -752,6 +933,10 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 lo
* to 0xFFFF * to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if trigger rumble isn't supported on this joystick * \returns 0, or -1 if trigger rumble isn't supported on this joystick
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_JoystickHasRumbleTriggers
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
@ -763,9 +948,35 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, U
* *
* \param joystick The joystick to query * \param joystick The joystick to query
* \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise. * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick); extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
/**
* Query whether a joystick has rumble support.
*
* \param joystick The joystick to query
* \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_JoystickRumble
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
/**
* Query whether a joystick has rumble support on triggers.
*
* \param joystick The joystick to query
* \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_JoystickRumbleTriggers
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick);
/** /**
* Update a joystick's LED color. * Update a joystick's LED color.
* *
@ -777,6 +988,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
* \param green The intensity of the green LED * \param green The intensity of the green LED
* \param blue The intensity of the blue LED * \param blue The intensity of the blue LED
* \returns 0 on success, -1 if this joystick does not have a modifiable LED * \returns 0 on success, -1 if this joystick does not have a modifiable LED
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
@ -787,6 +1000,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red
* \param data The data to send to the joystick * \param data The data to send to the joystick
* \param size The size of the data to send to the joystick * \param size The size of the data to send to the joystick
* \returns 0, or -1 if this joystick or driver doesn't support effect packets * \returns 0, or -1 if this joystick or driver doesn't support effect packets
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size); extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size);
@ -795,6 +1010,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const
* *
* \param joystick The joystick device to close * \param joystick The joystick device to close
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickOpen * \sa SDL_JoystickOpen
*/ */
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -58,6 +58,8 @@ typedef struct SDL_Keysym
* Query the window which currently has keyboard focus. * Query the window which currently has keyboard focus.
* *
* \returns the window with keyboard focus. * \returns the window with keyboard focus.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
@ -85,16 +87,32 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
* \param numkeys if non-NULL, receives the length of the returned array * \param numkeys if non-NULL, receives the length of the returned array
* \returns a pointer to an array of key states. * \returns a pointer to an array of key states.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PumpEvents * \sa SDL_PumpEvents
* \sa SDL_ResetKeyboard
*/ */
extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
/**
* Clear the state of the keyboard
*
* This function will generate key up events for all pressed keys.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetKeyboardState
*/
extern 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. See
* SDL_Keymod for details. * SDL_Keymod for details.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetKeyboardState * \sa SDL_GetKeyboardState
* \sa SDL_SetModState * \sa SDL_SetModState
*/ */
@ -113,6 +131,8 @@ extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
* *
* \param modstate the desired SDL_Keymod for the keyboard * \param modstate the desired SDL_Keymod for the keyboard
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetModState * \sa SDL_GetModState
*/ */
extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
@ -126,6 +146,8 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
* \param scancode the desired SDL_Scancode to query * \param scancode the desired SDL_Scancode to query
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode. * \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetKeyName * \sa SDL_GetKeyName
* \sa SDL_GetScancodeFromKey * \sa SDL_GetScancodeFromKey
*/ */
@ -140,6 +162,8 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode
* \param key the desired SDL_Keycode to query * \param key the desired SDL_Keycode to query
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode. * \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetKeyFromScancode * \sa SDL_GetKeyFromScancode
* \sa SDL_GetScancodeName * \sa SDL_GetScancodeName
*/ */
@ -196,6 +220,8 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
* must copy it. If the key doesn't have a name, this function * must copy it. If the key doesn't have a name, this function
* returns an empty string (""). * returns an empty string ("").
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetKeyFromName * \sa SDL_GetKeyFromName
* \sa SDL_GetKeyFromScancode * \sa SDL_GetKeyFromScancode
* \sa SDL_GetScancodeFromKey * \sa SDL_GetScancodeFromKey
@ -209,6 +235,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
* \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetKeyFromScancode * \sa SDL_GetKeyFromScancode
* \sa SDL_GetKeyName * \sa SDL_GetKeyName
* \sa SDL_GetScancodeFromName * \sa SDL_GetScancodeFromName
@ -225,6 +253,8 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
* *
* On some platforms using this function activates the screen keyboard. * On some platforms using this function activates the screen keyboard.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetTextInputRect * \sa SDL_SetTextInputRect
* \sa SDL_StopTextInput * \sa SDL_StopTextInput
*/ */
@ -244,19 +274,48 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
/** /**
* Stop receiving any text input events. * Stop receiving any text input events.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_StartTextInput * \sa SDL_StartTextInput
*/ */
extern DECLSPEC void SDLCALL SDL_StopTextInput(void); extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
/**
* Dismiss the composition window/IME without disabling the subsystem.
*
* \since This function is available since SDL 2.0.22.
*
* \sa SDL_StartTextInput
* \sa SDL_StopTextInput
*/
extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
/**
* Returns if an IME Composite or Candidate window is currently shown.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
/** /**
* Set the rectangle used to type Unicode text inputs. * Set the rectangle used to type Unicode text inputs.
* *
* To start text input in a given location, this function is intended to be
* called before SDL_StartTextInput, although some platforms support moving
* the rectangle even while text input (and a composition) is active.
*
* Note: If you want to use the system native IME window, try setting hint
* **SDL_HINT_IME_SHOW_UI** to **1**, otherwise this function won't give you
* any feedback.
*
* \param rect the SDL_Rect structure representing the rectangle to receive * \param rect the SDL_Rect structure representing the rectangle to receive
* text (ignored if NULL) * text (ignored if NULL)
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_StartTextInput * \sa SDL_StartTextInput
*/ */
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); extern DECLSPEC void SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
/** /**
* Check whether the platform has screen keyboard support. * Check whether the platform has screen keyboard support.

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -318,7 +318,12 @@ typedef enum
SDLK_APP2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP2), SDLK_APP2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP2),
SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND), SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND),
SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD) SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD),
SDLK_SOFTLEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTLEFT),
SDLK_SOFTRIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTRIGHT),
SDLK_CALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALL),
SDLK_ENDCALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ENDCALL)
} SDL_KeyCode; } SDL_KeyCode;
/** /**
@ -338,12 +343,14 @@ typedef enum
KMOD_NUM = 0x1000, KMOD_NUM = 0x1000,
KMOD_CAPS = 0x2000, KMOD_CAPS = 0x2000,
KMOD_MODE = 0x4000, KMOD_MODE = 0x4000,
KMOD_RESERVED = 0x8000, KMOD_SCROLL = 0x8000,
KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL, KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL,
KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT, KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT,
KMOD_ALT = KMOD_LALT | KMOD_RALT, KMOD_ALT = KMOD_LALT | KMOD_RALT,
KMOD_GUI = KMOD_LGUI | KMOD_RGUI KMOD_GUI = KMOD_LGUI | KMOD_RGUI,
KMOD_RESERVED = KMOD_SCROLL /* This is for source-level compatibility with SDL 2.0.0. */
} SDL_Keymod; } SDL_Keymod;
#endif /* SDL_keycode_h_ */ #endif /* SDL_keycode_h_ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -57,6 +57,8 @@ extern "C" {
* \returns an opaque pointer to the object handle or NULL if there was an * \returns an opaque pointer to the object handle or NULL if there was an
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadFunction * \sa SDL_LoadFunction
* \sa SDL_UnloadObject * \sa SDL_UnloadObject
*/ */
@ -82,6 +84,8 @@ extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
* \returns a pointer to the function or NULL if there was an error; call * \returns a pointer to the function or NULL if there was an error; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadObject * \sa SDL_LoadObject
* \sa SDL_UnloadObject * \sa SDL_UnloadObject
*/ */
@ -93,6 +97,8 @@ extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
* *
* \param handle a valid shared object handle returned by SDL_LoadObject() * \param handle a valid shared object handle returned by SDL_LoadObject()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadFunction * \sa SDL_LoadFunction
* \sa SDL_LoadObject * \sa SDL_LoadObject
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -85,6 +85,8 @@ typedef struct SDL_Locale
* *
* \return array of locales, terminated with a locale with a NULL language * \return array of locales, terminated with a locale with a NULL language
* field. Will return NULL on error. * field. Will return NULL on error.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void); extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -47,9 +47,9 @@ extern "C" {
/** /**
* \brief The maximum size of a log message * \brief The maximum size of a log message prior to SDL 2.0.24
* *
* Messages longer than the maximum size will be truncated * As of 2.0.24 there is no limit to the length of SDL log messages.
*/ */
#define SDL_MAX_LOG_MESSAGE 4096 #define SDL_MAX_LOG_MESSAGE 4096
@ -116,6 +116,8 @@ typedef enum
* *
* \param priority the SDL_LogPriority to assign * \param priority the SDL_LogPriority to assign
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogSetPriority * \sa SDL_LogSetPriority
*/ */
extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
@ -126,6 +128,8 @@ extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
* \param category the category to assign a priority to * \param category the category to assign a priority to
* \param priority the SDL_LogPriority to assign * \param priority the SDL_LogPriority to assign
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogGetPriority * \sa SDL_LogGetPriority
* \sa SDL_LogSetAllPriority * \sa SDL_LogSetAllPriority
*/ */
@ -138,6 +142,8 @@ extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
* \param category the category to query * \param category the category to query
* \returns the SDL_LogPriority for the requested category * \returns the SDL_LogPriority for the requested category
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogSetPriority * \sa SDL_LogSetPriority
*/ */
extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
@ -147,6 +153,8 @@ extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
* *
* This is called by SDL_Quit(). * This is called by SDL_Quit().
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogSetAllPriority * \sa SDL_LogSetAllPriority
* \sa SDL_LogSetPriority * \sa SDL_LogSetPriority
*/ */
@ -160,6 +168,8 @@ extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
* \param ... additional parameters matching % tokens in the `fmt` string, if * \param ... additional parameters matching % tokens in the `fmt` string, if
* any * any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
* \sa SDL_LogError * \sa SDL_LogError
@ -179,6 +189,8 @@ extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, .
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
@ -198,6 +210,8 @@ extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRI
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogError * \sa SDL_LogError
@ -217,6 +231,8 @@ extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
@ -236,6 +252,8 @@ extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
@ -255,6 +273,8 @@ extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
@ -274,6 +294,8 @@ extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogDebug * \sa SDL_LogDebug
* \sa SDL_LogError * \sa SDL_LogError
@ -294,6 +316,8 @@ extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STR
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Log * \sa SDL_Log
* \sa SDL_LogCritical * \sa SDL_LogCritical
* \sa SDL_LogDebug * \sa SDL_LogDebug
@ -350,6 +374,8 @@ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_
* \param userdata a pointer filled in with the pointer that is passed to * \param userdata a pointer filled in with the pointer that is passed to
* `callback` * `callback`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogSetOutputFunction * \sa SDL_LogSetOutputFunction
*/ */
extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
@ -360,6 +386,8 @@ extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *cal
* \param callback an SDL_LogOutputFunction to call instead of the default * \param callback an SDL_LogOutputFunction to call instead of the default
* \param userdata a pointer that is passed to `callback` * \param userdata a pointer that is passed to `callback`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LogGetOutputFunction * \sa SDL_LogGetOutputFunction
*/ */
extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -51,6 +51,15 @@
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(__GDK__)
/* On GDK, SDL provides a main function that initializes the game runtime.
Please note that #include'ing SDL_main.h is not enough to get a main()
function working. You must either link against SDL2main or, if not possible,
call the SDL_GDKRunApp function from your entry point.
*/
#define SDL_MAIN_NEEDED
#elif defined(__IPHONEOS__) #elif defined(__IPHONEOS__)
/* On iOS SDL provides a main function that creates an application delegate /* On iOS SDL provides a main function that creates an application delegate
and starts the iOS application run loop. and starts the iOS application run loop.
@ -83,6 +92,22 @@
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(__PSP__)
/* On PSP SDL provides a main function that sets the module info,
activates the GPU and starts the thread required to be able to exit
the software.
If you provide this yourself, you may define SDL_MAIN_HANDLED
*/
#define SDL_MAIN_AVAILABLE
#elif defined(__PS2__)
#define SDL_MAIN_AVAILABLE
#define SDL_PS2_SKIP_IOP_RESET() \
void reset_IOP(); \
void reset_IOP() {}
#endif #endif
#endif /* SDL_MAIN_HANDLED */ #endif /* SDL_MAIN_HANDLED */
@ -130,19 +155,57 @@ extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
* will not be changed it is necessary to define SDL_MAIN_HANDLED before * will not be changed it is necessary to define SDL_MAIN_HANDLED before
* including SDL.h. * including SDL.h.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init * \sa SDL_Init
*/ */
extern DECLSPEC void SDLCALL SDL_SetMainReady(void); extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
#ifdef __WIN32__ #if defined(__WIN32__) || defined(__GDK__)
/** /**
* This can be called to set the application class at startup * Register a win32 window class for SDL's use.
*
* This can be called to set the application window class at startup. It is
* safe to call this multiple times, as long as every call is eventually
* paired with a call to SDL_UnregisterApp, but a second registration attempt
* while a previous registration is still active will be ignored, other than
* to increment a counter.
*
* Most applications do not need to, and should not, call this directly; SDL
* will call it when initializing the video subsystem.
*
* \param name the window class name, in UTF-8 encoding. If NULL, SDL
* currently uses "SDL_app" but this isn't guaranteed.
* \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
* currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
* what is specified here.
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
* will use `GetModuleHandle(NULL)` instead.
* \returns 0 on success, -1 on error. SDL_GetError() may have details.
*
* \since This function is available since SDL 2.0.2.
*/
extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
/**
* Deregister the win32 window class from an SDL_RegisterApp call.
*
* This can be called to undo the effects of SDL_RegisterApp.
*
* Most applications do not need to, and should not, call this directly; SDL
* will call it when deinitializing the video subsystem.
*
* It is safe to call this multiple times, as long as every call is eventually
* paired with a prior call to SDL_RegisterApp. The window class will only be
* deregistered when the registration counter in SDL_RegisterApp decrements to
* zero through calls to this function.
*
* \since This function is available since SDL 2.0.2.
*/ */
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#endif /* __WIN32__ */ #endif /* defined(__WIN32__) || defined(__GDK__) */
#ifdef __WINRT__ #ifdef __WINRT__
@ -170,11 +233,28 @@ extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * r
* \param argv The argv parameter from the application's main() function * \param argv The argv parameter from the application's main() function
* \param mainFunction The SDL app's C-style main(), an SDL_main_func * \param mainFunction The SDL app's C-style main(), an SDL_main_func
* \return the return value from mainFunction * \return the return value from mainFunction
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction);
#endif /* __IPHONEOS__ */ #endif /* __IPHONEOS__ */
#ifdef __GDK__
/**
* Initialize and launch an SDL GDK application.
*
* \param mainFunction the SDL app's C-style main(), an SDL_main_func
* \param reserved reserved for future use; should be NULL
* \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
* more information on the failure.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved);
#endif /* __GDK__ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -175,6 +175,8 @@ extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *message
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ShowMessageBox * \sa SDL_ShowMessageBox
*/ */
extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -58,6 +58,8 @@ typedef void *SDL_MetalView;
* The returned handle can be casted directly to a NSView or UIView. To access * The returned handle can be casted directly to a NSView or UIView. To access
* the backing CAMetalLayer, call SDL_Metal_GetLayer(). * the backing CAMetalLayer, call SDL_Metal_GetLayer().
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_Metal_DestroyView * \sa SDL_Metal_DestroyView
* \sa SDL_Metal_GetLayer * \sa SDL_Metal_GetLayer
*/ */
@ -69,6 +71,8 @@ extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
* This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
* called after SDL_CreateWindow. * called after SDL_CreateWindow.
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_Metal_CreateView * \sa SDL_Metal_CreateView
*/ */
extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
@ -76,6 +80,8 @@ extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
/** /**
* Get a pointer to the backing CAMetalLayer for the given view. * Get a pointer to the backing CAMetalLayer for the given view.
* *
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_MetalCreateView * \sa SDL_MetalCreateView
*/ */
extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
@ -86,6 +92,9 @@ extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
* *
* \param window SDL_Window from which the drawable size should be queried * \param window SDL_Window from which the drawable size should be queried
* \param w Pointer to variable for storing the width in pixels, may be NULL * \param w Pointer to variable for storing the width in pixels, may be NULL
* \param h Pointer to variable for storing the height in pixels, may be NULL
*
* \since This function is available since SDL 2.0.14.
* *
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
* \sa SDL_CreateWindow * \sa SDL_CreateWindow

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -64,7 +64,7 @@ extern "C" {
* \returns 0 on success, or -1 on error; call SDL_GetError() for more * \returns 0 on success, or -1 on error; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available in SDL 2.0.14 and newer * \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url); extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -75,6 +75,8 @@ typedef enum
* Get the window which currently has mouse focus. * Get the window which currently has mouse focus.
* *
* \returns the window with mouse focus. * \returns the window with mouse focus.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
@ -93,6 +95,8 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
* focus window * focus window
* \returns a 32-bit button bitmask of the current button state. * \returns a 32-bit button bitmask of the current button state.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetGlobalMouseState * \sa SDL_GetGlobalMouseState
* \sa SDL_GetRelativeMouseState * \sa SDL_GetRelativeMouseState
* \sa SDL_PumpEvents * \sa SDL_PumpEvents
@ -141,6 +145,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y);
* \param y a pointer filled with the last recorded y coordinate of the mouse * \param y a pointer filled with the last recorded y coordinate of the mouse
* \returns a 32-bit button bitmask of the relative button state. * \returns a 32-bit button bitmask of the relative button state.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetMouseState * \sa SDL_GetMouseState
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
@ -148,7 +154,9 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
/** /**
* Move the mouse cursor to the given position within the window. * Move the mouse cursor to the given position within the window.
* *
* This function generates a mouse motion event. * This function generates a mouse motion event if relative mode is not
* enabled. If relative mode is enabled, you can force mouse events for the
* warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint.
* *
* Note that this function will appear to succeed, but not actually move the * Note that this function will appear to succeed, but not actually move the
* mouse when used over Microsoft Remote Desktop. * mouse when used over Microsoft Remote Desktop.
@ -158,6 +166,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
* \param x the x coordinate within the window * \param x the x coordinate within the window
* \param y the y coordinate within the window * \param y the y coordinate within the window
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WarpMouseGlobal * \sa SDL_WarpMouseGlobal
*/ */
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
@ -204,6 +214,8 @@ extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
* *
* If relative mode is not supported, this returns -1. * If relative mode is not supported, this returns -1.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRelativeMouseMode * \sa SDL_GetRelativeMouseMode
*/ */
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
@ -235,6 +247,15 @@ extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
* While capturing is enabled, the current window will have the * While capturing is enabled, the current window will have the
* `SDL_WINDOW_MOUSE_CAPTURE` flag set. * `SDL_WINDOW_MOUSE_CAPTURE` flag set.
* *
* Please note that as of SDL 2.0.22, SDL will attempt to "auto capture" the
* mouse while the user is pressing a button; this is to try and make mouse
* behavior more consistent between platforms, and deal with the common case
* of a user dragging the mouse outside of the window. This means that if you
* are calling SDL_CaptureMouse() only to deal with this situation, you no
* longer have to (although it is safe to do so). If this causes problems for
* your app, you can disable auto capture by setting the
* `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
*
* \param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable. * \param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable.
* \returns 0 on success or -1 if not supported; call SDL_GetError() for more * \returns 0 on success or -1 if not supported; call SDL_GetError() for more
* information. * information.
@ -250,6 +271,8 @@ extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled);
* *
* \returns SDL_TRUE if relative mode is enabled or SDL_FALSE otherwise. * \returns SDL_TRUE if relative mode is enabled or SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetRelativeMouseMode * \sa SDL_SetRelativeMouseMode
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
@ -289,6 +312,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
* \returns a new cursor with the specified parameters on success or NULL on * \returns a new cursor with the specified parameters on success or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeCursor * \sa SDL_FreeCursor
* \sa SDL_SetCursor * \sa SDL_SetCursor
* \sa SDL_ShowCursor * \sa SDL_ShowCursor
@ -339,6 +364,8 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
* *
* \param cursor a cursor to make active * \param cursor a cursor to make active
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateCursor * \sa SDL_CreateCursor
* \sa SDL_GetCursor * \sa SDL_GetCursor
* \sa SDL_ShowCursor * \sa SDL_ShowCursor
@ -353,6 +380,8 @@ extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
* *
* \returns the active cursor or NULL if there is no mouse. * \returns the active cursor or NULL if there is no mouse.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetCursor * \sa SDL_SetCursor
*/ */
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
@ -376,6 +405,8 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
* *
* \param cursor the cursor to free * \param cursor the cursor to free
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateColorCursor * \sa SDL_CreateColorCursor
* \sa SDL_CreateCursor * \sa SDL_CreateCursor
* \sa SDL_CreateSystemCursor * \sa SDL_CreateSystemCursor
@ -397,6 +428,8 @@ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
* cursor is hidden, or a negative error code on failure; call * cursor is hidden, or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateCursor * \sa SDL_CreateCursor
* \sa SDL_SetCursor * \sa SDL_SetCursor
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -71,6 +71,8 @@ typedef struct SDL_mutex SDL_mutex;
* \returns the initialized and unlocked mutex or NULL on failure; call * \returns the initialized and unlocked mutex or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_DestroyMutex * \sa SDL_DestroyMutex
* \sa SDL_LockMutex * \sa SDL_LockMutex
* \sa SDL_TryLockMutex * \sa SDL_TryLockMutex
@ -91,6 +93,8 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
* *
* \param mutex the mutex to lock * \param mutex the mutex to lock
* \return 0, or -1 on error. * \return 0, or -1 on error.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
#define SDL_mutexP(m) SDL_LockMutex(m) #define SDL_mutexP(m) SDL_LockMutex(m)
@ -108,6 +112,8 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
* \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for * \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
* more information. * more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateMutex * \sa SDL_CreateMutex
* \sa SDL_DestroyMutex * \sa SDL_DestroyMutex
* \sa SDL_LockMutex * \sa SDL_LockMutex
@ -129,6 +135,8 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
* *
* \param mutex the mutex to unlock. * \param mutex the mutex to unlock.
* \returns 0, or -1 on error. * \returns 0, or -1 on error.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
#define SDL_mutexV(m) SDL_UnlockMutex(m) #define SDL_mutexV(m) SDL_UnlockMutex(m)
@ -144,6 +152,8 @@ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
* *
* \param mutex the mutex to destroy * \param mutex the mutex to destroy
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateMutex * \sa SDL_CreateMutex
* \sa SDL_LockMutex * \sa SDL_LockMutex
* \sa SDL_TryLockMutex * \sa SDL_TryLockMutex
@ -176,6 +186,8 @@ typedef struct SDL_semaphore SDL_sem;
* \returns a new semaphore or NULL on failure; call SDL_GetError() for more * \returns a new semaphore or NULL on failure; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_SemPost
* \sa SDL_SemTryWait * \sa SDL_SemTryWait
@ -193,6 +205,8 @@ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
* *
* \param sem the semaphore to destroy * \param sem the semaphore to destroy
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_SemPost * \sa SDL_SemPost
* \sa SDL_SemTryWait * \sa SDL_SemTryWait
@ -217,6 +231,8 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_SemPost
@ -240,6 +256,8 @@ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
* block, or a negative error code on failure; call SDL_GetError() * block, or a negative error code on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_SemPost
@ -263,6 +281,8 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
* succeed in the allotted time, or a negative error code on failure; * succeed in the allotted time, or a negative error code on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_SemPost
@ -279,6 +299,8 @@ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemTryWait * \sa SDL_SemTryWait
@ -294,6 +316,8 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
* \param sem the semaphore to query * \param sem the semaphore to query
* \returns the current value of the semaphore. * \returns the current value of the semaphore.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
@ -316,6 +340,8 @@ typedef struct SDL_cond SDL_cond;
* \returns a new condition variable or NULL on failure; call SDL_GetError() * \returns a new condition variable or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondBroadcast * \sa SDL_CondBroadcast
* \sa SDL_CondSignal * \sa SDL_CondSignal
* \sa SDL_CondWait * \sa SDL_CondWait
@ -329,6 +355,8 @@ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
* *
* \param cond the condition variable to destroy * \param cond the condition variable to destroy
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondBroadcast * \sa SDL_CondBroadcast
* \sa SDL_CondSignal * \sa SDL_CondSignal
* \sa SDL_CondWait * \sa SDL_CondWait
@ -344,6 +372,8 @@ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondBroadcast * \sa SDL_CondBroadcast
* \sa SDL_CondWait * \sa SDL_CondWait
* \sa SDL_CondWaitTimeout * \sa SDL_CondWaitTimeout
@ -359,6 +389,8 @@ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondSignal * \sa SDL_CondSignal
* \sa SDL_CondWait * \sa SDL_CondWait
* \sa SDL_CondWaitTimeout * \sa SDL_CondWaitTimeout
@ -385,6 +417,8 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
* \returns 0 when it is signaled or a negative error code on failure; call * \returns 0 when it is signaled or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondBroadcast * \sa SDL_CondBroadcast
* \sa SDL_CondSignal * \sa SDL_CondSignal
* \sa SDL_CondWaitTimeout * \sa SDL_CondWaitTimeout
@ -412,6 +446,8 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
* the condition is not signaled in the allotted time, or a negative * the condition is not signaled in the allotted time, or a negative
* error code on failure; call SDL_GetError() for more information. * error code on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CondBroadcast * \sa SDL_CondBroadcast
* \sa SDL_CondSignal * \sa SDL_CondSignal
* \sa SDL_CondWait * \sa SDL_CondWait

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -26,7 +26,7 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#ifndef _MSC_VER #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)
#ifdef __IPHONEOS__ #ifdef __IPHONEOS__
#include <OpenGLES/ES2/gl.h> #include <OpenGLES/ES2/gl.h>

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -301,6 +301,11 @@ typedef enum
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
} SDL_PixelFormatEnum; } SDL_PixelFormatEnum;
/**
* The bits of this structure can be directly reinterpreted as an integer-packed
* color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888
* on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
*/
typedef struct SDL_Color typedef struct SDL_Color
{ {
Uint8 r; Uint8 r;
@ -367,6 +372,8 @@ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
* \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
* possible; call SDL_GetError() for more information. * possible; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MasksToPixelFormatEnum * \sa SDL_MasksToPixelFormatEnum
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
@ -389,6 +396,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
* \param Amask the alpha mask for the format * \param Amask the alpha mask for the format
* \returns one of the SDL_PixelFormatEnum values * \returns one of the SDL_PixelFormatEnum values
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PixelFormatEnumToMasks * \sa SDL_PixelFormatEnumToMasks
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
@ -408,6 +417,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
* \returns the new SDL_PixelFormat structure or NULL on failure; call * \returns the new SDL_PixelFormat structure or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeFormat * \sa SDL_FreeFormat
*/ */
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
@ -417,6 +428,8 @@ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
* *
* \param format the SDL_PixelFormat structure to free * \param format the SDL_PixelFormat structure to free
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocFormat * \sa SDL_AllocFormat
*/ */
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
@ -431,6 +444,8 @@ extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
* there wasn't enough memory); call SDL_GetError() for more * there wasn't enough memory); call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreePalette * \sa SDL_FreePalette
*/ */
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
@ -443,6 +458,8 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocPalette * \sa SDL_AllocPalette
* \sa SDL_FreePalette * \sa SDL_FreePalette
*/ */
@ -459,6 +476,8 @@ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
* \returns 0 on success or a negative error code if not all of the colors * \returns 0 on success or a negative error code if not all of the colors
* could be set; call SDL_GetError() for more information. * could be set; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocPalette * \sa SDL_AllocPalette
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
*/ */
@ -471,6 +490,8 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
* *
* \param palette the SDL_Palette structure to be freed * \param palette the SDL_Palette structure to be freed
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocPalette * \sa SDL_AllocPalette
*/ */
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
@ -499,6 +520,8 @@ extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
* \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
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRGB * \sa SDL_GetRGB
* \sa SDL_GetRGBA * \sa SDL_GetRGBA
* \sa SDL_MapRGBA * \sa SDL_MapRGBA
@ -532,6 +555,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
* \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
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRGB * \sa SDL_GetRGB
* \sa SDL_GetRGBA * \sa SDL_GetRGBA
* \sa SDL_MapRGB * \sa SDL_MapRGB
@ -555,6 +580,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
* \param g a pointer filled in with the green component * \param g a pointer filled in with the green component
* \param b a pointer filled in with the blue component * \param b a pointer filled in with the blue component
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRGBA * \sa SDL_GetRGBA
* \sa SDL_MapRGB * \sa SDL_MapRGB
* \sa SDL_MapRGBA * \sa SDL_MapRGBA
@ -582,6 +609,8 @@ extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
* \param b a pointer filled in with the blue component * \param b a pointer filled in with the blue component
* \param a a pointer filled in with the alpha component * \param a a pointer filled in with the alpha component
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRGB * \sa SDL_GetRGB
* \sa SDL_MapRGB * \sa SDL_MapRGB
* \sa SDL_MapRGBA * \sa SDL_MapRGBA
@ -597,6 +626,8 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
* \param gamma a gamma value where 0.0 is black and 1.0 is identity * \param gamma a gamma value where 0.0 is black and 1.0 is identity
* \param ramp an array of 256 values filled in with the gamma ramp * \param ramp an array of 256 values filled in with the gamma ramp
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowGammaRamp * \sa SDL_SetWindowGammaRamp
*/ */
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -65,11 +65,15 @@
#undef __LINUX__ /* do we need to do this? */ #undef __LINUX__ /* do we need to do this? */
#define __ANDROID__ 1 #define __ANDROID__ 1
#endif #endif
#if defined(__NGAGE__)
#undef __NGAGE__
#define __NGAGE__ 1
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
/* lets us know what version of Mac OS X we're compiling on */ /* lets us know what version of Mac OS X we're compiling on */
#include "AvailabilityMacros.h" #include <AvailabilityMacros.h>
#include "TargetConditionals.h" #include <TargetConditionals.h>
/* Fix building with older SDKs that don't define these /* Fix building with older SDKs that don't define these
See this for more information: See this for more information:
@ -104,9 +108,9 @@
/* if not compiling for iOS */ /* if not compiling for iOS */
#undef __MACOSX__ #undef __MACOSX__
#define __MACOSX__ 1 #define __MACOSX__ 1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
# error SDL for Mac OS X only supports deploying on 10.6 and above. # error SDL for Mac OS X only supports deploying on 10.7 and above.
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
#endif /* TARGET_OS_IPHONE */ #endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */ #endif /* defined(__APPLE__) */
@ -140,7 +144,7 @@
#endif #endif
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
/* Try to find out if we're compiling for WinRT or non-WinRT */ /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
#if defined(_MSC_VER) && defined(__has_include) #if defined(_MSC_VER) && defined(__has_include)
#if __has_include(<winapifamily.h>) #if __has_include(<winapifamily.h>)
#define HAVE_WINAPIFAMILY_H 1 #define HAVE_WINAPIFAMILY_H 1
@ -165,6 +169,15 @@
#if WINAPI_FAMILY_WINRT #if WINAPI_FAMILY_WINRT
#undef __WINRT__ #undef __WINRT__
#define __WINRT__ 1 #define __WINRT__ 1
#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
#undef __WINGDK__
#define __WINGDK__ 1
#elif defined(_GAMING_XBOX_XBOXONE)
#undef __XBOXONE__
#define __XBOXONE__ 1
#elif defined(_GAMING_XBOX_SCARLETT)
#undef __XBOXSERIES__
#define __XBOXSERIES__ 1
#else #else
#undef __WINDOWS__ #undef __WINDOWS__
#define __WINDOWS__ 1 #define __WINDOWS__ 1
@ -175,10 +188,18 @@
#undef __WIN32__ #undef __WIN32__
#define __WIN32__ 1 #define __WIN32__ 1
#endif #endif
/* This is to support generic "any GDK" separate from a platform-specific GDK */
#if defined(__WINGDK__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
#undef __GDK__
#define __GDK__ 1
#endif
#if defined(__PSP__) #if defined(__PSP__)
#undef __PSP__ #undef __PSP__
#define __PSP__ 1 #define __PSP__ 1
#endif #endif
#if defined(PS2)
#define __PS2__ 1
#endif
/* The NACL compiler defines __native_client__ and __pnacl__ /* The NACL compiler defines __native_client__ and __pnacl__
* Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
@ -219,6 +240,8 @@ extern "C" {
* *
* \returns the name of the platform. If the correct platform name is not * \returns the name of the platform. If the correct platform name is not
* available, returns a string beginning with the text "Unknown". * available, returns a string beginning with the text "Unknown".
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -72,6 +72,8 @@ typedef enum
* a NULL here if you don't care, will return -1 if we can't * a NULL here if you don't care, will return -1 if we can't
* determine a value, or we're not running on a battery * determine a value, or we're not running on a battery
* \returns an SDL_PowerState enum representing the current battery state. * \returns an SDL_PowerState enum representing the current battery state.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -54,8 +54,8 @@ typedef struct SDL_Point
/** /**
* The structure that defines a point (floating point) * The structure that defines a point (floating point)
* *
* \sa SDL_EnclosePoints * \sa SDL_EncloseFPoints
* \sa SDL_PointInRect * \sa SDL_PointInFRect
*/ */
typedef struct SDL_FPoint typedef struct SDL_FPoint
{ {
@ -71,6 +71,7 @@ typedef struct SDL_FPoint
* \sa SDL_RectEquals * \sa SDL_RectEquals
* \sa SDL_HasIntersection * \sa SDL_HasIntersection
* \sa SDL_IntersectRect * \sa SDL_IntersectRect
* \sa SDL_IntersectRectAndLine
* \sa SDL_UnionRect * \sa SDL_UnionRect
* \sa SDL_EnclosePoints * \sa SDL_EnclosePoints
*/ */
@ -83,6 +84,16 @@ typedef struct SDL_Rect
/** /**
* A rectangle, with the origin at the upper left (floating point). * A rectangle, with the origin at the upper left (floating point).
*
* \sa SDL_FRectEmpty
* \sa SDL_FRectEquals
* \sa SDL_FRectEqualsEpsilon
* \sa SDL_HasIntersectionF
* \sa SDL_IntersectFRect
* \sa SDL_IntersectFRectAndLine
* \sa SDL_UnionFRect
* \sa SDL_EncloseFPoints
* \sa SDL_PointInFRect
*/ */
typedef struct SDL_FRect typedef struct SDL_FRect
{ {
@ -161,6 +172,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
* \param B an SDL_Rect structure representing the second rectangle * \param B an SDL_Rect structure representing the second rectangle
* \param result an SDL_Rect structure filled in with the union of rectangles * \param result an SDL_Rect structure filled in with the union of rectangles
* `A` and `B` * `A` and `B`
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
const SDL_Rect * B, const SDL_Rect * B,
@ -180,6 +193,8 @@ extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
* rectangle * rectangle
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the * \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
* points were outside of the clipping rectangle. * points were outside of the clipping rectangle.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
int count, int count,
@ -201,12 +216,155 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
* \param X2 a pointer to the ending X-coordinate of the line * \param X2 a pointer to the ending X-coordinate of the line
* \param Y2 a pointer to the ending Y-coordinate of the line * \param Y2 a pointer to the ending Y-coordinate of the line
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
rect, int *X1, rect, int *X1,
int *Y1, int *X2, int *Y1, int *X2,
int *Y2); int *Y2);
/* SDL_FRect versions... */
/**
* Returns true if point resides inside a rectangle.
*/
SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect *r)
{
return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
(p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
}
/**
* Returns true if the rectangle has no area.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
{
return ((!r) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? SDL_TRUE : SDL_FALSE;
}
/**
* Returns true if the two rectangles are equal, within some given epsilon.
*
* \since This function is available since SDL 2.0.22.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
{
return (a && b && ((a == b) ||
((SDL_fabsf(a->x - b->x) <= epsilon) &&
(SDL_fabsf(a->y - b->y) <= epsilon) &&
(SDL_fabsf(a->w - b->w) <= epsilon) &&
(SDL_fabsf(a->h - b->h) <= epsilon))))
? SDL_TRUE : SDL_FALSE;
}
/**
* Returns true if the two rectangles are equal, using a default epsilon.
*
* \since This function is available since SDL 2.0.22.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b)
{
return SDL_FRectEqualsEpsilon(a, b, SDL_FLT_EPSILON);
}
/**
* Determine whether two rectangles intersect with float precision.
*
* If either pointer is NULL the function will return SDL_FALSE.
*
* \param A an SDL_FRect structure representing the first rectangle
* \param B an SDL_FRect structure representing the second rectangle
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.22.
*
* \sa SDL_IntersectRect
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF(const SDL_FRect * A,
const SDL_FRect * B);
/**
* Calculate the intersection of two rectangles with float precision.
*
* If `result` is NULL then this function will return SDL_FALSE.
*
* \param A an SDL_FRect structure representing the first rectangle
* \param B an SDL_FRect structure representing the second rectangle
* \param result an SDL_FRect structure filled in with the intersection of
* rectangles `A` and `B`
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.22.
*
* \sa SDL_HasIntersectionF
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect(const SDL_FRect * A,
const SDL_FRect * B,
SDL_FRect * result);
/**
* Calculate the union of two rectangles with float precision.
*
* \param A an SDL_FRect structure representing the first rectangle
* \param B an SDL_FRect structure representing the second rectangle
* \param result an SDL_FRect structure filled in with the union of rectangles
* `A` and `B`
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC void SDLCALL SDL_UnionFRect(const SDL_FRect * A,
const SDL_FRect * B,
SDL_FRect * result);
/**
* Calculate a minimal rectangle enclosing a set of points with float
* precision.
*
* If `clip` is not NULL then only points inside of the clipping rectangle are
* considered.
*
* \param points an array of SDL_FPoint structures representing points to be
* enclosed
* \param count the number of structures in the `points` array
* \param clip an SDL_FRect used for clipping or NULL to enclose all points
* \param result an SDL_FRect structure filled in with the minimal enclosing
* rectangle
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
* points were outside of the clipping rectangle.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints(const SDL_FPoint * points,
int count,
const SDL_FRect * clip,
SDL_FRect * result);
/**
* Calculate the intersection of a rectangle and line segment with float
* precision.
*
* This function is used to clip a line segment to a rectangle. A line segment
* contained entirely within the rectangle or that does not intersect will
* remain unchanged. A line segment that crosses the rectangle at either or
* both ends will be clipped to the boundary of the rectangle and the new
* coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
*
* \param rect an SDL_FRect structure representing the rectangle to intersect
* \param X1 a pointer to the starting X-coordinate of the line
* \param Y1 a pointer to the starting Y-coordinate of the line
* \param X2 a pointer to the ending X-coordinate of the line
* \param Y2 a pointer to the ending Y-coordinate of the line
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRectAndLine(const SDL_FRect *
rect, float *X1,
float *Y1, float *X2,
float *Y2);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -85,6 +85,16 @@ typedef struct SDL_RendererInfo
int max_texture_height; /**< The maximum texture height */ int max_texture_height; /**< The maximum texture height */
} SDL_RendererInfo; } SDL_RendererInfo;
/**
* Vertex structure
*/
typedef struct SDL_Vertex
{
SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
SDL_Color color; /**< Vertex color */
SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
} SDL_Vertex;
/** /**
* The scaling mode for a texture. * The scaling mode for a texture.
*/ */
@ -137,7 +147,6 @@ typedef struct SDL_Renderer SDL_Renderer;
struct SDL_Texture; struct SDL_Texture;
typedef struct SDL_Texture SDL_Texture; typedef struct SDL_Texture SDL_Texture;
/* Function prototypes */ /* Function prototypes */
/** /**
@ -168,6 +177,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
* \sa SDL_GetNumRenderDrivers * \sa SDL_GetNumRenderDrivers
*/ */
@ -186,6 +197,8 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
* \returns 0 on success, or -1 on error; call SDL_GetError() for more * \returns 0 on success, or -1 on error; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
*/ */
@ -204,6 +217,8 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateSoftwareRenderer * \sa SDL_CreateSoftwareRenderer
* \sa SDL_DestroyRenderer * \sa SDL_DestroyRenderer
* \sa SDL_GetNumRenderDrivers * \sa SDL_GetNumRenderDrivers
@ -225,6 +240,8 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
* \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.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
* \sa SDL_CreateWindowRenderer * \sa SDL_CreateWindowRenderer
* \sa SDL_DestroyRenderer * \sa SDL_DestroyRenderer
@ -238,10 +255,23 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *
* \returns the rendering context on success or NULL on failure; call * \returns the rendering context on success or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
*/ */
extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
/**
* Get the window associated with a renderer.
*
* \param renderer the renderer to query
* \returns the window on success or NULL on failure; call SDL_GetError() for
* more information.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_RenderGetWindow(SDL_Renderer *renderer);
/** /**
* Get information about a rendering context. * Get information about a rendering context.
* *
@ -251,6 +281,8 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
*/ */
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
@ -291,6 +323,8 @@ extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
* was active, the format was unsupported, or the width or height * was active, the format was unsupported, or the width or height
* were out of range; call SDL_GetError() for more information. * were out of range; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateTextureFromSurface * \sa SDL_CreateTextureFromSurface
* \sa SDL_DestroyTexture * \sa SDL_DestroyTexture
* \sa SDL_QueryTexture * \sa SDL_QueryTexture
@ -319,6 +353,8 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
* \returns the created texture or NULL on failure; call SDL_GetError() for * \returns the created texture or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateTexture * \sa SDL_CreateTexture
* \sa SDL_DestroyTexture * \sa SDL_DestroyTexture
* \sa SDL_QueryTexture * \sa SDL_QueryTexture
@ -331,14 +367,20 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer
* \param texture the texture to query * \param texture the texture to query
* \param format a pointer filled in with the raw format of the texture; the * \param format a pointer filled in with the raw format of the texture; the
* actual format may differ, but pixel transfers will use this * actual format may differ, but pixel transfers will use this
* format (one of the SDL_PixelFormatEnum values) * format (one of the SDL_PixelFormatEnum values). This argument
* can be NULL if you don't need this information.
* \param access a pointer filled in with the actual access to the texture * \param access a pointer filled in with the actual access to the texture
* (one of the SDL_TextureAccess values) * (one of the SDL_TextureAccess values). This argument can be
* \param w a pointer filled in with the width of the texture in pixels * NULL if you don't need this information.
* \param h a pointer filled in with the height of the texture in pixels * \param w a pointer filled in with the width of the texture in pixels. This
* argument can be NULL if you don't need this information.
* \param h a pointer filled in with the height of the texture in pixels. This
* argument can be NULL if you don't need this information.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateTexture * \sa SDL_CreateTexture
*/ */
extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
@ -364,6 +406,8 @@ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTextureColorMod * \sa SDL_GetTextureColorMod
* \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureAlphaMod
*/ */
@ -381,6 +425,8 @@ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTextureAlphaMod * \sa SDL_GetTextureAlphaMod
* \sa SDL_SetTextureColorMod * \sa SDL_SetTextureColorMod
*/ */
@ -404,6 +450,8 @@ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTextureAlphaMod * \sa SDL_GetTextureAlphaMod
* \sa SDL_SetTextureColorMod * \sa SDL_SetTextureColorMod
*/ */
@ -418,6 +466,8 @@ extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTextureColorMod * \sa SDL_GetTextureColorMod
* \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureAlphaMod
*/ */
@ -435,6 +485,8 @@ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTextureBlendMode * \sa SDL_GetTextureBlendMode
* \sa SDL_RenderCopy * \sa SDL_RenderCopy
*/ */
@ -449,6 +501,8 @@ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetTextureBlendMode * \sa SDL_SetTextureBlendMode
*/ */
extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
@ -463,6 +517,8 @@ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
* \param scaleMode the SDL_ScaleMode to use for texture scaling. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
* \returns 0 on success, or -1 if the texture is not valid. * \returns 0 on success, or -1 if the texture is not valid.
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_GetTextureScaleMode * \sa SDL_GetTextureScaleMode
*/ */
extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
@ -475,11 +531,40 @@ extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
* \param scaleMode a pointer filled in with the current scale mode. * \param scaleMode a pointer filled in with the current scale mode.
* \return 0 on success, or -1 if the texture is not valid. * \return 0 on success, or -1 if the texture is not valid.
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_SetTextureScaleMode * \sa SDL_SetTextureScaleMode
*/ */
extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
SDL_ScaleMode *scaleMode); SDL_ScaleMode *scaleMode);
/**
* Associate a user-specified pointer with a texture.
*
* \param texture the texture to update.
* \param userdata the pointer to associate with the texture.
* \returns 0 on success, or -1 if the texture is not valid.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GetTextureUserData
*/
extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture * texture,
void *userdata);
/**
* Get the user-specified pointer associated with a texture
*
* \param texture the texture to query.
* \return the pointer associated with the texture, or NULL if the texture is
* not valid.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_SetTextureUserData
*/
extern DECLSPEC void * SDLCALL SDL_GetTextureUserData(SDL_Texture * texture);
/** /**
* Update the given texture rectangle with new pixel data. * Update the given texture rectangle with new pixel data.
* *
@ -503,6 +588,8 @@ extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateTexture * \sa SDL_CreateTexture
* \sa SDL_LockTexture * \sa SDL_LockTexture
* \sa SDL_UnlockTexture * \sa SDL_UnlockTexture
@ -561,6 +648,8 @@ extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
* \param UVpitch the number of bytes between rows of pixel data for the UV * \param UVpitch the number of bytes between rows of pixel data for the UV
* plane. * plane.
* \return 0 on success, or -1 if the texture is not valid. * \return 0 on success, or -1 if the texture is not valid.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -590,6 +679,8 @@ extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture,
* or was not created with `SDL_TEXTUREACCESS_STREAMING`; call * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_UnlockTexture * \sa SDL_UnlockTexture
*/ */
extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
@ -623,6 +714,8 @@ extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
* \returns 0 on success, or -1 if the texture is not valid or was not created * \returns 0 on success, or -1 if the texture is not valid or was not created
* with `SDL_TEXTUREACCESS_STREAMING` * with `SDL_TEXTUREACCESS_STREAMING`
* *
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_LockTexture * \sa SDL_LockTexture
* \sa SDL_UnlockTexture * \sa SDL_UnlockTexture
*/ */
@ -634,7 +727,7 @@ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
* Unlock a texture, uploading the changes to video memory, if needed. * Unlock a texture, uploading the changes to video memory, if needed.
* *
* **Warning**: Please note that SDL_LockTexture() is intended to be * **Warning**: Please note that SDL_LockTexture() is intended to be
* write-only; it will notguarantee the previous contents of the texture will * write-only; it will not guarantee the previous contents of the texture will
* be provided. You must fully initialize any area of a texture that you lock * be provided. You must fully initialize any area of a texture that you lock
* before unlocking it, as the pixels might otherwise be uninitialized memory. * before unlocking it, as the pixels might otherwise be uninitialized memory.
* *
@ -643,6 +736,8 @@ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
* *
* \param texture a texture locked by SDL_LockTexture() * \param texture a texture locked by SDL_LockTexture()
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockTexture * \sa SDL_LockTexture
*/ */
extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
@ -730,9 +825,13 @@ extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, in
/** /**
* Get device independent resolution for rendering. * Get device independent resolution for rendering.
* *
* This may return 0 for `w` and `h` if the SDL_Renderer has never had its * When using the main rendering target (eg no target texture is set): this
* logical size set by SDL_RenderSetLogicalSize() and never had a render * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
* target set. * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical
* width and height.
*
* When using a target texture: Never return 0 for `w` and `h` at first. Then
* it returns the logical width and height that are set.
* *
* \param renderer a rendering context * \param renderer a rendering context
* \param w an int to be filled with the width * \param w an int to be filled with the width
@ -789,6 +888,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * render
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderGetViewport * \sa SDL_RenderGetViewport
*/ */
extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
@ -800,6 +901,8 @@ extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
* \param renderer the rendering context * \param renderer the rendering context
* \param rect an SDL_Rect structure filled in with the current drawing area * \param rect an SDL_Rect structure filled in with the current drawing area
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderSetViewport * \sa SDL_RenderSetViewport
*/ */
extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
@ -815,6 +918,8 @@ extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderGetClipRect * \sa SDL_RenderGetClipRect
* \sa SDL_RenderIsClipEnabled * \sa SDL_RenderIsClipEnabled
*/ */
@ -829,6 +934,8 @@ extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
* \param rect an SDL_Rect structure filled in with the current clipping area * \param rect an SDL_Rect structure filled in with the current clipping area
* or an empty rectangle if clipping is disabled * or an empty rectangle if clipping is disabled
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderIsClipEnabled * \sa SDL_RenderIsClipEnabled
* \sa SDL_RenderSetClipRect * \sa SDL_RenderSetClipRect
*/ */
@ -889,6 +996,57 @@ extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
float *scaleX, float *scaleY); float *scaleX, float *scaleY);
/**
* Get logical coordinates of point in renderer when given real coordinates of
* point in window.
*
* Logical coordinates will differ from real coordinates when render is scaled
* and logical renderer size set
*
* \param renderer the renderer from which the logical coordinates should be
* calculated
* \param windowX the real X coordinate in the window
* \param windowY the real Y coordinate in the window
* \param logicalX the pointer filled with the logical x coordinate
* \param logicalY the pointer filled with the logical y coordinate
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_RenderGetScale
* \sa SDL_RenderSetScale
* \sa SDL_RenderGetLogicalSize
* \sa SDL_RenderSetLogicalSize
*/
extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
int windowX, int windowY,
float *logicalX, float *logicalY);
/**
* Get real coordinates of point in window when given logical coordinates of
* point in renderer.
*
* Logical coordinates will differ from real coordinates when render is scaled
* and logical renderer size set
*
* \param renderer the renderer from which the window coordinates should be
* calculated
* \param logicalX the logical x coordinate
* \param logicalY the logical y coordinate
* \param windowX the pointer filled with the real X coordinate in the window
* \param windowY the pointer filled with the real Y coordinate in the window
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_RenderGetScale
* \sa SDL_RenderSetScale
* \sa SDL_RenderGetLogicalSize
* \sa SDL_RenderSetLogicalSize
*/
extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
float logicalX, float logicalY,
int *windowX, int *windowY);
/** /**
* Set the color used for drawing operations (Rect, Line and Clear). * Set the color used for drawing operations (Rect, Line and Clear).
* *
@ -905,6 +1063,8 @@ extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRenderDrawColor * \sa SDL_GetRenderDrawColor
* \sa SDL_RenderClear * \sa SDL_RenderClear
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
@ -935,6 +1095,8 @@ extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetRenderDrawColor * \sa SDL_SetRenderDrawColor
*/ */
extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
@ -951,6 +1113,8 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRenderDrawBlendMode * \sa SDL_GetRenderDrawBlendMode
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
@ -972,6 +1136,8 @@ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetRenderDrawBlendMode * \sa SDL_SetRenderDrawBlendMode
*/ */
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
@ -1005,6 +1171,8 @@ extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoints * \sa SDL_RenderDrawPoints
@ -1029,6 +1197,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoint * \sa SDL_RenderDrawPoint
@ -1110,6 +1280,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoint * \sa SDL_RenderDrawPoint
@ -1134,6 +1306,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoint * \sa SDL_RenderDrawPoint
@ -1162,6 +1336,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoint * \sa SDL_RenderDrawPoint
@ -1187,6 +1363,8 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
* \sa SDL_RenderDrawPoint * \sa SDL_RenderDrawPoint
@ -1221,6 +1399,8 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderCopyEx * \sa SDL_RenderCopyEx
* \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureAlphaMod
* \sa SDL_SetTextureBlendMode * \sa SDL_SetTextureBlendMode
@ -1263,6 +1443,8 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderCopy * \sa SDL_RenderCopy
* \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureAlphaMod
* \sa SDL_SetTextureBlendMode * \sa SDL_SetTextureBlendMode
@ -1284,6 +1466,8 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
* \param x The x coordinate of the point. * \param x The x coordinate of the point.
* \param y The y coordinate of the point. * \param y The y coordinate of the point.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
float x, float y); float x, float y);
@ -1295,6 +1479,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
* \param points The points to draw * \param points The points to draw
* \param count The number of points to draw * \param count The number of points to draw
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
const SDL_FPoint * points, const SDL_FPoint * points,
@ -1309,6 +1495,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
* \param x2 The x coordinate of the end point. * \param x2 The x coordinate of the end point.
* \param y2 The y coordinate of the end point. * \param y2 The y coordinate of the end point.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
float x1, float y1, float x2, float y2); float x1, float y1, float x2, float y2);
@ -1321,6 +1509,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
* \param points The points along the lines * \param points The points along the lines
* \param count The number of points, drawing count-1 lines * \param count The number of points, drawing count-1 lines
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
const SDL_FPoint * points, const SDL_FPoint * points,
@ -1333,6 +1523,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
* \param rect A pointer to the destination rectangle, or NULL to outline the * \param rect A pointer to the destination rectangle, or NULL to outline the
* entire rendering target. * entire rendering target.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
const SDL_FRect * rect); const SDL_FRect * rect);
@ -1345,6 +1537,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
* \param rects A pointer to an array of destination rectangles. * \param rects A pointer to an array of destination rectangles.
* \param count The number of rectangles. * \param count The number of rectangles.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
const SDL_FRect * rects, const SDL_FRect * rects,
@ -1358,6 +1552,8 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
* \param rect A pointer to the destination rectangle, or NULL for the entire * \param rect A pointer to the destination rectangle, or NULL for the entire
* rendering target. * rendering target.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
const SDL_FRect * rect); const SDL_FRect * rect);
@ -1370,6 +1566,8 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
* \param rects A pointer to an array of destination rectangles. * \param rects A pointer to an array of destination rectangles.
* \param count The number of rectangles. * \param count The number of rectangles.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
const SDL_FRect * rects, const SDL_FRect * rects,
@ -1386,6 +1584,8 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
* \param dstrect A pointer to the destination rectangle, or NULL for the * \param dstrect A pointer to the destination rectangle, or NULL for the
* entire rendering target. * entire rendering target.
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Texture * texture,
@ -1410,6 +1610,8 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
* \param flip An SDL_RendererFlip value stating which flipping actions should * \param flip An SDL_RendererFlip value stating which flipping actions should
* be performed on the texture * be performed on the texture
* \return 0 on success, or -1 on error * \return 0 on success, or -1 on error
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Texture * texture,
@ -1419,11 +1621,70 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
const SDL_FPoint *center, const SDL_FPoint *center,
const SDL_RendererFlip flip); const SDL_RendererFlip flip);
/**
* Render a list of triangles, optionally using a texture and indices into the
* vertex array Color and alpha modulation is done per vertex
* (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
*
* \param renderer The rendering context.
* \param texture (optional) The SDL texture to use.
* \param vertices Vertices.
* \param num_vertices Number of vertices.
* \param indices (optional) An array of integer indices into the 'vertices'
* array, if NULL all vertices will be rendered in sequential
* order.
* \param num_indices Number of indices.
* \return 0 on success, or -1 if the operation is not supported
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_RenderGeometryRaw
* \sa SDL_Vertex
*/
extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
SDL_Texture *texture,
const SDL_Vertex *vertices, int num_vertices,
const int *indices, int num_indices);
/**
* Render a list of triangles, optionally using a texture and indices into the
* vertex arrays Color and alpha modulation is done per vertex
* (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
*
* \param renderer The rendering context.
* \param texture (optional) The SDL texture to use.
* \param xy Vertex positions
* \param xy_stride Byte size to move from one element to the next element
* \param color Vertex colors (as SDL_Color)
* \param color_stride Byte size to move from one element to the next element
* \param uv Vertex normalized texture coordinates
* \param uv_stride Byte size to move from one element to the next element
* \param num_vertices Number of vertices.
* \param indices (optional) An array of indices into the 'vertices' arrays,
* if NULL all vertices will be rendered in sequential order.
* \param num_indices Number of indices.
* \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
* \return 0 on success, or -1 if the operation is not supported
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_RenderGeometry
* \sa SDL_Vertex
*/
extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
SDL_Texture *texture,
const float *xy, int xy_stride,
const SDL_Color *color, int color_stride,
const float *uv, int uv_stride,
int num_vertices,
const void *indices, int num_indices, int size_indices);
/** /**
* Read pixels from the current rendering target to an array of pixels. * Read pixels from the current rendering target to an array of pixels.
* *
* **WARNING**: This is a very slow operation, and should not be used * **WARNING**: This is a very slow operation, and should not be used
* frequently. * frequently. If you're using this on the main rendering target, it should be
* called after rendering and before SDL_RenderPresent().
* *
* `pitch` specifies the number of bytes between rows in the destination * `pitch` specifies the number of bytes between rows in the destination
* `pixels` data. This allows you to write to a subrectangle or have padded * `pixels` data. This allows you to write to a subrectangle or have padded
@ -1441,6 +1702,8 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
* \param pitch the pitch of the `pixels` parameter * \param pitch the pitch of the `pixels` parameter
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
const SDL_Rect * rect, const SDL_Rect * rect,
@ -1468,6 +1731,8 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
* *
* \param renderer the rendering context * \param renderer the rendering context
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RenderClear * \sa SDL_RenderClear
* \sa SDL_RenderDrawLine * \sa SDL_RenderDrawLine
* \sa SDL_RenderDrawLines * \sa SDL_RenderDrawLines
@ -1490,6 +1755,8 @@ extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
* *
* \param texture the texture to destroy * \param texture the texture to destroy
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateTexture * \sa SDL_CreateTexture
* \sa SDL_CreateTextureFromSurface * \sa SDL_CreateTextureFromSurface
*/ */
@ -1500,6 +1767,8 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
* *
* \param renderer the rendering context * \param renderer the rendering context
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer * \sa SDL_CreateRenderer
*/ */
extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
@ -1581,6 +1850,8 @@ extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw
* \param texture the texture to unbind from the current OpenGL/ES/ES2 context * \param texture the texture to unbind from the current OpenGL/ES/ES2 context
* \returns 0 on success, or -1 if the operation is not supported * \returns 0 on success, or -1 if the operation is not supported
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_BindTexture * \sa SDL_GL_BindTexture
* \sa SDL_GL_MakeCurrent * \sa SDL_GL_MakeCurrent
*/ */
@ -1596,6 +1867,8 @@ extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
* \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
* Metal renderer * Metal renderer
* *
* \since This function is available since SDL 2.0.8.
*
* \sa SDL_RenderGetMetalCommandEncoder * \sa SDL_RenderGetMetalCommandEncoder
*/ */
extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
@ -1606,14 +1879,32 @@ extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
* This function returns `void *`, so SDL doesn't have to include Metal's * This function returns `void *`, so SDL doesn't have to include Metal's
* headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
* *
* Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
* SDL a drawable to render to, which might happen if the window is
* hidden/minimized/offscreen. This doesn't apply to command encoders for
* render targets, just the window's backbacker. Check your return values!
*
* \param renderer The renderer to query * \param renderer The renderer to query
* \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
* renderer isn't a Metal renderer. * renderer isn't a Metal renderer or there was an error.
*
* \since This function is available since SDL 2.0.8.
* *
* \sa SDL_RenderGetMetalLayer * \sa SDL_RenderGetMetalLayer
*/ */
extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer); extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
/**
* Toggle VSync of the given renderer.
*
* \param renderer The renderer to toggle
* \param vsync 1 for on, 0 for off. All other values are reserved
* \returns a 0 int on success, or non-zero on failure
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,2 +1,2 @@
#define SDL_REVISION "https://github.com/libsdl-org/SDL.git@25f9ed87ff6947d9576fc9d79dee0784e638ac58" #define SDL_REVISION "https://github.com/libsdl-org/SDL.git@55b03c7493a7abed33cf803d1380a40fa8af903f"
#define SDL_REVISION_NUMBER 0 #define SDL_REVISION_NUMBER 0

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -45,9 +45,6 @@ extern "C" {
#define SDL_RWOPS_JNIFILE 3U /**< Android asset */ #define SDL_RWOPS_JNIFILE 3U /**< Android asset */
#define SDL_RWOPS_MEMORY 4U /**< Memory stream */ #define SDL_RWOPS_MEMORY 4U /**< Memory stream */
#define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */ #define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */
#if defined(__VITA__)
#define SDL_RWOPS_VITAFILE 6U /**< Vita file */
#endif
/** /**
* This is the read/write operation structure -- very basic. * This is the read/write operation structure -- very basic.
@ -101,7 +98,7 @@ typedef struct SDL_RWops
{ {
void *asset; void *asset;
} androidio; } androidio;
#elif defined(__WIN32__) #elif defined(__WIN32__) || defined(__GDK__)
struct struct
{ {
SDL_bool append; SDL_bool append;
@ -113,17 +110,6 @@ typedef struct SDL_RWops
size_t left; size_t left;
} buffer; } buffer;
} windowsio; } windowsio;
#elif defined(__VITA__)
struct
{
int h;
struct
{
void *data;
size_t size;
size_t left;
} buffer;
} vitaio;
#endif #endif
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
@ -156,25 +142,228 @@ typedef struct SDL_RWops
*/ */
/* @{ */ /* @{ */
/**
* Use this function to create a new SDL_RWops structure for reading from
* and/or writing to a named file.
*
* The `mode` string is treated roughly the same as in a call to the C
* library's fopen(), even if SDL doesn't happen to use fopen() behind the
* scenes.
*
* Available `mode` strings:
*
* - "r": Open a file for reading. The file must exist.
* - "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
* empty file.
* - "a": Append to a file. Writing operations append data at the end of the
* file. The file is created if it does not exist.
* - "r+": Open a file for update both reading and writing. The file must
* exist.
* - "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
* treated as a new empty file.
* - "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
* overwritten. You can reposition (fseek, rewind) the internal pointer to
* anywhere in the file for reading, but writing operations will move it
* back to the end of file. The file is created if it does not exist.
*
* **NOTE**: In order to open a file as a binary file, a "b" character has to
* be included in the `mode` string. This additional "b" character can either
* be appended at the end of the string (thus making the following compound
* modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the
* letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+").
* Additional characters may follow the sequence, although they should have no
* effect. For example, "t" is sometimes appended to make explicit the file is
* a text file.
*
* This function supports Unicode filenames, but they must be encoded in UTF-8
* format, regardless of the underlying operating system.
*
* As a fallback, SDL_RWFromFile() will transparently open a matching filename
* in an Android app's `assets`.
*
* Closing the SDL_RWops will close the file handle SDL is holding internally.
*
* \param file a UTF-8 string representing the filename to open
* \param mode an ASCII string representing the mode to be used for opening
* the file.
* \returns a pointer to the SDL_RWops structure that is created, or NULL on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RWclose
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFP
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_RWwrite
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
const char *mode); const char *mode);
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp,
SDL_bool autoclose); extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, SDL_bool autoclose);
#else #else
/**
* Use this function to create an SDL_RWops structure from a standard I/O file
* pointer (stdio.h's `FILE*`).
*
* This function is not available on Windows, since files opened in an
* application on that platform cannot be used by a dynamically linked
* library.
*
* On some platforms, the first parameter is a `void*`, on others, it's a
* `FILE*`, depending on what system headers are available to SDL. It is
* always intended to be the `FILE*` type from the C runtime's stdio.h.
*
* \param fp the `FILE*` that feeds the SDL_RWops stream
* \param autoclose SDL_TRUE to close the `FILE*` when closing the SDL_RWops,
* SDL_FALSE to leave the `FILE*` open when the RWops is
* closed
* \returns a pointer to the SDL_RWops structure that is created, or NULL on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RWclose
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_RWwrite
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp,
SDL_bool autoclose); SDL_bool autoclose);
#endif #endif
/**
* Use this function to prepare a read-write memory buffer for use with
* SDL_RWops.
*
* This function sets up an SDL_RWops struct based on a memory area of a
* certain size, for both read and write access.
*
* This memory buffer is not copied by the RWops; the pointer you provide must
* remain valid until you close the stream. Closing the stream will not free
* the original buffer.
*
* If you need to make sure the RWops never writes to the memory buffer, you
* should use SDL_RWFromConstMem() with a read-only buffer of memory instead.
*
* \param mem a pointer to a buffer to feed an SDL_RWops stream
* \param size the buffer size, in bytes
* \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RWclose
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromFP
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_RWwrite
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
/**
* Use this function to prepare a read-only memory buffer for use with RWops.
*
* This function sets up an SDL_RWops struct based on a memory area of a
* certain size. It assumes the memory area is not writable.
*
* Attempting to write to this RWops stream will report an error without
* writing to the memory buffer.
*
* This memory buffer is not copied by the RWops; the pointer you provide must
* remain valid until you close the stream. Closing the stream will not free
* the original buffer.
*
* If you need to write to a memory buffer, you should use SDL_RWFromMem()
* with a writable buffer of memory instead.
*
* \param mem a pointer to a read-only buffer to feed an SDL_RWops stream
* \param size the buffer size, in bytes
* \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RWclose
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromFP
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
int size); int size);
/* @} *//* RWFrom functions */ /* @} *//* RWFrom functions */
/**
* Use this function to allocate an empty, unpopulated SDL_RWops structure.
*
* Applications do not need to use this function unless they are providing
* their own SDL_RWops implementation. If you just need a SDL_RWops to
* read/write a common data source, you should use the built-in
* implementations in SDL, like SDL_RWFromFile() or SDL_RWFromMem(), etc.
*
* You must free the returned pointer with SDL_FreeRW(). Depending on your
* operating system and compiler, there may be a difference between the
* malloc() and free() your program uses and the versions SDL calls
* internally. Trying to mix the two can cause crashing such as segmentation
* faults. Since all SDL_RWops must free themselves when their **close**
* method is called, all SDL_RWops must be allocated through this function, so
* they can all be freed correctly with SDL_FreeRW().
*
* \returns a pointer to the allocated memory on success, or NULL on failure;
* call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeRW
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
/**
* Use this function to free an SDL_RWops structure allocated by
* SDL_AllocRW().
*
* Applications do not need to use this function unless they are providing
* their own SDL_RWops implementation. If you just need a SDL_RWops to
* read/write a common data source, you should use the built-in
* implementations in SDL, like SDL_RWFromFile() or SDL_RWFromMem(), etc, and
* call the **close** method on those SDL_RWops pointers when you are done
* with them.
*
* Only use SDL_FreeRW() on pointers returned by SDL_AllocRW(). The pointer is
* invalid as soon as this function returns. Any extra memory allocated during
* creation of the SDL_RWops is not freed by SDL_FreeRW(); the programmer must
* be responsible for managing that memory in their **close** method.
*
* \param area the SDL_RWops structure to be freed
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocRW
*/
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ #define RW_SEEK_SET 0 /**< Seek from the beginning of data */
@ -182,14 +371,16 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
#define RW_SEEK_END 2 /**< Seek relative to the end of data */ #define RW_SEEK_END 2 /**< Seek relative to the end of data */
/** /**
* Use this macro to get the size of the data stream in an SDL_RWops. * Use this function to get the size of the data stream in an SDL_RWops.
*
* Prior to SDL 2.0.10, this function was a macro.
* *
* \param context the SDL_RWops to get the size of the data stream from * \param context the SDL_RWops to get the size of the data stream from
* \returns the size of the data stream in the SDL_RWops on success, -1 if * \returns the size of the data stream in the SDL_RWops on success, -1 if
* unknown or a negative error code on failure; call SDL_GetError() * unknown or a negative error code on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
@ -209,12 +400,16 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
* SDL_RWseek() is actually a wrapper function that calls the SDL_RWops's * SDL_RWseek() is actually a wrapper function that calls the SDL_RWops's
* `seek` method appropriately, to simplify application development. * `seek` method appropriately, to simplify application development.
* *
* Prior to SDL 2.0.10, this function was a macro.
*
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops structure
* \param offset an offset in bytes, relative to **whence** location; can be * \param offset an offset in bytes, relative to **whence** location; can be
* negative * negative
* \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END` * \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END`
* \returns the final offset in the data stream after the seek or -1 on error. * \returns the final offset in the data stream after the seek or -1 on error.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_RWclose * \sa SDL_RWclose
* \sa SDL_RWFromConstMem * \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile * \sa SDL_RWFromFile
@ -234,11 +429,15 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context,
* method, with an offset of 0 bytes from `RW_SEEK_CUR`, to simplify * method, with an offset of 0 bytes from `RW_SEEK_CUR`, to simplify
* application development. * application development.
* *
* Prior to SDL 2.0.10, this function was a macro.
*
* \param context a SDL_RWops data stream object from which to get the current * \param context a SDL_RWops data stream object from which to get the current
* offset * offset
* \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.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_RWclose * \sa SDL_RWclose
* \sa SDL_RWFromConstMem * \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile * \sa SDL_RWFromFile
@ -261,6 +460,8 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
* SDL_RWread() is actually a function wrapper that calls the SDL_RWops's * SDL_RWread() is actually a function wrapper that calls the SDL_RWops's
* `read` method appropriately, to simplify application development. * `read` method appropriately, to simplify application development.
* *
* Prior to SDL 2.0.10, this function was a macro.
*
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops 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 size of each object to read, in bytes * \param size the size of each object to read, in bytes
@ -268,6 +469,8 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
* \returns the number of objects read, or 0 at error or end of file; call * \returns the number of objects read, or 0 at error or end of file; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_RWclose * \sa SDL_RWclose
* \sa SDL_RWFromConstMem * \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile * \sa SDL_RWFromFile
@ -291,6 +494,8 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context,
* SDL_RWwrite is actually a function wrapper that calls the SDL_RWops's * SDL_RWwrite is actually a function wrapper that calls the SDL_RWops's
* `write` method appropriately, to simplify application development. * `write` method appropriately, to simplify application development.
* *
* Prior to SDL 2.0.10, this function was a macro.
*
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops 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 size of an object to write, in bytes * \param size the size of an object to write, in bytes
@ -298,6 +503,8 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context,
* \returns the number of objects written, which will be less than **num** on * \returns the number of objects written, which will be less than **num** on
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_RWclose * \sa SDL_RWclose
* \sa SDL_RWFromConstMem * \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile * \sa SDL_RWFromFile
@ -321,13 +528,14 @@ extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context,
* Note that if this fails to flush the stream to disk, this function reports * Note that if this fails to flush the stream to disk, this function reports
* an error, but the SDL_RWops is still invalid once this function returns. * an error, but the SDL_RWops is still invalid once this function returns.
* *
* SDL_RWclose() is actually a macro that calls the SDL_RWops's `close` method * Prior to SDL 2.0.10, this function was a macro.
* appropriately, to simplify application development.
* *
* \param context SDL_RWops structure to close * \param context SDL_RWops structure to close
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_RWFromConstMem * \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile * \sa SDL_RWFromFile
* \sa SDL_RWFromFP * \sa SDL_RWFromFP
@ -351,6 +559,8 @@ extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context);
* \param datasize if not NULL, will store the number of bytes read * \param datasize if not NULL, will store the number of bytes read
* \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning * \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning
* \returns the data, or NULL if there was an error. * \returns the data, or NULL if there was an error.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src, extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src,
size_t *datasize, size_t *datasize,
@ -365,9 +575,14 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src,
* *
* The data should be freed with SDL_free(). * The data should be freed with SDL_free().
* *
* Prior to SDL 2.0.10, this function was a macro wrapping around
* SDL_LoadFile_RW.
*
* \param file the path to read all available data from * \param file the path to read all available data from
* \param datasize if not NULL, will store the number of bytes read * \param datasize if not NULL, will store the number of bytes read
* \returns the data, or NULL if there was an error. * \returns the data, or NULL if there was an error.
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
@ -377,12 +592,114 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
* Read an item of the specified endianness and return in native format. * Read an item of the specified endianness and return in native format.
*/ */
/* @{ */ /* @{ */
/**
* Use this function to read a byte from an SDL_RWops.
*
* \param src the SDL_RWops to read from
* \returns the read byte on success or 0 on failure; call SDL_GetError() for
* more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteU8
*/
extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
/**
* Use this function to read 16 bits of little-endian data from an SDL_RWops
* and return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 16 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadBE16
*/
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
/**
* Use this function to read 16 bits of big-endian data from an SDL_RWops and
* return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 16 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadLE16
*/
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
/**
* Use this function to read 32 bits of little-endian data from an SDL_RWops
* and return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 32 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadBE32
*/
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
/**
* Use this function to read 32 bits of big-endian data from an SDL_RWops and
* return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 32 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadLE32
*/
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
/**
* Use this function to read 64 bits of little-endian data from an SDL_RWops
* and return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 64 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadBE64
*/
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
/**
* Use this function to read 64 bits of big-endian data from an SDL_RWops and
* return in native format.
*
* SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order.
*
* \param src the stream from which to read data
* \returns 64 bits of data in the native byte order of the platform.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadLE64
*/
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
/* @} *//* Read endian functions */ /* @} *//* Read endian functions */
@ -392,12 +709,124 @@ extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
* Write an item of native format to the specified endianness. * Write an item of native format to the specified endianness.
*/ */
/* @{ */ /* @{ */
/**
* Use this function to write a byte to an SDL_RWops.
*
* \param dst the SDL_RWops to write to
* \param value the byte value to write
* \returns 1 on success or 0 on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ReadU8
*/
extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
/**
* Use this function to write 16 bits in native format to a SDL_RWops as
* little-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in little-endian
* format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteBE16
*/
extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
/**
* Use this function to write 16 bits in native format to a SDL_RWops as
* big-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteLE16
*/
extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
/**
* Use this function to write 32 bits in native format to a SDL_RWops as
* little-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in little-endian
* format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteBE32
*/
extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
/**
* Use this function to write 32 bits in native format to a SDL_RWops as
* big-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteLE32
*/
extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
/**
* Use this function to write 64 bits in native format to a SDL_RWops as
* little-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in little-endian
* format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteBE64
*/
extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
/**
* Use this function to write 64 bits in native format to a SDL_RWops as
* big-endian data.
*
* SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format.
*
* \param dst the stream to which data will be written
* \param value the data to be written, in native format
* \returns 1 on successful write, 0 on error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WriteLE64
*/
extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value);
/* @} *//* Write endian functions */ /* @} *//* Write endian functions */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -402,6 +402,26 @@ typedef enum
/* @} *//* Usage page 0x0C (additional media keys) */ /* @} *//* Usage page 0x0C (additional media keys) */
/**
* \name Mobile keys
*
* These are values that are often used on mobile phones.
*/
/* @{ */
SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and
used as a multi-function feature key for selecting
a software defined function shown on the bottom left
of the display. */
SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
used as a multi-function feature key for selecting
a software defined function shown on the bottom right
of the display. */
SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */
SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */
/* @} *//* Mobile keys */
/* Add any other keys here. */ /* Add any other keys here. */
SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -133,6 +133,8 @@ typedef enum
* In particular, you are guaranteed that the sensor list won't change, so the * In particular, you are guaranteed that the sensor list won't change, so the
* API functions that take a sensor index will be valid, and sensor events * API functions that take a sensor index will be valid, and sensor events
* will not be delivered. * will not be delivered.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC void SDLCALL SDL_LockSensors(void); extern DECLSPEC void SDLCALL SDL_LockSensors(void);
extern DECLSPEC void SDLCALL SDL_UnlockSensors(void); extern DECLSPEC void SDLCALL SDL_UnlockSensors(void);
@ -141,6 +143,8 @@ extern DECLSPEC void SDLCALL SDL_UnlockSensors(void);
* Count the number of sensors attached to the system right now. * Count the number of sensors attached to the system right now.
* *
* \returns the number of sensors detected. * \returns the number of sensors detected.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_NumSensors(void); extern DECLSPEC int SDLCALL SDL_NumSensors(void);
@ -149,6 +153,8 @@ extern DECLSPEC int SDLCALL SDL_NumSensors(void);
* *
* \param device_index The sensor to obtain name from * \param device_index The sensor to obtain name from
* \returns the sensor name, or NULL if `device_index` is out of range. * \returns the sensor name, or NULL if `device_index` is out of range.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index); extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index);
@ -158,6 +164,8 @@ extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index);
* \param device_index The sensor to get the type from * \param device_index The sensor to get the type from
* \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is * \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is
* out of range. * out of range.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index); extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index);
@ -167,6 +175,8 @@ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index)
* \param device_index The sensor to check * \param device_index The sensor to check
* \returns the sensor platform dependent type, or -1 if `device_index` is out * \returns the sensor platform dependent type, or -1 if `device_index` is out
* of range. * of range.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index); extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index);
@ -175,6 +185,8 @@ extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index)
* *
* \param device_index The sensor to get instance id from * \param device_index The sensor to get instance id from
* \returns the sensor instance ID, or -1 if `device_index` is out of range. * \returns the sensor instance ID, or -1 if `device_index` is out of range.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index); extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index);
@ -183,6 +195,8 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_in
* *
* \param device_index The sensor to open * \param device_index The sensor to open
* \returns an SDL_Sensor sensor object, or NULL if an error occurred. * \returns an SDL_Sensor sensor object, or NULL if an error occurred.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index);
@ -191,6 +205,8 @@ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index);
* *
* \param instance_id The sensor from instance id * \param instance_id The sensor from instance id
* \returns an SDL_Sensor object. * \returns an SDL_Sensor object.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id); extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id);
@ -199,6 +215,8 @@ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instan
* *
* \param sensor The SDL_Sensor object * \param sensor The SDL_Sensor object
* \returns the sensor name, or NULL if `sensor` is NULL. * \returns the sensor name, or NULL if `sensor` is NULL.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor); extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor);
@ -208,6 +226,8 @@ extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor);
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect
* \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is * \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is
* NULL. * NULL.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor); extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor);
@ -216,6 +236,8 @@ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor);
* *
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect
* \returns the sensor platform dependent type, or -1 if `sensor` is NULL. * \returns the sensor platform dependent type, or -1 if `sensor` is NULL.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor); extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor);
@ -224,6 +246,8 @@ extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor);
* *
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect
* \returns the sensor instance ID, or -1 if `sensor` is NULL. * \returns the sensor instance ID, or -1 if `sensor` is NULL.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor); extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor);
@ -236,6 +260,8 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data * \param num_values The number of values to write to data
* \returns 0 or -1 if an error occurred. * \returns 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values); extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values);
@ -243,6 +269,8 @@ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data,
* Close a sensor previously opened with SDL_SensorOpen(). * Close a sensor previously opened with SDL_SensorOpen().
* *
* \param sensor The SDL_Sensor object to close * \param sensor The SDL_Sensor object to close
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
@ -254,6 +282,8 @@ extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
* *
* This needs to be called from the thread that initialized the sensor * This needs to be called from the thread that initialized the sensor
* subsystem. * subsystem.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); extern DECLSPEC void SDLCALL SDL_SensorUpdate(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -62,6 +62,8 @@ extern "C" {
* and ::SDL_WINDOW_FULLSCREEN is always unset. * and ::SDL_WINDOW_FULLSCREEN is always unset.
* \return the window created, or NULL if window creation failed. * \return the window created, or NULL if window creation failed.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_DestroyWindow * \sa SDL_DestroyWindow
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
@ -73,6 +75,8 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,un
* \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if
* the window is unshaped or NULL. * the window is unshaped or NULL.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateShapedWindow * \sa SDL_CreateShapedWindow
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
@ -116,6 +120,8 @@ typedef struct SDL_WindowShapeMode {
* argument, or SDL_NONSHAPEABLE_WINDOW if the SDL_Window given does * argument, or SDL_NONSHAPEABLE_WINDOW if the SDL_Window given does
* not reference a valid shaped window. * not reference a valid shaped window.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WindowShapeMode * \sa SDL_WindowShapeMode
* \sa SDL_GetShapedWindowMode * \sa SDL_GetShapedWindowMode
*/ */
@ -133,6 +139,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *s
* window, or SDL_WINDOW_LACKS_SHAPE if the SDL_Window given is a * window, or SDL_WINDOW_LACKS_SHAPE if the SDL_Window given is a
* shapeable window currently lacking a shape. * shapeable window currently lacking a shape.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_WindowShapeMode * \sa SDL_WindowShapeMode
* \sa SDL_SetWindowShape * \sa SDL_SetWindowShape
*/ */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -80,9 +80,9 @@
# include <ctype.h> # include <ctype.h>
#endif #endif
#ifdef HAVE_MATH_H #ifdef HAVE_MATH_H
# if defined(__WINRT__) # if defined(_MSC_VER)
/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on /* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
for more information. for more information.
*/ */
# define _USE_MATH_DEFINES # define _USE_MATH_DEFINES
@ -115,6 +115,23 @@ char *alloca();
# endif # endif
#endif #endif
#ifdef SIZE_MAX
# define SDL_SIZE_MAX SIZE_MAX
#else
# define SDL_SIZE_MAX ((size_t) -1)
#endif
/**
* Check if the compiler supports a given builtin.
* Supported by virtually all clang versions and recent gcc. Use this
* instead of checking the clang version if possible.
*/
#ifdef __has_builtin
#define _SDL_HAS_BUILTIN(x) __has_builtin(x)
#else
#define _SDL_HAS_BUILTIN(x) 0
#endif
/** /**
* The number of elements in an array. * The number of elements in an array.
*/ */
@ -223,13 +240,26 @@ typedef uint64_t Uint64;
/* @} *//* Basic data types */ /* @} *//* Basic data types */
/**
* \name Floating-point constants
*/
/* @{ */
#ifdef FLT_EPSILON
#define SDL_FLT_EPSILON FLT_EPSILON
#else
#define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */
#endif
/* @} *//* Floating-point constants */
/* Make sure we have macros for printing width-based integers. /* Make sure we have macros for printing width-based integers.
* <stdint.h> should define these but this is not true all platforms. * <stdint.h> should define these but this is not true all platforms.
* (for example win32) */ * (for example win32) */
#ifndef SDL_PRIs64 #ifndef SDL_PRIs64
#ifdef PRIs64 #ifdef PRIs64
#define SDL_PRIs64 PRIs64 #define SDL_PRIs64 PRIs64
#elif defined(__WIN32__) #elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIs64 "I64d" #define SDL_PRIs64 "I64d"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(__LINUX__) && defined(__LP64__)
#define SDL_PRIs64 "ld" #define SDL_PRIs64 "ld"
@ -240,7 +270,7 @@ typedef uint64_t Uint64;
#ifndef SDL_PRIu64 #ifndef SDL_PRIu64
#ifdef PRIu64 #ifdef PRIu64
#define SDL_PRIu64 PRIu64 #define SDL_PRIu64 PRIu64
#elif defined(__WIN32__) #elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIu64 "I64u" #define SDL_PRIu64 "I64u"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(__LINUX__) && defined(__LP64__)
#define SDL_PRIu64 "lu" #define SDL_PRIu64 "lu"
@ -251,7 +281,7 @@ typedef uint64_t Uint64;
#ifndef SDL_PRIx64 #ifndef SDL_PRIx64
#ifdef PRIx64 #ifdef PRIx64
#define SDL_PRIx64 PRIx64 #define SDL_PRIx64 PRIx64
#elif defined(__WIN32__) #elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIx64 "I64x" #define SDL_PRIx64 "I64x"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(__LINUX__) && defined(__LP64__)
#define SDL_PRIx64 "lx" #define SDL_PRIx64 "lx"
@ -262,7 +292,7 @@ typedef uint64_t Uint64;
#ifndef SDL_PRIX64 #ifndef SDL_PRIX64
#ifdef PRIX64 #ifdef PRIX64
#define SDL_PRIX64 PRIX64 #define SDL_PRIX64 PRIX64
#elif defined(__WIN32__) #elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIX64 "I64X" #define SDL_PRIX64 "I64X"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(__LINUX__) && defined(__LP64__)
#define SDL_PRIX64 "lX" #define SDL_PRIX64 "lX"
@ -343,8 +373,22 @@ typedef uint64_t Uint64;
#endif #endif
#endif /* SDL_DISABLE_ANALYZE_MACROS */ #endif /* SDL_DISABLE_ANALYZE_MACROS */
#ifndef SDL_COMPILE_TIME_ASSERT
#if defined(__cplusplus)
#if (__cplusplus >= 201103L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#endif
#endif /* !SDL_COMPILE_TIME_ASSERT */
#ifndef SDL_COMPILE_TIME_ASSERT
/* universal, but may trigger -Wunused-local-typedefs */
#define SDL_COMPILE_TIME_ASSERT(name, x) \ #define SDL_COMPILE_TIME_ASSERT(name, x) \
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
#endif
/** \cond */ /** \cond */
#ifndef DOXYGEN_SHOULD_IGNORE_THIS #ifndef DOXYGEN_SHOULD_IGNORE_THIS
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
@ -402,8 +446,20 @@ typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size); typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
typedef void (SDLCALL *SDL_free_func)(void *mem); typedef void (SDLCALL *SDL_free_func)(void *mem);
/**
* Get the original set of SDL memory functions
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
SDL_calloc_func *calloc_func,
SDL_realloc_func *realloc_func,
SDL_free_func *free_func);
/** /**
* Get the current set of SDL memory functions * Get the current set of SDL memory functions
*
* \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
SDL_calloc_func *calloc_func, SDL_calloc_func *calloc_func,
@ -412,6 +468,8 @@ extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func
/** /**
* Replace SDL's memory allocation functions with a custom set * Replace SDL's memory allocation functions with a custom set
*
* \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
SDL_calloc_func calloc_func, SDL_calloc_func calloc_func,
@ -420,20 +478,23 @@ extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
/** /**
* Get the number of outstanding (unfreed) allocations * Get the number of outstanding (unfreed) allocations
*
* \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void); extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
extern DECLSPEC int SDLCALL SDL_abs(int x); extern DECLSPEC int SDLCALL SDL_abs(int x);
/* !!! FIXME: these have side effects. You probably shouldn't use them. */ /* NOTE: these double-evaluate their arguments, so you should never have side effects in the parameters */
/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) #define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) #define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
#define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
extern DECLSPEC int SDLCALL SDL_isalpha(int x); extern DECLSPEC int SDLCALL SDL_isalpha(int x);
extern DECLSPEC int SDLCALL SDL_isalnum(int x); extern DECLSPEC int SDLCALL SDL_isalnum(int x);
@ -450,6 +511,7 @@ extern DECLSPEC int SDLCALL SDL_isgraph(int x);
extern DECLSPEC int SDLCALL SDL_toupper(int x); extern DECLSPEC int SDLCALL SDL_toupper(int x);
extern DECLSPEC int SDLCALL SDL_tolower(int x); extern DECLSPEC int SDLCALL SDL_tolower(int x);
extern DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len); extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
@ -458,6 +520,11 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
#define SDL_copyp(dst, src) \
{ SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
SDL_memcpy((dst), (src), sizeof (*(src)))
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ /* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
{ {
@ -479,25 +546,13 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
if (dwords == 0) { if (dwords == 0) {
return; return;
} }
/* !!! FIXME: there are better ways to do this, but this is just to clean this up for now. */
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif
switch (dwords % 4) { switch (dwords % 4) {
case 0: do { *_p++ = _val; /* fallthrough */ case 0: do { *_p++ = _val; SDL_FALLTHROUGH;
case 3: *_p++ = _val; /* fallthrough */ case 3: *_p++ = _val; SDL_FALLTHROUGH;
case 2: *_p++ = _val; /* fallthrough */ case 2: *_p++ = _val; SDL_FALLTHROUGH;
case 1: *_p++ = _val; /* fallthrough */ case 1: *_p++ = _val;
} while ( --_n ); } while ( --_n );
} }
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif #endif
} }
@ -530,6 +585,7 @@ extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr); extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr);
extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
@ -555,6 +611,8 @@ extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING
extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap);
extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3);
extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap);
extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap);
#ifndef HAVE_M_PI #ifndef HAVE_M_PI
#ifndef M_PI #ifndef M_PI
@ -562,14 +620,28 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size
#endif #endif
#endif #endif
/**
* Use this function to compute arc cosine of `x`.
*
* The definition of `y = acos(x)` is `x = cos(y)`.
*
* Domain: `-1 <= x <= 1`
*
* Range: `0 <= y <= Pi`
*
* \param x floating point value, in radians.
* \returns arc cosine of `x`.
*
* \since This function is available since SDL 2.0.2.
*/
extern DECLSPEC double SDLCALL SDL_acos(double x); extern DECLSPEC double SDLCALL SDL_acos(double x);
extern DECLSPEC float SDLCALL SDL_acosf(float x); extern DECLSPEC float SDLCALL SDL_acosf(float x);
extern DECLSPEC double SDLCALL SDL_asin(double x); extern DECLSPEC double SDLCALL SDL_asin(double x);
extern DECLSPEC float SDLCALL SDL_asinf(float x); extern DECLSPEC float SDLCALL SDL_asinf(float x);
extern DECLSPEC double SDLCALL SDL_atan(double x); extern DECLSPEC double SDLCALL SDL_atan(double x);
extern DECLSPEC float SDLCALL SDL_atanf(float x); extern DECLSPEC float SDLCALL SDL_atanf(float x);
extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
extern DECLSPEC float SDLCALL SDL_atan2f(float x, float y); extern DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
extern DECLSPEC double SDLCALL SDL_ceil(double x); extern DECLSPEC double SDLCALL SDL_ceil(double x);
extern DECLSPEC float SDLCALL SDL_ceilf(float x); extern DECLSPEC float SDLCALL SDL_ceilf(float x);
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
@ -619,9 +691,12 @@ extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
size_t * inbytesleft, char **outbuf, size_t * inbytesleft, char **outbuf,
size_t * outbytesleft); size_t * outbytesleft);
/** /**
* This function converts a string between encodings in one pass, returning a * This function converts a string between encodings in one pass, returning a
* string that must be freed with SDL_free() or NULL on error. * string that must be freed with SDL_free() or NULL on error.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
const char *fromcode, const char *fromcode,
@ -630,6 +705,7 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (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
here, since there are possibly tests that are ineffective otherwise. */ here, since there are possibly tests that are ineffective otherwise. */
@ -683,6 +759,65 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
return SDL_memcpy(dst, src, dwords * 4); return SDL_memcpy(dst, src, dwords * 4);
} }
/**
* If a * b would overflow, return -1. Otherwise store a * b via ret
* and return 0.
*
* \since This function is available since SDL 2.24.0.
*/
SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
size_t b,
size_t *ret)
{
if (a != 0 && b > SDL_SIZE_MAX / a) {
return -1;
}
*ret = a * b;
return 0;
}
#if _SDL_HAS_BUILTIN(__builtin_mul_overflow)
/* This needs to be wrapped in an inline rather than being a direct #define,
* because __builtin_mul_overflow() is type-generic, but we want to be
* consistent about interpreting a and b as size_t. */
SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
size_t b,
size_t *ret)
{
return __builtin_mul_overflow(a, b, ret) == 0 ? 0 : -1;
}
#define SDL_size_mul_overflow(a, b, ret) (_SDL_size_mul_overflow_builtin(a, b, ret))
#endif
/**
* If a + b would overflow, return -1. Otherwise store a + b via ret
* and return 0.
*
* \since This function is available since SDL 2.24.0.
*/
SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
size_t b,
size_t *ret)
{
if (b > SDL_SIZE_MAX - a) {
return -1;
}
*ret = a + b;
return 0;
}
#if _SDL_HAS_BUILTIN(__builtin_add_overflow)
/* This needs to be wrapped in an inline rather than being a direct #define,
* the same as the call to __builtin_mul_overflow() above. */
SDL_FORCE_INLINE int _SDL_size_add_overflow_builtin (size_t a,
size_t b,
size_t *ret)
{
return __builtin_add_overflow(a, b, ret) == 0 ? 0 : -1;
}
#define SDL_size_add_overflow(a, b, ret) (_SDL_size_add_overflow_builtin(a, b, ret))
#endif
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -61,6 +61,8 @@ extern "C" {
*/ */
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
/** /**
* \brief A collection of pixels used in software blitting. * \brief A collection of pixels used in software blitting.
* *
@ -88,7 +90,7 @@ typedef struct SDL_Surface
SDL_Rect clip_rect; /**< Read-only */ SDL_Rect clip_rect; /**< Read-only */
/** info for fast blit mapping to other surfaces */ /** info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /**< Private */ SDL_BlitMap *map; /**< Private */
/** Reference count -- used when freeing surface */ /** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */ int refcount; /**< Read-mostly */
@ -149,6 +151,8 @@ typedef enum
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRGBSurfaceFrom * \sa SDL_CreateRGBSurfaceFrom
* \sa SDL_CreateRGBSurfaceWithFormat * \sa SDL_CreateRGBSurfaceWithFormat
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
@ -159,6 +163,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
/** /**
* Allocate a new RGB surface with a specific pixel format. * Allocate a new RGB surface with a specific pixel format.
* *
@ -174,6 +179,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.5.
*
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
* \sa SDL_CreateRGBSurfaceFrom * \sa SDL_CreateRGBSurfaceFrom
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
@ -203,6 +210,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
* \sa SDL_CreateRGBSurfaceWithFormat * \sa SDL_CreateRGBSurfaceWithFormat
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
@ -218,6 +227,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
Uint32 Amask); Uint32 Amask);
/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
/** /**
* Allocate a new RGB surface with with a specific pixel format and existing * Allocate a new RGB surface with with a specific pixel format and existing
* pixel data. * pixel data.
@ -238,6 +248,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.5.
*
* \sa SDL_CreateRGBSurfaceFrom * \sa SDL_CreateRGBSurfaceFrom
* \sa SDL_CreateRGBSurfaceWithFormat * \sa SDL_CreateRGBSurfaceWithFormat
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
@ -252,6 +264,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
* *
* \param surface the SDL_Surface to free. * \param surface the SDL_Surface to free.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
* \sa SDL_CreateRGBSurfaceFrom * \sa SDL_CreateRGBSurfaceFrom
* \sa SDL_LoadBMP * \sa SDL_LoadBMP
@ -268,6 +282,8 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
* \param palette the SDL_Palette structure to use * \param palette the SDL_Palette structure to use
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
SDL_Palette * palette); SDL_Palette * palette);
@ -288,6 +304,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MUSTLOCK * \sa SDL_MUSTLOCK
* \sa SDL_UnlockSurface * \sa SDL_UnlockSurface
*/ */
@ -298,6 +316,8 @@ extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
* *
* \param surface the SDL_Surface structure to be unlocked * \param surface the SDL_Surface structure to be unlocked
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockSurface * \sa SDL_LockSurface
*/ */
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
@ -305,14 +325,22 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
/** /**
* Load a BMP image from a seekable SDL data stream. * Load a BMP image from a seekable SDL data stream.
* *
* The new surface should be freed with SDL_FreeSurface(). * The new surface should be freed with SDL_FreeSurface(). Not doing so will
* result in a memory leak.
*
* src is an open SDL_RWops buffer, typically loaded with SDL_RWFromFile.
* Alternitavely, you might also use the macro SDL_LoadBMP to load a bitmap
* from a file, convert it to an SDL_Surface and then close the file.
* *
* \param src the data stream for the surface * \param src the data stream for the surface
* \param freesrc non-zero to close the stream after being read * \param freesrc non-zero to close the stream after being read
* \returns a pointer to a new SDL_Surface structure or NULL if there was an * \returns a pointer to a new SDL_Surface structure or NULL if there was an
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
* \sa SDL_RWFromFile
* \sa SDL_LoadBMP * \sa SDL_LoadBMP
* \sa SDL_SaveBMP_RW * \sa SDL_SaveBMP_RW
*/ */
@ -341,6 +369,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadBMP_RW * \sa SDL_LoadBMP_RW
* \sa SDL_SaveBMP * \sa SDL_SaveBMP
*/ */
@ -366,6 +396,8 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
* \sa SDL_LockSurface * \sa SDL_LockSurface
* \sa SDL_UnlockSurface * \sa SDL_UnlockSurface
@ -381,6 +413,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query
* \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise. * \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_SetSurfaceRLE * \sa SDL_SetSurfaceRLE
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface); extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
@ -404,6 +438,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
* \sa SDL_GetColorKey * \sa SDL_GetColorKey
*/ */
@ -418,6 +454,8 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query
* \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise. * \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_SetColorKey * \sa SDL_SetColorKey
* \sa SDL_GetColorKey * \sa SDL_GetColorKey
*/ */
@ -436,6 +474,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
* \sa SDL_SetColorKey * \sa SDL_SetColorKey
*/ */
@ -458,6 +498,8 @@ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetSurfaceColorMod * \sa SDL_GetSurfaceColorMod
* \sa SDL_SetSurfaceAlphaMod * \sa SDL_SetSurfaceAlphaMod
*/ */
@ -475,6 +517,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetSurfaceAlphaMod * \sa SDL_GetSurfaceAlphaMod
* \sa SDL_SetSurfaceColorMod * \sa SDL_SetSurfaceColorMod
*/ */
@ -495,6 +539,8 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetSurfaceAlphaMod * \sa SDL_GetSurfaceAlphaMod
* \sa SDL_SetSurfaceColorMod * \sa SDL_SetSurfaceColorMod
*/ */
@ -509,6 +555,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetSurfaceColorMod * \sa SDL_GetSurfaceColorMod
* \sa SDL_SetSurfaceAlphaMod * \sa SDL_SetSurfaceAlphaMod
*/ */
@ -527,6 +575,8 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetSurfaceBlendMode * \sa SDL_GetSurfaceBlendMode
*/ */
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
@ -540,6 +590,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetSurfaceBlendMode * \sa SDL_SetSurfaceBlendMode
*/ */
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
@ -560,6 +612,8 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
* \returns SDL_TRUE if the rectangle intersects the surface, otherwise * \returns SDL_TRUE if the rectangle intersects the surface, otherwise
* SDL_FALSE and blits will be completely clipped. * SDL_FALSE and blits will be completely clipped.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
* \sa SDL_GetClipRect * \sa SDL_GetClipRect
*/ */
@ -577,6 +631,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
* \param rect an SDL_Rect structure filled in with the clipping rectangle for * \param rect an SDL_Rect structure filled in with the clipping rectangle for
* the surface * the surface
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
* \sa SDL_SetClipRect * \sa SDL_SetClipRect
*/ */
@ -610,6 +666,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocFormat * \sa SDL_AllocFormat
* \sa SDL_ConvertSurfaceFormat * \sa SDL_ConvertSurfaceFormat
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
@ -633,8 +691,10 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AllocFormat * \sa SDL_AllocFormat
* \sa SDL_ConvertSurfaceFormat * \sa SDL_ConvertSurface
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
@ -647,12 +707,14 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
* \param height the height of the block to copy, in pixels * \param height the height of the block to copy, in pixels
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format
* \param src a pointer to the source pixels * \param src a pointer to the source pixels
* \param src_pitch the pitch of the block to copy, in bytes * \param src_pitch the pitch of the source pixels, in bytes
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format
* \param dst a pointer to be filled in with new pixel data * \param dst a pointer to be filled in with new pixel data
* \param dst_pitch the pitch of the destination pixels, in bytes * \param dst_pitch the pitch of the destination pixels, in bytes
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
Uint32 src_format, Uint32 src_format,
@ -660,6 +722,32 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
Uint32 dst_format, Uint32 dst_format,
void * dst, int dst_pitch); void * dst, int dst_pitch);
/**
* Premultiply the alpha on a block of pixels.
*
* This is safe to use with src == dst, but not for other overlapping areas.
*
* This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888.
*
* \param width the width of the block to convert, in pixels
* \param height the height of the block to convert, in pixels
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format
* \param src a pointer to the source pixels
* \param src_pitch the pitch of the source pixels, in bytes
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format
* \param dst a pointer to be filled in with premultiplied pixel data
* \param dst_pitch the pitch of the destination pixels, in bytes
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
Uint32 src_format,
const void * src, int src_pitch,
Uint32 dst_format,
void * dst, int dst_pitch);
/** /**
* Perform a fast fill of a rectangle with a specific color. * Perform a fast fill of a rectangle with a specific color.
* *
@ -679,6 +767,8 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FillRects * \sa SDL_FillRects
*/ */
extern DECLSPEC int SDLCALL SDL_FillRect extern DECLSPEC int SDLCALL SDL_FillRect
@ -703,6 +793,8 @@ extern DECLSPEC int SDLCALL SDL_FillRect
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FillRect * \sa SDL_FillRect
*/ */
extern DECLSPEC int SDLCALL SDL_FillRects extern DECLSPEC int SDLCALL SDL_FillRects
@ -774,6 +866,8 @@ extern DECLSPEC int SDLCALL SDL_FillRects
* SDL_UpperBlit() has been replaced by SDL_BlitSurface(), which is merely a * SDL_UpperBlit() has been replaced by SDL_BlitSurface(), which is merely a
* macro for this function with a less confusing name. * macro for this function with a less confusing name.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
*/ */
extern DECLSPEC int SDLCALL SDL_UpperBlit extern DECLSPEC int SDLCALL SDL_UpperBlit
@ -798,6 +892,8 @@ extern DECLSPEC int SDLCALL SDL_UpperBlit
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
*/ */
extern DECLSPEC int SDLCALL SDL_LowerBlit extern DECLSPEC int SDLCALL SDL_LowerBlit
@ -805,12 +901,14 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit
SDL_Surface * dst, SDL_Rect * dstrect); SDL_Surface * dst, SDL_Rect * dstrect);
/** /**
* Perform a fast, low quality, stretch blit between two surfaces of the * Perform a fast, low quality, stretch blit between two surfaces of the same
* same format. * format.
* *
* Please use SDL_BlitScaled() instead. * Please use SDL_BlitScaled() instead.
*/ *
* \since This function is available since SDL 2.0.0.
*/
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
const SDL_Rect * srcrect, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Surface * dst,
@ -818,6 +916,8 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
/** /**
* Perform bilinear scaling between two surfaces of the same format, 32BPP. * Perform bilinear scaling between two surfaces of the same format, 32BPP.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src, extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
const SDL_Rect * srcrect, const SDL_Rect * srcrect,
@ -833,6 +933,8 @@ extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
* SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is * SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is
* merely a macro for this function with a less confusing name. * merely a macro for this function with a less confusing name.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitScaled * \sa SDL_BlitScaled
*/ */
extern DECLSPEC int SDLCALL SDL_UpperBlitScaled extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
@ -854,6 +956,8 @@ extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitScaled * \sa SDL_BlitScaled
*/ */
extern DECLSPEC int SDLCALL SDL_LowerBlitScaled extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
@ -862,17 +966,23 @@ extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
/** /**
* Set the YUV conversion mode * Set the YUV conversion mode
*
* \since This function is available since SDL 2.0.8.
*/ */
extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode); extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
/** /**
* Get the YUV conversion mode * Get the YUV conversion mode
*
* \since This function is available since SDL 2.0.8.
*/ */
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void); extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
/** /**
* Get the YUV conversion mode, returning the correct mode for the resolution * Get the YUV conversion mode, returning the correct mode for the resolution
* when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC * when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
*
* \since This function is available since SDL 2.0.8.
*/ */
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height); extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -41,7 +41,7 @@ extern "C" {
/* Platform specific functions for Windows */ /* Platform specific functions for Windows */
#ifdef __WIN32__ #if defined(__WIN32__) || defined(__GDK__)
typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
@ -50,9 +50,15 @@ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsi
* *
* \param callback The SDL_WindowsMessageHook function to call. * \param callback The SDL_WindowsMessageHook function to call.
* \param userdata a pointer to pass to every iteration of `callback` * \param userdata a pointer to pass to every iteration of `callback`
*
* \since This function is available since SDL 2.0.4.
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
#endif /* defined(__WIN32__) || defined(__GDK__) */
#if defined(__WIN32__) || defined(__WINGDK__)
/** /**
* Get the D3D9 adapter index that matches the specified display index. * Get the D3D9 adapter index that matches the specified display index.
* *
@ -95,9 +101,35 @@ typedef struct ID3D11Device ID3D11Device;
* \param renderer the renderer from which to get the associated D3D11 device * \param renderer the renderer from which to get the associated D3D11 device
* \returns the D3D11 device associated with given renderer or NULL if it is * \returns the D3D11 device associated with given renderer or NULL if it is
* not a D3D11 renderer; call SDL_GetError() for more information. * not a D3D11 renderer; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer); extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer);
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
#if defined(__WIN32__) || defined(__GDK__)
typedef struct ID3D12Device ID3D12Device;
/**
* Get the D3D12 device associated with a renderer.
*
* Once you are done using the device, you should release it to avoid a
* resource leak.
*
* \param renderer the renderer from which to get the associated D3D12 device
* \returns the D3D12 device associated with given renderer or NULL if it is
* not a D3D12 renderer; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* renderer);
#endif /* defined(__WIN32__) || defined(__GDK__) */
#if defined(__WIN32__) || defined(__WINGDK__)
/** /**
* Get the DXGI Adapter and Output indices for the specified display index. * Get the DXGI Adapter and Output indices for the specified display index.
* *
@ -118,8 +150,7 @@ extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * re
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
#endif /* __WIN32__ */ #endif /* defined(__WIN32__) || defined(__WINGDK__) */
/* Platform specific functions for Linux */ /* Platform specific functions for Linux */
#ifdef __LINUX__ #ifdef __LINUX__
@ -132,18 +163,83 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a
* \param threadID the Unix thread ID to change priority of. * \param threadID the Unix thread ID to change priority of.
* \param priority The new, Unix-specific, priority value. * \param priority The new, Unix-specific, priority value.
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority);
/**
* Sets the priority (not nice level) and scheduling policy for a thread.
*
* This uses setpriority() if possible, and RealtimeKit if available.
*
* \param threadID The Unix thread ID to change priority of.
* \param sdlPriority The new SDL_ThreadPriority value.
* \param schedPolicy The new scheduling policy (SCHED_FIFO, SCHED_RR,
* SCHED_OTHER, etc...)
* \returns 0 on success, or -1 on error.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
#endif /* __LINUX__ */ #endif /* __LINUX__ */
/* Platform specific functions for iOS */ /* Platform specific functions for iOS */
#ifdef __IPHONEOS__ #ifdef __IPHONEOS__
#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) #define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
/**
* Use this function to set the animation callback on Apple iOS.
*
* The function prototype for `callback` is:
*
* ```c
* void callback(void* callbackParam);
* ```
*
* Where its parameter, `callbackParam`, is what was passed as `callbackParam`
* to SDL_iPhoneSetAnimationCallback().
*
* This function is only available on Apple iOS.
*
* For more information see:
* https://github.com/libsdl-org/SDL/blob/main/docs/README-ios.md
*
* This functions is also accessible using the macro
* SDL_iOSSetAnimationCallback() since SDL 2.0.4.
*
* \param window the window for which the animation callback should be set
* \param interval the number of frames after which **callback** will be
* called
* \param callback the function to call for every frame.
* \param callbackParam a pointer that is passed to `callback`.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_iPhoneSetEventPump
*/
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (SDLCALL *callback)(void*), void *callbackParam);
#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled) #define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
/**
* Use this function to enable or disable the SDL event pump on Apple iOS.
*
* This function is only available on Apple iOS.
*
* This functions is also accessible using the macro SDL_iOSSetEventPump()
* since SDL 2.0.4.
*
* \param enabled SDL_TRUE to enable the event pump, SDL_FALSE to disable it
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_iPhoneSetAnimationCallback
*/
extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
#endif /* __IPHONEOS__ */ #endif /* __IPHONEOS__ */
@ -196,6 +292,7 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
/** /**
* Query Android API level of the current device. * Query Android API level of the current device.
* *
* - API level 31: Android 12
* - API level 30: Android 11 * - API level 30: Android 11
* - API level 29: Android 10 * - API level 29: Android 10
* - API level 28: Android 9 * - API level 28: Android 9
@ -219,6 +316,8 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
* - API level 10: Android 2.3.3 * - API level 10: Android 2.3.3
* *
* \returns the Android API level. * \returns the Android API level.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
@ -226,6 +325,8 @@ extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
* Query if the application is running on Android TV. * Query if the application is running on Android TV.
* *
* \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise. * \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.8.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void); extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
@ -233,6 +334,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
* Query if the application is running on a Chromebook. * Query if the application is running on a Chromebook.
* *
* \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise. * \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void); extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
@ -240,11 +343,15 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
* Query if the application is running on a Samsung DeX docking station. * Query if the application is running on a Samsung DeX docking station.
* *
* \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise. * \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void); extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
/** /**
* Trigger the Android system back button behavior. * Trigger the Android system back button behavior.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
@ -315,6 +422,8 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void);
* *
* \param permission The permission to request. * \param permission The permission to request.
* \returns SDL_TRUE if the permission was granted, SDL_FALSE otherwise. * \returns SDL_TRUE if the permission was granted, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission); extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission);
@ -338,9 +447,23 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permis
* \param xoffset set this parameter only when gravity >=0 * \param xoffset set this parameter only when gravity >=0
* \param yoffset set this parameter only when gravity >=0 * \param yoffset set this parameter only when gravity >=0
* \returns 0 if success, -1 if any error occurs. * \returns 0 if success, -1 if any error occurs.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset); extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
/**
* Send a user command to SDLActivity.
*
* Override "boolean onUnhandledMessage(Message msg)" to handle the message.
*
* \param command user command that must be greater or equal to 0x8000
* \param param user parameter
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
#endif /* __ANDROID__ */ #endif /* __ANDROID__ */
/* Platform specific functions for WinRT */ /* Platform specific functions for WinRT */
@ -436,9 +559,11 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
/** /**
* Detects the device family of WinRT plattform at runtime. * Detects the device family of WinRT platform at runtime.
* *
* \returns a value from the SDL_WinRT_DeviceFamily enum. * \returns a value from the SDL_WinRT_DeviceFamily enum.
*
* \since This function is available since SDL 2.0.8.
*/ */
extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily(); extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
@ -450,6 +575,8 @@ extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
* If SDL can't determine this, it will return SDL_FALSE. * If SDL can't determine this, it will return SDL_FALSE.
* *
* \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise. * \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void); extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
@ -464,6 +591,27 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void);
extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
#endif #endif
/* Functions used only by GDK */
#if defined(__GDK__)
typedef struct XTaskQueueObject * XTaskQueueHandle;
/**
* Gets a reference to the global async task queue handle for GDK,
* initializing if needed.
*
* Once you are done with the task queue, you should call
* XTaskQueueCloseHandle to reduce the reference count to avoid a resource
* leak.
*
* \param outTaskQueue a pointer to be filled in with task queue handle.
* \returns 0 if success, -1 if any error occurs.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue);
#endif
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -98,6 +98,10 @@ typedef struct _UIViewController UIViewController;
typedef Uint32 GLuint; typedef Uint32 GLuint;
#endif #endif
#if defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)
#define SDL_METALVIEW_TAG 255
#endif
#if defined(SDL_VIDEO_DRIVER_ANDROID) #if defined(SDL_VIDEO_DRIVER_ANDROID)
typedef struct ANativeWindow ANativeWindow; typedef struct ANativeWindow ANativeWindow;
typedef void *EGLSurface; typedef void *EGLSurface;
@ -143,7 +147,8 @@ typedef enum
SDL_SYSWM_VIVANTE, SDL_SYSWM_VIVANTE,
SDL_SYSWM_OS2, SDL_SYSWM_OS2,
SDL_SYSWM_HAIKU, SDL_SYSWM_HAIKU,
SDL_SYSWM_KMSDRM SDL_SYSWM_KMSDRM,
SDL_SYSWM_RISCOS
} SDL_SYSWM_TYPE; } SDL_SYSWM_TYPE;
/** /**
@ -292,6 +297,9 @@ struct SDL_SysWMinfo
void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */ void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */
struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */
struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */ struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */
struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */
struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */
struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */
} wl; } wl;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -50,6 +50,7 @@
#define VERBOSE_RENDER 0x00000004 #define VERBOSE_RENDER 0x00000004
#define VERBOSE_EVENT 0x00000008 #define VERBOSE_EVENT 0x00000008
#define VERBOSE_AUDIO 0x00000010 #define VERBOSE_AUDIO 0x00000010
#define VERBOSE_MOTION 0x00000020
typedef struct typedef struct
{ {
@ -114,6 +115,10 @@ typedef struct
int gl_minor_version; int gl_minor_version;
int gl_debug; int gl_debug;
int gl_profile_mask; int gl_profile_mask;
/* Additional fields added in 2.0.18 */
SDL_Rect confine;
} SDLTest_CommonState; } SDLTest_CommonState;
#include "begin_code.h" #include "begin_code.h"
@ -215,9 +220,10 @@ void SDLTest_CommonQuit(SDLTest_CommonState * state);
* *
* \param renderer The renderer to draw to. * \param renderer The renderer to draw to.
* \param window The window whose information should be displayed. * \param window The window whose information should be displayed.
* \param usedHeight Returns the height used, so the caller can draw more below.
* *
*/ */
void SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window); void SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * usedHeight);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -38,7 +38,8 @@ extern "C" {
/* Function prototypes */ /* Function prototypes */
#define FONT_CHARACTER_SIZE 8 #define FONT_CHARACTER_SIZE 8
#define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2)
/** /**
* \brief Draw a string in the currently set font. * \brief Draw a string in the currently set font.
@ -50,10 +51,12 @@ extern "C" {
* *
* \returns 0 on success, -1 on failure. * \returns 0 on success, -1 on failure.
*/ */
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c); int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c);
/** /**
* \brief Draw a string in the currently set font. * \brief Draw a UTF-8 string in the currently set font.
*
* The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.
* *
* \param renderer The renderer to draw on. * \param renderer The renderer to draw on.
* \param x The X coordinate of the upper left corner of the string. * \param x The X coordinate of the upper left corner of the string.
@ -64,6 +67,90 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c);
*/ */
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s); int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
/**
* \brief Data used for multi-line text output
*/
typedef struct SDLTest_TextWindow
{
SDL_Rect rect;
int current;
int numlines;
char **lines;
} SDLTest_TextWindow;
/**
* \brief Create a multi-line text output window
*
* \param x The X coordinate of the upper left corner of the window.
* \param y The Y coordinate of the upper left corner of the window.
* \param w The width of the window (currently ignored)
* \param h The height of the window (currently ignored)
*
* \returns the new window, or NULL on failure.
*
* \since This function is available since SDL 2.24.0
*/
SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h);
/**
* \brief Display a multi-line text output window
*
* This function should be called every frame to display the text
*
* \param textwin The text output window
* \param renderer The renderer to use for display
*
* \since This function is available since SDL 2.24.0
*/
void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer);
/**
* \brief Add text to a multi-line text output window
*
* Adds UTF-8 text to the end of the current text. The newline character starts a
* new line of text. The backspace character deletes the last character or, if the
* line is empty, deletes the line and goes to the end of the previous line.
*
* \param textwin The text output window
* \param fmt A printf() style format string
* \param ... additional parameters matching % tokens in the `fmt` string, if any
*
* \since This function is available since SDL 2.24.0
*/
void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
/**
* \brief Add text to a multi-line text output window
*
* Adds UTF-8 text to the end of the current text. The newline character starts a
* new line of text. The backspace character deletes the last character or, if the
* line is empty, deletes the line and goes to the end of the previous line.
*
* \param textwin The text output window
* \param text The text to add to the window
* \param len The length, in bytes, of the text to add to the window
*
* \since This function is available since SDL 2.24.0
*/
void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len);
/**
* \brief Clear the text in a multi-line text output window
*
* \param textwin The text output window
*
* \since This function is available since SDL 2.24.0
*/
void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin);
/**
* \brief Free the storage associated with a multi-line text output window
*
* \param textwin The text output window
*
* \since This function is available since SDL 2.24.0
*/
void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin);
/** /**
* \brief Cleanup textures used by font drawing functions. * \brief Cleanup textures used by font drawing functions.

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -76,9 +76,9 @@ typedef struct SDLTest_TestCaseReference {
/* !< Func2Stress */ /* !< Func2Stress */
SDLTest_TestCaseFp testCase; SDLTest_TestCaseFp testCase;
/* !< Short name (or function name) "Func2Stress" */ /* !< Short name (or function name) "Func2Stress" */
char *name; const char *name;
/* !< Long name or full description "This test pushes func2() to the limit." */ /* !< Long name or full description "This test pushes func2() to the limit." */
char *description; const char *description;
/* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
int enabled; int enabled;
} SDLTest_TestCaseReference; } SDLTest_TestCaseReference;
@ -88,7 +88,7 @@ typedef struct SDLTest_TestCaseReference {
*/ */
typedef struct SDLTest_TestSuiteReference { typedef struct SDLTest_TestSuiteReference {
/* !< "PlatformSuite" */ /* !< "PlatformSuite" */
char *name; const char *name;
/* !< The function that is run before each test. NULL skips. */ /* !< The function that is run before each test. NULL skips. */
SDLTest_TestCaseSetUpFp testSetUp; SDLTest_TestCaseSetUpFp testSetUp;
/* !< The test cases that are run as part of the suite. Last item should be NULL. */ /* !< The test cases that are run as part of the suite. Last item should be NULL. */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -35,7 +35,7 @@
#include "SDL_atomic.h" #include "SDL_atomic.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#if defined(__WIN32__) #if defined(__WIN32__) || defined(__GDK__)
#include <process.h> /* _beginthreadex() and _endthreadex() */ #include <process.h> /* _beginthreadex() and _endthreadex() */
#endif #endif
#if defined(__OS2__) /* for _beginthread() and _endthread() */ #if defined(__OS2__) /* for _beginthread() and _endthread() */
@ -88,7 +88,7 @@ typedef enum {
typedef int (SDLCALL * SDL_ThreadFunction) (void *data); typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
#if defined(__WIN32__) #if defined(__WIN32__) || defined(__GDK__)
/** /**
* \file SDL_thread.h * \file SDL_thread.h
* *
@ -123,24 +123,18 @@ typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#define SDL_endthread _endthreadex #define SDL_endthread _endthreadex
#endif #endif
/**
* Create a thread.
*/
extern DECLSPEC SDL_Thread *SDLCALL extern DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread); pfnSDL_CurrentEndThread pfnEndThread);
extern DECLSPEC SDL_Thread *SDLCALL extern DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn,
const char *name, const size_t stacksize, void *data, const char *name, const size_t stacksize, void *data,
pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread); pfnSDL_CurrentEndThread pfnEndThread);
/**
* Create a thread.
*/
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API #if defined(SDL_CreateThread) && SDL_DYNAMIC_API
#undef SDL_CreateThread #undef SDL_CreateThread
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) #define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
@ -205,6 +199,8 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
* new thread could not be created; call SDL_GetError() for more * new thread could not be created; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateThreadWithStackSize * \sa SDL_CreateThreadWithStackSize
* \sa SDL_WaitThread * \sa SDL_WaitThread
*/ */
@ -250,6 +246,8 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
* new thread could not be created; call SDL_GetError() for more * new thread could not be created; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_WaitThread * \sa SDL_WaitThread
*/ */
extern DECLSPEC SDL_Thread *SDLCALL extern DECLSPEC SDL_Thread *SDLCALL
@ -267,6 +265,8 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
* \returns a pointer to a UTF-8 string that names the specified thread, or * \returns a pointer to a UTF-8 string that names the specified thread, or
* NULL if it doesn't have a name. * NULL if it doesn't have a name.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateThread * \sa SDL_CreateThread
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
@ -283,6 +283,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
* *
* \returns the ID of the current thread. * \returns the ID of the current thread.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetThreadID * \sa SDL_GetThreadID
*/ */
extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
@ -298,6 +300,8 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
* \returns the ID of the specified thread, or the ID of the current thread if * \returns the ID of the specified thread, or the ID of the current thread if
* `thread` is NULL. * `thread` is NULL.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ThreadID * \sa SDL_ThreadID
*/ */
extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
@ -312,6 +316,8 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
* \param priority the SDL_ThreadPriority to set * \param priority the SDL_ThreadPriority to set
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
@ -343,6 +349,8 @@ extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
* from the thread function by its 'return', or NULL to not * from the thread function by its 'return', or NULL to not
* receive such value back. * receive such value back.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateThread * \sa SDL_CreateThread
* \sa SDL_DetachThread * \sa SDL_DetachThread
*/ */
@ -440,6 +448,8 @@ extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SD
/** /**
* Cleanup all TLS data for this thread. * Cleanup all TLS data for this thread.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC void SDLCALL SDL_TLSCleanup(void); extern DECLSPEC void SDLCALL SDL_TLSCleanup(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -42,24 +42,66 @@ extern "C" {
* *
* This value wraps if the program runs for more than ~49 days. * This value wraps if the program runs for more than ~49 days.
* *
* This function is not recommended as of SDL 2.0.18; use SDL_GetTicks64()
* instead, where the value doesn't wrap every ~49 days. There are places in
* SDL where we provide a 32-bit timestamp that can not change without
* breaking binary compatibility, though, so this function isn't officially
* deprecated.
*
* \returns an unsigned 32-bit value representing the number of milliseconds * \returns an unsigned 32-bit value representing the number of milliseconds
* since the SDL library initialized. * since the SDL library initialized.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_TICKS_PASSED * \sa SDL_TICKS_PASSED
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
/** /**
* Compare SDL ticks values, and return true if `A` has passed `B`. * Get the number of milliseconds since SDL library initialization.
*
* Note that you should not use the SDL_TICKS_PASSED macro with values
* returned by this function, as that macro does clever math to compensate for
* the 32-bit overflow every ~49 days that SDL_GetTicks() suffers from. 64-bit
* values from this function can be safely compared directly.
* *
* For example, if you want to wait 100 ms, you could do this: * For example, if you want to wait 100 ms, you could do this:
* *
* ```c++ * ```c
* Uint32 timeout = SDL_GetTicks() + 100; * const Uint64 timeout = SDL_GetTicks64() + 100;
* while (SDL_GetTicks64() < timeout) {
* // ... do work until timeout has elapsed
* }
* ```
*
* \returns an unsigned 64-bit value representing the number of milliseconds
* since the SDL library initialized.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
/**
* Compare 32-bit SDL ticks values, and return true if `A` has passed `B`.
*
* This should be used with results from SDL_GetTicks(), as this macro
* attempts to deal with the 32-bit counter wrapping back to zero every ~49
* days, but should _not_ be used with SDL_GetTicks64(), which does not have
* that problem.
*
* For example, with SDL_GetTicks(), if you want to wait 100 ms, you could
* do this:
*
* ```c
* const Uint32 timeout = SDL_GetTicks() + 100;
* while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
* // ... do work until timeout has elapsed * // ... do work until timeout has elapsed
* } * }
* ``` * ```
*
* Note that this does not handle tick differences greater
* than 2^31 so take care when using the above kind of code
* with large timeout delays (tens of days).
*/ */
#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
@ -74,6 +116,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
* *
* \returns the current counter value. * \returns the current counter value.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetPerformanceFrequency * \sa SDL_GetPerformanceFrequency
*/ */
extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
@ -97,6 +141,8 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
* scheduling. * scheduling.
* *
* \param ms the number of milliseconds to delay * \param ms the number of milliseconds to delay
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
@ -143,6 +189,8 @@ typedef int SDL_TimerID;
* \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more * \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more
* information. * information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RemoveTimer * \sa SDL_RemoveTimer
*/ */
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
@ -156,6 +204,8 @@ extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
* \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't * \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't
* found. * found.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AddTimer * \sa SDL_AddTimer
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -95,8 +95,18 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void);
*/ */
extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
/**
* Get the touch device name as reported from the driver or NULL if the index
* is invalid.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index);
/** /**
* Get the type of the given touch device. * Get the type of the given touch device.
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID);
@ -123,6 +133,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
* \returns a pointer to the SDL_Finger object or NULL if no object at the * \returns a pointer to the SDL_Finger object or NULL if no object at the
* given ID and index could be found. * given ID and index could be found.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_RecordGesture * \sa SDL_RecordGesture
*/ */
extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -58,8 +58,8 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/ */
#define SDL_MAJOR_VERSION 2 #define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 0 #define SDL_MINOR_VERSION 24
#define SDL_PATCHLEVEL 16 #define SDL_PATCHLEVEL 2
/** /**
* Macro to determine SDL version program was compiled against. * Macro to determine SDL version program was compiled against.
@ -83,6 +83,8 @@ typedef struct SDL_version
(x)->patch = SDL_PATCHLEVEL; \ (x)->patch = SDL_PATCHLEVEL; \
} }
/* TODO: Remove this whole block in SDL 3 */
#if SDL_MAJOR_VERSION < 3
/** /**
* This macro turns the version numbers into a numeric value: * This macro turns the version numbers into a numeric value:
* \verbatim * \verbatim
@ -90,21 +92,35 @@ typedef struct SDL_version
\endverbatim \endverbatim
* *
* This assumes that there will never be more than 100 patchlevels. * This assumes that there will never be more than 100 patchlevels.
*
* In versions higher than 2.9.0, the minor version overflows into
* the thousands digit: for example, 2.23.0 is encoded as 4300,
* and 2.255.99 would be encoded as 25799.
* This macro will not be available in SDL 3.x.
*/ */
#define SDL_VERSIONNUM(X, Y, Z) \ #define SDL_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z)) ((X)*1000 + (Y)*100 + (Z))
/** /**
* This is the version number macro for the current SDL version. * This is the version number macro for the current SDL version.
*
* In versions higher than 2.9.0, the minor version overflows into
* the thousands digit: for example, 2.23.0 is encoded as 4300.
* This macro will not be available in SDL 3.x.
*
* Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead.
*/ */
#define SDL_COMPILEDVERSION \ #define SDL_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
#endif /* SDL_MAJOR_VERSION < 3 */
/** /**
* This macro will evaluate to true if compiled with SDL at least X.Y.Z. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
*/ */
#define SDL_VERSION_ATLEAST(X, Y, Z) \ #define SDL_VERSION_ATLEAST(X, Y, Z) \
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) ((SDL_MAJOR_VERSION >= X) && \
(SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION >= Y) && \
(SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION > Y || SDL_PATCHLEVEL >= Z))
/** /**
* Get the version of SDL that is linked against your program. * Get the version of SDL that is linked against your program.
@ -118,6 +134,8 @@ typedef struct SDL_version
* *
* \param ver the SDL_version structure that contains the version information * \param ver the SDL_version structure that contains the version information
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRevision * \sa SDL_GetRevision
*/ */
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
@ -145,6 +163,8 @@ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
* \returns an arbitrary string, uniquely identifying the exact revision of * \returns an arbitrary string, uniquely identifying the exact revision of
* the SDL library in use. * the SDL library in use.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetVersion * \sa SDL_GetVersion
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
@ -153,10 +173,22 @@ extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
* Obsolete function, do not use. * Obsolete function, do not use.
* *
* When SDL was hosted in a Mercurial repository, and was built carefully, * When SDL was hosted in a Mercurial repository, and was built carefully,
* this would return the revision number that the build was created from. * this would return the revision number that the build was created from. This
* This number was not reliable for several reasons, but more importantly, * number was not reliable for several reasons, but more importantly, SDL is
* SDL is now hosted in a git repository, which does not offer numbers at * now hosted in a git repository, which does not offer numbers at all, only
* all, only hashes. This function only ever returns zero now. Don't use it. * hashes. This function only ever returns zero now. Don't use it.
*
* Before SDL 2.0.16, this might have returned an unreliable, but non-zero
* number.
*
* \deprecated Use SDL_GetRevision() instead; if SDL was carefully built, it
* will return a git hash.
*
* \returns zero, always, in modern SDL releases.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetRevision
*/ */
extern SDL_DEPRECATED DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); extern SDL_DEPRECATED DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -174,7 +174,9 @@ typedef enum
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */ SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */ SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
SDL_WINDOWEVENT_HIT_TEST /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */ SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */
} SDL_WindowEventID; } SDL_WindowEventID;
/** /**
@ -207,7 +209,7 @@ typedef enum
{ {
SDL_FLASH_CANCEL, /**< Cancel any window flash state */ SDL_FLASH_CANCEL, /**< Cancel any window flash state */
SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */ SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
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;
/** /**
@ -246,7 +248,8 @@ typedef enum
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
SDL_GL_CONTEXT_RESET_NOTIFICATION, SDL_GL_CONTEXT_RESET_NOTIFICATION,
SDL_GL_CONTEXT_NO_ERROR SDL_GL_CONTEXT_NO_ERROR,
SDL_GL_FLOATBUFFERS
} SDL_GLattr; } SDL_GLattr;
typedef enum typedef enum
@ -284,6 +287,8 @@ typedef enum
* \returns a number >= 1 on success or a negative error code on failure; call * \returns a number >= 1 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetVideoDriver * \sa SDL_GetVideoDriver
*/ */
extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
@ -297,6 +302,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
* \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**.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDrivers * \sa SDL_GetNumVideoDrivers
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
@ -323,6 +330,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDrivers * \sa SDL_GetNumVideoDrivers
* \sa SDL_GetVideoDriver * \sa SDL_GetVideoDriver
* \sa SDL_InitSubSystem * \sa SDL_InitSubSystem
@ -335,6 +344,8 @@ extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
* *
* This function closes all windows, and restores the original video mode. * This function closes all windows, and restores the original video mode.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_VideoInit * \sa SDL_VideoInit
*/ */
extern DECLSPEC void SDLCALL SDL_VideoQuit(void); extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
@ -388,6 +399,8 @@ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDisplays * \sa SDL_GetNumVideoDisplays
*/ */
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
@ -432,6 +445,15 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
* A failure of this function usually means that either no DPI information is * A failure of this function usually means that either no DPI information is
* available or the `displayIndex` is out of range. * available or the `displayIndex` is out of range.
* *
* **WARNING**: This reports the DPI that the hardware reports, and it is not
* always reliable! It is almost always better to use SDL_GetWindowSize() to
* find the window size, which might be in logical points instead of pixels,
* and then SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(),
* SDL_Metal_GetDrawableSize(), or SDL_GetRendererOutputSize(), and compare
* the two values to get an actual scaling value between the two. We will be
* rethinking how high-dpi details should be managed in SDL3 to make things
* more consistent, reliable, and clear.
*
* \param displayIndex the index of the display from which DPI information * \param displayIndex the index of the display from which DPI information
* should be queried * should be queried
* \param ddpi a pointer filled in with the diagonal DPI of the display; may * \param ddpi a pointer filled in with the diagonal DPI of the display; may
@ -456,6 +478,8 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, fl
* \returns The SDL_DisplayOrientation enum value of the display, or * \returns The SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available. * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
* *
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_GetNumVideoDisplays * \sa SDL_GetNumVideoDisplays
*/ */
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex); extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex);
@ -495,6 +519,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumDisplayModes * \sa SDL_GetNumDisplayModes
*/ */
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
@ -514,6 +540,8 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetCurrentDisplayMode * \sa SDL_GetCurrentDisplayMode
* \sa SDL_GetDisplayMode * \sa SDL_GetDisplayMode
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
@ -534,6 +562,8 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_Disp
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDesktopDisplayMode * \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetDisplayMode * \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays * \sa SDL_GetNumVideoDisplays
@ -560,11 +590,42 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
* \returns the passed in value `closest` or NULL if no matching video mode * \returns the passed in value `closest` or NULL if no matching video mode
* was available; call SDL_GetError() for more information. * was available; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayMode * \sa SDL_GetDisplayMode
* \sa SDL_GetNumDisplayModes * \sa SDL_GetNumDisplayModes
*/ */
extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
/**
* Get the index of the display containing a point
*
* \param point the point to query
* \returns the index of the display containing the point or a negative error
* code on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetPointDisplayIndex(const SDL_Point * point);
/**
* Get the index of the display primarily containing a rect
*
* \param rect the rect to query
* \returns the index of the display entirely containing the rect or closest
* to the center of the rect on success or a negative error code on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetRectDisplayIndex(const SDL_Rect * rect);
/** /**
* Get the index of the display associated with a window. * Get the index of the display associated with a window.
* *
@ -573,6 +634,8 @@ extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayI
* success or a negative error code on failure; call SDL_GetError() * success or a negative error code on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayBounds * \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays * \sa SDL_GetNumVideoDisplays
*/ */
@ -592,6 +655,8 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowDisplayMode * \sa SDL_GetWindowDisplayMode
* \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowFullscreen
*/ */
@ -607,12 +672,28 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
* \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowFullscreen
*/ */
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
SDL_DisplayMode * mode); SDL_DisplayMode * mode);
/**
* Get the raw ICC profile data for the screen the window is currently on.
*
* Data returned should be freed with SDL_free.
*
* \param window the window to query
* \param size the size of the ICC profile
* \returns the raw ICC profile data on success or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC void* SDLCALL SDL_GetWindowICCProfile(SDL_Window * window, size_t* size);
/** /**
* Get the pixel format associated with the window. * Get the pixel format associated with the window.
* *
@ -620,6 +701,8 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
* \returns the pixel format of the window on success or * \returns the pixel format of the window on success or
* SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
* information. * information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
@ -653,7 +736,10 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
* in pixels may differ from its size in screen coordinates on platforms with * in pixels may differ from its size in screen coordinates on platforms with
* high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the * high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the
* client area's size in screen coordinates, and SDL_GL_GetDrawableSize() or * client area's size in screen coordinates, and SDL_GL_GetDrawableSize() or
* SDL_GetRendererOutputSize() to query the drawable size in pixels. * SDL_GetRendererOutputSize() to query the drawable size in pixels. Note that
* when this flag is set, the drawable size can vary after the window is
* created and should be queried after major window events such as when the
* window is resized or moved between displays.
* *
* If the window is set fullscreen, the width and height parameters `w` and * If the window is set fullscreen, the width and height parameters `w` and
* `h` will not be used. However, invalid size parameters (e.g. too large) may * `h` will not be used. However, invalid size parameters (e.g. too large) may
@ -707,6 +793,8 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
* \returns the window that was created or NULL on failure; call * \returns the window that was created or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
* \sa SDL_DestroyWindow * \sa SDL_DestroyWindow
*/ */
@ -738,6 +826,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
* \returns the window associated with `id` or NULL if it doesn't exist; call * \returns the window associated with `id` or NULL if it doesn't exist; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowID * \sa SDL_GetWindowID
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
@ -748,6 +838,8 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
* \param window the window to query * \param window the window to query
* \returns a mask of the SDL_WindowFlags associated with `window` * \returns a mask of the SDL_WindowFlags associated with `window`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
* \sa SDL_HideWindow * \sa SDL_HideWindow
* \sa SDL_MaximizeWindow * \sa SDL_MaximizeWindow
@ -766,6 +858,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
* \param window the window to change * \param window the window to change
* \param title the desired window title in UTF-8 format * \param title the desired window title in UTF-8 format
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowTitle * \sa SDL_GetWindowTitle
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
@ -778,6 +872,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
* \returns the title of the window in UTF-8 format or "" if there is no * \returns the title of the window in UTF-8 format or "" if there is no
* title. * title.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowTitle * \sa SDL_SetWindowTitle
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
@ -787,6 +883,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
* *
* \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
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
SDL_Surface * icon); SDL_Surface * icon);
@ -801,6 +899,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
* \param userdata the associated pointer * \param userdata the associated pointer
* \returns the previous value associated with `name`. * \returns the previous value associated with `name`.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowData * \sa SDL_GetWindowData
*/ */
extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
@ -814,6 +914,8 @@ extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
* \param name the name of the pointer * \param name the name of the pointer
* \returns the value associated with `name`. * \returns the value associated with `name`.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowData * \sa SDL_SetWindowData
*/ */
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
@ -830,6 +932,8 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
* \param y the y coordinate of the window in screen coordinates, or * \param y the y coordinate of the window in screen coordinates, or
* `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED` * `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowPosition * \sa SDL_GetWindowPosition
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
@ -847,6 +951,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
* \param y a pointer filled in with the y position of the window, in screen * \param y a pointer filled in with the y position of the window, in screen
* coordinates, may be NULL * coordinates, may be NULL
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowPosition * \sa SDL_SetWindowPosition
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
@ -869,6 +975,8 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
* \param h the height of the window in pixels, in screen coordinates, must be * \param h the height of the window in pixels, in screen coordinates, must be
* > 0 * > 0
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
*/ */
@ -893,6 +1001,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
* \param h a pointer filled in with the height of the window, in screen * \param h a pointer filled in with the height of the window, in screen
* coordinates, may be NULL * coordinates, may be NULL
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_GetDrawableSize * \sa SDL_GL_GetDrawableSize
* \sa SDL_Vulkan_GetDrawableSize * \sa SDL_Vulkan_GetDrawableSize
* \sa SDL_SetWindowSize * \sa SDL_SetWindowSize
@ -943,6 +1053,8 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window,
* \param min_w the minimum width of the window in pixels * \param min_w the minimum width of the window in pixels
* \param min_h the minimum height of the window in pixels * \param min_h the minimum height of the window in pixels
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowMinimumSize * \sa SDL_GetWindowMinimumSize
* \sa SDL_SetWindowMaximumSize * \sa SDL_SetWindowMaximumSize
*/ */
@ -958,6 +1070,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
* \param h a pointer filled in with the minimum height of the window, may be * \param h a pointer filled in with the minimum height of the window, may be
* NULL * NULL
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowMaximumSize * \sa SDL_GetWindowMaximumSize
* \sa SDL_SetWindowMinimumSize * \sa SDL_SetWindowMinimumSize
*/ */
@ -971,6 +1085,8 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
* \param max_w the maximum width of the window in pixels * \param max_w the maximum width of the window in pixels
* \param max_h the maximum height of the window in pixels * \param max_h the maximum height of the window in pixels
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowMaximumSize * \sa SDL_GetWindowMaximumSize
* \sa SDL_SetWindowMinimumSize * \sa SDL_SetWindowMinimumSize
*/ */
@ -986,6 +1102,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
* \param h a pointer filled in with the maximum height of the window, may be * \param h a pointer filled in with the maximum height of the window, may be
* NULL * NULL
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowMinimumSize * \sa SDL_GetWindowMinimumSize
* \sa SDL_SetWindowMaximumSize * \sa SDL_SetWindowMaximumSize
*/ */
@ -1031,25 +1149,29 @@ extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window,
SDL_bool resizable); SDL_bool resizable);
/** /**
* \brief Set the window to always be above the others. * Set the window to always be above the others.
* *
* This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
* flag. This will bring the window to the front and keep the window above * will bring the window to the front and keep the window above the rest.
* the rest.
* *
* \param window The window of which to change the always on top state. * \param window The window of which to change the always on top state
* \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to disable. * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
* disable
* *
* \sa SDL_SetWindowAlwaysOnTop * \since This function is available since SDL 2.0.16.
*
* \sa SDL_GetWindowFlags
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window,
SDL_bool on_top); SDL_bool on_top);
/** /**
* Show a window. * Show a window.
* *
* \param window the window to show * \param window the window to show
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HideWindow * \sa SDL_HideWindow
* \sa SDL_RaiseWindow * \sa SDL_RaiseWindow
*/ */
@ -1060,6 +1182,8 @@ extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window);
* *
* \param window the window to hide * \param window the window to hide
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ShowWindow * \sa SDL_ShowWindow
*/ */
extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
@ -1068,6 +1192,8 @@ extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
* Raise a window above other windows and set the input focus. * Raise a window above other windows and set the input focus.
* *
* \param window the window to raise * \param window the window to raise
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
@ -1076,6 +1202,8 @@ extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
* *
* \param window the window to maximize * \param window the window to maximize
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MinimizeWindow * \sa SDL_MinimizeWindow
* \sa SDL_RestoreWindow * \sa SDL_RestoreWindow
*/ */
@ -1086,6 +1214,8 @@ extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window);
* *
* \param window the window to minimize * \param window the window to minimize
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MaximizeWindow * \sa SDL_MaximizeWindow
* \sa SDL_RestoreWindow * \sa SDL_RestoreWindow
*/ */
@ -1096,6 +1226,8 @@ extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window);
* *
* \param window the window to restore * \param window the window to restore
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MaximizeWindow * \sa SDL_MaximizeWindow
* \sa SDL_MinimizeWindow * \sa SDL_MinimizeWindow
*/ */
@ -1139,6 +1271,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
* \returns the surface associated with the window, or NULL on failure; call * \returns the surface associated with the window, or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_UpdateWindowSurface * \sa SDL_UpdateWindowSurface
* \sa SDL_UpdateWindowSurfaceRects * \sa SDL_UpdateWindowSurfaceRects
*/ */
@ -1156,6 +1290,8 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowSurface * \sa SDL_GetWindowSurface
* \sa SDL_UpdateWindowSurfaceRects * \sa SDL_UpdateWindowSurfaceRects
*/ */
@ -1176,6 +1312,8 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowSurface * \sa SDL_GetWindowSurface
* \sa SDL_UpdateWindowSurface * \sa SDL_UpdateWindowSurface
*/ */
@ -1186,7 +1324,9 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
/** /**
* Set a window's input grab mode. * Set a window's input grab mode.
* *
* When input is grabbed the mouse is confined to the window. * When input is grabbed, the mouse is confined to the window. This function
* will also grab the keyboard if `SDL_HINT_GRAB_KEYBOARD` is set. To grab the
* keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab().
* *
* If the caller enables a grab while another window is currently grabbed, the * If the caller enables a grab while another window is currently grabbed, the
* other window loses its grab in favor of the caller's window. * other window loses its grab in favor of the caller's window.
@ -1194,6 +1334,8 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
* \param window the window for which the input grab mode should be set * \param window the window for which the input grab mode should be set
* \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetGrabbedWindow * \sa SDL_GetGrabbedWindow
* \sa SDL_GetWindowGrab * \sa SDL_GetWindowGrab
*/ */
@ -1203,12 +1345,27 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
/** /**
* Set a window's keyboard grab mode. * Set a window's keyboard grab mode.
* *
* Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
* the Meta/Super key. Note that not all system keyboard shortcuts can be
* captured by applications (one example is Ctrl+Alt+Del on Windows).
*
* This is primarily intended for specialized applications such as VNC clients
* or VM frontends. Normal games should not use keyboard grab.
*
* When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
* window is full-screen to ensure the user is not trapped in your
* application. If you have a custom keyboard shortcut to exit fullscreen
* mode, you may suppress this behavior with
* `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
*
* If the caller enables a grab while another window is currently grabbed, the * If the caller enables a grab while another window is currently grabbed, the
* other window loses its grab in favor of the caller's window. * other window loses its grab in favor of the caller's window.
* *
* \param window The window for which the keyboard grab mode should be set. * \param window The window for which the keyboard grab mode should be set.
* \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release. * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
* *
* \since This function is available since SDL 2.0.16.
*
* \sa SDL_GetWindowKeyboardGrab * \sa SDL_GetWindowKeyboardGrab
* \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowMouseGrab
* \sa SDL_SetWindowGrab * \sa SDL_SetWindowGrab
@ -1219,7 +1376,12 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window * window,
/** /**
* Set a window's mouse grab mode. * Set a window's mouse grab mode.
* *
* Mouse grab confines the mouse cursor to the window.
*
* \param window The window for which the mouse grab mode should be set. * \param window The window for which the mouse grab mode should be set.
* \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
*
* \since This function is available since SDL 2.0.16.
* *
* \sa SDL_GetWindowMouseGrab * \sa SDL_GetWindowMouseGrab
* \sa SDL_SetWindowKeyboardGrab * \sa SDL_SetWindowKeyboardGrab
@ -1234,6 +1396,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window * window,
* \param window the window to query * \param window the window to query
* \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise. * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowGrab * \sa SDL_SetWindowGrab
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
@ -1244,6 +1408,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
* \param window the window to query * \param window the window to query
* \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise. * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.16.
*
* \sa SDL_SetWindowKeyboardGrab * \sa SDL_SetWindowKeyboardGrab
* \sa SDL_GetWindowGrab * \sa SDL_GetWindowGrab
*/ */
@ -1255,6 +1421,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window * window);
* \param window the window to query * \param window the window to query
* \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise. * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.16.
*
* \sa SDL_SetWindowKeyboardGrab * \sa SDL_SetWindowKeyboardGrab
* \sa SDL_GetWindowGrab * \sa SDL_GetWindowGrab
*/ */
@ -1272,6 +1440,38 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window * window);
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
/**
* Confines the cursor to the specified area of a window.
*
* Note that this does NOT grab the cursor, it only defines the area a cursor
* is restricted to when the window has mouse focus.
*
* \param window The window that will be associated with the barrier.
* \param rect A rectangle area in window-relative coordinates. If NULL the
* barrier for the specified window will be destroyed.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GetWindowMouseRect
* \sa SDL_SetWindowMouseGrab
*/
extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window * window, const SDL_Rect * rect);
/**
* Get the mouse confinement rectangle of a window.
*
* \param window The window to query
* \returns A pointer to the mouse confinement rectangle of a window, or NULL
* if there isn't one.
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_SetWindowMouseRect
*/
extern DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window * window);
/** /**
* Set the brightness (gamma multiplier) for a given window's display. * Set the brightness (gamma multiplier) for a given window's display.
* *
@ -1293,6 +1493,8 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowBrightness * \sa SDL_GetWindowBrightness
* \sa SDL_SetWindowGammaRamp * \sa SDL_SetWindowGammaRamp
*/ */
@ -1311,6 +1513,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float b
* \returns the brightness for the display where 0.0 is completely dark and * \returns the brightness for the display where 0.0 is completely dark and
* 1.0 is normal brightness. * 1.0 is normal brightness.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowBrightness * \sa SDL_SetWindowBrightness
*/ */
extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
@ -1410,6 +1614,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowGammaRamp * \sa SDL_GetWindowGammaRamp
*/ */
extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
@ -1436,6 +1642,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowGammaRamp * \sa SDL_SetWindowGammaRamp
*/ */
extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
@ -1527,6 +1735,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window,
* \param operation the flash operation * \param operation the flash operation
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.16.
*/ */
extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window * window, SDL_FlashOperation operation); extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window * window, SDL_FlashOperation operation);
@ -1538,6 +1748,8 @@ extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window * window, SDL_FlashOperat
* *
* \param window the window to destroy * \param window the window to destroy
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
* \sa SDL_CreateWindowFrom * \sa SDL_CreateWindowFrom
*/ */
@ -1606,6 +1818,8 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_GetProcAddress * \sa SDL_GL_GetProcAddress
* \sa SDL_GL_UnloadLibrary * \sa SDL_GL_UnloadLibrary
*/ */
@ -1656,6 +1870,8 @@ extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
* \returns a pointer to the named OpenGL function. The returned pointer * \returns a pointer to the named OpenGL function. The returned pointer
* should be cast to the appropriate function signature. * should be cast to the appropriate function signature.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_ExtensionSupported * \sa SDL_GL_ExtensionSupported
* \sa SDL_GL_LoadLibrary * \sa SDL_GL_LoadLibrary
* \sa SDL_GL_UnloadLibrary * \sa SDL_GL_UnloadLibrary
@ -1665,6 +1881,8 @@ extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
/** /**
* Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_LoadLibrary * \sa SDL_GL_LoadLibrary
*/ */
extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
@ -1714,6 +1932,8 @@ extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_GetAttribute * \sa SDL_GL_GetAttribute
* \sa SDL_GL_ResetAttributes * \sa SDL_GL_ResetAttributes
*/ */
@ -1727,6 +1947,8 @@ extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_ResetAttributes * \sa SDL_GL_ResetAttributes
* \sa SDL_GL_SetAttribute * \sa SDL_GL_SetAttribute
*/ */
@ -1747,6 +1969,8 @@ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
* \returns the OpenGL context associated with `window` or NULL on error; call * \returns the OpenGL context associated with `window` or NULL on error; call
* SDL_GetError() for more details. * SDL_GetError() for more details.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_DeleteContext * \sa SDL_GL_DeleteContext
* \sa SDL_GL_MakeCurrent * \sa SDL_GL_MakeCurrent
*/ */
@ -1763,6 +1987,8 @@ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_CreateContext * \sa SDL_GL_CreateContext
*/ */
extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
@ -1825,13 +2051,8 @@ extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w,
* retry the call with 1 for the interval. * retry the call with 1 for the interval.
* *
* Adaptive vsync is implemented for some glX drivers with * Adaptive vsync is implemented for some glX drivers with
* GLX_EXT_swap_control_tear: * GLX_EXT_swap_control_tear, and for some Windows drivers with
* * WGL_EXT_swap_control_tear.
* https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt
*
* and for some Windows drivers with WGL_EXT_swap_control_tear:
*
* https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt
* *
* Read more on the Khronos wiki: * Read more on the Khronos wiki:
* https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
@ -1875,6 +2096,8 @@ extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
* extra. * extra.
* *
* \param window the window to change * \param window the window to change
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
@ -1883,6 +2106,8 @@ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
* *
* \param context the OpenGL context to be deleted * \param context the OpenGL context to be deleted
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GL_CreateContext * \sa SDL_GL_CreateContext
*/ */
extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);

View file

@ -101,7 +101,7 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */
* \returns 0 on success or -1 if the library couldn't be loaded; call * \returns 0 on success or -1 if the library couldn't be loaded; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available in SDL 2.0.8 * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_Vulkan_GetVkInstanceProcAddr * \sa SDL_Vulkan_GetVkInstanceProcAddr
* \sa SDL_Vulkan_UnloadLibrary * \sa SDL_Vulkan_UnloadLibrary
@ -115,13 +115,15 @@ extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
* creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
* *
* \returns the function pointer for `vkGetInstanceProcAddr` or NULL on error. * \returns the function pointer for `vkGetInstanceProcAddr` or NULL on error.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
/** /**
* Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary() * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary()
* *
* \since This function is available in SDL 2.0.8 * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_Vulkan_LoadLibrary * \sa SDL_Vulkan_LoadLibrary
*/ */
@ -151,7 +153,7 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
* Vulkan instance extensions * Vulkan instance extensions
* \returns SDL_TRUE on success, SDL_FALSE on error. * \returns SDL_TRUE on success, SDL_FALSE on error.
* *
* \since This function is available in SDL 2.0.8 * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_Vulkan_CreateSurface * \sa SDL_Vulkan_CreateSurface
*/ */
@ -172,7 +174,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window *wi
* created surface * created surface
* \returns SDL_TRUE on success, SDL_FALSE on error. * \returns SDL_TRUE on success, SDL_FALSE on error.
* *
* \since This function is available in SDL 2.0.8 * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_Vulkan_GetInstanceExtensions * \sa SDL_Vulkan_GetInstanceExtensions
* \sa SDL_Vulkan_GetDrawableSize * \sa SDL_Vulkan_GetDrawableSize
@ -193,7 +195,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
* \param w Pointer to the variable to write the width to or NULL * \param w Pointer to the variable to write the width to or NULL
* \param h Pointer to the variable to write the height to or NULL * \param h Pointer to the variable to write the height to or NULL
* *
* \since This function is available in SDL 2.0.8 * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
* \sa SDL_CreateWindow * \sa SDL_CreateWindow

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -34,7 +34,7 @@
#define _begin_code_h #define _begin_code_h
#ifndef SDL_DEPRECATED #ifndef SDL_DEPRECATED
# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
# define SDL_DEPRECATED __attribute__((deprecated)) # define SDL_DEPRECATED __attribute__((deprecated))
# else # else
# define SDL_DEPRECATED # define SDL_DEPRECATED
@ -51,7 +51,7 @@
/* Some compilers use a special export keyword */ /* Some compilers use a special export keyword */
#ifndef DECLSPEC #ifndef DECLSPEC
# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__) # if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__) || defined(__GDK__)
# ifdef DLL_EXPORT # ifdef DLL_EXPORT
# define DECLSPEC __declspec(dllexport) # define DECLSPEC __declspec(dllexport)
# else # else
@ -74,7 +74,7 @@
/* By default SDL uses the C calling convention */ /* By default SDL uses the C calling convention */
#ifndef SDLCALL #ifndef SDLCALL
#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) #if (defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)) && !defined(__GNUC__)
#define SDLCALL __cdecl #define SDLCALL __cdecl
#elif defined(__OS2__) || defined(__EMX__) #elif defined(__OS2__) || defined(__EMX__)
#define SDLCALL _System #define SDLCALL _System
@ -107,7 +107,7 @@
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma nopackwarning #pragma nopackwarning
#endif #endif
#ifdef _M_X64 #ifdef _WIN64
/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
#pragma pack(push,8) #pragma pack(push,8)
#else #else
@ -164,3 +164,24 @@
#endif #endif
#endif /* NULL */ #endif /* NULL */
#endif /* ! Mac OS X - breaks precompiled headers */ #endif /* ! Mac OS X - breaks precompiled headers */
#ifndef SDL_FALLTHROUGH
#if (defined(__cplusplus) && __cplusplus >= 201703L) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L)
#define SDL_FALLTHROUGH [[fallthrough]]
#else
#if defined(__has_attribute)
#define _HAS_FALLTHROUGH __has_attribute(__fallthrough__)
#else
#define _HAS_FALLTHROUGH 0
#endif /* __has_attribute */
#if _HAS_FALLTHROUGH && \
((defined(__GNUC__) && __GNUC__ >= 7) || \
(defined(__clang_major__) && __clang_major__ >= 10))
#define SDL_FALLTHROUGH __attribute__((__fallthrough__))
#else
#define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
#endif /* _HAS_FALLTHROUGH */
#undef _HAS_FALLTHROUGH
#endif /* C++17 or C2x */
#endif /* SDL_FALLTHROUGH not defined */

View file

@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.