Update SDL3

This commit is contained in:
2024-08-07 21:05:59 +03:00
committed by Ari Vuollet
parent 8ba4e442a6
commit 431767a150
41 changed files with 1211 additions and 684 deletions

View File

@@ -119,11 +119,11 @@ void Screen::SetCursorVisible(const bool value)
// Just enable relative mode when cursor is constrained and not visible // Just enable relative mode when cursor is constrained and not visible
if (CursorLock != CursorLockMode::None && !CursorVisible && focused) if (CursorLock != CursorLockMode::None && !CursorVisible && focused)
{ {
Input::Mouse->SetRelativeMode(true); Input::Mouse->SetRelativeMode(true, win);
} }
else if (CursorLock == CursorLockMode::None || CursorVisible || !focused) else if (CursorLock == CursorLockMode::None || CursorVisible || !focused)
{ {
Input::Mouse->SetRelativeMode(false); Input::Mouse->SetRelativeMode(false, win);
} }
} }
@@ -158,11 +158,11 @@ void Screen::SetCursorLock(CursorLockMode mode)
bool focused = win && Engine::HasGameViewportFocus(); bool focused = win && Engine::HasGameViewportFocus();
if (CursorLock != CursorLockMode::None && !CursorVisible && focused) if (CursorLock != CursorLockMode::None && !CursorVisible && focused)
{ {
Input::Mouse->SetRelativeMode(true); Input::Mouse->SetRelativeMode(true, win);
} }
else if (CursorLock == CursorLockMode::None || CursorVisible || !focused) else if (CursorLock == CursorLockMode::None || CursorVisible || !focused)
{ {
Input::Mouse->SetRelativeMode(false); Input::Mouse->SetRelativeMode(false, win);
} }
} }

View File

@@ -136,7 +136,8 @@ public:
/// The cursor will be hidden while in relative mode. /// The cursor will be hidden while in relative mode.
/// </summary> /// </summary>
/// <param name="relativeMode">The new relative mode state.</param> /// <param name="relativeMode">The new relative mode state.</param>
virtual void SetRelativeMode(bool relativeMode) /// <param name="window">The window.</param>
virtual void SetRelativeMode(bool relativeMode, Window* window)
{ {
_relativeMode = relativeMode; _relativeMode = relativeMode;
} }

View File

@@ -377,7 +377,7 @@ public:
OnMouseMoved(newPosition); OnMouseMoved(newPosition);
} }
void SetRelativeMode(bool relativeMode) final override void SetRelativeMode(bool relativeMode, Window* window) final override
{ {
if (relativeMode == _relativeMode) if (relativeMode == _relativeMode)
return; return;
@@ -385,15 +385,12 @@ public:
if (relativeMode) if (relativeMode)
SDL_GetGlobalMouseState(&oldPosition.X, &oldPosition.Y); SDL_GetGlobalMouseState(&oldPosition.X, &oldPosition.Y);
Mouse::SetRelativeMode(relativeMode); Mouse::SetRelativeMode(relativeMode, window);
if (SDL_SetRelativeMouseMode(relativeMode ? SDL_TRUE : SDL_FALSE) != 0) if (SDL_SetWindowRelativeMouseMode(static_cast<SDLWindow*>(window)->_window, relativeMode ? SDL_TRUE : SDL_FALSE) != 0)
LOG(Error, "Failed to set mouse relative mode: {0}", String(SDL_GetError())); LOG(Error, "Failed to set mouse relative mode: {0}", String(SDL_GetError()));
if (!relativeMode) if (!relativeMode)
{ SetMousePosition(oldPosition);
SDL_WarpMouseGlobal(oldPosition.X, oldPosition.Y);
OnMouseMoved(oldPosition);
}
} }
}; };

View File

@@ -276,6 +276,7 @@ Rectangle SDLPlatform::GetVirtualDesktopBounds()
SDL_GetDisplayBounds(display, &rect); SDL_GetDisplayBounds(display, &rect);
bounds = Rectangle::Union(bounds, Rectangle(static_cast<float>(rect.x), static_cast<float>(rect.y), static_cast<float>(rect.w), static_cast<float>(rect.h))); bounds = Rectangle::Union(bounds, Rectangle(static_cast<float>(rect.x), static_cast<float>(rect.y), static_cast<float>(rect.w), static_cast<float>(rect.h)));
} }
SDL_free((void*)displays);
return bounds; return bounds;
} }

View File

@@ -34,7 +34,12 @@
#endif #endif
#define DefaultDPI 96 #define DefaultDPI 96
SDLWindow* lastEventWindow = nullptr;
namespace
{
SDLWindow* LastEventWindow = nullptr;
static SDL_Cursor* Cursors[SDL_NUM_SYSTEM_CURSORS] = { nullptr };
}
void* GetNativeWindowPointer(SDL_Window* window); void* GetNativeWindowPointer(SDL_Window* window);
SDL_HitTestResult OnWindowHitTest(SDL_Window* win, const SDL_Point* area, void* data); SDL_HitTestResult OnWindowHitTest(SDL_Window* win, const SDL_Point* area, void* data);
@@ -236,7 +241,7 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
} }
#endif #endif
lastEventWindow = this; LastEventWindow = this;
#if PLATFORM_LINUX #if PLATFORM_LINUX
// Initialize using the shared Display instance from SDL // Initialize using the shared Display instance from SDL
@@ -293,8 +298,8 @@ void* SDLWindow::GetX11Display() const
SDLWindow::~SDLWindow() SDLWindow::~SDLWindow()
{ {
if (lastEventWindow == this) if (LastEventWindow == this)
lastEventWindow = nullptr; LastEventWindow = nullptr;
if (_window == nullptr) if (_window == nullptr)
return; return;
@@ -374,47 +379,20 @@ SDL_HitTestResult OnWindowHitTest(SDL_Window* win, const SDL_Point* area, void*
SDLWindow* SDLWindow::GetWindowFromEvent(const SDL_Event& event) SDLWindow* SDLWindow::GetWindowFromEvent(const SDL_Event& event)
{ {
SDL_WindowID windowId; SDL_Window* window = SDL_GetWindowFromEvent(&event);
if (event.type >= SDL_EVENT_WINDOW_FIRST && event.type <= SDL_EVENT_WINDOW_LAST) if (window == nullptr)
windowId = event.window.windowID;
else if (event.type == SDL_EVENT_KEY_DOWN || event.type == SDL_EVENT_KEY_UP)
windowId = event.key.windowID;
else if (event.type == SDL_EVENT_TEXT_EDITING)
windowId = event.edit.windowID;
else if (event.type == SDL_EVENT_TEXT_INPUT)
windowId = event.text.windowID;
else if (event.type == SDL_EVENT_MOUSE_MOTION)
windowId = event.motion.windowID;
else if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN || event.type == SDL_EVENT_MOUSE_BUTTON_UP)
windowId = event.button.windowID;
else if (event.type == SDL_EVENT_MOUSE_WHEEL)
windowId = event.wheel.windowID;
else if (event.type == SDL_EVENT_FINGER_MOTION || event.type == SDL_EVENT_FINGER_DOWN || event.type == SDL_EVENT_FINGER_UP)
windowId = event.tfinger.windowID;
else if (event.type == SDL_EVENT_PEN_DOWN || event.type == SDL_EVENT_PEN_UP)
windowId = event.ptip.windowID;
else if (event.type == SDL_EVENT_PEN_MOTION)
windowId = event.pmotion.windowID;
else if (event.type == SDL_EVENT_PEN_BUTTON_DOWN || event.type == SDL_EVENT_PEN_BUTTON_UP)
windowId = event.pbutton.windowID;
else if (event.type == SDL_EVENT_DROP_BEGIN || event.type == SDL_EVENT_DROP_FILE || event.type == SDL_EVENT_DROP_TEXT || event.type == SDL_EVENT_DROP_COMPLETE || event.type == SDL_EVENT_DROP_POSITION)
windowId = event.drop.windowID;
else if (event.type >= SDL_EVENT_USER && event.type <= SDL_EVENT_LAST)
windowId = event.user.windowID;
else
return nullptr; return nullptr;
if (LastEventWindow == nullptr || window != LastEventWindow->_window)
if (lastEventWindow == nullptr || windowId != lastEventWindow->_windowId) LastEventWindow = GetWindowWithSDLWindow(window);
lastEventWindow = GetWindowWithId(windowId); return LastEventWindow;
return lastEventWindow;
} }
SDLWindow* SDLWindow::GetWindowWithId(uint32 windowId) SDLWindow* SDLWindow::GetWindowWithSDLWindow(SDL_Window* window)
{ {
WindowsManager::WindowsLocker.Lock(); WindowsManager::WindowsLocker.Lock();
for (auto win : WindowsManager::Windows) for (auto win : WindowsManager::Windows)
{ {
if (win->_windowId == windowId) if (win->_window == window)
return win; return win;
} }
WindowsManager::WindowsLocker.Unlock(); WindowsManager::WindowsLocker.Unlock();
@@ -426,7 +404,6 @@ void SDLWindow::HandleEvent(SDL_Event& event)
if (_isClosing) if (_isClosing)
return; return;
// NOTE: Update window handling in SDLWindow::GetWindowFromEvent when any new events are added here
switch (event.type) switch (event.type)
{ {
case SDL_EVENT_WINDOW_EXPOSED: case SDL_EVENT_WINDOW_EXPOSED:
@@ -1012,7 +989,7 @@ void SDLWindow::StartTrackingMouse(bool useMouseScreenOffset)
// For viewport camera mouse tracking we want to use relative mode for best precision // For viewport camera mouse tracking we want to use relative mode for best precision
if (_cursor == CursorType::Hidden) if (_cursor == CursorType::Hidden)
Input::Mouse->SetRelativeMode(true); Input::Mouse->SetRelativeMode(true, this);
} }
} }
@@ -1031,7 +1008,7 @@ void SDLWindow::EndTrackingMouse()
LOG(Warning, "SDL_CaptureMouse: {0}", String(SDL_GetError())); LOG(Warning, "SDL_CaptureMouse: {0}", String(SDL_GetError()));
} }
Input::Mouse->SetRelativeMode(false); Input::Mouse->SetRelativeMode(false, this);
} }
void SDLWindow::StartClippingCursor(const Rectangle& bounds) void SDLWindow::StartClippingCursor(const Rectangle& bounds)
@@ -1090,21 +1067,19 @@ void SDLWindow::CheckForWindowResize()
OnResize(width, height); OnResize(width, height);
} }
void SDLWindow::UpdateCursor() const void SDLWindow::UpdateCursor()
{ {
static SDL_Cursor* cursors[SDL_NUM_SYSTEM_CURSORS] = { nullptr };
if (_cursor == CursorType::Hidden) if (_cursor == CursorType::Hidden)
{ {
SDL_HideCursor(); SDL_HideCursor();
if (_isTrackingMouse) if (_isTrackingMouse)
Input::Mouse->SetRelativeMode(true); Input::Mouse->SetRelativeMode(true, this);
return; return;
} }
SDL_ShowCursor(); SDL_ShowCursor();
//if (_isTrackingMouse) //if (_isTrackingMouse)
// Input::Mouse->SetRelativeMode(false); // Input::Mouse->SetRelativeMode(false, this);
int32 index = SDL_SYSTEM_CURSOR_DEFAULT; int32 index = SDL_SYSTEM_CURSOR_DEFAULT;
switch (_cursor) switch (_cursor)
@@ -1147,9 +1122,9 @@ void SDLWindow::UpdateCursor() const
break; break;
} }
if (cursors[index] == nullptr) if (Cursors[index] == nullptr)
cursors[index] = SDL_CreateSystemCursor(static_cast<SDL_SystemCursor>(index)); Cursors[index] = SDL_CreateSystemCursor(static_cast<SDL_SystemCursor>(index));
SDL_SetCursor(cursors[index]); SDL_SetCursor(Cursors[index]);
} }
#endif #endif

View File

