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
This commit is contained in:
Sam Lantinga
2022-12-28 17:06:38 -08:00
parent 9b8208c195
commit 66351fd4ba
36 changed files with 357 additions and 319 deletions

View File

@@ -247,24 +247,22 @@ int mouse_createFreeColorCursor(void *arg)
}
/* Helper that changes cursor visibility */
void _changeCursorVisibility(int state)
void _changeCursorVisibility(SDL_bool state)
{
int oldState;
int newState;
int result;
SDL_bool newState;
oldState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
if (state) {
SDL_ShowCursor();
} else {
SDL_HideCursor();
}
SDLTest_AssertPass("Call to %s", state ? "SDL_ShowCursor()" : "SDL_HideCursor()");
result = SDL_ShowCursor(state);
SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE");
SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i",
(state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result);
newState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i",
state, newState);
newState = SDL_CursorVisible();
SDLTest_AssertPass("Call to SDL_CursorVisible()");
SDLTest_AssertCheck(state == newState, "Validate new state, expected: %s, got: %s",
state ? "SDL_TRUE" : "SDL_FALSE",
newState ? "SDL_TRUE" : "SDL_FALSE");
}
/**
@@ -274,23 +272,19 @@ void _changeCursorVisibility(int state)
*/
int mouse_showCursor(void *arg)
{
int currentState;
SDL_bool currentState;
/* Get current state */
currentState = SDL_ShowCursor(SDL_QUERY);
SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE,
"Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState);
if (currentState == SDL_DISABLE) {
/* Show the cursor, then hide it again */
_changeCursorVisibility(SDL_ENABLE);
_changeCursorVisibility(SDL_DISABLE);
} else if (currentState == SDL_ENABLE) {
currentState = SDL_CursorVisible();
SDLTest_AssertPass("Call to SDL_CursorVisible()");
if (currentState) {
/* Hide the cursor, then show it again */
_changeCursorVisibility(SDL_DISABLE);
_changeCursorVisibility(SDL_ENABLE);
_changeCursorVisibility(SDL_FALSE);
_changeCursorVisibility(SDL_TRUE);
} else {
return TEST_ABORTED;
/* Show the cursor, then hide it again */
_changeCursorVisibility(SDL_TRUE);
_changeCursorVisibility(SDL_FALSE);
}
return TEST_COMPLETED;