From 66351fd4ba6b862c26d325a5286f37d523303a27 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 28 Dec 2022 17:06:38 -0800
Subject: [PATCH] Replace tri-state functions SDL_EventState(),
SDL_GetJoystickEventState(), SDL_GetGamepadEventState(), SDL_ShowCursor()
`SDL_QUERY`, `SDL_IGNORE`, `SDL_ENABLE`, and `SDL_DISABLE` have been removed.
SDL_EventState() has been replaced with SDL_SetEventEnabled()
SDL_GetEventState() has been replaced with SDL_EventEnabled()
SDL_GameControllerEventState has been replaced with SDL_SetGamepadEventsEnabled() and SDL_GamepadEventsEnabled()
SDL_JoystickEventState has been replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()
SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()
Fixes https://github.com/libsdl-org/SDL/issues/6929
---
docs/README-migration.md | 19 ++++--
include/SDL3/SDL_events.h | 45 ++++---------
include/SDL3/SDL_gamepad.h | 30 ++++++---
include/SDL3/SDL_joystick.h | 47 ++++++-------
include/SDL3/SDL_mouse.h | 43 ++++++++----
include/SDL3/SDL_oldnames.h | 4 --
include/SDL3/SDL_syswm.h | 2 +-
src/audio/SDL_audio.c | 6 +-
src/core/haiku/SDL_BApp.h | 4 +-
src/dynapi/SDL_dynapi.sym | 14 ++--
src/dynapi/SDL_dynapi_overrides.h | 14 ++--
src/dynapi/SDL_dynapi_procs.h | 14 ++--
src/events/SDL_clipboardevents.c | 2 +-
src/events/SDL_displayevents.c | 2 +-
src/events/SDL_dropevents.c | 2 +-
src/events/SDL_events.c | 61 +++++++++--------
src/events/SDL_keyboard.c | 10 +--
src/events/SDL_mouse.c | 44 +++++++------
src/events/SDL_touch.c | 6 +-
src/events/SDL_windowevents.c | 2 +-
src/joystick/SDL_gamepad.c | 72 ++++++++++----------
src/joystick/SDL_joystick.c | 73 +++++++++++----------
src/sensor/SDL_sensor.c | 2 +-
src/video/SDL_video.c | 22 ++++---
src/video/cocoa/SDL_cocoakeyboard.m | 2 +-
src/video/emscripten/SDL_emscriptenevents.c | 14 ++--
src/video/haiku/SDL_BApp.h | 4 +-
src/video/uikit/SDL_uikitview.m | 2 +-
src/video/wayland/SDL_waylandevents.c | 4 +-
src/video/windows/SDL_windowsevents.c | 2 +-
src/video/x11/SDL_x11events.c | 12 ++--
test/testautomation_mouse.c | 50 +++++++-------
test/testcustomcursor.c | 10 ++-
test/testdropfile.c | 2 +-
test/testoverlay2.c | 2 +-
test/testwm2.c | 4 +-
36 files changed, 343 insertions(+), 305 deletions(-)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 8d3e77c740c8..d42785155c96 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -82,12 +82,11 @@ The `timestamp_us` member of the sensor events has been renamed `sensor_timestam
You should set the `event.common.timestamp` field before passing an event to `SDL_PushEvent()`. If the timestamp is 0 it will be filled in with `SDL_GetTicksNS()`.
-`SDL_GetEventState` used to be a macro, now it's a real function, but otherwise functions identically.
-
The `SDL_DISPLAYEVENT_*` events have been moved to top level events, and `SDL_DISPLAYEVENT` has been removed. In general, handling this change just means checking for the individual events instead of first checking for `SDL_DISPLAYEVENT` and then checking for display events. You can compare the event >= `SDL_DISPLAYEVENT_FIRST` and <= `SDL_DISPLAYEVENT_LAST` if you need to see whether it's a display event.
The `SDL_WINDOWEVENT_*` events have been moved to top level events, and `SDL_WINDOWEVENT` has been removed. In general, handling this change just means checking for the individual events instead of first checking for `SDL_WINDOWEVENT` and then checking for window events. You can compare the event >= `SDL_WINDOWEVENT_FIRST` and <= `SDL_WINDOWEVENT_LAST` if you need to see whether it's a window event.
+`SDL_QUERY`, `SDL_IGNORE`, `SDL_ENABLE`, and `SDL_DISABLE` have been removed. You can use the functions SDL_SetEventEnabled() and SDL_EventEnabled() to set and query event processing state.
The following symbols have been renamed:
* SDL_CONTROLLERAXISMOTION => SDL_GAMEPADAXISMOTION
@@ -108,6 +107,10 @@ The following structures have been renamed:
* SDL_ControllerSensorEvent => SDL_GamepadSensorEvent
* SDL_ControllerTouchpadEvent => SDL_GamepadTouchpadEvent
+The following functions have been removed:
+* SDL_EventState() - replaced with SDL_SetEventEnabled()
+* SDL_GetEventState() - replaced with SDL_EventEnabled()
+
## SDL_gamecontroller.h
SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.
@@ -133,7 +136,6 @@ The following functions have been renamed:
* SDL_GameControllerAddMappingsFromFile => SDL_AddGamepadMappingsFromFile
* SDL_GameControllerAddMappingsFromRW => SDL_AddGamepadMappingsFromRW
* SDL_GameControllerClose => SDL_CloseGamepad
-* SDL_GameControllerEventState => SDL_GetGamepadEventState
* SDL_GameControllerFromInstanceID => SDL_GetGamepadFromInstanceID
* SDL_GameControllerFromPlayerIndex => SDL_GetGamepadFromPlayerIndex
* SDL_GameControllerGetAppleSFSymbolsNameForAxis => SDL_GetGamepadAppleSFSymbolsNameForAxis
@@ -184,10 +186,11 @@ The following functions have been renamed:
* SDL_IsGameController => SDL_IsGamepad
The following functions have been removed:
+* SDL_GameControllerEventState - replaced with SDL_SetGamepadEventsEnabled() and SDL_GamepadEventsEnabled()
+* SDL_GameControllerMappingForDeviceIndex() - replaced with SDL_GetGamepadInstanceMapping()
* SDL_GameControllerNameForIndex() - replaced with SDL_GetGamepadInstanceName()
* SDL_GameControllerPathForIndex() - replaced with SDL_GetGamepadInstancePath()
* SDL_GameControllerTypeForIndex() - replaced with SDL_GetGamepadInstanceType()
-* SDL_GameControllerMappingForDeviceIndex() - replaced with SDL_GetGamepadInstanceMapping()
The following symbols have been renamed:
* SDL_CONTROLLER_AXIS_INVALID => SDL_GAMEPAD_AXIS_INVALID
@@ -302,7 +305,6 @@ The following functions have been renamed:
* SDL_JoystickClose => SDL_CloseJoystick
* SDL_JoystickCurrentPowerLevel => SDL_GetJoystickPowerLevel
* SDL_JoystickDetachVirtual => SDL_DetachVirtualJoystick
-* SDL_JoystickEventState => SDL_GetJoystickEventState
* SDL_JoystickFromInstanceID => SDL_GetJoystickFromInstanceID
* SDL_JoystickFromPlayerIndex => SDL_GetJoystickFromPlayerIndex
* SDL_JoystickGetAttached => SDL_IsJoystickConnected
@@ -342,7 +344,7 @@ The following symbols have been renamed:
* SDL_JOYSTICK_TYPE_GAMECONTROLLER => SDL_JOYSTICK_TYPE_GAMEPAD
The following functions have been removed:
-* SDL_NumJoysticks - replaced with SDL_HasJoysticks() and SDL_GetJoysticks()
+* SDL_JoystickEventState - replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()
* SDL_JoystickGetDeviceGUID() - replaced with SDL_GetJoystickInstanceGUID()
* SDL_JoystickGetDeviceInstanceID()
* SDL_JoystickGetDevicePlayerIndex() - replaced with SDL_GetJoystickInstancePlayerIndex()
@@ -352,6 +354,7 @@ The following functions have been removed:
* SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickInstanceVendor()
* SDL_JoystickNameForIndex() - replaced with SDL_GetJoystickInstanceName()
* SDL_JoystickPathForIndex() - replaced with SDL_GetJoystickInstancePath()
+* SDL_NumJoysticks - replaced with SDL_HasJoysticks() and SDL_GetJoysticks()
## SDL_keycode.h
@@ -404,6 +407,10 @@ Furthermore, the different `SDL_*RunApp()` functions (SDL_WinRtRunApp, SDL_GDKRu
have been unified into just `int SDL_RunApp(int argc, char* argv[], void * reserved)` (which is also
used by additional platforms that didn't have a SDL_RunApp-like function before).
+## SDL_mouse.h
+
+SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()
+
## SDL_pixels.h
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index 44923e1ec618..6e068ff40c43 100644
--- a/include/SDL3/SDL_events.h
+++ b/include/SDL3/SDL_events.h
@@ -516,7 +516,7 @@ typedef struct SDL_TouchFingerEvent
/**
* \brief An event used to request a file open by the system (event.drop.*)
- * This event is enabled by default, you can disable it with SDL_EventState().
+ * This event is enabled by default, you can disable it with SDL_SetEventEnabled().
* \note If this event is enabled, you must free the filename in the event.
*/
typedef struct SDL_DropEvent
@@ -577,7 +577,7 @@ typedef struct SDL_SysWMmsg SDL_SysWMmsg;
/**
* \brief A video driver dependent system event (event.syswm.*)
- * This event is disabled by default, you can enable it with SDL_EventState()
+ * This event is disabled by default, you can enable it with SDL_SetEventEnabled()
*
* \note If you want to use this event, you should include SDL_syswm.h.
*/
@@ -969,7 +969,7 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
* closed, otherwise the window will remain open if possible.
*
* Note: Disabled events never make it to the event filter function; see
- * SDL_EventState().
+ * SDL_SetEventEnabled().
*
* Note: If you just want to inspect events without filtering, you should use
* SDL_AddEventWatch() instead.
@@ -984,7 +984,7 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AddEventWatch
- * \sa SDL_EventState
+ * \sa SDL_SetEventEnabled
* \sa SDL_GetEventFilter
* \sa SDL_PeepEvents
* \sa SDL_PushEvent
@@ -1074,52 +1074,29 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
void *userdata);
-/* @{ */
-#define SDL_QUERY -1
-#define SDL_IGNORE 0
-#define SDL_DISABLE 0
-#define SDL_ENABLE 1
-
/**
- * Set or query the state of processing events by type.
- *
- * `state` may be any of the following:
- *
- * - `SDL_QUERY`: returns the current processing state of the specified event
- * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
- * from the event queue and will not be filtered
- * - `SDL_ENABLE`: the event will be processed normally
+ * Set the state of processing events by type.
*
* \param type the type of event; see SDL_EventType for details
- * \param state how to process the event
- * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
- * of the event before this function makes any changes to it.
+ * \param state whether to process the event or not
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_GetEventState
+ * \sa SDL_IsEventEnabled
*/
-extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
+extern DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, SDL_bool enabled);
/**
* Query the state of processing events by type.
*
- * This is equivalent to calling `SDL_EventState(type, SDL_QUERY)`.
- *
- * In SDL3, this is a proper function, but in SDL2, this was a macro.
- *
* \param type the type of event; see SDL_EventType for details
- * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
- * of the event before this function makes any changes to it.
+ * \returns SDL_TRUE if the event is being processed, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_EventState
+ * \sa SDL_SetEventEnabled
*/
-extern DECLSPEC Uint8 SDLCALL SDL_GetEventState(Uint32 type);
-
-/* @} */
-
+extern DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
/**
* Allocate a set of user-defined events, and return the beginning event
diff --git a/include/SDL3/SDL_gamepad.h b/include/SDL3/SDL_gamepad.h
index ba84ada1b732..a1dcf89366a1 100644
--- a/include/SDL3/SDL_gamepad.h
+++ b/include/SDL3/SDL_gamepad.h
@@ -184,7 +184,7 @@ typedef struct SDL_GamepadBinding
extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mappingString);
/**
- * Load a set of Game Controller mappings from a seekable SDL data stream.
+ * Load a set of gamepad mappings from a seekable SDL data stream.
*
* You can call this function several times, if needed, to load different
* database files.
@@ -256,7 +256,7 @@ extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForIndex(int mapping_index);
extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid);
/**
- * Get the current mapping of a Game Controller.
+ * Get the current mapping of a gamepad.
*
* The returned string must be freed with SDL_free().
*
@@ -649,24 +649,34 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGamepadConnected(SDL_Gamepad *gamepad);
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
/**
- * Query or change current state of Game Controller events.
+ * Set the state of gamepad event processing.
*
* If gamepad events are disabled, you must call SDL_UpdateGamepads()
* yourself and check the state of the gamepad when you want gamepad
* information.
*
- * Any number can be passed to SDL_GetGamepadEventState(), but only -1, 0,
- * and 1 will have any effect. Other numbers will just be returned.
+ * \param state whether to process gamepad events or not
*
- * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
- * \returns the same value passed to the function, with exception to -1
- * (SDL_QUERY), which will return the current state.
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GamepadEventsEnabled
+ */
+extern DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(SDL_bool enabled);
+
+/**
+ * Query the state of gamepad event processing.
+ *
+ * If gamepad events are disabled, you must call SDL_UpdateGamepads()
+ * yourself and check the state of the gamepad when you want gamepad
+ * information.
+ *
+ * \returns SDL_TRUE if gamepad events are being processed, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_GetJoystickEventState
+ * \sa SDL_SetGamepadEventsEnabled
*/
-extern DECLSPEC int SDLCALL SDL_GetGamepadEventState(int state);
+extern DECLSPEC SDL_bool SDLCALL SDL_GamepadEventsEnabled(void);
/**
* Manually pump gamepad updates if not using the loop.
diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h
index 75d3ec418d65..5e2742e92729 100644
--- a/include/SDL3/SDL_joystick.h
+++ b/include/SDL3/SDL_joystick.h
@@ -107,6 +107,9 @@ typedef enum
SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel;
+#define SDL_JOYSTICK_AXIS_MAX 32767
+#define SDL_JOYSTICK_AXIS_MIN -32768
+
/* Set max recognized G-force from accelerometer
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
*/
@@ -717,44 +720,44 @@ extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
/**
- * Update the current state of the open joysticks.
+ * Set the state of joystick event processing.
*
- * This is called automatically by the event loop if any joystick events are
- * enabled.
+ * If joystick events are disabled, you must call SDL_UpdateJoysticks()
+ * yourself and check the state of the joystick when you want joystick
+ * information.
+ *
+ * \param state whether to process joystick events or not
*
* \since This function is available since SDL 3.0.0.
*
- * \sa SDL_GetJoystickEventState
+ * \sa SDL_JoystickEventsEnabled
*/
-extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
+extern DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
/**
- * Enable/disable joystick event polling.
+ * Query the state of joystick event processing.
*
* If joystick events are disabled, you must call SDL_UpdateJoysticks()
- * yourself and manually check the state of the joystick when you want
- * joystick information.
+ * yourself and check the state of the joystick when you want joystick
+ * information.
*
- * It is recommended that you leave joystick event handling enabled.
+ * \returns SDL_TRUE if joystick events are being processed, SDL_FALSE otherwise.
*
- * **WARNING**: Calling this function may delete all events currently in SDL's
- * event queue.
+ * \since This function is available since SDL 3.0.0.
*
- * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
- * \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
- * call SDL_GetError() for more information.
+ * \sa SDL_SetJoystickEventsEnabled
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_JoystickEventsEnabled(void);
+
+/**
+ * Update the current state of the open joysticks.
*
- * If `state` is `SDL_QUERY` then the current state is returned,
- * otherwise the new processing state is returned.
+ * This is called automatically by the event loop if any joystick events are
+ * enabled.
*
* \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetGamepadEventState
*/
-extern DECLSPEC int SDLCALL SDL_GetJoystickEventState(int state);
-
-#define SDL_JOYSTICK_AXIS_MAX 32767
-#define SDL_JOYSTICK_AXIS_MIN -32768
+extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
/**
* Get the current state of an axis control on a joystick.
diff --git a/include/SDL3/SDL_mouse.h b/include/SDL3/SDL_mouse.h
index f74e2b8b321b..d9860680242c 100644
--- a/include/SDL3/SDL_mouse.h
+++ b/include/SDL3/SDL_mouse.h
@@ -318,7 +318,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
*
* \sa SDL_FreeCursor
* \sa SDL_SetCursor
- * \sa SDL_ShowCursor
*/
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
const Uint8 * mask,
@@ -370,7 +369,6 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
*
* \sa SDL_CreateCursor
* \sa SDL_GetCursor
- * \sa SDL_ShowCursor
*/
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
@@ -419,26 +417,43 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
/**
- * Toggle whether or not the cursor is shown.
+ * Show the cursor.
*
- * The cursor starts off displayed but can be turned off. Passing `SDL_ENABLE`
- * displays the cursor and passing `SDL_DISABLE` hides it.
+ * \returns 0 on success or a negative error code on failure; call
+ * SDL_GetError() for more information.
*
- * The current state of the mouse cursor can be queried by passing
- * `SDL_QUERY`; either `SDL_DISABLE` or `SDL_ENABLE` will be returned.
+ * \since This function is available since SDL 3.0.0.
*
- * \param toggle `SDL_ENABLE` to show the cursor, `SDL_DISABLE` to hide it,
- * `SDL_QUERY` to query the current state without changing it.
- * \returns `SDL_ENABLE` if the cursor is shown, or `SDL_DISABLE` if the
- * cursor is hidden, or a negative error code on failure; call
+ * \sa SDL_CursorVisible
+ * \sa SDL_HideCursor
+ */
+extern DECLSPEC int SDLCALL SDL_ShowCursor(void);
+
+/**
+ * Hide the cursor.
+ *
+ * \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_CreateCursor
- * \sa SDL_SetCursor
+ * \sa SDL_CursorVisible
+ * \sa SDL_ShowCursor
+ */
+extern DECLSPEC int SDLCALL SDL_HideCursor(void);
+
+/**
+ * Return whether the cursor is currently being shown.
+ *
+ * \returns `SDL_TRUE` if the cursor is being shown, or `SDL_FALSE` if the
+ * cursor is hidden.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_HideCursor
+ * \sa SDL_ShowCursor
*/
-extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
+extern DECLSPEC SDL_bool SDLCALL SDL_CursorVisible(void);
/**
* Used as a mask when testing buttons in buttonstate.
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 4f6e17e9b5f3..269e27e7f2d3 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -125,7 +125,6 @@
#define SDL_GameControllerButton SDL_GamepadButton
#define SDL_GameControllerButtonBind SDL_GamepadBinding
#define SDL_GameControllerClose SDL_CloseGamepad
-#define SDL_GameControllerEventState SDL_GetGamepadEventState
#define SDL_GameControllerFromInstanceID SDL_GetGamepadFromInstanceID
#define SDL_GameControllerFromPlayerIndex SDL_GetGamepadFromPlayerIndex
#define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GetGamepadAppleSFSymbolsNameForAxis
@@ -184,7 +183,6 @@
#define SDL_JoystickClose SDL_CloseJoystick
#define SDL_JoystickCurrentPowerLevel SDL_GetJoystickPowerLevel
#define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick
-#define SDL_JoystickEventState SDL_GetJoystickEventState
#define SDL_JoystickFromInstanceID SDL_GetJoystickFromInstanceID
#define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex
#define SDL_JoystickGetAttached SDL_IsJoystickConnected
@@ -437,7 +435,6 @@
#define SDL_GameControllerButton SDL_GameControllerButton_renamed_SDL_GamepadButton
#define SDL_GameControllerButtonBind SDL_GameControllerButtonBind_renamed_SDL_GamepadBinding
#define SDL_GameControllerClose SDL_GameControllerClose_renamed_SDL_CloseGamepad
-#define SDL_GameControllerEventState SDL_GameControllerEventState_renamed_SDL_GetGamepadEventState
#define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_renamed_SDL_GetGamepadFromInstanceID
#define SDL_GameControllerFromPlayerIndex SDL_GameControllerFromPlayerIndex_renamed_SDL_GetGamepadFromPlayerIndex
#define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GameControllerGetAppleSFSymbolsNameForAxis_renamed_SDL_GetGamepadAppleSFSymbolsNameForAxis
@@ -500,7 +497,6 @@
#define SDL_JoystickClose SDL_JoystickClose_renamed_SDL_CloseJoystick
#define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_renamed_SDL_GetJoystickPowerLevel
#define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick
-#define SDL_JoystickEventState SDL_JoystickEventState_renamed_SDL_GetJoystickEventState
#define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromInstanceID
#define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex
#define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_IsJoystickConnected
diff --git a/include/SDL3/SDL_syswm.h b/include/SDL3/SDL_syswm.h
index d1b53e646a7c..36145dbe1be9 100644
--- a/include/SDL3/SDL_syswm.h
+++ b/include/SDL3/SDL_syswm.h
@@ -39,7 +39,7 @@
* Your application has access to a special type of event ::SDL_SYSWMEVENT,
* which contains window-manager specific information and arrives whenever
* an unhandled window event occurs. This event is ignored by default, but
- * you can enable it with SDL_EventState().
+ * you can enable it with SDL_SetEventEnabled().
*
* As of SDL 3.0, this file no longer includes the platform specific headers
* and types. You should include the headers you need and define one or more
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 880975eee77b..aee7d8420ec0 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -412,7 +412,7 @@ void SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpe
const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle);
if (device_index != -1) {
/* Post the event, if desired */
- if (SDL_GetEventState(SDL_AUDIODEVICEADDED) == SDL_ENABLE) {
+ if (SDL_EventEnabled(SDL_AUDIODEVICEADDED)) {
SDL_Event event;
event.type = SDL_AUDIODEVICEADDED;
event.common.timestamp = 0;
@@ -443,7 +443,7 @@ void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
current_audio.impl.UnlockDevice(device);
/* Post the event, if desired */
- if (SDL_GetEventState(SDL_AUDIODEVICEREMOVED) == SDL_ENABLE) {
+ if (SDL_EventEnabled(SDL_AUDIODEVICEREMOVED)) {
SDL_Event event;
event.type = SDL_AUDIODEVICEREMOVED;
event.common.timestamp = 0;
@@ -495,7 +495,7 @@ void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
Note that opened devices will send the non-zero event in
SDL_OpenedAudioDeviceDisconnected(). */
if (!device_was_opened) {
- if (SDL_GetEventState(SDL_AUDIODEVICEREMOVED) == SDL_ENABLE) {
+ if (SDL_EventEnabled(SDL_AUDIODEVICEREMOVED)) {
SDL_Event event;
event.type = SDL_AUDIODEVICEREMOVED;
event.common.timestamp = 0;
diff --git a/src/core/haiku/SDL_BApp.h b/src/core/haiku/SDL_BApp.h
index a766411a0063..fa108a5c4da0 100644
--- a/src/core/haiku/SDL_BApp.h
+++ b/src/core/haiku/SDL_BApp.h
@@ -260,7 +260,7 @@ class SDL_BApp : public BApplication
be_app->HideCursor();
} else {
SDL_SendMouseMotion(0, win, 0, 0, x, y);
- if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
+ if (SDL_CursorVisible() && be_app->IsCursorHidden())
be_app->ShowCursor();
}
}
@@ -311,7 +311,7 @@ class SDL_BApp : public BApplication
HAIKU_SetKeyState(scancode, state);
SDL_SendKeyboardKey(0, state, HAIKU_GetScancodeFromBeKey(scancode));
- if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
+ if (state == SDL_PRESSED && SDL_EventEnabled(SDL_TEXTINPUT)) {
const int8 *keyUtf8;
ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 64c73fdedf0f..328b9cc4775d 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -101,7 +101,6 @@ SDL3_0.0.0 {
SDL_EGL_SetEGLAttributeCallbacks;
SDL_EnableScreenSaver;
SDL_Error;
- SDL_EventState;
SDL_FillSurfaceRect;
SDL_FillSurfaceRects;
SDL_FilterEvents;
@@ -173,7 +172,6 @@ SDL3_0.0.0 {
SDL_GetError;
SDL_GetErrorMsg;
SDL_GetEventFilter;
- SDL_GetEventState;
SDL_GetGamepadAppleSFSymbolsNameForAxis;
SDL_GetGamepadAppleSFSymbolsNameForButton;
SDL_GetGamepadAxis;
@@ -182,7 +180,6 @@ SDL3_0.0.0 {
SDL_GetGamepadBindForButton;
SDL_GetGamepadButton;
SDL_GetGamepadButtonFromString;
- SDL_GetGamepadEventState;
SDL_GetGamepadFirmwareVersion;
SDL_GetGamepadFromInstanceID;
SDL_GetGamepadFromPlayerIndex;
@@ -222,7 +219,6 @@ SDL3_0.0.0 {
SDL_GetJoystickAxis;
SDL_GetJoystickAxisInitialState;
SDL_GetJoystickButton;
- SDL_GetJoystickEventState;
SDL_GetJoystickFirmwareVersion;
SDL_GetJoystickFromInstanceID;
SDL_GetJoystickFromPlayerIndex;
@@ -657,7 +653,6 @@ SDL3_0.0.0 {
SDL_SetWindowTitle;
SDL_SetWindowsMessageHook;
SDL_SetYUVConversionMode;
- SDL_ShowCursor;
SDL_ShowMessageBox;
SDL_ShowSimpleMessageBox;
SDL_ShowWindow;
@@ -855,6 +850,15 @@ SDL3_0.0.0 {
SDL_wcsncasecmp;
SDL_wcsncmp;
SDL_wcsstr;
+ SDL_SetEventEnabled;
+ SDL_EventEnabled;
+ SDL_SetGamepadEventsEnabled;
+ SDL_GamepadEventsEnabled;
+ SDL_SetJoystickEventsEnabled;
+ SDL_JoystickEventsEnabled;
+ SDL_ShowCursor;
+ SDL_HideCursor;
+ SDL_CursorVisible;
# extra symbols go here (don't modify this line)
local: *;
};
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 936b61c0988e..7c77747cc567 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -127,7 +127,6 @@
#define SDL_EGL_SetEGLAttributeCallbacks SDL_EGL_SetEGLAttributeCallbacks_REAL
#define SDL_EnableScreenSaver SDL_EnableScreenSaver_REAL
#define SDL_Error SDL_Error_REAL
-#define SDL_EventState SDL_EventState_REAL
#define SDL_FillSurfaceRect SDL_FillSurfaceRect_REAL
#define SDL_FillSurfaceRects SDL_FillSurfaceRects_REAL
#define SDL_FilterEvents SDL_FilterEvents_REAL
@@ -199,7 +198,6 @@
#define SDL_GetError SDL_GetError_REAL
#define SDL_GetErrorMsg SDL_GetErrorMsg_REAL
#define SDL_GetEventFilter SDL_GetEventFilter_REAL
-#define SDL_GetEventState SDL_GetEventState_REAL
#define SDL_GetGamepadAppleSFSymbolsNameForAxis SDL_GetGamepadAppleSFSymbolsNameForAxis_REAL
#define SDL_GetGamepadAppleSFSymbolsNameForButton SDL_GetGamepadAppleSFSymbolsNameForButton_REAL
#define SDL_GetGamepadAxis SDL_GetGamepadAxis_REAL
@@ -208,7 +206,6 @@
#define SDL_GetGamepadBindForButton SDL_GetGamepadBindForButton_REAL
#define SDL_GetGamepadButton SDL_GetGamepadButton_REAL
#define SDL_GetGamepadButtonFromString SDL_GetGamepadButtonFromString_REAL
-#define SDL_GetGamepadEventState SDL_GetGamepadEventState_REAL
#define SDL_GetGamepadFirmwareVersion SDL_GetGamepadFirmwareVersion_REAL
#define SDL_GetGamepadFromInstanceID SDL_GetGamepadFromInstanceID_REAL
#define SDL_GetGamepadFromPlayerIndex SDL_GetGamepadFromPlayerIndex_REAL
@@ -248,7 +245,6 @@
#define SDL_GetJoystickAxis SDL_GetJoystickAxis_REAL
#define SDL_GetJoystickAxisInitialState SDL_GetJoystickAxisInitialState_REAL
#define SDL_GetJoystickButton SDL_GetJoystickButton_REAL
-#define SDL_GetJoystickEventState SDL_GetJoystickEventState_REAL
#define SDL_GetJoystickFirmwareVersion SDL_GetJoystickFirmwareVersion_REAL
#define SDL_GetJoystickFromInstanceID SDL_GetJoystickFromInstanceID_REAL
#define SDL_GetJoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex_REAL
@@ -683,7 +679,6 @@
#define SDL_SetWindowTitle SDL_SetWindowTitle_REAL
#define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL
#define SDL_SetYUVConversionMode SDL_SetYUVConversionMode_REAL
-#define SDL_ShowCursor SDL_ShowCursor_REAL
#define SDL_ShowMessageBox SDL_ShowMessageBox_REAL
#define SDL_ShowSimpleMessageBox SDL_ShowSimpleMessageBox_REAL
#define SDL_ShowWindow SDL_ShowWindow_REAL
@@ -883,3 +878,12 @@
#define SDL_wcsstr SDL_wcsstr_REAL
/* New API symbols are added at the end */
+#define SDL_SetEventEnabled SDL_SetEventEnabled_REAL
+#define SDL_EventEnabled SDL_EventEnabled_REAL
+#define SDL_SetGamepadEventsEnabled SDL_SetGamepadEventsEnabled_REAL
+#define SDL_GamepadEventsEnabled SDL_GamepadEventsEnabled_REAL
+#define SDL_SetJoystickEventsEnabled SDL_SetJoystickEventsEnabled_REAL
+#define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL
+#define SDL_ShowCursor SDL_ShowCursor_REAL
+#define SDL_HideCursor SDL_HideCursor_REAL
+#define SDL_CursorVisible SDL_CursorVisible_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index bebc2691964f..62953b55d499 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -204,7 +204,6 @@ SDL_DYNAPI_PROC(SDL_EGLSurface,SDL_EGL_GetWindowEGLSurface,(SDL_Window *a),(a),r
SDL_DYNAPI_PROC(void,SDL_EGL_SetEGLAttributeCallbacks,(SDL_EGLAttribArrayCallback a, SDL_EGLIntArrayCallback
(Patch may be truncated, please check the link at the top of this post.)