@@ -21,6 +21,7 @@ class FLAXENGINE_API SDLWindow : public WindowBase
#endif #endif
{ {
friend SDLPlatform; friend SDLPlatform;
friend class SDLMouse;
#if PLATFORM_LINUX #if PLATFORM_LINUX
friend LinuxPlatform; friend LinuxPlatform;
friend MessageBox; friend MessageBox;
@@ -55,10 +56,10 @@ public:
private: private:
static SDLWindow* GetWindowFromEvent(const SDL_Event& event); static SDLWindow* GetWindowFromEvent(const SDL_Event& event);
static SDLWindow* GetWindowWithId(uint32 windowId); static SDLWindow* GetWindowWithSDLWindow(SDL_Window* window);
void HandleEvent(SDL_Event& event); void HandleEvent(SDL_Event& event);
void CheckForWindowResize(); void CheckForWindowResize();
void UpdateCursor() const; void UpdateCursor();
#if PLATFORM_LINUX #if PLATFORM_LINUX
DragDropEffect DoDragDropWayland(const StringView& data); DragDropEffect DoDragDropWayland(const StringView& data);

View File

@@ -400,9 +400,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
* "coreaudio" or "wasapi". These never have Unicode characters, and are not * "coreaudio" or "wasapi". These never have Unicode characters, and are not
* meant to be proper names. * meant to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param index the index of the audio driver; the value ranges from 0 to * \param index the index of the audio driver; the value ranges from 0 to
* SDL_GetNumAudioDrivers() - 1. * SDL_GetNumAudioDrivers() - 1.
* \returns the name of the audio driver at the requested index, or NULL if an * \returns the name of the audio driver at the requested index, or NULL if an
@@ -424,9 +421,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index);
* "coreaudio" or "wasapi". These never have Unicode characters, and are not * "coreaudio" or "wasapi". These never have Unicode characters, and are not
* meant to be proper names. * meant to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the name of the current audio driver or NULL if no driver has been * \returns the name of the current audio driver or NULL if no driver has been
* initialized. * initialized.
* *
@@ -450,13 +444,11 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void);
* If this function returns NULL, to signify an error, `*count` will be set to * If this function returns NULL, to signify an error, `*count` will be set to
* zero. * zero.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of devices returned, may * \param count a pointer filled in with the number of devices returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of device instance IDs or NULL on error; call * \returns a 0 terminated array of device instance IDs or NULL on error; call
* SDL_GetError() for more information. * SDL_GetError() for more information. This should be freed with
* SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -465,7 +457,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void);
* \sa SDL_OpenAudioDevice * \sa SDL_OpenAudioDevice
* \sa SDL_GetAudioRecordingDevices * \sa SDL_GetAudioRecordingDevices
*/ */
extern SDL_DECLSPEC const SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevices(int *count); extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevices(int *count);
/** /**
* Get a list of currently-connected audio recording devices. * Get a list of currently-connected audio recording devices.
@@ -481,13 +473,11 @@ extern SDL_DECLSPEC const SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevice
* If this function returns NULL, to signify an error, `*count` will be set to * If this function returns NULL, to signify an error, `*count` will be set to
* zero. * zero.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of devices returned, may * \param count a pointer filled in with the number of devices returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of device instance IDs, or NULL on failure; * \returns a 0 terminated array of device instance IDs, or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -496,14 +486,11 @@ extern SDL_DECLSPEC const SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevice
* \sa SDL_OpenAudioDevice * \sa SDL_OpenAudioDevice
* \sa SDL_GetAudioPlaybackDevices * \sa SDL_GetAudioPlaybackDevices
*/ */
extern SDL_DECLSPEC const SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int *count); extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int *count);
/** /**
* Get the human-readable name of a specific audio device. * Get the human-readable name of a specific audio device.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param devid the instance ID of the device to query. * \param devid the instance ID of the device to query.
* \returns the name of the audio device, or NULL on failure; call * \returns the name of the audio device, or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -562,13 +549,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid
* Audio devices usually have no remapping applied. This is represented by * Audio devices usually have no remapping applied. This is represented by
* returning NULL, and does not signify an error. * returning NULL, and does not signify an error.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param devid the instance ID of the device to query. * \param devid the instance ID of the device to query.
* \param count On output, set to number of channels in the map. Can be NULL. * \param count On output, set to number of channels in the map. Can be NULL.
* \returns an array of the current channel mapping, with as many elements as * \returns an array of the current channel mapping, with as many elements as
* the current output spec's channels, or NULL if default. * the current output spec's channels, or NULL if default. This
* should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -576,7 +561,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid
* *
* \sa SDL_SetAudioStreamInputChannelMap * \sa SDL_SetAudioStreamInputChannelMap
*/ */
extern SDL_DECLSPEC const int * SDLCALL SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count); extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count);
/** /**
* Open a specific audio device. * Open a specific audio device.
@@ -836,7 +821,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
* stream's format at any time. * stream's format at any time.
* *
* \param devid an audio device to bind a stream to. * \param devid an audio device to bind a stream to.
* \param streams an array of audio streams to unbind. * \param streams an array of audio streams to bind.
* \param num_streams number streams listed in the `streams` array. * \param num_streams number streams listed in the `streams` array.
* \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.
@@ -1113,13 +1098,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream,
* Audio streams default to no remapping applied. This is represented by * Audio streams default to no remapping applied. This is represented by
* returning NULL, and does not signify an error. * returning NULL, and does not signify an error.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param stream the SDL_AudioStream to query. * \param stream the SDL_AudioStream to query.
* \param count On output, set to number of channels in the map. Can be NULL. * \param count On output, set to number of channels in the map. Can be NULL.
* \returns an array of the current channel mapping, with as many elements as * \returns an array of the current channel mapping, with as many elements as
* the current output spec's channels, or NULL if default. * the current output spec's channels, or NULL if default. This
* should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread, as it holds * \threadsafety It is safe to call this function from any thread, as it holds
* a stream-specific mutex while running. * a stream-specific mutex while running.
@@ -1128,7 +1111,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream,
* *
* \sa SDL_SetAudioStreamInputChannelMap * \sa SDL_SetAudioStreamInputChannelMap
*/ */
extern SDL_DECLSPEC const int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count); extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count);
/** /**
* Get the current output channel map of an audio stream. * Get the current output channel map of an audio stream.
@@ -1139,13 +1122,11 @@ extern SDL_DECLSPEC const int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_Au
* Audio streams default to no remapping applied. This is represented by * Audio streams default to no remapping applied. This is represented by
* returning NULL, and does not signify an error. * returning NULL, and does not signify an error.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param stream the SDL_AudioStream to query. * \param stream the SDL_AudioStream to query.
* \param count On output, set to number of channels in the map. Can be NULL. * \param count On output, set to number of channels in the map. Can be NULL.
* \returns an array of the current channel mapping, with as many elements as * \returns an array of the current channel mapping, with as many elements as
* the current output spec's channels, or NULL if default. * the current output spec's channels, or NULL if default. This
* should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread, as it holds * \threadsafety It is safe to call this function from any thread, as it holds
* a stream-specific mutex while running. * a stream-specific mutex while running.
@@ -1154,7 +1135,7 @@ extern SDL_DECLSPEC const int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_Au
* *
* \sa SDL_SetAudioStreamInputChannelMap * \sa SDL_SetAudioStreamInputChannelMap
*/ */
extern SDL_DECLSPEC const int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count); extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count);
/** /**
* Set the current input channel map of an audio stream. * Set the current input channel map of an audio stream.

View File

@@ -134,9 +134,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void);
* "coremedia" or "android". These never have Unicode characters, and are not * "coremedia" or "android". These never have Unicode characters, and are not
* meant to be proper names. * meant to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param index the index of the camera driver; the value ranges from 0 to * \param index the index of the camera driver; the value ranges from 0 to
* SDL_GetNumCameraDrivers() - 1. * SDL_GetNumCameraDrivers() - 1.
* \returns the name of the camera driver at the requested index, or NULL if * \returns the name of the camera driver at the requested index, or NULL if
@@ -157,9 +154,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDriver(int index);
* "coremedia" or "android". These never have Unicode characters, and are not * "coremedia" or "android". These never have Unicode characters, and are not
* meant to be proper names. * meant to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the name of the current camera driver or NULL if no driver has * \returns the name of the current camera driver or NULL if no driver has
* been initialized. * been initialized.
* *
@@ -172,13 +166,11 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void);
/** /**
* Get a list of currently connected camera devices. * Get a list of currently connected camera devices.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of cameras returned, may * \param count a pointer filled in with the number of cameras returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of camera instance IDs or NULL on failure; * \returns a 0 terminated array of camera instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -186,7 +178,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void);
* *
* \sa SDL_OpenCamera * \sa SDL_OpenCamera
*/ */
extern SDL_DECLSPEC const SDL_CameraID * SDLCALL SDL_GetCameras(int *count); extern SDL_DECLSPEC SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
/** /**
* Get the list of native formats/sizes a camera supports. * Get the list of native formats/sizes a camera supports.
@@ -210,14 +202,13 @@ extern SDL_DECLSPEC const SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
* there _is_ a camera until the user has given you permission to check * there _is_ a camera until the user has given you permission to check
* through a scary warning popup. * through a scary warning popup.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param devid the camera device instance ID to query. * \param devid the camera device instance ID to query.
* \param count a pointer filled in with the number of elements in the list, * \param count a pointer filled in with the number of elements in the list,
* may be NULL. * may be NULL.
* \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on * \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This is a
* single allocation that should be freed with SDL_free() when it is
* no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
@@ -226,14 +217,11 @@ extern SDL_DECLSPEC const SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
* \sa SDL_GetCameras * \sa SDL_GetCameras
* \sa SDL_OpenCamera * \sa SDL_OpenCamera
*/ */
extern SDL_DECLSPEC const SDL_CameraSpec * const * SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count); extern SDL_DECLSPEC SDL_CameraSpec ** SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count);
/** /**
* Get the human-readable device name for a camera. * Get the human-readable device name for a camera.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the camera device instance ID. * \param instance_id the camera device instance ID.
* \returns a human-readable device name or NULL on failure; call * \returns a human-readable device name or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.

View File

@@ -62,18 +62,16 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
* This functions returns empty string if there was not enough memory left for * This functions returns empty string if there was not enough memory left for
* a copy of the clipboard's content. * a copy of the clipboard's content.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the clipboard text on success or an empty string on failure; call * \returns the clipboard text on success or an empty string on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information. This should be freed with
* SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_HasClipboardText * \sa SDL_HasClipboardText
* \sa SDL_SetClipboardText * \sa SDL_SetClipboardText
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetClipboardText(void); extern SDL_DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
/** /**
* Query whether the clipboard exists and contains a non-empty text string. * Query whether the clipboard exists and contains a non-empty text string.
@@ -107,18 +105,16 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPrimarySelectionText(const char *text);
* This functions returns empty string if there was not enough memory left for * This functions returns empty string if there was not enough memory left for
* a copy of the primary selection's content. * a copy of the primary selection's content.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the primary selection text on success or an empty string on * \returns the primary selection text on success or an empty string on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_HasPrimarySelectionText * \sa SDL_HasPrimarySelectionText
* \sa SDL_SetPrimarySelectionText * \sa SDL_SetPrimarySelectionText
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetPrimarySelectionText(void); extern SDL_DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void);
/** /**
* Query whether the primary selection exists and contains a non-empty text * Query whether the primary selection exists and contains a non-empty text
@@ -221,17 +217,15 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearClipboardData(void);
* \param mime_type the mime type to read from the clipboard. * \param mime_type the mime type to read from the clipboard.
* \param size a pointer filled in with the length of the returned data. * \param size a pointer filled in with the length of the returned data.
* \returns the retrieved data buffer or NULL on failure; call SDL_GetError() * \returns the retrieved data buffer or NULL on failure; call SDL_GetError()
* for more information. * for more information. This should be freed with SDL_free() when it
* * is no longer needed.
* This returns temporary memory which will be automatically freed
* later, and can be claimed with SDL_ClaimTemporaryMemory().
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_HasClipboardData * \sa SDL_HasClipboardData
* \sa SDL_SetClipboardData * \sa SDL_SetClipboardData
*/ */
extern SDL_DECLSPEC const void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size); extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size);
/** /**
* Query whether there is data in the clipboard for the provided mime type. * Query whether there is data in the clipboard for the provided mime type.

View File

@@ -79,28 +79,28 @@ typedef enum SDL_EventType
/* Application events */ /* Application events */
SDL_EVENT_QUIT = 0x100, /**< User-requested quit */ SDL_EVENT_QUIT = 0x100, /**< User-requested quit */
/* These application events have special meaning on iOS, see README-ios.md for details */ /* These application events have special meaning on iOS and Android, see README-ios.md and README-android.md for details */
SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationWillTerminate() Called on iOS in applicationWillTerminate()
Called on Android in onDestroy() Called on Android in onDestroy()
*/ */
SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationDidReceiveMemoryWarning() Called on iOS in applicationDidReceiveMemoryWarning()
Called on Android in onLowMemory() Called on Android in onTrimMemory()
*/ */
SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationWillResignActive() Called on iOS in applicationWillResignActive()
Called on Android in onPause() Called on Android in onPause()
*/ */
SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationDidEnterBackground() Called on iOS in applicationDidEnterBackground()
Called on Android in onPause() Called on Android in onPause()
*/ */
SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationWillEnterForeground() Called on iOS in applicationWillEnterForeground()
Called on Android in onResume() Called on Android in onResume()
*/ */
SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch().
Called on iOS in applicationDidBecomeActive() Called on iOS in applicationDidBecomeActive()
Called on Android in onResume() Called on Android in onResume()
*/ */
@@ -130,6 +130,7 @@ typedef enum SDL_EventType
SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */ SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */ SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
SDL_EVENT_WINDOW_METAL_VIEW_RESIZED,/**< The pixel size of a Metal view associated with the window has changed */
SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */ SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */
SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */ SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */
SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */ SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */
@@ -142,6 +143,7 @@ typedef enum SDL_EventType
SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */ SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */
SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */ SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */
SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */ SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */
SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, /**< The window safe area has been changed */
SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */ SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */
SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */ SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */
SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */ SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */
@@ -350,9 +352,6 @@ typedef struct SDL_KeyboardEvent
* will be inserted into the editing text. The length is the number of UTF-8 * will be inserted into the editing text. The length is the number of UTF-8
* characters that will be replaced by new typing. * characters that will be replaced by new typing.
* *
* The text string is temporary memory which will be automatically freed
* later, and can be claimed with SDL_ClaimTemporaryMemory().
*
* \since This struct is available since SDL 3.0.0. * \since This struct is available since SDL 3.0.0.
*/ */
typedef struct SDL_TextEditingEvent typedef struct SDL_TextEditingEvent
@@ -369,9 +368,6 @@ typedef struct SDL_TextEditingEvent
/** /**
* Keyboard IME candidates event structure (event.edit_candidates.*) * Keyboard IME candidates event structure (event.edit_candidates.*)
* *
* The candidates are temporary memory which will be automatically freed
* later, and can be claimed with SDL_ClaimTemporaryMemory().
*
* \since This struct is available since SDL 3.0.0. * \since This struct is available since SDL 3.0.0.
*/ */
typedef struct SDL_TextEditingCandidatesEvent typedef struct SDL_TextEditingCandidatesEvent
@@ -389,9 +385,6 @@ typedef struct SDL_TextEditingCandidatesEvent
/** /**
* Keyboard text input event structure (event.text.*) * Keyboard text input event structure (event.text.*)
* *
* The text string is temporary memory which will be automatically freed
* later, and can be claimed with SDL_ClaimTemporaryMemory().
*
* This event will never be delivered unless text input is enabled by calling * This event will never be delivered unless text input is enabled by calling
* SDL_StartTextInput(). Text input is disabled by default! * SDL_StartTextInput(). Text input is disabled by default!
* *
@@ -787,10 +780,6 @@ typedef struct SDL_PenButtonEvent
* An event used to drop text or request a file open by the system * An event used to drop text or request a file open by the system
* (event.drop.*) * (event.drop.*)
* *
* The source and data strings are temporary memory which will be
* automatically freed later, and can be claimed with
* SDL_ClaimTemporaryMemory().
*
* \since This struct is available since SDL 3.0.0. * \since This struct is available since SDL 3.0.0.
*/ */
typedef struct SDL_DropEvent typedef struct SDL_DropEvent
@@ -1229,7 +1218,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
* \param userdata what was passed as `userdata` to SDL_SetEventFilter() or * \param userdata what was passed as `userdata` to SDL_SetEventFilter() or
* SDL_AddEventWatch, etc. * SDL_AddEventWatch, etc.
* \param event the event that triggered the callback. * \param event the event that triggered the callback.
* \returns 1 to permit event to be added to the queue, and 0 to disallow it. * \returns SDL_TRUE to permit event to be added to the queue, and SDL_FALSE to disallow it.
* When used with SDL_AddEventWatch, the return value is ignored. * When used with SDL_AddEventWatch, the return value is ignored.
* *
* \threadsafety SDL may call this callback at any time from any thread; the * \threadsafety SDL may call this callback at any time from any thread; the
@@ -1241,14 +1230,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
* \sa SDL_SetEventFilter * \sa SDL_SetEventFilter
* \sa SDL_AddEventWatch * \sa SDL_AddEventWatch
*/ */
typedef int (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event); typedef SDL_bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event);
/** /**
* Set up a filter to process all events before they change internal state and * Set up a filter to process all events before they change internal state and
* are posted to the internal event queue. * are posted to the internal event queue.
* *
* If the filter function returns 1 when called, then the event will be added * If the filter function returns SDL_TRUE when called, then the event will be added
* to the internal queue. If it returns 0, then the event will be dropped from * to the internal queue. If it returns SDL_FALSE, then the event will be dropped from
* the queue, but the internal state will still be updated. This allows * the queue, but the internal state will still be updated. This allows
* selective filtering of dynamically arriving events. * selective filtering of dynamically arriving events.
* *
@@ -1357,7 +1346,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, void
/** /**
* Run a specific filter function on the current event queue, removing any * Run a specific filter function on the current event queue, removing any
* events for which the filter returns 0. * events for which the filter returns SDL_FALSE.
* *
* See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(), * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
* this function does not change the filter permanently, it only uses the * this function does not change the filter permanently, it only uses the
@@ -1412,47 +1401,18 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
/** /**
* Allocate temporary memory. * Get window associated with an event.
* *
* You can use this to allocate memory that will be automatically freed later, * \param event an event containing a `windowID`.
* after event processing is complete. * \returns the associated window on success or NULL if there is none.
*
* \param size the amount of memory to allocate.
* \returns a pointer to the memory allocated or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_ClaimTemporaryMemory * \sa SDL_PollEvent
* \sa SDL_WaitEvent
* \sa SDL_WaitEventTimeout
*/ */
extern SDL_DECLSPEC void * SDLCALL SDL_AllocateTemporaryMemory(size_t size); extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event);
/**
* Claim ownership of temporary memory.
*
* Some functions return temporary memory which SDL will automatically clean
* up. If you want to hold onto it for a long time or beyond the current
* function scope, you can call this function to get a pointer that you own,
* and can free using SDL_free() when you're done.
*
* If the memory isn't temporary, this will return NULL, and you don't have
* ownership of the memory.
*
* \param mem a pointer allocated with SDL_AllocateTemporaryMemory().
* \returns a pointer to the memory now owned by the application, which must
* be freed using SDL_free(), or NULL if the memory is not temporary
* or is not owned by this thread.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AllocateTemporaryMemory
* \sa SDL_free
*/
extern SDL_DECLSPEC void * SDLCALL SDL_ClaimTemporaryMemory(const void *mem);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -68,9 +68,6 @@ extern "C" {
* The returned path is guaranteed to end with a path separator ('\\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns an absolute path in UTF-8 encoding to the application data * \returns an absolute path in UTF-8 encoding to the application data
* directory. NULL will be returned on error or when the platform * directory. NULL will be returned on error or when the platform
* doesn't implement this functionality, call SDL_GetError() for more * doesn't implement this functionality, call SDL_GetError() for more
@@ -124,20 +121,18 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void);
* The returned path is guaranteed to end with a path separator ('\\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param org the name of your organization. * \param org the name of your organization.
* \param app the name of your application. * \param app the name of your application.
* \returns a UTF-8 string of the user directory in platform-dependent * \returns a UTF-8 string of the user directory in platform-dependent
* notation. NULL if there's a problem (creating directory failed, * notation. NULL if there's a problem (creating directory failed,
* etc.). * etc.). This should be freed with SDL_free() when it is no longer
* needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetBasePath * \sa SDL_GetBasePath
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetPrefPath(const char *org, const char *app); extern SDL_DECLSPEC char * SDLCALL SDL_GetPrefPath(const char *org, const char *app);
/** /**
* The type of the OS-provided default folder for a specific purpose. * The type of the OS-provided default folder for a specific purpose.
@@ -225,9 +220,6 @@ typedef enum SDL_Folder
* The returned path is guaranteed to end with a path separator ('\\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* If NULL is returned, the error may be obtained with SDL_GetError(). * If NULL is returned, the error may be obtained with SDL_GetError().
* *
* \param folder the type of folder to find. * \param folder the type of folder to find.
@@ -369,9 +361,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *
* convenience, but if `count` is non-NULL, on return it will contain the * convenience, but if `count` is non-NULL, on return it will contain the
* number of items in the array, not counting the NULL terminator. * number of items in the array, not counting the NULL terminator.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param path the path of the directory to enumerate. * \param path the path of the directory to enumerate.
* \param pattern the pattern that files in the directory must match. Can be * \param pattern the pattern that files in the directory must match. Can be
* NULL. * NULL.
@@ -379,13 +368,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *
* \param count on return, will be set to the number of items in the returned * \param count on return, will be set to the number of items in the returned
* array. Can be NULL. * array. Can be NULL.
* \returns an array of strings on success or NULL on failure; call * \returns an array of strings on success or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information. This is a single allocation
* that should be freed with SDL_free() when it is no longer needed.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const char * const * SDLCALL SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count); extern SDL_DECLSPEC char ** SDLCALL SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -389,46 +389,41 @@ extern SDL_DECLSPEC int SDLCALL SDL_ReloadGamepadMappings(void);
/** /**
* Get the current gamepad mappings. * Get the current gamepad mappings.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of mappings returned, can * \param count a pointer filled in with the number of mappings returned, can
* be NULL. * be NULL.
* \returns an array of the mapping strings, NULL-terminated, or NULL on * \returns an array of the mapping strings, NULL-terminated, or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This is a
* single allocation that should be freed with SDL_free() when it is
* no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const char * const * SDLCALL SDL_GetGamepadMappings(int *count); extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
/** /**
* Get the gamepad mapping string for a given GUID. * Get the gamepad mapping string for a given GUID.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param guid a structure containing the GUID for which a mapping is desired. * \param guid a structure containing the GUID for which a mapping is desired.
* \returns a mapping string or NULL on failure; call SDL_GetError() for more * \returns a mapping string or NULL on failure; call SDL_GetError() for more
* information. * information. This should be freed with SDL_free() when it is no
* longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
* \sa SDL_GetJoystickGUID * \sa SDL_GetJoystickGUID
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid); extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
/** /**
* Get the current mapping of a gamepad. * Get the current mapping of a gamepad.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* Details about mappings are discussed with SDL_AddGamepadMapping(). * Details about mappings are discussed with SDL_AddGamepadMapping().
* *
* \param gamepad the gamepad you want to get the current mapping for. * \param gamepad the gamepad you want to get the current mapping for.
* \returns a string that has the gamepad's mapping or NULL if no mapping is * \returns a string that has the gamepad's mapping or NULL if no mapping is
* available; call SDL_GetError() for more information. * available; call SDL_GetError() for more information. This should
* be freed with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
@@ -437,7 +432,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID g
* \sa SDL_GetGamepadMappingForGUID * \sa SDL_GetGamepadMappingForGUID
* \sa SDL_SetGamepadMapping * \sa SDL_SetGamepadMapping
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad); extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
/** /**
* Set the current mapping of a joystick or gamepad. * Set the current mapping of a joystick or gamepad.
@@ -471,20 +466,18 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasGamepad(void);
/** /**
* Get a list of currently connected gamepads. * Get a list of currently connected gamepads.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of gamepads returned, may * \param count a pointer filled in with the number of gamepads returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of joystick instance IDs or NULL on failure; * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_HasGamepad * \sa SDL_HasGamepad
* \sa SDL_OpenGamepad * \sa SDL_OpenGamepad
*/ */
extern SDL_DECLSPEC const SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count); extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
/** /**
* Check if the given joystick is supported by the gamepad interface. * Check if the given joystick is supported by the gamepad interface.
@@ -505,9 +498,6 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
* *
* This can be called before any gamepads are opened. * This can be called before any gamepads are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the name of the selected gamepad. If no name can be found, this * \returns the name of the selected gamepad. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
@@ -524,9 +514,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID
* *
* This can be called before any gamepads are opened. * This can be called before any gamepads are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the path of the selected gamepad. If no path can be found, this * \returns the path of the selected gamepad. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
@@ -564,8 +551,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID in
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetGamepadGUID * \sa SDL_GUIDToString
* \sa SDL_GetGamepadGUIDString
* \sa SDL_GetGamepads * \sa SDL_GetGamepads
*/ */
extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id); extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
@@ -658,18 +644,16 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_Joys
* *
* This can be called before any gamepads are opened. * This can be called before any gamepads are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the mapping string. Returns NULL if no mapping is available. * \returns the mapping string. Returns NULL if no mapping is available. This
* should be freed with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetGamepads * \sa SDL_GetGamepads
* \sa SDL_GetGamepadMapping * \sa SDL_GetGamepadMapping
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id); extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
/** /**
* Open a gamepad for use. * Open a gamepad for use.
@@ -758,9 +742,6 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad
/** /**
* Get the implementation-dependent name for an opened gamepad. * Get the implementation-dependent name for an opened gamepad.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad a gamepad identifier previously returned by * \param gamepad a gamepad identifier previously returned by
* SDL_OpenGamepad(). * SDL_OpenGamepad().
* \returns the implementation dependent name for the gamepad, or NULL if * \returns the implementation dependent name for the gamepad, or NULL if
@@ -775,9 +756,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad
/** /**
* Get the implementation-dependent path for an opened gamepad. * Get the implementation-dependent path for an opened gamepad.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad a gamepad identifier previously returned by * \param gamepad a gamepad identifier previously returned by
* SDL_OpenGamepad(). * SDL_OpenGamepad().
* \returns the implementation dependent path for the gamepad, or NULL if * \returns the implementation dependent path for the gamepad, or NULL if
@@ -903,9 +881,6 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *ga
* *
* Returns the serial number of the gamepad, or NULL if it is not available. * Returns the serial number of the gamepad, or NULL if it is not available.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad the gamepad object to query. * \param gamepad the gamepad object to query.
* \returns the serial number, or NULL if unavailable. * \returns the serial number, or NULL if unavailable.
* *
@@ -1023,17 +998,16 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GamepadEventsEnabled(void);
/** /**
* Get the SDL joystick layer bindings for a gamepad. * Get the SDL joystick layer bindings for a gamepad.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad a gamepad. * \param gamepad a gamepad.
* \param count a pointer filled in with the number of bindings returned. * \param count a pointer filled in with the number of bindings returned.
* \returns a NULL terminated array of pointers to bindings or NULL on * \returns a NULL terminated array of pointers to bindings or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This is a
* single allocation that should be freed with SDL_free() when it is
* no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_GamepadBinding * const * SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
/** /**
* Manually pump gamepad updates if not using the loop. * Manually pump gamepad updates if not using the loop.
@@ -1067,9 +1041,6 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const c
/** /**
* Convert from an SDL_GamepadType enum to a string. * Convert from an SDL_GamepadType enum to a string.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param type an enum value for a given SDL_GamepadType. * \param type an enum value for a given SDL_GamepadType.
* \returns a string for the given type, or NULL if an invalid type is * \returns a string for the given type, or NULL if an invalid type is
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
@@ -1106,9 +1077,6 @@ extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const c
/** /**
* Convert from an SDL_GamepadAxis enum to a string. * Convert from an SDL_GamepadAxis enum to a string.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param axis an enum value for a given SDL_GamepadAxis. * \param axis an enum value for a given SDL_GamepadAxis.
* \returns a string for the given axis, or NULL if an invalid axis is * \returns a string for the given axis, or NULL if an invalid axis is
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
@@ -1182,9 +1150,6 @@ extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(con
/** /**
* Convert from an SDL_GamepadButton enum to a string. * Convert from an SDL_GamepadButton enum to a string.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param button an enum value for a given SDL_GamepadButton. * \param button an enum value for a given SDL_GamepadButton.
* \returns a string for the given button, or NULL if an invalid button is * \returns a string for the given button, or NULL if an invalid button is
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
@@ -1471,9 +1436,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
* Return the sfSymbolsName for a given button on a gamepad on Apple * Return the sfSymbolsName for a given button on a gamepad on Apple
* platforms. * platforms.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad the gamepad to query. * \param gamepad the gamepad to query.
* \param button a button on the gamepad. * \param button a button on the gamepad.
* \returns the sfSymbolsName or NULL if the name can't be found. * \returns the sfSymbolsName or NULL if the name can't be found.
@@ -1487,9 +1449,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButt
/** /**
* Return the sfSymbolsName for a given axis on a gamepad on Apple platforms. * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param gamepad the gamepad to query. * \param gamepad the gamepad to query.
* \param axis an axis on the gamepad. * \param axis an axis on the gamepad.
* \returns the sfSymbolsName or NULL if the name can't be found. * \returns the sfSymbolsName or NULL if the name can't be found.

View File

@@ -66,18 +66,15 @@ typedef struct SDL_GUID {
/** /**
* Get an ASCII string representation for a given SDL_GUID. * Get an ASCII string representation for a given SDL_GUID.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param guid the SDL_GUID you wish to convert to string. * \param guid the SDL_GUID you wish to convert to string.
* \returns the string representation of the GUID or NULL on failure; call * \param pszGUID buffer in which to write the ASCII string.
* SDL_GetError() for more information. * \param cbGUID the size of pszGUID, should be at least 33 bytes.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_StringToGUID * \sa SDL_StringToGUID
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GUIDToString(SDL_GUID guid); extern SDL_DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
/** /**
* Convert a GUID string into a SDL_GUID structure. * Convert a GUID string into a SDL_GUID structure.

View File

@@ -45,6 +45,7 @@
* SDL_HapticID *haptics = SDL_GetHaptics(NULL); * SDL_HapticID *haptics = SDL_GetHaptics(NULL);
* if (haptics) { * if (haptics) {
* haptic = SDL_OpenHaptic(haptics[0]); * haptic = SDL_OpenHaptic(haptics[0]);
* SDL_free(haptics);
* } * }
* if (haptic == NULL) * if (haptic == NULL)
* return -1; * return -1;
@@ -931,28 +932,23 @@ typedef Uint32 SDL_HapticID;
/** /**
* Get a list of currently connected haptic devices. * Get a list of currently connected haptic devices.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of haptic devices * \param count a pointer filled in with the number of haptic devices
* returned, may be NULL. * returned, may be NULL.
* \returns a 0 terminated array of haptic device instance IDs or NULL on * \returns a 0 terminated array of haptic device instance IDs or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_OpenHaptic * \sa SDL_OpenHaptic
*/ */
extern SDL_DECLSPEC const SDL_HapticID * SDLCALL SDL_GetHaptics(int *count); extern SDL_DECLSPEC SDL_HapticID * SDLCALL SDL_GetHaptics(int *count);
/** /**
* Get the implementation dependent name of a haptic device. * Get the implementation dependent name of a haptic device.
* *
* This can be called before any haptic devices are opened. * This can be called before any haptic devices are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the haptic device instance ID. * \param instance_id the haptic device instance ID.
* \returns the name of the selected haptic device. If no name can be found, * \returns the name of the selected haptic device. If no name can be found,
* this function returns NULL; call SDL_GetError() for more * this function returns NULL; call SDL_GetError() for more
@@ -1016,9 +1012,6 @@ extern SDL_DECLSPEC SDL_HapticID SDLCALL SDL_GetHapticID(SDL_Haptic *haptic);
/** /**
* Get the implementation dependent name of a haptic device. * Get the implementation dependent name of a haptic device.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param haptic the SDL_Haptic obtained from SDL_OpenJoystick(). * \param haptic the SDL_Haptic obtained from SDL_OpenJoystick().
* \returns the name of the selected haptic device. If no name can be found, * \returns the name of the selected haptic device. If no name can be found,
* this function returns NULL; call SDL_GetError() for more * this function returns NULL; call SDL_GetError() for more

View File

@@ -102,21 +102,6 @@ extern "C" {
*/ */
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" #define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE"
/**
* A variable to control whether SDL will pause audio in background.
*
* The variable can be set to the following values:
*
* - "0": Not paused, requires that SDL_HINT_ANDROID_BLOCK_ON_PAUSE be set to
* "0"
* - "1": Paused. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO "SDL_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO"
/** /**
* A variable to control whether we trap the Android back button to handle it * A variable to control whether we trap the Android back button to handle it
* manually. * manually.
@@ -147,43 +132,8 @@ extern "C" {
* together, as well as match applications with associated desktop settings * together, as well as match applications with associated desktop settings
* and icons. * and icons.
* *
* On Wayland this corresponds to the "app ID" window property and on X11 this * This will override SDL_PROP_APP_METADATA_IDENTIFIER_STRING, if set by the
* corresponds to the WM_CLASS property. Windows inherit the value of this * application.
* hint at creation time. Changing this hint after a window has been created
* will not change the app ID or class of existing windows.
*
* For *nix platforms, this string should be formatted in reverse-DNS notation
* and follow some basic rules to be valid:
*
* - The application ID must be composed of two or more elements separated by
* a period (.) character.
* - Each element must contain one or more of the alphanumeric characters
* (A-Z, a-z, 0-9) plus underscore (_) and hyphen (-) and must not start
* with a digit. Note that hyphens, while technically allowed, should not be
* used if possible, as they are not supported by all components that use
* the ID, such as D-Bus. For maximum compatibility, replace hyphens with an
* underscore.
* - The empty string is not a valid element (ie: your application ID may not
* start or end with a period and it is not valid to have two periods in a
* row).
* - The entire ID must be less than 255 characters in length.
*
* Examples of valid app ID strings:
*
* - org.MyOrg.MyApp
* - com.your_company.your_app
*
* Desktops such as GNOME and KDE require that the app ID string matches your
* application's .desktop file name (e.g. if the app ID string is
* 'org.MyOrg.MyApp', your application's .desktop file should be named
* 'org.MyOrg.MyApp.desktop').
*
* If you plan to package your application in a container such as Flatpak, the
* app ID should match the name of your Flatpak container as well.
*
* If not set, SDL will attempt to use the application executable name. If the
* executable name cannot be retrieved, the generic string "SDL_App" will be
* used.
* *
* This hint should be set before SDL is initialized. * This hint should be set before SDL is initialized.
* *
@@ -192,7 +142,7 @@ extern "C" {
#define SDL_HINT_APP_ID "SDL_APP_ID" #define SDL_HINT_APP_ID "SDL_APP_ID"
/** /**
* Specify an application name. * A variable setting the application name.
* *
* This hint lets you specify the application name sent to the OS when * 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 * required. For example, this will often appear in volume control applets for
@@ -200,12 +150,8 @@ extern "C" {
* screensaver. You should use a string that describes your program ("My Game * screensaver. You should use a string that describes your program ("My Game
* 2: The Revenge") * 2: The Revenge")
* *
* Setting this to "" or leaving it unset will have SDL use a reasonable * This will override SDL_PROP_APP_METADATA_NAME_STRING, if set by the
* default: probably the application's name or "SDL Application" if SDL * application.
* doesn't have any better information.
*
* Note that, for audio streams, this can be overridden with
* SDL_HINT_AUDIO_DEVICE_APP_NAME.
* *
* This hint should be set before SDL is initialized. * This hint should be set before SDL is initialized.
* *
@@ -251,6 +197,20 @@ extern "C" {
*/ */
#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" #define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"
/**
* Specify the default ALSA audio device name.
*
* This variable is a specific audio device to open when the "default" audio
* device is used. By default if 4 channel audio is requested, the
* "plug:surround40" device will be opened and if 6 channel audio is requested
* the "plug:surround51" device will be opened.
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE "SDL_AUDIO_ALSA_DEFAULT_DEVICE"
/** /**
* A variable controlling the audio category on iOS and macOS. * A variable controlling the audio category on iOS and macOS.
* *
@@ -270,27 +230,17 @@ extern "C" {
#define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" #define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY"
/** /**
* Specify an application name for an audio device. * A variable controlling the default audio channel count.
* *
* Some audio backends (such as PulseAudio) allow you to describe your audio * If the application doesn't specify the audio channel count when opening the
* stream. Among other things, this description might show up in a system * device, this hint can be used to specify a default channel count that will
* control panel that lets the user adjust the volume on specific audio * be used. This defaults to "1" for recording and "2" for playback devices.
* streams instead of using one giant master volume slider.
*
* This hints lets you transmit that information to the OS. The contents of
* this hint are used while opening an audio device. 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: this will be the name set with SDL_HINT_APP_NAME, if that hint is
* set. Otherwise, it'll probably the application's name or "SDL Application"
* if SDL doesn't have any better information.
* *
* This hint should be set before an audio device is opened. * This hint should be set before an audio device is opened.
* *
* \since This hint is available since SDL 3.0.0. * \since This hint is available since SDL 3.0.0.
*/ */
#define SDL_HINT_AUDIO_DEVICE_APP_NAME "SDL_AUDIO_DEVICE_APP_NAME" #define SDL_HINT_AUDIO_CHANNELS "SDL_AUDIO_CHANNELS"
/** /**
* Specify an application icon name for an audio device. * Specify an application icon name for an audio device.
@@ -390,6 +340,41 @@ extern "C" {
*/ */
#define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" #define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE"
/**
* Specify the input file when recording audio using the disk audio driver.
*
* This defaults to "sdlaudio-in.raw"
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_DISK_INPUT_FILE "SDL_AUDIO_DISK_INPUT_FILE"
/**
* Specify the output file when playing audio using the disk audio driver.
*
* This defaults to "sdlaudio.raw"
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_DISK_OUTPUT_FILE "SDL_AUDIO_DISK_OUTPUT_FILE"
/**
* A variable controlling the audio rate when using the disk audio driver.
*
* The disk audio driver normally simulates real-time for the audio rate that
* was specified, but you can use this variable to adjust this rate higher or
* lower down to 0. The default value is "1.0".
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_DISK_TIMESCALE "SDL_AUDIO_DISK_TIMESCALE"
/** /**
* A variable that specifies an audio backend to use. * A variable that specifies an audio backend to use.
* *
@@ -404,6 +389,54 @@ extern "C" {
*/ */
#define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER" #define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER"
/**
* A variable controlling the audio rate when using the dummy audio driver.
*
* The dummy audio driver normally simulates real-time for the audio rate that
* was specified, but you can use this variable to adjust this rate higher or
* lower down to 0. The default value is "1.0".
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_DUMMY_TIMESCALE "SDL_AUDIO_DUMMY_TIMESCALE"
/**
* A variable controlling the default audio format.
*
* If the application doesn't specify the audio format when opening the
* device, this hint can be used to specify a default format that will be
* used.
*
* The variable can be set to the following values: - "U8": Unsigned 8-bit
* audio - "S8": Signed 8-bit audio - "S16LE": Signed 16-bit little-endian
* audio - "S16BE": Signed 16-bit big-endian audio - "S16": Signed 16-bit
* native-endian audio (default) - "S32LE": Signed 32-bit little-endian audio
* - "S32BE": Signed 32-bit big-endian audio - "S32": Signed 32-bit
* native-endian audio - "F32LE": Floating point little-endian audio -
* "F32BE": Floating point big-endian audio - "F32": Floating point
* native-endian audio
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_FORMAT "SDL_AUDIO_FORMAT"
/**
* A variable controlling the default audio frequency.
*
* If the application doesn't specify the audio frequency when opening the
* device, this hint can be used to specify a default frequency that will be
* used. This defaults to "44100".
*
* This hint should be set before an audio device is opened.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_AUDIO_FREQUENCY "SDL_AUDIO_FREQUENCY"
/** /**
* A variable that causes SDL to not ignore audio "monitors". * A variable that causes SDL to not ignore audio "monitors".
* *
@@ -661,6 +694,23 @@ extern "C" {
*/ */
#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD" #define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
/**
* A variable containing a list of evdev devices to use if udev is not
* available.
*
* The list of devices is in the form:
*
* deviceclass:path[,deviceclass:path[,...]]
*
* where device class is an integer representing the SDL_UDEV_deviceclass and
* path is the full path to the event device.
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_EVDEV_DEVICES "SDL_EVDEV_DEVICES"
/** /**
* A variable controlling verbosity of the logging of SDL events pushed onto * A variable controlling verbosity of the logging of SDL events pushed onto
* the internal queue. * the internal queue.
@@ -906,6 +956,56 @@ extern "C" {
*/ */
#define SDL_HINT_GDK_TEXTINPUT_TITLE "SDL_GDK_TEXTINPUT_TITLE" #define SDL_HINT_GDK_TEXTINPUT_TITLE "SDL_GDK_TEXTINPUT_TITLE"
/**
* A variable to control whether HIDAPI uses libusb for device access.
*
* By default libusb will only be used for a few devices that require direct
* USB access, and this can be controlled with
* SDL_HINT_HIDAPI_LIBUSB_WHITELIST.
*
* The variable can be set to the following values:
*
* - "0": HIDAPI will not use libusb for device access.
* - "1": HIDAPI will use libusb for device access if available. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_HIDAPI_LIBUSB "SDL_HIDAPI_LIBUSB"
/**
* A variable to control whether HIDAPI uses libusb only for whitelisted
* devices.
*
* By default libusb will only be used for a few devices that require direct
* USB access.
*
* The variable can be set to the following values:
*
* - "0": HIDAPI will use libusb for all device access.
* - "1": HIDAPI will use libusb only for whitelisted devices. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST "SDL_HIDAPI_LIBUSB_WHITELIST"
/**
* A variable to control whether HIDAPI uses udev for device detection.
*
* The variable can be set to the following values:
*
* - "0": HIDAPI will poll for device changes.
* - "1": HIDAPI will use udev for device detection. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_HIDAPI_UDEV "SDL_HIDAPI_UDEV"
/** /**
* A variable to control whether SDL_hid_enumerate() enumerates all HID * A variable to control whether SDL_hid_enumerate() enumerates all HID
* devices or only controllers. * devices or only controllers.
@@ -2012,7 +2112,7 @@ extern "C" {
* layout. e.g. pressing the key associated with SDL_SCANCODE_A on a Russian * layout. e.g. pressing the key associated with SDL_SCANCODE_A on a Russian
* keyboard would yield 'a' instead of 'ф'. * keyboard would yield 'a' instead of 'ф'.
* *
* The default value for this hint is "french_numbers" * The default value for this hint is "french_numbers,latin_letters"
* *
* Some platforms like Emscripten only provide modified keycodes and the * Some platforms like Emscripten only provide modified keycodes and the
* options are not used. * options are not used.
@@ -2205,6 +2305,38 @@ extern "C" {
*/ */
#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME" #define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME"
/**
* A variable controlling whether warping a hidden mouse cursor will activate
* relative mouse mode.
*
* When this hint is set and the mouse cursor is hidden, SDL will emulate
* mouse warps using relative mouse mode. This can provide smoother and more
* reliable mouse motion for some older games, which continuously calculate
* the distance travelled by the mouse pointer and warp it back to the center
* of the window, rather than using relative mouse motion.
*
* Note that relative mouse mode may have different mouse acceleration
* behavior than pointer warps.
*
* If your game or application needs to warp the mouse cursor while hidden for
* other purposes, such as drawing a software cursor, it should disable this
* hint.
*
* The variable can be set to the following values:
*
* - "0": Attempts to warp the mouse will always be made.
* - "1": Some mouse warps will be emulated by forcing relative mouse mode.
* (default)
*
* If not set, this is automatically enabled unless an application uses
* relative mouse mode directly.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE "SDL_MOUSE_EMULATE_WARP_WITH_RELATIVE"
/** /**
* Allow mouse click events when clicking to focus an SDL window. * Allow mouse click events when clicking to focus an SDL window.
* *
@@ -2365,6 +2497,24 @@ extern "C" {
*/ */
#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" #define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS"
/**
* A variable controlling whether the keyboard should be muted on the console.
*
* Normally the keyboard is muted while SDL applications are running so that
* keyboard input doesn't show up as key strokes on the console. This hint
* allows you to turn that off for debugging purposes.
*
* The variable can be set to the following values:
*
* - "0": Allow keystrokes to go through to the console.
* - "1": Mute keyboard input so it doesn't show up on the console. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_MUTE_CONSOLE_KEYBOARD "SDL_MUTE_CONSOLE_KEYBOARD"
/** /**
* Tell SDL not to catch the SIGINT or SIGTERM signals on POSIX platforms. * Tell SDL not to catch the SIGINT or SIGTERM signals on POSIX platforms.
* *
@@ -2380,6 +2530,16 @@ extern "C" {
*/ */
#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" #define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS"
/**
* Specify the OpenGL library to load.
*
* This hint should be set before creating an OpenGL window or creating an
* OpenGL context.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_OPENGL_LIBRARY "SDL_OPENGL_LIBRARY"
/** /**
* A variable controlling what driver to use for OpenGL ES contexts. * A variable controlling what driver to use for OpenGL ES contexts.
* *
@@ -2665,6 +2825,8 @@ extern "C" {
* A variable to control whether the return key on the soft keyboard should * A variable to control whether the return key on the soft keyboard should
* hide the soft keyboard on Android and iOS. * hide the soft keyboard on Android and iOS.
* *
* This hint sets the default value of SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN.
*
* The variable can be set to the following values: * The variable can be set to the following values:
* *
* - "0": The return key will be handled as a key event. (default) * - "0": The return key will be handled as a key event. (default)
@@ -2970,6 +3132,19 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_DRIVER "SDL_VIDEO_DRIVER" #define SDL_HINT_VIDEO_DRIVER "SDL_VIDEO_DRIVER"
/**
* A variable controlling whether the dummy video driver saves output frames.
*
* - "0": Video frames are not saved to disk. (default)
* - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp",
* where X is the window ID, and Y is the frame number.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES "SDL_VIDEO_DUMMY_SAVE_FRAMES"
/** /**
* If eglGetPlatformDisplay fails, fall back to calling eglGetDisplay. * If eglGetPlatformDisplay fails, fall back to calling eglGetDisplay.
* *
@@ -3034,6 +3209,23 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" #define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
/**
* A variable controlling whether the offscreen video driver saves output
* frames.
*
* This only saves frames that are generated using software rendering, not
* accelerated OpenGL rendering.
*
* - "0": Video frames are not saved to disk. (default)
* - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp",
* where X is the window ID, and Y is the frame number.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES "SDL_VIDEO_OFFSCREEN_SAVE_FRAMES"
/** /**
* A variable controlling whether all window operations will block until * A variable controlling whether all window operations will block until
* complete. * complete.
@@ -3078,34 +3270,6 @@ 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"
/**
* Enable or disable hidden mouse pointer warp emulation, needed by some older
* games.
*
* Wayland requires the pointer confinement protocol to warp the mouse, but
* that is just a hint that the compositor is free to ignore, and warping the
* the pointer to or from regions outside of the focused window is prohibited.
* When this hint is set and the pointer is hidden, SDL will emulate mouse
* warps using relative mouse mode. This is required for some older games
* (such as Source engine games), which warp the mouse to the centre of the
* screen rather than using relative mouse motion. Note that relative mouse
* mode may have different mouse acceleration behaviour than pointer warps.
*
* The variable can be set to the following values:
*
* - "0": Attempts to warp the mouse will be made, if the appropriate protocol
* is available.
* - "1": Some mouse warps will be emulated by forcing relative mouse mode.
*
* If not set, this is automatically enabled unless an application uses
* relative mouse mode directly.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP "SDL_VIDEO_WAYLAND_EMULATE_MOUSE_WARP"
/** /**
* A variable controlling whether video mode emulation is enabled under * A variable controlling whether video mode emulation is enabled under
* Wayland. * Wayland.
@@ -3261,6 +3425,20 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" #define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING"
/**
* A variable controlling whether SDL uses DirectColor visuals.
*
* The variable can be set to the following values:
*
* - "0": Disable DirectColor visuals.
* - "1": Enable DirectColor visuals. (default)
*
* This hint should be set before initializing the video subsystem.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VIDEO_X11_NODIRECTCOLOR "SDL_VIDEO_X11_NODIRECTCOLOR"
/** /**
* A variable forcing the content scaling factor for X11 displays. * A variable forcing the content scaling factor for X11 displays.
* *
@@ -3272,6 +3450,15 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_X11_SCALING_FACTOR "SDL_VIDEO_X11_SCALING_FACTOR" #define SDL_HINT_VIDEO_X11_SCALING_FACTOR "SDL_VIDEO_X11_SCALING_FACTOR"
/**
* A variable forcing the visual ID used for X11 display modes.
*
* This hint should be set before initializing the video subsystem.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VIDEO_X11_VISUALID "SDL_VIDEO_X11_VISUALID"
/** /**
* A variable forcing the visual ID chosen for new X11 windows. * A variable forcing the visual ID chosen for new X11 windows.
* *
@@ -3295,6 +3482,90 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" #define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"
/**
* A variable controlling whether touch should be enabled on the back panel of
* the PlayStation Vita.
*
* The variable can be set to the following values:
*
* - "0": Disable touch on the back panel.
* - "1": Enable touch on the back panel. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_ENABLE_BACK_TOUCH "SDL_VITA_ENABLE_BACK_TOUCH"
/**
* A variable controlling whether touch should be enabled on the front panel
* of the PlayStation Vita.
*
* The variable can be set to the following values:
*
* - "0": Disable touch on the front panel.
* - "1": Enable touch on the front panel. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_ENABLE_FRONT_TOUCH "SDL_VITA_ENABLE_FRONT_TOUCH"
/**
* A variable controlling the module path on the PlayStation Vita.
*
* This hint defaults to "app0:module"
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_MODULE_PATH "SDL_VITA_MODULE_PATH"
/**
* A variable controlling whether to perform PVR initialization on the
* PlayStation Vita.
*
* - "0": Skip PVR initialization.
* - "1": Perform the normal PVR initialization. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_PVR_INIT "SDL_VITA_PVR_INIT"
/**
* A variable overriding the resolution reported on the PlayStation Vita.
*
* The variable can be set to the following values:
*
* - "544": 544p (default)
* - "720": 725p for PSTV
* - "1080": 1088i for PSTV
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_RESOLUTION "SDL_VITA_RESOLUTION"
/**
* A variable controlling whether OpenGL should be used instead of OpenGL ES
* on the PlayStation Vita.
*
* The variable can be set to the following values:
*
* - "0": Use OpenGL ES. (default)
* - "1": Use OpenGL.
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VITA_PVR_OPENGL "SDL_VITA_PVR_OPENGL"
/** /**
* A variable controlling which touchpad should generate synthetic mouse * A variable controlling which touchpad should generate synthetic mouse
* events. * events.
@@ -3311,6 +3582,27 @@ extern "C" {
*/ */
#define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_VITA_TOUCH_MOUSE_DEVICE" #define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_VITA_TOUCH_MOUSE_DEVICE"
/**
* A variable overriding the display index used in SDL_Vulkan_CreateSurface()
*
* The display index starts at 0, which is the default.
*
* This hint should be set before calling SDL_Vulkan_CreateSurface()
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VULKAN_DISPLAY "SDL_VULKAN_DISPLAY"
/**
* Specify the Vulkan library to load.
*
* This hint should be set before creating a Vulkan window or calling
* SDL_Vulkan_LoadLibrary().
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_VULKAN_LIBRARY "SDL_VULKAN_LIBRARY"
/** /**
* A variable controlling how the fact chunk affects the loading of a WAVE * A variable controlling how the fact chunk affects the loading of a WAVE
* file. * file.
@@ -3343,6 +3635,18 @@ extern "C" {
*/ */
#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" #define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK"
/**
* A variable controlling the maximum number of chunks in a WAVE file.
*
* This sets an upper bound on the number of chunks in a WAVE file to avoid
* wasting time on malformed or corrupt WAVE files. This defaults to "10000".
*
* This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO()
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_WAVE_CHUNK_LIMIT "SDL_WAVE_CHUNK_LIMIT"
/** /**
* A variable controlling how the size of the RIFF chunk affects the loading * A variable controlling how the size of the RIFF chunk affects the loading
* of a WAVE file. * of a WAVE file.
@@ -3354,7 +3658,7 @@ extern "C" {
* Note that files that have trailing data unrelated to the WAVE file or * Note that files that have trailing data unrelated to the WAVE file or
* corrupt files may slow down the loading process without a reliable * corrupt files may slow down the loading process without a reliable
* boundary. By default, SDL stops after 10000 chunks to prevent wasting time. * boundary. By default, SDL stops after 10000 chunks to prevent wasting time.
* Use the environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. * Use SDL_HINT_WAVE_CHUNK_LIMIT to adjust this value.
* *
* The variable can be set to the following values: * The variable can be set to the following values:
* *
@@ -3533,27 +3837,6 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" #define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD"
/**
* A variable controlling whether SDL uses Critical Sections for mutexes on
* Windows.
*
* On Windows 7 and newer, Slim Reader/Writer Locks are available. They offer
* better performance, allocate no kernel resources and use less memory. SDL
* will fall back to Critical Sections on older OS versions or if forced to by
* this hint.
*
* The variable can be set to the following values:
*
* - "0": Use SRW Locks when available, otherwise fall back to Critical
* Sections. (default)
* - "1": Force the use of Critical Sections in all cases.
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS "SDL_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS"
/** /**
* A variable controlling whether SDL uses Kernel Semaphores on Windows. * A variable controlling whether SDL uses Kernel Semaphores on Windows.
* *
@@ -3780,6 +4063,17 @@ extern "C" {
*/ */
#define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE" #define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE"
/**
* Specify the XCB library to load for the X11 driver.
*
* This defaults to "libX11-xcb.so"
*
* This hint should be set before initializing the video subsystem.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_X11_XCB_LIBRARY "SDL_X11_XCB_LIBRARY"
/** /**
* A variable controlling whether XInput should be used for controller * A variable controlling whether XInput should be used for controller
* handling. * handling.
@@ -3818,7 +4112,10 @@ typedef enum SDL_HintPriority
* \param name the hint to set. * \param name the hint to set.
* \param value the value of the hint variable. * \param value the value of the hint variable.
* \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 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
@@ -3826,9 +4123,9 @@ typedef enum SDL_HintPriority
* \sa SDL_ResetHint * \sa SDL_ResetHint
* \sa SDL_SetHint * \sa SDL_SetHint
*/ */
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, extern SDL_DECLSPEC int SDLCALL SDL_SetHintWithPriority(const char *name,
const char *value, const char *value,
SDL_HintPriority priority); SDL_HintPriority priority);
/** /**
* Set a hint with normal priority. * Set a hint with normal priority.
@@ -3839,7 +4136,10 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
* *
* \param name the hint to set. * \param name the hint to set.
* \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 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
@@ -3847,8 +4147,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name,
* \sa SDL_ResetHint * \sa SDL_ResetHint
* \sa SDL_SetHintWithPriority * \sa SDL_SetHintWithPriority
*/ */
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, extern SDL_DECLSPEC int SDLCALL SDL_SetHint(const char *name, const char *value);
const char *value);
/** /**
* Reset a hint to the default value. * Reset a hint to the default value.
@@ -3858,14 +4157,17 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name,
* change. * change.
* *
* \param name the hint to set. * \param name the hint to set.
* \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise. * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetHint * \sa SDL_SetHint
* \sa SDL_ResetHints * \sa SDL_ResetHints
*/ */
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResetHint(const char *name); extern SDL_DECLSPEC int SDLCALL SDL_ResetHint(const char *name);
/** /**
* Reset all hints to the default values. * Reset all hints to the default values.
@@ -3874,6 +4176,8 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ResetHint(const char *name);
* variable, or NULL if the environment isn't set. Callbacks will be called * variable, or NULL if the environment isn't set. Callbacks will be called
* normally with this change. * normally with this change.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_ResetHint * \sa SDL_ResetHint
@@ -3883,12 +4187,16 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetHints(void);
/** /**
* Get the value of a hint. * Get the value of a hint.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param name the hint to query. * \param name the hint to query.
* \returns the string value of a hint or NULL if the hint isn't set. * \returns the string value of a hint or NULL if the hint isn't set.
* *
* \threadsafety It is safe to call this function from any thread, however the
* return value only remains valid until the hint is changed; if
* another thread might do so, the app should supply locks
* and/or make a copy of the string. Note that using a hint
* callback instead is always thread-safe, as SDL holds a lock
* on the thread subsystem during the callback.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetHint * \sa SDL_SetHint
@@ -3904,6 +4212,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
* \returns the boolean value of a hint or the provided default value if the * \returns the boolean value of a hint or the provided default value if the
* hint does not exist. * hint does not exist.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetHint * \sa SDL_GetHint
@@ -3912,37 +4222,48 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value); extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value);
/** /**
* Type definition of the hint callback function. * A callback used to send notifications of hint value changes.
*
* This is called an initial time during SDL_AddHintCallback with the hint's
* current value, and then again each time the hint's value changes.
* *
* \param userdata what was passed as `userdata` to SDL_AddHintCallback(). * \param userdata what was passed as `userdata` to SDL_AddHintCallback().
* \param name what was passed as `name` to SDL_AddHintCallback(). * \param name what was passed as `name` to SDL_AddHintCallback().
* \param oldValue the previous hint value. * \param oldValue the previous hint value.
* \param newValue the new value hint is to be set to. * \param newValue the new value hint is to be set to.
* *
* \threadsafety This callback is fired from whatever thread is setting a new
* hint value. SDL holds a lock on the hint subsystem when
* calling this callback.
*
* \since This datatype is available since SDL 3.0.0. * \since This datatype is available since SDL 3.0.0.
*
* \sa SDL_AddHintCallback
*/ */
typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue);
/** /**
* Add a function to watch a particular hint. * Add a function to watch a particular hint.
* *
* The callback function is called _during_ this function, to provide it an
* initial value, and again each time the hint's value changes.
*
* \param name the hint to watch. * \param name the hint to watch.
* \param callback an SDL_HintCallback function that will be called when the * \param callback An SDL_HintCallback function that will be called when the
* hint value changes. * hint value changes.
* \param userdata a pointer to pass to the callback function. * \param userdata a pointer to pass to the callback function.
* \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.
* *
* \threadsafety It is **NOT** safe to call this function from two threads at * \threadsafety It is safe to call this function from any thread.
* once.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_DelHintCallback * \sa SDL_DelHintCallback
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_AddHintCallback(const char *name, extern SDL_DECLSPEC int SDLCALL SDL_AddHintCallback(const char *name,
SDL_HintCallback callback, SDL_HintCallback callback,
void *userdata); void *userdata);
/** /**
* Remove a function watching a particular hint. * Remove a function watching a particular hint.
@@ -3952,13 +4273,15 @@ extern SDL_DECLSPEC int SDLCALL SDL_AddHintCallback(const char *name,
* hint value changes. * hint value changes.
* \param userdata a pointer being passed to the callback function. * \param userdata a pointer being passed to the callback function.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AddHintCallback * \sa SDL_AddHintCallback
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, extern SDL_DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name,
SDL_HintCallback callback, SDL_HintCallback callback,
void *userdata); void *userdata);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -105,12 +105,18 @@ typedef Uint32 SDL_InitFlags;
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then * call SDL_Quit() to force shutdown). If a subsystem is already loaded then
* this call will increase the ref-count and return. * this call will increase the ref-count and return.
* *
* Consider reporting some basic metadata about your application before
* calling SDL_Init, using either SDL_SetAppMetadata() or
* SDL_SetAppMetadataProperty().
*
* \param flags subsystem initialization flags. * \param flags subsystem initialization 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 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetAppMetadata
* \sa SDL_SetAppMetadataProperty
* \sa SDL_InitSubSystem * \sa SDL_InitSubSystem
* \sa SDL_Quit * \sa SDL_Quit
* \sa SDL_SetMainReady * \sa SDL_SetMainReady
@@ -182,6 +188,138 @@ extern SDL_DECLSPEC SDL_InitFlags SDLCALL SDL_WasInit(SDL_InitFlags flags);
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_Quit(void); extern SDL_DECLSPEC void SDLCALL SDL_Quit(void);
/**
* Specify basic metadata about your app.
*
* You can optionally provide metadata about your app to SDL. This is not
* required, but strongly encouraged.
*
* There are several locations where SDL can make use of metadata (an "About"
* box in the macOS menu bar, the name of the app can be shown on some audio
* mixers, etc). Any piece of metadata can be left as NULL, if a specific
* detail doesn't make sense for the app.
*
* This function should be called as early as possible, before SDL_Init.
* Multiple calls to this function are allowed, but various state might not
* change once it has been set up with a previous call to this function.
*
* Passing a NULL removes any previous metadata.
*
* This is a simplified interface for the most important information. You can
* supply significantly more detailed metadata with
* SDL_SetAppMetadataProperty().
*
* \param appname The name of the application ("My Game 2: Bad Guy's
* Revenge!").
* \param appversion The version of the application ("1.0.0beta5" or a git
* hash, or whatever makes sense).
* \param appidentifier A unique string in reverse-domain format that
* identifies this app ("com.example.mygame2").
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetAppMetadataProperty
*/
extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier);
/**
* Specify metadata about your app through a set of properties.
*
* You can optionally provide metadata about your app to SDL. This is not
* required, but strongly encouraged.
*
* There are several locations where SDL can make use of metadata (an "About"
* box in the macOS menu bar, the name of the app can be shown on some audio
* mixers, etc). Any piece of metadata can be left out, if a specific detail
* doesn't make sense for the app.
*
* This function should be called as early as possible, before SDL_Init.
* Multiple calls to this function are allowed, but various state might not
* change once it has been set up with a previous call to this function.
*
* Once set, this metadata can be read using SDL_GetMetadataProperty().
*
* These are the supported properties:
*
* - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the
* application, like "My Game 2: Bad Guy's Revenge!". This will show up
* anywhere the OS shows the name of the application separately from window
* titles, such as volume control applets, etc. This defaults to "SDL
* Application".
* - SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is
* running; there are no rules on format, so "1.0.3beta2" and "April 22nd,
* 2024" and a git hash are all valid options. This has no default.
* - `SDL_PROP_APP_METADATA_IDENTIFIER_STRING`: A unique string that
* identifies this app. This must be in reverse-domain format, like
* "com.example.mygame2". This string is used by desktop compositors to
* identify and group windows together, as well as match applications with
* associated desktop settings and icons. If you plan to package your
* application in a container such as Flatpak, the app ID should match the
* name of your Flatpak container as well. This has no default.
* - SDL_PROP_APP_METADATA_CREATOR_STRING`: The human-readable name of the
* creator/developer/maker of this app, like "MojoWorkshop, LLC"
* - SDL_PROP_APP_METADATA_COPYRIGHT_STRING`: The human-readable copyright
* notice, like "Copyright (c) 2024 MojoWorkshop, LLC" or whatnot. Keep this
* to one line, don't paste a copy of a whole software license in here. This
* has no default.
* - SDL_PROP_APP_METADATA_URL_STRING`: A URL to the app on the web. Maybe a
* product page, or a storefront, or even a GitHub repository, for user's
* further information This has no default.
* - SDL_PROP_APP_METADATA_TYPE_STRING`: The type of application this is.
* Currently this string can be "game" for a video game, "mediaplayer" for a
* media player, or generically "application" if nothing else applies.
* Future versions of SDL might add new types. This defaults to
* "application".
*
* \param name the name of the metadata property to set.
* \param value the value of the property, or NULL to remove that property.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetAppMetadataProperty
* \sa SDL_SetAppMetadata
*/
extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadataProperty(const char *name, const char *value);
#define SDL_PROP_APP_METADATA_NAME_STRING "SDL.app.metadata.name"
#define SDL_PROP_APP_METADATA_VERSION_STRING "SDL.app.metadata.version"
#define SDL_PROP_APP_METADATA_IDENTIFIER_STRING "SDL.app.metadata.identifier"
#define SDL_PROP_APP_METADATA_CREATOR_STRING "SDL.app.metadata.creator"
#define SDL_PROP_APP_METADATA_COPYRIGHT_STRING "SDL.app.metadata.copyright"
#define SDL_PROP_APP_METADATA_URL_STRING "SDL.app.metadata.url"
#define SDL_PROP_APP_METADATA_TYPE_STRING "SDL.app.metadata.type"
/**
* Get metadata about your app.
*
* This returns metadata previously set using SDL_SetAppMetadata() or
* SDL_SetAppMetadataProperty(). See SDL_SetAppMetadataProperty() for the list
* of available properties and their meanings.
*
* \param name the name of the metadata property to get.
* \returns the current value of the metadata property, or the default if it
* is not set, NULL for properties with no default.
*
* \threadsafety It is safe to call this function from any thread, although
* the string returned is not protected and could potentially be
* freed if you call SDL_SetAppMetadataProperty() to set that
* property from another thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetAppMetadata
* \sa SDL_SetAppMetadataProperty
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAppMetadataProperty(const char *name);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -481,9 +481,9 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context);
* *
* This function reads up `size` bytes from the data source to the area * This function reads up `size` bytes from the data source to the area
* pointed at by `ptr`. This function may read less bytes than requested. It * pointed at by `ptr`. This function may read less bytes than requested. It
* will return zero when the data stream is completely read, or on error. To * will return zero when the data stream is completely read, and
* determine if there was an error or all data was read, call * SDL_GetIOStatus() will return SDL_IO_STATUS_EOF, or on error, and
* SDL_GetIOStatus(). * SDL_GetIOStatus() will return SDL_IO_STATUS_ERROR.
* *
* \param context a pointer to an SDL_IOStream structure. * \param context a pointer to an SDL_IOStream structure.
* \param ptr a pointer to a buffer to read data into. * \param ptr a pointer to a buffer to read data into.

View File

@@ -201,29 +201,24 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasJoystick(void);
/** /**
* Get a list of currently connected joysticks. * Get a list of currently connected joysticks.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of joysticks returned, may * \param count a pointer filled in with the number of joysticks returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of joystick instance IDs or NULL on failure; * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_HasJoystick * \sa SDL_HasJoystick
* \sa SDL_OpenJoystick * \sa SDL_OpenJoystick
*/ */
extern SDL_DECLSPEC const SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count); extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count);
/** /**
* Get the implementation dependent name of a joystick. * Get the implementation dependent name of a joystick.
* *
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \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.
@@ -240,9 +235,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID
* *
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the joystick instance ID. * \param instance_id the joystick instance ID.
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
@@ -662,9 +654,6 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joyst
/** /**
* Get the implementation dependent name of a joystick. * Get the implementation dependent name of a joystick.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \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.
@@ -678,9 +667,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joyst
/** /**
* Get the implementation dependent path of a joystick. * Get the implementation dependent path of a joystick.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
@@ -798,9 +784,6 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *
* *
* Returns the serial number of the joystick, or NULL if it is not available. * Returns the serial number of the joystick, or NULL if it is not available.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick().
* \returns the serial number of the selected joystick, or NULL if * \returns the serial number of the selected joystick, or NULL if
* unavailable. * unavailable.

View File

@@ -73,29 +73,24 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasKeyboard(void);
* power buttons, etc. You should wait for input from a device before you * power buttons, etc. You should wait for input from a device before you
* consider it actively in use. * consider it actively in use.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of keyboards returned, may * \param count a pointer filled in with the number of keyboards returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of keyboards instance IDs or NULL on failure; * \returns a 0 terminated array of keyboards instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetKeyboardNameForID * \sa SDL_GetKeyboardNameForID
* \sa SDL_HasKeyboard * \sa SDL_HasKeyboard
*/ */
extern SDL_DECLSPEC const SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count); extern SDL_DECLSPEC SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count);
/** /**
* Get the name of a keyboard. * Get the name of a keyboard.
* *
* This function returns "" if the keyboard doesn't have a name. * This function returns "" if the keyboard doesn't have a name.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the keyboard instance ID. * \param instance_id the keyboard instance ID.
* \returns the name of the selected keyboard or NULL on failure; call * \returns the name of the selected keyboard or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -189,61 +184,27 @@ extern SDL_DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
/**
* Get the key code corresponding to the given scancode according to a default
* en_US keyboard layout.
*
* See SDL_Keycode for details.
*
* \param scancode the desired SDL_Scancode to query.
* \param modstate the modifier state to use when translating the scancode to
* a keycode.
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetKeyName
* \sa SDL_GetScancodeFromKey
*/
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetDefaultKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate);
/** /**
* Get the key code corresponding to the given scancode according to the * Get the key code corresponding to the given scancode according to the
* current keyboard layout. * current keyboard layout.
* *
* See SDL_Keycode for details. * If you want to get the keycode as it would be delivered in key events,
* including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should
* pass `key_event` as SDL_TRUE. Otherwise this function simply translates the
* scancode based on the given modifier state.
* *
* \param scancode the desired SDL_Scancode to query. * \param scancode the desired SDL_Scancode to query.
* \param modstate the modifier state to use when translating the scancode to * \param modstate the modifier state to use when translating the scancode to
* a keycode. * a keycode.
* \param key_event SDL_TRUE if the keycode will be used in key events.
* \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 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDefaultKeyFromScancode
* \sa SDL_GetKeyName * \sa SDL_GetKeyName
* \sa SDL_GetScancodeFromKey * \sa SDL_GetScancodeFromKey
*/ */
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate); extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, SDL_bool key_event);
/**
* Get the scancode corresponding to the given key code according to a default
* en_US keyboard layout.
*
* Note that there may be multiple scancode+modifier states that can generate
* this keycode, this will just return the first one found.
*
* \param key the desired SDL_Keycode to query.
* \param modstate a pointer to the modifier state that would be used when the
* scancode generates this key, may be NULL.
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetScancodeFromKey
* \sa SDL_GetScancodeName
*/
extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetDefaultScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate);
/** /**
* Get the scancode corresponding to the given key code according to the * Get the scancode corresponding to the given key code according to the
@@ -259,7 +220,6 @@ extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetDefaultScancodeFromKey(SDL_Keyco
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDefaultScancodeFromKey
* \sa SDL_GetKeyFromScancode * \sa SDL_GetKeyFromScancode
* \sa SDL_GetScancodeName * \sa SDL_GetScancodeName
*/ */
@@ -284,9 +244,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const
/** /**
* Get a human-readable name for a scancode. * Get a human-readable name for a scancode.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* **Warning**: The returned name is by design not stable across platforms, * **Warning**: The returned name is by design not stable across platforms,
* e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left
* Windows" under Microsoft Windows, and some scancodes like * Windows" under Microsoft Windows, and some scancodes like
@@ -326,14 +283,8 @@ extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *nam
/** /**
* Get a human-readable name for a key. * Get a human-readable name for a key.
* *
* Both lowercase and uppercase alphabetic keycodes have uppercase names, e.g.
* SDL_Keycode 'a' and 'A' both have the name "A".
*
* If the key doesn't have a name, this function returns an empty string (""). * If the key doesn't have a name, this function returns an empty string ("").
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param key the desired SDL_Keycode to query. * \param key the desired SDL_Keycode to query.
* \returns a UTF-8 encoded string of the key name. * \returns a UTF-8 encoded string of the key name.
* *
@@ -378,11 +329,110 @@ extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetTextInputArea * \sa SDL_SetTextInputArea
* \sa SDL_StartTextInputWithProperties
* \sa SDL_StopTextInput * \sa SDL_StopTextInput
* \sa SDL_TextInputActive * \sa SDL_TextInputActive
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_StartTextInput(SDL_Window *window); extern SDL_DECLSPEC int SDLCALL SDL_StartTextInput(SDL_Window *window);
/**
* Text input type.
*
* These are the valid values for SDL_PROP_TEXTINPUT_TYPE_NUMBER. Not every
* value is valid on every platform, but where a value isn't supported, a
* reasonable fallback will be used.
*
* \since This enum is available since SDL 3.0.0.
*
* \sa SDL_StartTextInputWithProperties
*/
typedef enum SDL_TextInputType
{
SDL_TEXTINPUT_TYPE_TEXT, /**< The input is text */
SDL_TEXTINPUT_TYPE_TEXT_NAME, /**< The input is a person's name */
SDL_TEXTINPUT_TYPE_TEXT_EMAIL, /**< The input is an e-mail address */
SDL_TEXTINPUT_TYPE_TEXT_USERNAME, /**< The input is a username */
SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN, /**< The input is a secure password that is hidden */
SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE, /**< The input is a secure password that is visible */
SDL_TEXTINPUT_TYPE_NUMBER, /**< The input is a number */
SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN, /**< The input is a secure PIN that is hidden */
SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE /**< The input is a secure PIN that is visible */
} SDL_TextInputType;
/**
* Auto capitalization type.
*
* These are the valid values for
* SDL_PROP_TEXTINPUT_AUTOCAPITALIZATION_NUMBER. Not every value is valid on
* every platform, but where a value isn't supported, a reasonable fallback
* will be used.
*
* \since This enum is available since SDL 3.0.0.
*
* \sa SDL_StartTextInputWithProperties
*/
typedef enum SDL_Capitalization
{
SDL_CAPITALIZE_NONE, /**< No auto-capitalization will be done */
SDL_CAPITALIZE_SENTENCES, /**< The first letter of sentences will be capitalized */
SDL_CAPITALIZE_WORDS, /**< The first letter of words will be capitalized */
SDL_CAPITALIZE_LETTERS /**< All letters will be capitalized */
} SDL_Capitalization;
/**
* Start accepting Unicode text input events in a window, with properties
* describing the input.
*
* This function will enable text input (SDL_EVENT_TEXT_INPUT and
* SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this
* function paired with SDL_StopTextInput().
*
* Text input events are not received by default.
*
* On some platforms using this function shows the screen keyboard.
*
* These are the supported properties:
*
* - `SDL_PROP_TEXTINPUT_TYPE_NUMBER` - an SDL_TextInputType value that
* describes text being input, defaults to SDL_TEXTINPUT_TYPE_TEXT.
* - `SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER` - an SDL_Capitalization value
* that describes how text should be capitalized, defaults to
* SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for
* SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail
* addresses, usernames, and passwords.
* - `SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN` - true to enable auto completion
* and auto correction, defaults to SDL_TRUE.
* - `SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN` - true if multiple lines of text
* are allowed. This defaults to SDL_TRUE if SDL_HINT_RETURN_KEY_HIDES_IME
* is "0" or is not set, and defaults to SDL_FALSE if
* SDL_HINT_RETURN_KEY_HIDES_IME is "1".
*
* On Android you can directly specify the input type:
*
* - `SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER` - the text input type to
* use, overriding other properties. This is documented at
* https://developer.android.com/reference/android/text/InputType
*
* \param window the window to enable text input.
* \param props the properties to use.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetTextInputArea
* \sa SDL_StartTextInput
* \sa SDL_StopTextInput
* \sa SDL_TextInputActive
*/
extern SDL_DECLSPEC int SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props);
#define SDL_PROP_TEXTINPUT_TYPE_NUMBER "SDL.textinput.type"
#define SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER "SDL.textinput.capitalization"
#define SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN "SDL.textinput.autocorrect"
#define SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN "SDL.textinput.multiline"
#define SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER "SDL.textinput.android.inputtype"
/** /**
* Check whether or not Unicode text input events are enabled for a window. * Check whether or not Unicode text input events are enabled for a window.
* *

View File

@@ -43,8 +43,6 @@
* to SDLK_0...SDLK_9 on AZERTY layouts. * to SDLK_0...SDLK_9 on AZERTY layouts.
* *
* \since This datatype is available since SDL 3.0.0. * \since This datatype is available since SDL 3.0.0.
*
* \sa SDL_KeyCode
*/ */
typedef Uint32 SDL_Keycode; typedef Uint32 SDL_Keycode;

