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:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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: *;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 b, SDL_EGLIntArrayCallback c),(a,b,c),)
|
||||
SDL_DYNAPI_PROC(void,SDL_EnableScreenSaver,(void),(),)
|
||||
SDL_DYNAPI_PROC(int,SDL_Error,(SDL_errorcode a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint8,SDL_EventState,(Uint32 a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_FillSurfaceRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_FillSurfaceRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_FilterEvents,(SDL_EventFilter a, void *b),(a,b),)
|
||||
@@ -273,7 +272,6 @@ SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(int a, SDL_Rect *b),(a,b),return
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetError,(void),(),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetErrorMsg,(char *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(Uint8,SDL_GetEventState,(Uint32 a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadAppleSFSymbolsNameForAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadAppleSFSymbolsNameForButton,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(Sint16,SDL_GetGamepadAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return)
|
||||
@@ -282,7 +280,6 @@ SDL_DYNAPI_PROC(SDL_GamepadBinding,SDL_GetGamepadBindForAxis,(SDL_Gamepad *a, SD
|
||||
SDL_DYNAPI_PROC(SDL_GamepadBinding,SDL_GetGamepadBindForButton,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(Uint8,SDL_GetGamepadButton,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_GamepadButton,SDL_GetGamepadButtonFromString,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetGamepadEventState,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadFirmwareVersion,(SDL_Gamepad *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromInstanceID,(SDL_JoystickID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromPlayerIndex,(int a),(a),return)
|
||||
@@ -322,7 +319,6 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),re
|
||||
SDL_DYNAPI_PROC(Sint16,SDL_GetJoystickAxis,(SDL_Joystick *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetJoystickAxisInitialState,(SDL_Joystick *a, int b, Sint16 *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(Uint8,SDL_GetJoystickButton,(SDL_Joystick *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetJoystickEventState,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickFirmwareVersion,(SDL_Joystick *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromInstanceID,(SDL_JoystickID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromPlayerIndex,(int a),(a),return)
|
||||
@@ -737,7 +733,6 @@ SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b, SDL_Windo
|
||||
SDL_DYNAPI_PROC(void,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetWindowTitle,(SDL_Window *a, const char *b),(a,b),)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetYUVConversionMode,(SDL_YUV_CONVERSION_MODE a),(a),)
|
||||
SDL_DYNAPI_PROC(int,SDL_ShowCursor,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(Uint32 a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_ShowWindow,(SDL_Window *a),(a),)
|
||||
@@ -928,3 +923,12 @@ SDL_DYNAPI_PROC(int,SDL_wcsncmp,(const wchar_t *a, const wchar_t *b, size_t c),(
|
||||
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsstr,(const wchar_t *a, const wchar_t *b),(a,b),return)
|
||||
|
||||
/* New API symbols are added at the end */
|
||||
SDL_DYNAPI_PROC(void,SDL_SetEventEnabled,(Uint32 a, SDL_bool b),(a,b),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_EventEnabled,(Uint32 a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetGamepadEventsEnabled,(SDL_bool a),(a),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadEventsEnabled,(void),(),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetJoystickEventsEnabled,(SDL_bool a),(a),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickEventsEnabled,(void),(),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ShowCursor,(void),(),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_HideCursor,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return)
|
||||
|
||||
@@ -31,7 +31,7 @@ int SDL_SendClipboardUpdate(void)
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_CLIPBOARDUPDATE)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_CLIPBOARDUPDATE;
|
||||
event.common.timestamp = 0;
|
||||
|
||||
@@ -44,7 +44,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(displayevent) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(displayevent)) {
|
||||
SDL_Event event;
|
||||
event.type = displayevent;
|
||||
event.common.timestamp = 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
|
||||
int posted = 0;
|
||||
|
||||
/* Post the event, if desired */
|
||||
if (SDL_GetEventState(evtype) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(evtype)) {
|
||||
const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping;
|
||||
SDL_Event event;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static SDL_bool SDL_update_joysticks = SDL_TRUE;
|
||||
static void SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value)
|
||||
{
|
||||
if (hint_value &&
|
||||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_GetJoystickEventState(SDL_QUERY))) {
|
||||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventsEnabled())) {
|
||||
SDL_update_joysticks = SDL_TRUE;
|
||||
} else {
|
||||
SDL_update_joysticks = SDL_FALSE;
|
||||
@@ -139,7 +139,7 @@ static void SDLCALL SDL_AutoUpdateSensorsChanged(void *userdata, const char *nam
|
||||
|
||||
static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
(void)SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE);
|
||||
SDL_SetEventEnabled(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,12 +585,12 @@ int SDL_StartEventLoop(void)
|
||||
#endif /* !SDL_THREADS_DISABLED */
|
||||
|
||||
/* Process most event types */
|
||||
(void)SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
|
||||
(void)SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
|
||||
(void)SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
|
||||
SDL_SetEventEnabled(SDL_TEXTINPUT, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_TEXTEDITING, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_SYSWMEVENT, SDL_FALSE);
|
||||
#if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */
|
||||
(void)SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
|
||||
(void)SDL_EventState(SDL_DROPTEXT, SDL_DISABLE);
|
||||
SDL_SetEventEnabled(SDL_DROPFILE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_DROPTEXT, SDL_FALSE);
|
||||
#endif
|
||||
|
||||
SDL_EventQ.active = SDL_TRUE;
|
||||
@@ -883,7 +883,7 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel)
|
||||
|
||||
SDL_SendPendingSignalEvents(); /* in case we had a signal handler fire, etc. */
|
||||
|
||||
if (push_sentinel && SDL_GetEventState(SDL_POLLSENTINEL) == SDL_ENABLE) {
|
||||
if (push_sentinel && SDL_EventEnabled(SDL_POLLSENTINEL)) {
|
||||
SDL_Event sentinel;
|
||||
|
||||
sentinel.type = SDL_POLLSENTINEL;
|
||||
@@ -1266,22 +1266,23 @@ void SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
|
||||
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||
}
|
||||
|
||||
Uint8 SDL_EventState(Uint32 type, int state)
|
||||
void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled)
|
||||
{
|
||||
const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE);
|
||||
Uint8 current_state;
|
||||
SDL_bool current_state;
|
||||
Uint8 hi = ((type >> 8) & 0xff);
|
||||
Uint8 lo = (type & 0xff);
|
||||
|
||||
if (SDL_disabled_events[hi] &&
|
||||
(SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) {
|
||||
current_state = SDL_DISABLE;
|
||||
current_state = SDL_FALSE;
|
||||
} else {
|
||||
current_state = SDL_ENABLE;
|
||||
current_state = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (isde && state != current_state) {
|
||||
if (state == SDL_DISABLE) {
|
||||
if (enabled != current_state) {
|
||||
if (enabled) {
|
||||
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));
|
||||
} else {
|
||||
/* Disable this event type and discard pending events */
|
||||
if (!SDL_disabled_events[hi]) {
|
||||
SDL_disabled_events[hi] = (SDL_DisabledEventBlock *)SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
|
||||
@@ -1291,8 +1292,6 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31));
|
||||
SDL_FlushEvent(type);
|
||||
}
|
||||
} else { // state == SDL_ENABLE
|
||||
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));
|
||||
}
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
@@ -1301,20 +1300,26 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
SDL_CalculateShouldUpdateSensors(SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_TRUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* turn off drag'n'drop support if we've disabled the events.
|
||||
This might change some UI details at the OS level. */
|
||||
if (isde && ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT))) {
|
||||
SDL_ToggleDragAndDropSupport();
|
||||
/* turn off drag'n'drop support if we've disabled the events.
|
||||
This might change some UI details at the OS level. */
|
||||
if (type == SDL_DROPFILE || type == SDL_DROPTEXT) {
|
||||
SDL_ToggleDragAndDropSupport();
|
||||
}
|
||||
}
|
||||
|
||||
return current_state;
|
||||
}
|
||||
|
||||
Uint8 SDL_GetEventState(Uint32 type)
|
||||
SDL_bool SDL_EventEnabled(Uint32 type)
|
||||
{
|
||||
return SDL_EventState(type, SDL_QUERY);
|
||||
Uint8 hi = ((type >> 8) & 0xff);
|
||||
Uint8 lo = (type & 0xff);
|
||||
|
||||
if (SDL_disabled_events[hi] &&
|
||||
(SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 SDL_RegisterEvents(int numevents)
|
||||
@@ -1335,7 +1340,7 @@ int SDL_SendAppEvent(SDL_EventType eventType)
|
||||
int posted;
|
||||
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(eventType) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(eventType)) {
|
||||
SDL_Event event;
|
||||
event.type = eventType;
|
||||
event.common.timestamp = 0;
|
||||
@@ -1349,7 +1354,7 @@ int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
|
||||
int posted;
|
||||
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_SYSWMEVENT)) {
|
||||
SDL_Event event;
|
||||
SDL_memset(&event, 0, sizeof(event));
|
||||
event.type = SDL_SYSWMEVENT;
|
||||
|
||||
@@ -766,7 +766,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
0, 0);
|
||||
|
||||
/* Ensures IME compositions are committed */
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_VideoDevice *video = SDL_GetVideoDevice();
|
||||
if (video && video->StopTextInput) {
|
||||
video->StopTextInput(video);
|
||||
@@ -780,7 +780,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
|
||||
0, 0);
|
||||
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_VideoDevice *video = SDL_GetVideoDevice();
|
||||
if (video && video->StartTextInput) {
|
||||
video->StartTextInput(video);
|
||||
@@ -901,7 +901,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint8 source, Uint8 sta
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(type)) {
|
||||
SDL_Event event;
|
||||
event.type = type;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -1014,7 +1014,7 @@ int SDL_SendKeyboardText(const char *text)
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_Event event;
|
||||
size_t pos = 0, advance, length = SDL_strlen(text);
|
||||
|
||||
@@ -1040,7 +1040,7 @@ int SDL_SendEditingText(const char *text, int start, int length)
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTEDITING)) {
|
||||
SDL_Event event;
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
|
||||
|
||||
@@ -601,7 +601,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_MOUSEMOTION)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_MOUSEMOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -758,7 +758,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(type)) {
|
||||
SDL_Event event;
|
||||
event.type = type;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -850,7 +850,7 @@ int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_MOUSEWHEEL)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_MOUSEWHEEL;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -878,7 +878,7 @@ void SDL_QuitMouse(void)
|
||||
SDL_UpdateMouseCapture(SDL_TRUE);
|
||||
}
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor(1);
|
||||
SDL_ShowCursor();
|
||||
|
||||
cursor = mouse->cursors;
|
||||
while (cursor) {
|
||||
@@ -1413,25 +1413,31 @@ void SDL_FreeCursor(SDL_Cursor *cursor)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_ShowCursor(int toggle)
|
||||
int SDL_ShowCursor(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_bool shown;
|
||||
|
||||
if (mouse == NULL) {
|
||||
return 0;
|
||||
if (!mouse->cursor_shown) {
|
||||
mouse->cursor_shown = SDL_TRUE;
|
||||
SDL_SetCursor(NULL);
|
||||
}
|
||||
|
||||
shown = mouse->cursor_shown;
|
||||
if (toggle >= 0) {
|
||||
if (toggle) {
|
||||
mouse->cursor_shown = SDL_TRUE;
|
||||
} else {
|
||||
mouse->cursor_shown = SDL_FALSE;
|
||||
}
|
||||
if (mouse->cursor_shown != shown) {
|
||||
SDL_SetCursor(NULL);
|
||||
}
|
||||
}
|
||||
return shown;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_HideCursor(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (mouse->cursor_shown) {
|
||||
mouse->cursor_shown = SDL_FALSE;
|
||||
SDL_SetCursor(NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool SDL_CursorVisible(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
return mouse->cursor_shown;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W
|
||||
}
|
||||
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_FINGERDOWN)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_FINGERDOWN;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -340,7 +340,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W
|
||||
}
|
||||
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_FINGERUP)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_FINGERUP;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -437,7 +437,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid,
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_FINGERMOTION)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_FINGERMOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
|
||||
@@ -181,7 +181,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(windowevent) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(windowevent)) {
|
||||
SDL_Event event;
|
||||
event.type = windowevent;
|
||||
event.common.timestamp = 0;
|
||||
|
||||
@@ -3076,7 +3076,7 @@ static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gamep
|
||||
/* translate the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_GAMEPADAXISMOTION) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_GAMEPADAXISMOTION)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_GAMEPADAXISMOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -3138,7 +3138,7 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam
|
||||
/* translate the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(event.type)) {
|
||||
event.common.timestamp = timestamp;
|
||||
event.cbutton.which = gamepad->joystick->instance_id;
|
||||
event.cbutton.button = button;
|
||||
@@ -3149,46 +3149,46 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam
|
||||
return posted;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off gamepad events
|
||||
*/
|
||||
int SDL_GetGamepadEventState(int state)
|
||||
static const Uint32 SDL_gamepad_event_list[] = {
|
||||
SDL_GAMEPADAXISMOTION,
|
||||
SDL_GAMEPADBUTTONDOWN,
|
||||
SDL_GAMEPADBUTTONUP,
|
||||
SDL_GAMEPADADDED,
|
||||
SDL_GAMEPADREMOVED,
|
||||
SDL_GAMEPADDEVICEREMAPPED,
|
||||
SDL_GAMEPADTOUCHPADDOWN,
|
||||
SDL_GAMEPADTOUCHPADMOTION,
|
||||
SDL_GAMEPADTOUCHPADUP,
|
||||
SDL_GAMEPADSENSORUPDATE,
|
||||
};
|
||||
|
||||
void SDL_SetGamepadEventsEnabled(SDL_bool enabled)
|
||||
{
|
||||
#if SDL_EVENTS_DISABLED
|
||||
return SDL_IGNORE;
|
||||
#else
|
||||
const Uint32 event_list[] = {
|
||||
SDL_GAMEPADAXISMOTION,
|
||||
SDL_GAMEPADBUTTONDOWN,
|
||||
SDL_GAMEPADBUTTONUP,
|
||||
SDL_GAMEPADADDED,
|
||||
SDL_GAMEPADREMOVED,
|
||||
SDL_GAMEPADDEVICEREMAPPED,
|
||||
SDL_GAMEPADTOUCHPADDOWN,
|
||||
SDL_GAMEPADTOUCHPADMOTION,
|
||||
SDL_GAMEPADTOUCHPADUP,
|
||||
SDL_GAMEPADSENSORUPDATE,
|
||||
};
|
||||
#ifndef SDL_EVENTS_DISABLED
|
||||
unsigned int i;
|
||||
|
||||
switch (state) {
|
||||
case SDL_QUERY:
|
||||
state = SDL_IGNORE;
|
||||
for (i = 0; i < SDL_arraysize(event_list); ++i) {
|
||||
state = SDL_EventState(event_list[i], SDL_QUERY);
|
||||
if (state == SDL_ENABLE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < SDL_arraysize(event_list); ++i) {
|
||||
(void)SDL_EventState(event_list[i], state);
|
||||
}
|
||||
break;
|
||||
for (i = 0; i < SDL_arraysize(SDL_gamepad_event_list); ++i) {
|
||||
SDL_SetEventEnabled(SDL_gamepad_event_list[i], enabled);
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
}
|
||||
|
||||
SDL_bool SDL_GamepadEventsEnabled(void)
|
||||
{
|
||||
SDL_bool enabled = SDL_FALSE;
|
||||
|
||||
#ifndef SDL_EVENTS_DISABLED
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SDL_gamepad_event_list); ++i) {
|
||||
enabled = SDL_EventEnabled(SDL_gamepad_event_list[i]);
|
||||
if (enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
#endif /* SDL_EVENTS_DISABLED */
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick)
|
||||
|
||||
@@ -1404,7 +1404,7 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id)
|
||||
event.type = SDL_JOYDEVICEADDED;
|
||||
event.common.timestamp = 0;
|
||||
|
||||
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(event.type)) {
|
||||
event.jdevice.which = instance_id;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
@@ -1466,7 +1466,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id)
|
||||
event.type = SDL_JOYDEVICEREMOVED;
|
||||
event.common.timestamp = 0;
|
||||
|
||||
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(event.type)) {
|
||||
event.jdevice.which = instance_id;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
@@ -1532,7 +1532,7 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_JOYAXISMOTION)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_JOYAXISMOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -1574,7 +1574,7 @@ int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uin
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_JOYHATMOTION)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_JOYHATMOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -1632,7 +1632,7 @@ int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butto
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(event.type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(event.type)) {
|
||||
event.common.timestamp = timestamp;
|
||||
event.jbutton.which = joystick->instance_id;
|
||||
event.jbutton.button = button;
|
||||
@@ -1698,38 +1698,45 @@ void SDL_UpdateJoysticks(void)
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
int SDL_GetJoystickEventState(int state)
|
||||
static const Uint32 SDL_joystick_event_list[] = {
|
||||
SDL_JOYAXISMOTION,
|
||||
SDL_JOYHATMOTION,
|
||||
SDL_JOYBUTTONDOWN,
|
||||
SDL_JOYBUTTONUP,
|
||||
SDL_JOYDEVICEADDED,
|
||||
SDL_JOYDEVICEREMOVED,
|
||||
SDL_JOYBATTERYUPDATED
|
||||
};
|
||||
|
||||
void SDL_SetJoystickEventsEnabled(SDL_bool enabled)
|
||||
{
|
||||
#if SDL_EVENTS_DISABLED
|
||||
return SDL_DISABLE;
|
||||
#else
|
||||
const Uint32 event_list[] = {
|
||||
SDL_JOYAXISMOTION, SDL_JOYHATMOTION,
|
||||
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED,
|
||||
SDL_JOYBATTERYUPDATED
|
||||
};
|
||||
#ifndef SDL_EVENTS_DISABLED
|
||||
unsigned int i;
|
||||
|
||||
switch (state) {
|
||||
case SDL_QUERY:
|
||||
state = SDL_DISABLE;
|
||||
for (i = 0; i < SDL_arraysize(event_list); ++i) {
|
||||
state = SDL_EventState(event_list[i], SDL_QUERY);
|
||||
if (state == SDL_ENABLE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < SDL_arraysize(event_list); ++i) {
|
||||
(void)SDL_EventState(event_list[i], state);
|
||||
}
|
||||
break;
|
||||
for (i = 0; i < SDL_arraysize(SDL_joystick_event_list); ++i) {
|
||||
SDL_SetEventEnabled(SDL_joystick_event_list[i], enabled);
|
||||
}
|
||||
return state;
|
||||
#endif /* SDL_EVENTS_DISABLED */
|
||||
}
|
||||
|
||||
SDL_bool SDL_JoystickEventsEnabled()
|
||||
{
|
||||
SDL_bool enabled = SDL_FALSE;
|
||||
|
||||
#ifndef SDL_EVENTS_DISABLED
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SDL_joystick_event_list); ++i) {
|
||||
enabled = SDL_EventEnabled(SDL_joystick_event_list[i]);
|
||||
if (enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16)
|
||||
{
|
||||
Uint16 *guid16 = (Uint16 *)guid.data;
|
||||
@@ -2819,7 +2826,7 @@ void SDL_SendJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel
|
||||
SDL_assert(joystick->ref_count); /* make sure we are calling this only for update, not for initialization */
|
||||
if (ePowerLevel != joystick->epowerlevel) {
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_JOYBATTERYUPDATED) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_JOYBATTERYUPDATED)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_JOYBATTERYUPDATED;
|
||||
event.common.timestamp = 0;
|
||||
@@ -2923,7 +2930,7 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(event_type) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(event_type)) {
|
||||
SDL_Event event;
|
||||
event.type = event_type;
|
||||
event.common.timestamp = timestamp;
|
||||
@@ -2963,7 +2970,7 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT
|
||||
|
||||
/* Post the event, if desired */
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_GAMEPADSENSORUPDATE) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_GAMEPADSENSORUPDATE)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_GAMEPADSENSORUPDATE;
|
||||
event.common.timestamp = timestamp;
|
||||
|
||||
@@ -492,7 +492,7 @@ int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_tim
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
if (SDL_GetEventState(SDL_SENSORUPDATE) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_SENSORUPDATE)) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_SENSORUPDATE;
|
||||
event.common.timestamp = timestamp;
|
||||
|
||||
@@ -1491,8 +1491,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
|
||||
|
||||
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void)
|
||||
{
|
||||
if ((SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) ||
|
||||
(SDL_GetEventState(SDL_DROPTEXT) == SDL_ENABLE)) {
|
||||
if (SDL_EventEnabled(SDL_DROPFILE) || SDL_EventEnabled(SDL_DROPTEXT)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
@@ -4230,8 +4229,8 @@ void SDL_StartTextInput(void)
|
||||
SDL_Window *window;
|
||||
|
||||
/* First, enable text events */
|
||||
(void)SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
|
||||
(void)SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
|
||||
SDL_SetEventEnabled(SDL_TEXTINPUT, SDL_TRUE);
|
||||
SDL_SetEventEnabled(SDL_TEXTEDITING, SDL_TRUE);
|
||||
|
||||
/* Then show the on-screen keyboard, if any */
|
||||
window = SDL_GetFocusWindow();
|
||||
@@ -4265,7 +4264,7 @@ SDL_IsTextInputShown(void)
|
||||
SDL_bool
|
||||
SDL_IsTextInputActive(void)
|
||||
{
|
||||
return SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(SDL_TEXTINPUT);
|
||||
}
|
||||
|
||||
void SDL_StopTextInput(void)
|
||||
@@ -4284,8 +4283,8 @@ void SDL_StopTextInput(void)
|
||||
}
|
||||
|
||||
/* Finally disable text events */
|
||||
(void)SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
|
||||
(void)SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
|
||||
SDL_SetEventEnabled(SDL_TEXTINPUT, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_TEXTEDITING, SDL_FALSE);
|
||||
}
|
||||
|
||||
void SDL_SetTextInputRect(const SDL_Rect *rect)
|
||||
@@ -4368,7 +4367,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
int dummybutton;
|
||||
int retval = -1;
|
||||
SDL_bool relative_mode;
|
||||
int show_cursor_prev;
|
||||
SDL_bool show_cursor_prev;
|
||||
SDL_Window *current_window;
|
||||
SDL_MessageBoxData mbdata;
|
||||
|
||||
@@ -4384,7 +4383,8 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
relative_mode = SDL_GetRelativeMouseMode();
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
show_cursor_prev = SDL_ShowCursor(1);
|
||||
show_cursor_prev = SDL_CursorVisible();
|
||||
SDL_ShowCursor();
|
||||
SDL_ResetKeyboard();
|
||||
|
||||
if (buttonid == NULL) {
|
||||
@@ -4489,7 +4489,9 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
SDL_RaiseWindow(current_window);
|
||||
}
|
||||
|
||||
SDL_ShowCursor(show_cursor_prev);
|
||||
if (!show_cursor_prev) {
|
||||
SDL_HideCursor();
|
||||
}
|
||||
SDL_SetRelativeMouseMode(relative_mode);
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
|
||||
|
||||
@@ -405,7 +405,7 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL forums/mailing list <https://discourse.libsdl.org/> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
||||
}
|
||||
#endif
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
/* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
|
||||
[data.fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
#if 0
|
||||
|
||||
@@ -680,7 +680,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_GetEventState(sdl_event_type) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(sdl_event_type);
|
||||
}
|
||||
|
||||
static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
|
||||
@@ -701,7 +701,7 @@ static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseE
|
||||
}
|
||||
|
||||
SDL_SetMouseFocus(eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? window_data->window : NULL);
|
||||
return SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(SDL_MOUSEMOTION);
|
||||
}
|
||||
|
||||
static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
||||
@@ -723,7 +723,7 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent
|
||||
}
|
||||
|
||||
SDL_SendMouseWheel(0, window_data->window, 0, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
|
||||
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(SDL_MOUSEWHEEL);
|
||||
}
|
||||
|
||||
static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
||||
@@ -739,7 +739,7 @@ static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent
|
||||
|
||||
sdl_event_type = (eventType == EMSCRIPTEN_EVENT_FOCUS) ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST;
|
||||
SDL_SendWindowEvent(window_data->window, sdl_event_type, 0, 0);
|
||||
return SDL_GetEventState(sdl_event_type) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(sdl_event_type);
|
||||
}
|
||||
|
||||
static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
||||
@@ -772,7 +772,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent
|
||||
SDL_SendTouch(0, deviceId, id, window_data->window, SDL_TRUE, x, y, 1.0f);
|
||||
|
||||
/* disable browser scrolling/pinch-to-zoom if app handles touch events */
|
||||
if (!preventDefault && SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
|
||||
if (!preventDefault && SDL_EventEnabled(SDL_FINGERDOWN)) {
|
||||
preventDefault = 1;
|
||||
}
|
||||
} else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
|
||||
@@ -822,7 +822,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
|
||||
is_nav_key = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((eventType == EMSCRIPTEN_EVENT_KEYDOWN) && (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) && !is_nav_key) {
|
||||
if ((eventType == EMSCRIPTEN_EVENT_KEYDOWN) && SDL_EventEnabled(SDL_TEXTINPUT) && !is_nav_key) {
|
||||
prevent_default = SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ static EM_BOOL Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboard
|
||||
if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) {
|
||||
SDL_SendKeyboardText(text);
|
||||
}
|
||||
return SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE;
|
||||
return SDL_EventEnabled(SDL_TEXTINPUT);
|
||||
}
|
||||
|
||||
static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -165,7 +165,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||
|
||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4))
|
||||
{
|
||||
if (SDL_ShowCursor(-1)) {
|
||||
if (SDL_CursorVisible()) {
|
||||
return nil;
|
||||
} else {
|
||||
return [UIPointerStyle hiddenPointerStyle];
|
||||
|
||||
@@ -374,7 +374,7 @@ int Wayland_WaitEventTimeout(_THIS, Sint64 timeoutNS)
|
||||
WAYLAND_wl_display_flush(d->display);
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (d->text_input_manager == NULL && SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_IME_PumpEvents();
|
||||
}
|
||||
#endif
|
||||
@@ -443,7 +443,7 @@ void Wayland_PumpEvents(_THIS)
|
||||
int err;
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (d->text_input_manager == NULL && SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_IME_PumpEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -720,7 +720,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT returnCode = -1;
|
||||
|
||||
/* Send a SDL_SYSWMEVENT if the application wants them */
|
||||
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_SYSWMEVENT)) {
|
||||
SDL_SysWMmsg wmmsg;
|
||||
|
||||
wmmsg.version = SDL_SYSWM_CURRENT_VERSION;
|
||||
|
||||
@@ -334,7 +334,7 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata, XEvent *xev)
|
||||
* Since event data is only available until XFreeEventData is called,
|
||||
* the *only* way for an application to access it is to register an event filter/watcher
|
||||
* and do all the processing on the SDL_SYSWMEVENT inside the callback. */
|
||||
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_SYSWMEVENT)) {
|
||||
SDL_SysWMmsg wmmsg;
|
||||
|
||||
wmmsg.version = SDL_SYSWM_CURRENT_VERSION;
|
||||
@@ -816,7 +816,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent)
|
||||
#endif
|
||||
|
||||
/* Send a SDL_SYSWMEVENT if the application wants them */
|
||||
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_SYSWMEVENT)) {
|
||||
SDL_SysWMmsg wmmsg;
|
||||
|
||||
wmmsg.version = SDL_SYSWM_CURRENT_VERSION;
|
||||
@@ -1078,7 +1078,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent)
|
||||
#endif
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
handled_by_ime = SDL_IME_ProcessKeyEvent(keysym, keycode, (xevent->type == KeyPress ? SDL_PRESSED : SDL_RELEASED));
|
||||
}
|
||||
#endif
|
||||
@@ -1171,7 +1171,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent)
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED,
|
||||
xevent->xconfigure.x, xevent->xconfigure.y);
|
||||
#ifdef SDL_USE_IME
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
/* Update IME candidate list position */
|
||||
SDL_IME_UpdateTextRect(NULL);
|
||||
}
|
||||
@@ -1668,7 +1668,7 @@ int X11_WaitEventTimeout(_THIS, Sint64 timeoutNS)
|
||||
X11_DispatchEvent(_this, &xevent);
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_IME_PumpEvents();
|
||||
}
|
||||
#endif
|
||||
@@ -1709,7 +1709,7 @@ void X11_PumpEvents(_THIS)
|
||||
}
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
if (SDL_EventEnabled(SDL_TEXTINPUT)) {
|
||||
SDL_IME_PumpEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user