View File

@@ -89,17 +89,16 @@ typedef struct SDL_Locale
* if possible, and you can call this function again to get an updated copy of * if possible, and you can call this function again to get an updated copy of
* preferred locales. * preferred locales.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of locales returned, may * \param count a pointer filled in with the number of locales returned, may
* be NULL. * be NULL.
* \returns a NULL terminated array of locale pointers, or NULL on failure; * \returns a NULL terminated array of locale pointers, or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This is a single
* allocation that should be freed with SDL_free() when it is no
* longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_Locale * const * SDLCALL SDL_GetPreferredLocales(int *count); extern SDL_DECLSPEC SDL_Locale ** SDLCALL SDL_GetPreferredLocales(int *count);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -29,9 +29,27 @@
* it will only be sent out if it has that minimum priority or higher. * it will only be sent out if it has that minimum priority or higher.
* *
* SDL's own logs are sent below the default priority threshold, so they are * SDL's own logs are sent below the default priority threshold, so they are
* quiet by default. If you're debugging SDL you might want: * quiet by default.
* *
* SDL_SetLogPriorities(SDL_LOG_PRIORITY_WARN); * You can change the log verbosity programmatically using
* SDL_SetLogPriority() or with SDL_SetHint(SDL_HINT_LOGGING, ...), or with
* the "SDL_LOGGING" environment variable. This variable is a comma separated
* set of category=level tokens that define the default logging levels for SDL
* applications.
*
* The category can be a numeric category, one of "app", "error", "assert",
* "system", "audio", "video", "render", "input", "test", or `*` for any
* unspecified category.
*
* The level can be a numeric level, one of "verbose", "debug", "info",
* "warn", "error", "critical", or "quiet" to disable that category.
*
* You can omit the category if you want to set the logging level for all
* categories.
*
* If this hint isn't set, the default log levels are equivalent to:
*
* `app=info,assert=warn,test=verbose,*=error`
* *
* Here's where the messages go on different platforms: * Here's where the messages go on different platforms:
* *
@@ -163,6 +181,26 @@ extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category);
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void); extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
/**
* Set the text prepended to log messages of a given priority.
*
* By default SDL_LOG_PRIORITY_INFO and below have no prefix, and
* SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g.
* "WARNING: ".
*
* \param priority the SDL_LogPriority to modify.
* \param prefix the prefix to use for that log priority, or NULL to use no
* prefix.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetLogPriorities
* \sa SDL_SetLogPriority
*/
extern SDL_DECLSPEC int SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix);
/** /**
* Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. * Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
* *

View File

@@ -135,29 +135,24 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasMouse(void);
* You should wait for input from a device before you consider it actively in * You should wait for input from a device before you consider it actively in
* use. * use.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of mice returned, may be * \param count a pointer filled in with the number of mice returned, may be
* NULL. * NULL.
* \returns a 0 terminated array of mouse instance IDs or NULL on failure; * \returns a 0 terminated array of mouse instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetMouseNameForID * \sa SDL_GetMouseNameForID
* \sa SDL_HasMouse * \sa SDL_HasMouse
*/ */
extern SDL_DECLSPEC const SDL_MouseID * SDLCALL SDL_GetMice(int *count); extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count);
/** /**
* Get the name of a mouse. * Get the name of a mouse.
* *
* This function returns "" if the mouse doesn't have a name. * This function returns "" if the mouse doesn't have a name.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the mouse instance ID. * \param instance_id the mouse instance ID.
* \returns the name of the selected mouse, or NULL on failure; call * \returns the name of the selected mouse, or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -293,23 +288,36 @@ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
extern SDL_DECLSPEC int SDLCALL SDL_WarpMouseGlobal(float x, float y); extern SDL_DECLSPEC int SDLCALL SDL_WarpMouseGlobal(float x, float y);
/** /**
* Set relative mouse mode. * Set relative mouse mode for a window.
* *
* While the mouse is in relative mode, the cursor is hidden, the mouse * While the window has focus and relative mouse mode is enabled, the cursor is hidden, the mouse
* position is constrained to the window, and SDL will report continuous * position is constrained to the window, and SDL will report continuous
* relative mouse motion even if the mouse is at the edge of the window. * relative mouse motion even if the mouse is at the edge of the window.
* *
* This function will flush any pending mouse motion. * This function will flush any pending mouse motion for this window.
* *
* \param window the window to change.
* \param enabled SDL_TRUE to enable relative mode, SDL_FALSE to disable. * \param enabled SDL_TRUE to enable relative mode, SDL_FALSE to disable.
* \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 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetRelativeMouseMode * \sa SDL_GetWindowRelativeMouseMode
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); extern SDL_DECLSPEC int SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, SDL_bool enabled);
/**
* Query whether relative mouse mode is enabled for a window.
*
* \param window the window to query.
* \returns SDL_TRUE if relative mode is enabled for a window or SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowRelativeMouseMode
*/
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window);
/** /**
* Capture the mouse and to track input outside an SDL window. * Capture the mouse and to track input outside an SDL window.
@@ -326,7 +334,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
* mouse while the user is dragging something, until the user releases a mouse * mouse while the user is dragging something, until the user releases a mouse
* button. It is not recommended that you capture the mouse for long periods * button. It is not recommended that you capture the mouse for long periods
* of time, such as the entire time your app is running. For that, you should * of time, such as the entire time your app is running. For that, you should
* probably use SDL_SetRelativeMouseMode() or SDL_SetWindowMouseGrab(), * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
* depending on your goals. * depending on your goals.
* *
* While captured, mouse events still report coordinates relative to the * While captured, mouse events still report coordinates relative to the
@@ -357,17 +365,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); extern SDL_DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled);
/**
* Query whether relative mouse mode is enabled.
*
* \returns SDL_TRUE if relative mode is enabled or SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetRelativeMouseMode
*/
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
/** /**
* Create a cursor using the specified bitmap data and mask (in MSB format). * Create a cursor using the specified bitmap data and mask (in MSB format).
* *
@@ -418,6 +415,15 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data,
/** /**
* Create a color cursor. * Create a color cursor.
* *
* If this function is passed a surface with alternate representations, the
* surface will be interpreted as the content to be used for 100% display
* scale, and the alternate representations will be used for high DPI
* situations. For example, if the original surface is 32x32, then on a 2x
* macOS display or 200% display scale on Windows, a 64x64 version of the
* image will be used, if available. If a matching version of the image isn't
* available, the closest size image will be scaled to the appropriate size
* and be used instead.
*
* \param surface an SDL_Surface structure representing the cursor image. * \param surface an SDL_Surface structure representing the cursor image.
* \param hot_x the x position of the cursor hot spot. * \param hot_x the x position of the cursor hot spot.
* \param hot_y the y position of the cursor hot spot. * \param hot_y the y position of the cursor hot spot.

View File

@@ -544,7 +544,7 @@ typedef struct SDL_Semaphore SDL_Semaphore;
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_PostSemaphore * \sa SDL_SignalSemaphore
* \sa SDL_TryWaitSemaphore * \sa SDL_TryWaitSemaphore
* \sa SDL_GetSemaphoreValue * \sa SDL_GetSemaphoreValue
* \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphore
@@ -583,7 +583,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_PostSemaphore * \sa SDL_SignalSemaphore
* \sa SDL_TryWaitSemaphore * \sa SDL_TryWaitSemaphore
* \sa SDL_WaitSemaphoreTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
@@ -604,7 +604,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_PostSemaphore * \sa SDL_SignalSemaphore
* \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphore
* \sa SDL_WaitSemaphoreTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
@@ -626,7 +626,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_PostSemaphore * \sa SDL_SignalSemaphore
* \sa SDL_TryWaitSemaphore * \sa SDL_TryWaitSemaphore
* \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphore
*/ */
@@ -645,7 +645,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sin
* \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphore
* \sa SDL_WaitSemaphoreTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_PostSemaphore(SDL_Semaphore *sem); extern SDL_DECLSPEC int SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem);
/** /**
* Get the current value of a semaphore. * Get the current value of a semaphore.

View File

@@ -444,7 +444,7 @@
#define SDL_CondWaitTimeout SDL_WaitConditionTimeout #define SDL_CondWaitTimeout SDL_WaitConditionTimeout
#define SDL_CreateCond SDL_CreateCondition #define SDL_CreateCond SDL_CreateCondition
#define SDL_DestroyCond SDL_DestroyCondition #define SDL_DestroyCond SDL_DestroyCondition
#define SDL_SemPost SDL_PostSemaphore #define SDL_SemPost SDL_SignalSemaphore
#define SDL_SemTryWait SDL_TryWaitSemaphore #define SDL_SemTryWait SDL_TryWaitSemaphore
#define SDL_SemValue SDL_GetSemaphoreValue #define SDL_SemValue SDL_GetSemaphoreValue
#define SDL_SemWait SDL_WaitSemaphore #define SDL_SemWait SDL_WaitSemaphore
@@ -618,6 +618,8 @@
#define SDL_GDKGetTaskQueue SDL_GetGDKTaskQueue #define SDL_GDKGetTaskQueue SDL_GetGDKTaskQueue
#define SDL_LinuxSetThreadPriority SDL_SetLinuxThreadPriority #define SDL_LinuxSetThreadPriority SDL_SetLinuxThreadPriority
#define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy #define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy
#define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidEnterForeground
#define SDL_OnApplicationWillResignActive SDL_OnApplicationWillEnterBackground
#define SDL_WinRTGetDeviceFamily SDL_GetWinRTDeviceFamily #define SDL_WinRTGetDeviceFamily SDL_GetWinRTDeviceFamily
#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPath #define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPath
#define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback #define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback
@@ -1063,7 +1065,7 @@
#define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout #define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout
#define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition #define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition
#define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition #define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition
#define SDL_SemPost SDL_SemPost_renamed_SDL_PostSemaphore #define SDL_SemPost SDL_SemPost_renamed_SDL_SignalSemaphore
#define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore #define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore
#define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue #define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue
#define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore #define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore
@@ -1237,6 +1239,8 @@
#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_renamed_SDL_GetGDKTaskQueue #define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_renamed_SDL_GetGDKTaskQueue
#define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_renamed_SDL_SetLinuxThreadPriority #define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_renamed_SDL_SetLinuxThreadPriority
#define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy #define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy
#define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidBecomeActive_renamed_SDL_OnApplicationDidEnterForeground
#define SDL_OnApplicationWillResignActive SDL_OnApplicationWillResignActive_renamed_SDL_OnApplicationWillEnterBackground
#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_renamed_SDL_GetWinRTDeviceFamily #define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_renamed_SDL_GetWinRTDeviceFamily
#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPathUTF8_renamed_SDL_GetWinRTFSPath #define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPathUTF8_renamed_SDL_GetWinRTFSPath
#define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback #define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback

View File

@@ -224,9 +224,6 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_PenConnected(SDL_PenID instance_id);
/** /**
* Retrieves a human-readable description for a SDL_PenID. * Retrieves a human-readable description for a SDL_PenID.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the pen to query. * \param instance_id the pen to query.
* \returns a string that contains the name of the pen, intended for human * \returns a string that contains the name of the pen, intended for human
* consumption. The string might or might not be localised, depending * consumption. The string might or might not be localised, depending

View File

@@ -378,16 +378,18 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetPointerProperty(SDL_PropertiesID props
/** /**
* Get a string property from a group of properties. * Get a string property from a group of properties.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param props the properties to query. * \param props the properties to query.
* \param name the name of the property to query. * \param name the name of the property to query.
* \param default_value the default value of the property. * \param default_value the default value of the property.
* \returns the value of the property, or `default_value` if it is not set or * \returns the value of the property, or `default_value` if it is not set or
* not a string property. * not a string property.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety It is safe to call this function from any thread, although
* the data returned is not protected and could potentially be
* freed if you call SDL_SetStringProperty() or
* SDL_ClearProperty() on these properties from another thread.
* If you need to avoid this, use SDL_LockProperties() and
* SDL_UnlockProperties().
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *

View File

@@ -112,6 +112,25 @@ typedef struct SDL_FRect
} SDL_FRect; } SDL_FRect;
/**
* Convert an SDL_Rect to SDL_FRect
*
* \param rect a pointer to an SDL_Rect.
* \param frect a pointer filled in with the floating point representation of
* `rect`.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*/
SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect)
{
frect->x = (float)rect->x;
frect->y = (float)rect->y;
frect->w = (float)rect->w;
frect->h = (float)rect->h;
}
/** /**
* Determine whether a point resides inside a rectangle. * Determine whether a point resides inside a rectangle.
* *

View File

@@ -154,9 +154,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
* "direct3d12" or "metal". These never have Unicode characters, and are not * "direct3d12" or "metal". These never have Unicode characters, and are not
* meant to be proper names. * meant to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param index the index of the rendering driver; the value ranges from 0 to * \param index the index of the rendering driver; the value ranges from 0 to
* SDL_GetNumRenderDrivers() - 1. * SDL_GetNumRenderDrivers() - 1.
* \returns the name of the rendering driver at the requested index, or NULL * \returns the name of the rendering driver at the requested index, or NULL
@@ -325,9 +322,6 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *rende
/** /**
* Get the name of a renderer. * Get the name of a renderer.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param renderer the rendering context. * \param renderer the rendering context.
* \returns the name of the selected renderer, or NULL on failure; call * \returns the name of the selected renderer, or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
@@ -1443,6 +1437,26 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SD
*/ */
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer); extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
/**
* Get the safe area for rendering within the current viewport.
*
* Some devices have portions of the screen which are partially obscured or
* not interactive, possibly due to on-screen controls, curved edges, camera
* notches, TV overscan, etc. This function provides the area of the current
* viewport which is safe to have interactible content. You should continue
* rendering into the rest of the render target, but it should not contain
* visually important or interactible content.
*
* \param renderer the rendering context.
* \param rect a pointer filled in with the area that is safe for interactive
* content.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
/** /**
* Set the clip rectangle for rendering on the specified target. * Set the clip rectangle for rendering on the specified target.
* *
@@ -1905,17 +1919,21 @@ extern SDL_DECLSPEC int SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, S
* Perform a scaled copy using the 9-grid algorithm to the current rendering * Perform a scaled copy using the 9-grid algorithm to the current rendering
* target at subpixel precision. * target at subpixel precision.
* *
* The pixels in the texture are split into a 3x3 grid, using the corner size * The pixels in the texture are split into a 3x3 grid, using the different
* for each corner, and the sides and center making up the remaining pixels. * corner sizes for each corner, and the sides and center making up the
* The corners are then scaled using `scale` and fit into the corners of the * remaining pixels. The corners are then scaled using `scale` and fit into
* destination rectangle. The sides and center are then stretched into place * the corners of the destination rectangle. The sides and center are then
* to cover the remaining destination rectangle. * stretched into place to cover the remaining destination rectangle.
* *
* \param renderer the renderer which should copy parts of a texture. * \param renderer the renderer which should copy parts of a texture.
* \param texture the source texture. * \param texture the source texture.
* \param srcrect the SDL_Rect structure representing the rectangle to be used * \param srcrect the SDL_Rect structure representing the rectangle to be used
* for the 9-grid, or NULL to use the entire texture. * for the 9-grid, or NULL to use the entire texture.
* \param corner_size the size, in pixels, of the corner in `srcrect`. * \param left_width the width, in pixels, of the left corners in `srcrect`.
* \param right_width the width, in pixels, of the right corners in `srcrect`.
* \param top_height the height, in pixels, of the top corners in `srcrect`.
* \param bottom_height the height, in pixels, of the bottom corners in
* `srcrect`.
* \param scale the scale used to transform the corner of `srcrect` into the * \param scale the scale used to transform the corner of `srcrect` into the
* corner of `dstrect`, or 0.0f for an unscaled copy. * corner of `dstrect`, or 0.0f for an unscaled copy.
* \param dstrect a pointer to the destination rectangle, or NULL for the * \param dstrect a pointer to the destination rectangle, or NULL for the
@@ -1927,7 +1945,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, S
* *
* \sa SDL_RenderTexture * \sa SDL_RenderTexture
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float corner_size, float scale, const SDL_FRect *dstrect); extern SDL_DECLSPEC int SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect);
/** /**
* Render a list of triangles, optionally using a texture and indices into the * Render a list of triangles, optionally using a texture and indices into the
@@ -2039,15 +2057,16 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *ren
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CreateRenderer
* \sa SDL_RenderClear * \sa SDL_RenderClear
* \sa SDL_RenderFillRect
* \sa SDL_RenderFillRects
* \sa SDL_RenderLine * \sa SDL_RenderLine
* \sa SDL_RenderLines * \sa SDL_RenderLines
* \sa SDL_RenderPoint * \sa SDL_RenderPoint
* \sa SDL_RenderPoints * \sa SDL_RenderPoints
* \sa SDL_RenderRect * \sa SDL_RenderRect
* \sa SDL_RenderRects * \sa SDL_RenderRects
* \sa SDL_RenderFillRect
* \sa SDL_RenderFillRects
* \sa SDL_SetRenderDrawBlendMode * \sa SDL_SetRenderDrawBlendMode
* \sa SDL_SetRenderDrawColor * \sa SDL_SetRenderDrawColor
*/ */

View File

@@ -31,9 +31,9 @@
/* #undef SDL_VENDOR_INFO */ /* #undef SDL_VENDOR_INFO */
#ifdef SDL_VENDOR_INFO #ifdef SDL_VENDOR_INFO
#define SDL_REVISION "SDL-ff7a60d (" SDL_VENDOR_INFO ")" #define SDL_REVISION "SDL-627cb8acd (" SDL_VENDOR_INFO ")"
#else #else
#define SDL_REVISION "SDL-ff7a60d" #define SDL_REVISION "SDL-627cb8acd"
#endif #endif
#endif /* SDL_revision_h_ */ #endif /* SDL_revision_h_ */

View File

@@ -149,20 +149,18 @@ typedef enum SDL_SensorType
* \param count a pointer filled in with the number of sensors returned, may * \param count a pointer filled in with the number of sensors returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of sensor instance IDs or NULL on failure; * \returns a 0 terminated array of sensor instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_SensorID * SDLCALL SDL_GetSensors(int *count); extern SDL_DECLSPEC SDL_SensorID * SDLCALL SDL_GetSensors(int *count);
/** /**
* Get the implementation dependent name of a sensor. * Get the implementation dependent name of a sensor.
* *
* This can be called before any sensors are opened. * This can be called before any sensors are opened.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the sensor instance ID. * \param instance_id the sensor instance ID.
* \returns the sensor name, or NULL if `instance_id` is not valid. * \returns the sensor name, or NULL if `instance_id` is not valid.
* *
@@ -232,9 +230,6 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSensorProperties(SDL_Sensor
/** /**
* Get the implementation dependent name of a sensor. * Get the implementation dependent name of a sensor.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param sensor the SDL_Sensor object. * \param sensor the SDL_Sensor object.
* \returns the sensor name or NULL on failure; call SDL_GetError() for more * \returns the sensor name or NULL on failure; call SDL_GetError() for more
* information. * information.

View File

@@ -91,8 +91,9 @@ void *alloca(size_t);
/** /**
* The number of elements in an array. * The number of elements in an array.
* *
* NOTE: This macro double-evaluates the argument, so you should never have * This macro looks like it double-evaluates the argument, but it does so
* side effects in the parameter. * inside of `sizeof`, so there are no side-effects here, as expressions do
* not actually run any code in these cases.
* *
* \since This macro is available since SDL 3.0.0. * \since This macro is available since SDL 3.0.0.
*/ */
@@ -664,6 +665,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name); extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name);
extern SDL_DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); extern SDL_DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
extern SDL_DECLSPEC int SDLCALL SDL_unsetenv(const char *name);
typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b); typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b);
extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare); extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
@@ -2962,8 +2964,9 @@ size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
/* Starting LLVM 16, the analyser errors out if these functions do not have /* Starting LLVM 16, the analyser errors out if these functions do not have
their prototype defined (clang-diagnostic-implicit-function-declaration) */ their prototype defined (clang-diagnostic-implicit-function-declaration) */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define SDL_malloc malloc #define SDL_malloc malloc
#define SDL_calloc calloc #define SDL_calloc calloc

View File

@@ -401,9 +401,6 @@ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetStorageSpaceRemaining(SDL_Storage *sto
* convenience, but if `count` is non-NULL, on return it will contain the * convenience, but if `count` is non-NULL, on return it will contain the
* number of items in the array, not counting the NULL terminator. * number of items in the array, not counting the NULL terminator.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param storage a storage container. * \param storage a storage container.
* \param path the path of the directory to enumerate. * \param path the path of the directory to enumerate.
* \param pattern the pattern that files in the directory must match. Can be * \param pattern the pattern that files in the directory must match. Can be
@@ -413,14 +410,16 @@ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetStorageSpaceRemaining(SDL_Storage *sto
* array. Can be NULL. * array. Can be NULL.
* \returns an array of strings on success or NULL on failure; call * \returns an array of strings on success or NULL on failure; call
* SDL_GetError() for more information. The caller should pass the * SDL_GetError() for more information. The caller should pass the
* returned pointer to SDL_free when done with it. * returned pointer to SDL_free when done with it. This is a single
* allocation that should be freed with SDL_free() when it is no
* longer needed.
* *
* \threadsafety It is safe to call this function from any thread, assuming * \threadsafety It is safe to call this function from any thread, assuming
* the `storage` object is thread-safe. * the `storage` object is thread-safe.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const char * const * SDLCALL SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count); extern SDL_DECLSPEC char ** SDLCALL SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -306,6 +306,87 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_
*/ */
extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface); extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface);
/**
* Add an alternate version of a surface.
*
* This function adds an alternate version of this surface, usually used for
* content with high DPI representations like cursors or icons. The size,
* format, and content do not need to match the original surface, and these
* alternate versions will not be updated when the original surface changes.
*
* This function adds a reference to the alternate version, so you should call
* SDL_DestroySurface() on the image after this call.
*
* \param surface the SDL_Surface structure to update.
* \param image a pointer to an alternate SDL_Surface to associate with this
* surface.
* \returns SDL_TRUE if alternate versions are available or SDL_TRUE
* otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_RemoveSurfaceAlternateImages
* \sa SDL_GetSurfaceImages
* \sa SDL_SurfaceHasAlternateImages
*/
extern SDL_DECLSPEC int SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image);
/**
* Return whether a surface has alternate versions available.
*
* \param surface the SDL_Surface structure to query.
* \returns SDL_TRUE if alternate versions are available or SDL_TRUE
* otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AddSurfaceAlternateImage
* \sa SDL_RemoveSurfaceAlternateImages
* \sa SDL_GetSurfaceImages
*/
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surface);
/**
* Get an array including all versions of a surface.
*
* This returns all versions of a surface, with the surface being queried as
* the first element in the returned array.
*
* Freeing the array of surfaces does not affect the surfaces in the array.
* They are still referenced by the surface being queried and will be cleaned
* up normally.
*
* \param surface the SDL_Surface structure to query.
* \param count a pointer filled in with the number of surface pointers
* returned, may be NULL.
* \returns a NULL terminated array of SDL_Surface pointers or NULL on
* failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AddSurfaceAlternateImage
* \sa SDL_RemoveSurfaceAlternateImages
* \sa SDL_SurfaceHasAlternateImages
*/
extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *surface, int *count);
/**
* Remove all alternate versions of a surface.
*
* This function removes a reference from all the alternative versions,
* destroying them if this is the last reference to them.
*
* \param surface the SDL_Surface structure to update.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AddSurfaceAlternateImage
* \sa SDL_GetSurfaceImages
* \sa SDL_SurfaceHasAlternateImages
*/
extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface);
/** /**
* Set up a surface for directly accessing the pixels. * Set up a surface for directly accessing the pixels.
* *
@@ -679,6 +760,9 @@ extern SDL_DECLSPEC int SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMo
/** /**
* Creates a new surface identical to the existing surface. * Creates a new surface identical to the existing surface.
* *
* If the original surface has alternate images, the new surface will have a
* reference to them as well.
*
* The returned surface should be freed with SDL_DestroySurface(). * The returned surface should be freed with SDL_DestroySurface().
* *
* \param surface the surface to duplicate. * \param surface the surface to duplicate.
@@ -691,6 +775,25 @@ extern SDL_DECLSPEC int SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMo
*/ */
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface); extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
/**
* Creates a new surface identical to the existing surface, scaled to the
* desired size.
*
* The returned surface should be freed with SDL_DestroySurface().
*
* \param surface the surface to duplicate and scale.
* \param width the width of the new surface.
* \param height the height of the new surface.
* \param scaleMode the SDL_ScaleMode to be used.
* \returns a copy of the surface or NULL on failure; call SDL_GetError() for
* more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_DestroySurface
*/
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode);
/** /**
* Copy an existing surface to a new surface of the specified format. * Copy an existing surface to a new surface of the specified format.
* *
@@ -702,6 +805,9 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surf
* If you are converting to an indexed surface and want to map colors to a * If you are converting to an indexed surface and want to map colors to a
* palette, you can use SDL_ConvertSurfaceAndColorspace() instead. * palette, you can use SDL_ConvertSurfaceAndColorspace() instead.
* *
* If the original surface has alternate images, the new surface will have a
* reference to them as well.
*
* \param surface the existing SDL_Surface structure to convert. * \param surface the existing SDL_Surface structure to convert.
* \param format the new pixel format. * \param format the new pixel format.
* \returns the new SDL_Surface structure that is created or NULL on failure; * \returns the new SDL_Surface structure that is created or NULL on failure;
@@ -722,6 +828,9 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surfac
* and returns the new surface. This will perform any pixel format and * and returns the new surface. This will perform any pixel format and
* colorspace conversion needed. * colorspace conversion needed.
* *
* If the original surface has alternate images, the new surface will have a
* reference to them as well.
*
* \param surface the existing SDL_Surface structure to convert. * \param surface the existing SDL_Surface structure to convert.
* \param format the new pixel format. * \param format the new pixel format.
* \param palette an optional palette to use for indexed formats, may be NULL. * \param palette an optional palette to use for indexed formats, may be NULL.
@@ -1031,7 +1140,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SD
* \param dst the SDL_Surface structure that is the blit target. * \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the target rectangle in * \param dstrect the SDL_Rect structure representing the target rectangle in
* the destination surface, may not be NULL. * the destination surface, may not be NULL.
* \param scaleMode scale algorithm to be used. * \param scaleMode the SDL_ScaleMode to be used.
* \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.
* *
@@ -1106,15 +1215,19 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src,
* which may be of a different format. * which may be of a different format.
* *
* The pixels in the source surface are split into a 3x3 grid, using the * The pixels in the source surface are split into a 3x3 grid, using the
* corner size for each corner, and the sides and center making up the * different corner sizes for each corner, and the sides and center making up
* remaining pixels. The corners are then scaled using `scale` and fit into * the remaining pixels. The corners are then scaled using `scale` and fit
* the corners of the destination rectangle. The sides and center are then * into the corners of the destination rectangle. The sides and center are
* stretched into place to cover the remaining destination rectangle. * then stretched into place to cover the remaining destination rectangle.
* *
* \param src the SDL_Surface structure to be copied from. * \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be used * \param srcrect the SDL_Rect structure representing the rectangle to be used
* for the 9-grid, or NULL to use the entire surface. * for the 9-grid, or NULL to use the entire surface.
* \param corner_size the size, in pixels, of the corner in `srcrect`. * \param left_width the width, in pixels, of the left corners in `srcrect`.
* \param right_width the width, in pixels, of the right corners in `srcrect`.
* \param top_height the height, in pixels, of the top corners in `srcrect`.
* \param bottom_height the height, in pixels, of the bottom corners in
* `srcrect`.
* \param scale the scale used to transform the corner of `srcrect` into the * \param scale the scale used to transform the corner of `srcrect` into the
* corner of `dstrect`, or 0.0f for an unscaled blit. * corner of `dstrect`, or 0.0f for an unscaled blit.
* \param scaleMode scale algorithm to be used. * \param scaleMode scale algorithm to be used.
@@ -1132,7 +1245,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src,
* *
* \sa SDL_BlitSurface * \sa SDL_BlitSurface
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int corner_size, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect); extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
/** /**
* Map an RGB triple to an opaque pixel value for a surface. * Map an RGB triple to an opaque pixel value for a surface.

View File

@@ -320,6 +320,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void);
/** /**
* Query Android API level of the current device. * Query Android API level of the current device.
* *
* - API level 35: Android 15 (VANILLA_ICE_CREAM)
* - API level 34: Android 14 (UPSIDE_DOWN_CAKE) * - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
* - API level 33: Android 13 (TIRAMISU) * - API level 33: Android 13 (TIRAMISU)
* - API level 32: Android 12L (S_V2) * - API level 32: Android 12L (S_V2)
@@ -410,9 +411,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void);
* *
* https://developer.android.com/reference/android/content/Context#getFilesDir() * https://developer.android.com/reference/android/content/Context#getFilesDir()
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the path used for internal storage or NULL on failure; call * \returns the path used for internal storage or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -452,9 +450,6 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void);
* *
* https://developer.android.com/reference/android/content/Context#getExternalFilesDir() * https://developer.android.com/reference/android/content/Context#getExternalFilesDir()
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the path used for external storage for this application on success * \returns the path used for external storage for this application on success
* or NULL on failure; call SDL_GetError() for more information. * or NULL on failure; call SDL_GetError() for more information.
* *
@@ -476,9 +471,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void)
* *
* https://developer.android.com/reference/android/content/Context#getCacheDir() * https://developer.android.com/reference/android/content/Context#getCacheDir()
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the path used for caches for this application on success or NULL * \returns the path used for caches for this application on success or NULL
* on failure; call SDL_GetError() for more information. * on failure; call SDL_GetError() for more information.
* *
@@ -631,9 +623,6 @@ typedef enum SDL_WinRT_DeviceFamily
* *
* https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param pathType the type of path to retrieve, one of SDL_WinRT_Path. * \param pathType the type of path to retrieve, one of SDL_WinRT_Path.
* \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if
* the path is not available for any reason; call SDL_GetError() for * the path is not available for any reason; call SDL_GetError() for
@@ -716,7 +705,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillResignActive(void); extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterBackground(void);
/** /**
* Let iOS apps with external event handling report * Let iOS apps with external event handling report
@@ -767,7 +756,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void); extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterForeground(void);
#ifdef SDL_PLATFORM_IOS #ifdef SDL_PLATFORM_IOS

View File

@@ -156,6 +156,8 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, SDL_InitFlags flags)
/** /**
* Free the common state object. * Free the common state object.
* *
* You should call SDL_Quit() before calling this function.
*
* \param state The common state object to destroy * \param state The common state object to destroy
*/ */
void SDLTest_CommonDestroyState(SDLTest_CommonState *state); void SDLTest_CommonDestroyState(SDLTest_CommonState *state);
@@ -206,9 +208,16 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state);
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv); SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv);
/** /**
* Common event handler for test windows if you use a standard SDL_main. * Print the details of an event.
* *
* This will free data from the event, like the string in a drop event! * This is automatically called by SDLTest_CommonEvent() as needed.
*
* \param event The event to print.
*/
void SDLTest_PrintEvent(const SDL_Event *event);
/**
* Common event handler for test windows if you use a standard SDL_main.
* *
* \param state The common state used to create test window. * \param state The common state used to create test window.
* \param event The event to handle. * \param event The event to handle.

View File

@@ -330,9 +330,6 @@ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithPropertiesRuntime(S
/** /**
* Get the thread name as it was specified in SDL_CreateThread(). * Get the thread name as it was specified in SDL_CreateThread().
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param thread the thread to query. * \param thread the thread to query.
* \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.

View File

@@ -137,7 +137,8 @@ typedef Uint32 SDL_TimerID;
* The callback function is passed the current timer interval and returns the * The callback function is passed the current timer interval and returns the
* next timer interval, in milliseconds. If the returned value is the same as * next timer interval, in milliseconds. If the returned value is the same as
* the one passed in, the periodic alarm continues, otherwise a new alarm is * the one passed in, the periodic alarm continues, otherwise a new alarm is
* scheduled. If the callback returns 0, the periodic alarm is cancelled. * scheduled. If the callback returns 0, the periodic alarm is canceled and
* will be removed.
* *
* \param userdata an arbitrary pointer provided by the app through * \param userdata an arbitrary pointer provided by the app through
* SDL_AddTimer, for its own use. * SDL_AddTimer, for its own use.
@@ -164,7 +165,7 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(void *userdata, SDL_TimerID timerID,
* The callback function is passed the current timer interval and the user * The callback function is passed the current timer interval and the user
* supplied parameter from the SDL_AddTimer() call and should return the next * supplied parameter from the SDL_AddTimer() call and should return the next
* timer interval. If the value returned from the callback is 0, the timer is * timer interval. If the value returned from the callback is 0, the timer is
* canceled. * canceled and will be removed.
* *
* The callback is run on a separate thread, and for short timeouts can * The callback is run on a separate thread, and for short timeouts can
* potentially be called before this function returns. * potentially be called before this function returns.
@@ -200,7 +201,8 @@ extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerC
* The callback function is passed the current timer interval and returns the * The callback function is passed the current timer interval and returns the
* next timer interval, in nanoseconds. If the returned value is the same as * next timer interval, in nanoseconds. If the returned value is the same as
* the one passed in, the periodic alarm continues, otherwise a new alarm is * the one passed in, the periodic alarm continues, otherwise a new alarm is
* scheduled. If the callback returns 0, the periodic alarm is cancelled. * scheduled. If the callback returns 0, the periodic alarm is canceled and
* will be removed.
* *
* \param userdata an arbitrary pointer provided by the app through * \param userdata an arbitrary pointer provided by the app through
* SDL_AddTimer, for its own use. * SDL_AddTimer, for its own use.
@@ -227,7 +229,7 @@ typedef Uint64 (SDLCALL *SDL_NSTimerCallback)(void *userdata, SDL_TimerID timerI
* The callback function is passed the current timer interval and the user * The callback function is passed the current timer interval and the user
* supplied parameter from the SDL_AddTimerNS() call and should return the * supplied parameter from the SDL_AddTimerNS() call and should return the
* next timer interval. If the value returned from the callback is 0, the * next timer interval. If the value returned from the callback is 0, the
* timer is canceled. * timer is canceled and will be removed.
* *
* The callback is run on a separate thread, and for short timeouts can * The callback is run on a separate thread, and for short timeouts can
* potentially be called before this function returns. * potentially be called before this function returns.

View File

@@ -59,7 +59,7 @@ typedef enum SDL_TouchDeviceType
* *
* \since This struct is available since SDL 3.0.0. * \since This struct is available since SDL 3.0.0.
* *
* \sa SDL_GetTouchFinger * \sa SDL_GetTouchFingers
*/ */
typedef struct SDL_Finger typedef struct SDL_Finger
{ {
@@ -83,24 +83,19 @@ typedef struct SDL_Finger
* Therefore the returned list might be empty, although devices are available. * Therefore the returned list might be empty, although devices are available.
* After using all devices at least once the number will be correct. * After using all devices at least once the number will be correct.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of devices returned, may * \param count a pointer filled in with the number of devices returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of touch device IDs or NULL on failure; call * \returns a 0 terminated array of touch device IDs or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information. This should be freed with
* SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count); extern SDL_DECLSPEC SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count);
/** /**
* Get the touch device name as reported from the driver. * Get the touch device name as reported from the driver.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param touchID the touch device instance ID. * \param touchID the touch device instance ID.
* \returns touch device name, or NULL on failure; call SDL_GetError() for * \returns touch device name, or NULL on failure; call SDL_GetError() for
* more information. * more information.
@@ -122,18 +117,17 @@ extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_Touch
/** /**
* Get a list of active fingers for a given touch device. * Get a list of active fingers for a given touch device.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param touchID the ID of a touch device. * \param touchID the ID of a touch device.
* \param count a pointer filled in with the number of fingers returned, can * \param count a pointer filled in with the number of fingers returned, can
* be NULL. * be NULL.
* \returns a NULL terminated array of SDL_Finger pointers or NULL on failure; * \returns a NULL terminated array of SDL_Finger pointers or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This is a single
* allocation that should be freed with SDL_free() when it is no
* longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_Finger * const * SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count); extern SDL_DECLSPEC SDL_Finger ** SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -155,7 +155,8 @@ typedef Uint64 SDL_WindowFlags;
#define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */ #define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */
#define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */ #define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */
#define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ #define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
#define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000008000) /**< window should always be above others */ #define SDL_WINDOW_MOUSE_RELATIVE_MODE SDL_UINT64_C(0x0000000000008000) /**< window has relative mode enabled */
#define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000010000) /**< window should always be above others */
#define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */ #define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */
#define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */ #define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */
#define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */ #define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */
@@ -349,9 +350,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
* "x11" or "windows". These never have Unicode characters, and are not meant * "x11" or "windows". These never have Unicode characters, and are not meant
* to be proper names. * to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \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**.
* *
@@ -368,9 +366,6 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index);
* "x11" or "windows". These never have Unicode characters, and are not meant * "x11" or "windows". These never have Unicode characters, and are not meant
* to be proper names. * to be proper names.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \returns the name of the current video driver or NULL if no driver has been * \returns the name of the current video driver or NULL if no driver has been
* initialized. * initialized.
* *
@@ -393,17 +388,15 @@ extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void);
/** /**
* Get a list of currently connected displays. * Get a list of currently connected displays.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of displays returned, may * \param count a pointer filled in with the number of displays returned, may
* be NULL. * be NULL.
* \returns a 0 terminated array of display instance IDs or NULL on failure; * \returns a 0 terminated array of display instance IDs or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count); extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count);
/** /**
* Return the primary display. * Return the primary display.
@@ -449,9 +442,6 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa
/** /**
* Get the name of a display in UTF-8 encoding. * Get the name of a display in UTF-8 encoding.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param displayID the instance ID of the display to query. * \param displayID the instance ID of the display to query.
* \returns the name of a display or NULL on failure; call SDL_GetError() for * \returns the name of a display or NULL on failure; call SDL_GetError() for
* more information. * more information.
@@ -559,20 +549,19 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displ
* - refresh rate -> highest to lowest * - refresh rate -> highest to lowest
* - pixel density -> lowest to highest * - pixel density -> lowest to highest
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param displayID the instance ID of the display to query. * \param displayID the instance ID of the display to query.
* \param count a pointer filled in with the number of display modes returned, * \param count a pointer filled in with the number of display modes returned,
* may be NULL. * may be NULL.
* \returns a NULL terminated array of display mode pointers or NULL on * \returns a NULL terminated array of display mode pointers or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information. This is a
* single allocation that should be freed with SDL_free() when it is
* no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplays * \sa SDL_GetDisplays
*/ */
extern SDL_DECLSPEC const SDL_DisplayMode * const * SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count); extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
/** /**
* Get the closest match to the requested display mode. * Get the closest match to the requested display mode.
@@ -591,16 +580,17 @@ extern SDL_DECLSPEC const SDL_DisplayMode * const * SDLCALL SDL_GetFullscreenDis
* for the desktop refresh rate. * for the desktop refresh rate.
* \param include_high_density_modes boolean to include high density modes in * \param include_high_density_modes boolean to include high density modes in
* the search. * the search.
* \returns a pointer to the closest display mode equal to or larger than the * \param mode a pointer filled in with the closest display mode equal to or
* desired mode, or NULL on failure; call SDL_GetError() for more * larger than the desired mode.
* information. * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplays * \sa SDL_GetDisplays
* \sa SDL_GetFullscreenDisplayModes * \sa SDL_GetFullscreenDisplayModes
*/ */
extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes); extern SDL_DECLSPEC int SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes, SDL_DisplayMode *mode);
/** /**
* Get information about the desktop's display mode. * Get information about the desktop's display mode.
@@ -773,17 +763,15 @@ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode(
/** /**
* Get the raw ICC profile data for the screen the window is currently on. * Get the raw ICC profile data for the screen the window is currently on.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param window the window to query. * \param window the window to query.
* \param size the size of the ICC profile. * \param size the size of the ICC profile.
* \returns the raw ICC profile data on success or NULL on failure; call * \returns the raw ICC profile data on success or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information. This should be freed with
* SDL_free() when it is no longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC const void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size); extern SDL_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.
@@ -800,17 +788,16 @@ extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetWindowPixelFormat(SDL_Window
/** /**
* Get a list of valid windows. * Get a list of valid windows.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of windows returned, may * \param count a pointer filled in with the number of windows returned, may
* be NULL. * be NULL.
* \returns a NULL terminated array of SDL_Window pointers or NULL on failure; * \returns a NULL terminated array of SDL_Window pointers or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information. This is a single
* allocation that should be freed with SDL_free() when it is no
* longer needed.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC SDL_Window * const * SDLCALL SDL_GetWindows(int *count); extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count);
/** /**
* Create a window with the specified dimensions and flags. * Create a window with the specified dimensions and flags.
@@ -1335,9 +1322,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowTitle(SDL_Window *window, const cha
/** /**
* Get the title of a window. * Get the title of a window.
* *
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param window the window to query. * \param window the window to query.
* \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.
@@ -1351,6 +1335,15 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
/** /**
* Set the icon for a window. * Set the icon for a window.
* *
* If this function is passed a surface with alternate representations, the
* surface will be interpreted as the content to be used for 100% display
* scale, and the alternate representations will be used for high DPI
* situations. For example, if the original surface is 32x32, then on a 2x
* macOS display or 200% display scale on Windows, a 64x64 version of the
* image will be used, if available. If a matching version of the image isn't
* available, the closest size image will be scaled to the appropriate size
* and be used instead.
*
* \param window the window to change. * \param window the window to change.
* \param icon an SDL_Surface structure containing the icon for the window. * \param icon an SDL_Surface structure containing the icon for the window.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
@@ -1480,6 +1473,26 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h); extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
/**
* Get the safe area for this window.
*
* Some devices have portions of the screen which are partially obscured or
* not interactive, possibly due to on-screen controls, curved edges, camera
* notches, TV overscan, etc. This function provides the area of the window
* which is safe to have interactible content. You should continue rendering
* into the rest of the window, but it should not contain visually important
* or interactible content.
*
* \param window the window to query.
* \param rect a pointer filled in with the client area that is safe for
* interactive content.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect);
/** /**
* Request that the aspect ratio of a window's client area be set. * Request that the aspect ratio of a window's client area be set.
* *
@@ -2522,7 +2535,7 @@ extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GL_GetCurrentEGLDisplay * \sa SDL_EGL_GetCurrentDisplay
*/ */
extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc); extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
@@ -2671,7 +2684,7 @@ extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentEGLDisplay(void); extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void);
/** /**
* Get the currently active EGL config. * Get the currently active EGL config.
@@ -2681,7 +2694,7 @@ extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentEGLDisplay(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void); extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void);
/** /**
* Get the EGL surface associated with the window. * Get the EGL surface associated with the window.
@@ -2692,7 +2705,7 @@ extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowEGLSurface(SDL_Window *window); extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window);
/** /**
* Sets the callbacks for defining custom EGLAttrib arrays for EGL * Sets the callbacks for defining custom EGLAttrib arrays for EGL
@@ -2716,7 +2729,7 @@ extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowEGLSurface(SDL_Windo
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
SDL_EGLIntArrayCallback surfaceAttribCallback, SDL_EGLIntArrayCallback surfaceAttribCallback,
SDL_EGLIntArrayCallback contextAttribCallback); SDL_EGLIntArrayCallback contextAttribCallback);

View File

@@ -88,8 +88,8 @@ namespace Flax.Deps.Dependencies
Path.Combine(root, "include", "SDL3"), Path.Combine(root, "include", "SDL3"),
}; };
CloneGitRepoFastSince(root, "https://github.com/libsdl-org/SDL.git", new System.DateTime(2024, 7, 15)); CloneGitRepoFastSince(root, "https://github.com/libsdl-org/SDL.git", new DateTime(2024, 8, 5));
GitResetToCommit(root, "ff7a60db85f53c249cbd277915452b4c67323765"); GitResetToCommit(root, "627cb8acd09e6cbf8362d808634a26f37382c73d");
foreach (var platform in options.Platforms) foreach (var platform in options.Platforms)
{ {