early-access version 2847

This commit is contained in:
pineappleEA
2022-07-19 05:48:31 +02:00
parent ba74a2373c
commit 05e3c38e7f
498 changed files with 16027 additions and 27028 deletions

View File

@@ -35,7 +35,7 @@
#include "SDL_syswm.h"
#undef SDL_PRIs64
#if defined(__WIN32__) && !defined(__CYGWIN__)
#ifdef __WIN32__
#define SDL_PRIs64 "I64d"
#else
#define SDL_PRIs64 "lld"
@@ -150,19 +150,13 @@ SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue,
SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE);
}
/**
* Verbosity of logged events as defined in SDL_HINT_EVENT_LOGGING:
* - 0: (default) no logging
* - 1: logging of most events
* - 2: as above, plus mouse and finger motion
* - 3: as above, plus SDL_SysWMEvents
*/
static int SDL_EventLoggingVerbosity = 0;
/* 0 (default) means no logging, 1 means logging, 2 means logging with mouse and finger motion */
static int SDL_DoEventLogging = 0;
static void SDLCALL
SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_EventLoggingVerbosity = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 3) : 0;
SDL_DoEventLogging = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 2) : 0;
}
static void
@@ -172,7 +166,7 @@ SDL_LogEvent(const SDL_Event *event)
char details[128];
/* sensor/mouse/finger motion are spammy, ignore these if they aren't demanded. */
if ( (SDL_EventLoggingVerbosity < 2) &&
if ( (SDL_DoEventLogging < 2) &&
( (event->type == SDL_MOUSEMOTION) ||
(event->type == SDL_FINGERMOTION) ||
(event->type == SDL_CONTROLLERTOUCHPADMOTION) ||
@@ -181,11 +175,6 @@ SDL_LogEvent(const SDL_Event *event)
return;
}
/* window manager events are even more spammy, and don't provide much useful info. */
if ((SDL_EventLoggingVerbosity < 3) && (event->type == SDL_SYSWMEVENT)) {
return;
}
/* this is to make SDL_snprintf() calls cleaner. */
#define uint unsigned int
@@ -217,28 +206,11 @@ SDL_LogEvent(const SDL_Event *event)
SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) break;
SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) break;
SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) break;
SDL_EVENT_CASE(SDL_LOCALECHANGED) break;
SDL_EVENT_CASE(SDL_KEYMAPCHANGED) break;
SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) break;
SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) break;
SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) break;
SDL_EVENT_CASE(SDL_DISPLAYEVENT) {
char name2[64];
switch (event->display.event) {
case SDL_DISPLAYEVENT_NONE: SDL_strlcpy(name2, "SDL_DISPLAYEVENT_NONE (THIS IS PROBABLY A BUG!)", sizeof(name2)); break;
#define SDL_DISPLAYEVENT_CASE(x) case x: SDL_strlcpy(name2, #x, sizeof (name2)); break
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_ORIENTATION);
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_CONNECTED);
SDL_DISPLAYEVENT_CASE(SDL_DISPLAYEVENT_DISCONNECTED);
#undef SDL_DISPLAYEVENT_CASE
default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2)); break;
}
SDL_snprintf(details, sizeof (details), " (timestamp=%u display=%u event=%s data1=%d)",
(uint) event->display.timestamp, (uint) event->display.display, name2, (int) event->display.data1);
break;
}
SDL_EVENT_CASE(SDL_WINDOWEVENT) {
char name2[64];
switch(event->window.event) {
@@ -260,8 +232,6 @@ SDL_LogEvent(const SDL_Event *event)
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_CLOSE);
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_TAKE_FOCUS);
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIT_TEST);
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ICCPROF_CHANGED);
SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_DISPLAY_CHANGED);
#undef SDL_WINDOWEVENT_CASE
default: SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof (name2)); break;
}
@@ -601,7 +571,7 @@ SDL_AddEvent(SDL_Event * event)
SDL_EventQ.free = entry->next;
}
if (SDL_EventLoggingVerbosity > 0) {
if (SDL_DoEventLogging) {
SDL_LogEvent(event);
}
@@ -690,12 +660,12 @@ static int
SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action,
Uint32 minType, Uint32 maxType, SDL_bool include_sentinel)
{
int i, used, sentinels_expected = 0;
int i, used;
/* Don't look after we've quit */
if (!SDL_AtomicGet(&SDL_EventQ.active)) {
/* We get a few spurious events at shutdown, so don't warn then */
if (action == SDL_GETEVENT) {
if (action != SDL_ADDEVENT) {
SDL_SetError("The event system has been shut down");
}
return (-1);
@@ -753,15 +723,8 @@ SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action
}
if (type == SDL_POLLSENTINEL) {
/* Special handling for the sentinel event */
if (!include_sentinel) {
/* Skip it, we don't want to include it */
continue;
}
if (!events || action != SDL_GETEVENT) {
++sentinels_expected;
}
if (SDL_AtomicGet(&SDL_sentinel_pending) > sentinels_expected) {
/* Skip it, there's another one pending */
if (!include_sentinel || SDL_AtomicGet(&SDL_sentinel_pending) > 0) {
/* Skip it, we don't want to include it or there's another one pending */
continue;
}
}
@@ -928,11 +891,7 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event,
c) Periodic processing that takes place in some platform PumpEvents() functions happens
d) Signals received in WaitEventTimeout() are turned into SDL events
*/
/* We only want a single sentinel in the queue. We could get more than one if event is NULL,
* since the SDL_PeepEvents() call below won't remove it in that case.
*/
SDL_bool add_sentinel = (SDL_AtomicGet(&SDL_sentinel_pending) == 0) ? SDL_TRUE : SDL_FALSE;
SDL_PumpEventsInternal(add_sentinel);
SDL_PumpEventsInternal(SDL_TRUE);
if (!_this->wakeup_lock || SDL_LockMutex(_this->wakeup_lock) == 0) {
int status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
@@ -973,10 +932,7 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event,
status = _this->WaitEventTimeout(_this, loop_timeout);
/* Set wakeup_window to NULL without holding the lock. */
_this->wakeup_window = NULL;
if (status == 0 && need_periodic_poll && loop_timeout == PERIODIC_POLL_INTERVAL_MS) {
/* We may have woken up to poll. Try again */
continue;
} else if (status <= 0) {
if (status <= 0) {
/* There is either an error or the timeout is elapsed: return */
return status;
}
@@ -1031,7 +987,6 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
SDL_Window *wakeup_window;
Uint32 start, expiration;
SDL_bool include_sentinel = (timeout == 0) ? SDL_TRUE : SDL_FALSE;
int result;
/* If there isn't a poll sentinel event pending, pump events and add one */
if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) {
@@ -1039,34 +994,33 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
}
/* First check for existing events */
result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, include_sentinel);
if (result < 0) {
switch (SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, include_sentinel)) {
case -1:
return 0;
}
if (include_sentinel) {
if (event) {
if (event->type == SDL_POLLSENTINEL) {
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
} else {
/* Need to peek the next event to check for sentinel */
SDL_Event dummy;
if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, SDL_TRUE) &&
dummy.type == SDL_POLLSENTINEL) {
SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_POLLSENTINEL, SDL_POLLSENTINEL, SDL_TRUE);
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
}
}
if (result == 0) {
case 0:
if (timeout == 0) {
/* No events available, and not willing to wait */
return 0;
}
} else {
break;
default:
if (include_sentinel) {
if (event) {
if (event->type == SDL_POLLSENTINEL) {
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
} else {
/* Need to peek the next event to check for sentinel */
SDL_Event dummy;
if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, SDL_TRUE) &&
dummy.type == SDL_POLLSENTINEL) {
/* Reached the end of a poll cycle, and not willing to wait */
return 0;
}
}
}
/* Has existing events */
return 1;
}
@@ -1278,7 +1232,8 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
Uint8
SDL_EventState(Uint32 type, int state)
{
const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE);
const SDL_bool isdnd = ((state == SDL_DISABLE) || (state == SDL_ENABLE)) &&
((type == SDL_DROPFILE) || (type == SDL_DROPTEXT));
Uint8 current_state;
Uint8 hi = ((type >> 8) & 0xff);
Uint8 lo = (type & 0xff);
@@ -1290,32 +1245,44 @@ SDL_EventState(Uint32 type, int state)
current_state = SDL_ENABLE;
}
if (isde && state != current_state) {
if (state == SDL_DISABLE) {
if (state != current_state)
{
switch (state) {
case SDL_DISABLE:
/* 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));
if (!SDL_disabled_events[hi]) {
/* Out of memory, nothing we can do... */
break;
}
}
/* Out of memory, nothing we can do... */
if (SDL_disabled_events[hi]) {
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));
SDL_FlushEvent(type);
break;
case SDL_ENABLE:
SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
break;
default:
/* Querying state... */
break;
}
#if !SDL_JOYSTICK_DISABLED
SDL_CalculateShouldUpdateJoysticks();
if (state == SDL_DISABLE || state == SDL_ENABLE) {
SDL_CalculateShouldUpdateJoysticks();
}
#endif
#if !SDL_SENSOR_DISABLED
SDL_CalculateShouldUpdateSensors();
if (state == SDL_DISABLE || state == SDL_ENABLE) {
SDL_CalculateShouldUpdateSensors();
}
#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))) {
if (isdnd) {
SDL_ToggleDragAndDropSupport();
}

View File

@@ -282,10 +282,6 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
SDLK_APP2,
SDLK_AUDIOREWIND,
SDLK_AUDIOFASTFORWARD,
SDLK_SOFTLEFT,
SDLK_SOFTRIGHT,
SDLK_CALL,
SDLK_ENDCALL,
};
static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
@@ -522,10 +518,6 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
"App2",
"AudioRewind",
"AudioFastForward",
"SoftLeft",
"SoftRight",
"Call",
"EndCall",
};
/* Taken from SDL_iconv() */
@@ -646,7 +638,6 @@ SDL_SetKeyboardFocus(SDL_Window * window)
/* old window must lose an existing mouse capture. */
if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) {
SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */
SDL_UpdateMouseCapture(SDL_TRUE);
SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE));
}
@@ -876,14 +867,10 @@ SDL_SendKeyboardText(const char *text)
posted = 0;
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
SDL_Event event;
size_t i = 0, length = SDL_strlen(text);
event.text.type = SDL_TEXTINPUT;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
while (i < length) {
i += SDL_utf8strlcpy(event.text.text, text + i, SDL_arraysize(event.text.text));
posted |= (SDL_PushEvent(&event) > 0);
}
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
@@ -903,22 +890,6 @@ SDL_SendEditingText(const char *text, int start, int length)
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
SDL_strlen(text) > SDL_arraysize(event.text.text)) {
event.editExt.type = SDL_TEXTEDITING_EXT;
event.editExt.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.editExt.text = text ? SDL_strdup(text) : NULL;
event.editExt.start = start;
event.editExt.length = length;
} else {
event.edit.type = SDL_TEXTEDITING;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
}
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);

View File

@@ -109,28 +109,6 @@ SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldVal
mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE);
}
#if defined(__vita__)
static void SDLCALL
SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
if (hint) {
switch(*hint) {
default:
case '0':
mouse->vita_touch_mouse_device = 0;
break;
case '1':
mouse->vita_touch_mouse_device = 1;
break;
case '2':
mouse->vita_touch_mouse_device = 2;
break;
}
}
}
#endif
static void SDLCALL
SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
@@ -149,18 +127,6 @@ SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldVal
}
}
static void SDLCALL
SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE);
if (auto_capture != mouse->auto_capture) {
mouse->auto_capture = auto_capture;
SDL_UpdateMouseCapture(SDL_FALSE);
}
}
/* Public functions */
int
SDL_MouseInit(void)
@@ -184,17 +150,9 @@ SDL_MouseInit(void)
SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
SDL_TouchMouseEventsChanged, mouse);
#if defined(__vita__)
SDL_AddHintCallback(SDL_HINT_VITA_TOUCH_MOUSE_DEVICE,
SDL_VitaTouchMouseDeviceChanged, mouse);
#endif
SDL_AddHintCallback(SDL_HINT_MOUSE_TOUCH_EVENTS,
SDL_MouseTouchEventsChanged, mouse);
SDL_AddHintCallback(SDL_HINT_MOUSE_AUTO_CAPTURE,
SDL_MouseAutoCaptureChanged, mouse);
mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */
mouse->cursor_shown = SDL_TRUE;
@@ -290,10 +248,23 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_
}
}
/* Linux doesn't give you mouse events outside your window unless you grab
the pointer.
Windows doesn't give you mouse events outside your window unless you call
SetCapture().
Both of these are slightly scary changes, so for now we'll punt and if the
mouse leaves the window you'll lose mouse focus and reset button state.
*/
#ifdef SUPPORT_DRAG_OUTSIDE_WINDOW
if (!inWindow && !buttonstate) {
#else
if (!inWindow) {
#endif
if (window == mouse->focus) {
#ifdef DEBUG_MOUSE
SDL_Log("Mouse left window, synthesizing move & focus lost event\n");
printf("Mouse left window, synthesizing move & focus lost event\n");
#endif
if (send_mouse_motion) {
SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
@@ -305,7 +276,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_
if (window != mouse->focus) {
#ifdef DEBUG_MOUSE
SDL_Log("Mouse entered window, synthesizing focus gain & move event\n");
printf("Mouse entered window, synthesizing focus gain & move event\n");
#endif
SDL_SetMouseFocus(window);
if (send_mouse_motion) {
@@ -407,12 +378,14 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
/* Ignore relative motion when first positioning the mouse */
if (!mouse->has_position) {
xrel = 0;
yrel = 0;
mouse->x = x;
mouse->y = y;
mouse->has_position = SDL_TRUE;
} else if (!xrel && !yrel) { /* Drop events that don't change state */
#ifdef DEBUG_MOUSE
SDL_Log("Mouse event didn't change state - dropped!\n");
printf("Mouse event didn't change state - dropped!\n");
#endif
return 0;
}
@@ -560,7 +533,7 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
Uint32 type;
Uint32 buttonstate;
SDL_MouseInputSource *source;
source = GetMouseInputSource(mouse, mouseID);
if (!source) {
return 0;
@@ -660,11 +633,6 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, SDL_TRUE);
}
/* Automatically capture the mouse while buttons are pressed */
if (mouse->auto_capture) {
SDL_UpdateMouseCapture(SDL_FALSE);
}
return posted;
}
@@ -759,7 +727,6 @@ SDL_MouseQuit(void)
if (mouse->CaptureMouse) {
SDL_CaptureMouse(SDL_FALSE);
SDL_UpdateMouseCapture(SDL_TRUE);
}
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_ShowCursor(1);
@@ -790,26 +757,11 @@ SDL_MouseQuit(void)
}
mouse->num_clickstates = 0;
SDL_DelHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_TIME,
SDL_MouseDoubleClickTimeChanged, mouse);
SDL_DelHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS,
SDL_MouseDoubleClickRadiusChanged, mouse);
SDL_DelHintCallback(SDL_HINT_MOUSE_NORMAL_SPEED_SCALE,
SDL_MouseNormalSpeedScaleChanged, mouse);
SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE,
SDL_MouseRelativeSpeedScaleChanged, mouse);
SDL_DelHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
SDL_TouchMouseEventsChanged, mouse);
SDL_DelHintCallback(SDL_HINT_MOUSE_TOUCH_EVENTS,
SDL_MouseTouchEventsChanged, mouse);
SDL_DelHintCallback(SDL_HINT_MOUSE_AUTO_CAPTURE,
SDL_MouseAutoCaptureChanged, mouse);
}
Uint32
@@ -867,7 +819,7 @@ SDL_GetGlobalMouseState(int *x, int *y)
}
void
SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode)
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
@@ -883,20 +835,6 @@ SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_r
return;
}
if (mouse->relative_mode && !ignore_relative_mode) {
/* 2.0.22 made warping in relative mode actually functional, which
* surprised many applications that weren't expecting the additional
* mouse motion.
*
* So for now, warping in relative mode adjusts the absolution position
* but doesn't generate motion events.
*/
mouse->x = x;
mouse->y = y;
mouse->has_position = SDL_TRUE;
return;
}
/* Ignore the previous position when we warp */
mouse->has_position = SDL_FALSE;
@@ -908,12 +846,6 @@ SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_r
}
}
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_PerformWarpMouseInWindow(window, x, y, SDL_FALSE);
}
int
SDL_WarpMouseGlobal(int x, int y)
{
@@ -973,9 +905,8 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
if (enabled && focusWindow) {
SDL_SetMouseFocus(focusWindow);
if (mouse->relative_mode_warp) {
SDL_PerformWarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2, SDL_TRUE);
}
if (mouse->relative_mode_warp)
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
}
if (focusWindow) {
@@ -983,10 +914,8 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
/* Put the cursor back to where the application expects it */
if (!enabled) {
SDL_PerformWarpMouseInWindow(focusWindow, mouse->x, mouse->y, SDL_TRUE);
SDL_WarpMouseInWindow(focusWindow, mouse->x, mouse->y);
}
SDL_UpdateMouseCapture(SDL_FALSE);
}
if (!enabled) {
@@ -1008,84 +937,39 @@ SDL_GetRelativeMouseMode()
return mouse->relative_mode;
}
int
SDL_UpdateMouseCapture(SDL_bool force_release)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *capture_window = NULL;
if (!mouse->CaptureMouse) {
return 0;
}
if (!force_release) {
if (SDL_GetMessageBoxCount() == 0 &&
(mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0))) {
if (!mouse->relative_mode) {
capture_window = SDL_GetKeyboardFocus();
}
}
}
if (capture_window != mouse->capture_window) {
/* We can get here recursively on Windows, so make sure we complete
* all of the window state operations before we change the capture state
* (e.g. https://github.com/libsdl-org/SDL/pull/5608)
*/
SDL_Window *previous_capture = mouse->capture_window;
if (previous_capture) {
previous_capture->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
}
if (capture_window) {
capture_window->flags |= SDL_WINDOW_MOUSE_CAPTURE;
}
mouse->capture_window = capture_window;
if (mouse->CaptureMouse(capture_window) < 0) {
/* CaptureMouse() will have set an error, just restore the state */
if (previous_capture) {
previous_capture->flags |= SDL_WINDOW_MOUSE_CAPTURE;
}
if (capture_window) {
capture_window->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
}
mouse->capture_window = previous_capture;
return -1;
}
}
return 0;
}
int
SDL_CaptureMouse(SDL_bool enabled)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *focusWindow;
SDL_bool isCaptured;
if (!mouse->CaptureMouse) {
return SDL_Unsupported();
}
#ifdef __WIN32__
/* Windows mouse capture is tied to the current thread, and must be called
* from the thread that created the window being captured. Since we update
* the mouse capture state from the event processing, any application state
* changes must be processed on that thread as well.
*/
if (!SDL_OnVideoThread()) {
return SDL_SetError("SDL_CaptureMouse() must be called on the main thread");
}
#endif /* __WIN32__ */
focusWindow = SDL_GetKeyboardFocus();
if (enabled && SDL_GetKeyboardFocus() == NULL) {
return SDL_SetError("No window has focus");
isCaptured = focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE);
if (isCaptured == enabled) {
return 0; /* already done! */
}
mouse->capture_desired = enabled;
return SDL_UpdateMouseCapture(SDL_FALSE);
if (enabled) {
if (!focusWindow) {
return SDL_SetError("No window has focus");
} else if (mouse->CaptureMouse(focusWindow) == -1) {
return -1; /* CaptureMouse() should call SetError */
}
focusWindow->flags |= SDL_WINDOW_MOUSE_CAPTURE;
} else {
if (mouse->CaptureMouse(NULL) == -1) {
return -1; /* CaptureMouse() should call SetError */
}
focusWindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
}
return 0;
}
SDL_Cursor *
@@ -1145,7 +1029,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
SDL_Cursor *cursor;
if (!surface) {
SDL_InvalidParamError("surface");
SDL_SetError("Passed NULL cursor surface");
return NULL;
}

View File

@@ -100,12 +100,6 @@ typedef struct
SDL_bool touch_mouse_events;
SDL_bool mouse_touch_events;
SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */
#if defined(__vita__)
Uint8 vita_touch_mouse_device;
#endif
SDL_bool auto_capture;
SDL_bool capture_desired;
SDL_Window *capture_window;
/* Data for input source state */
int num_sources;
@@ -137,9 +131,6 @@ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
/* Set the mouse focus window */
extern void SDL_SetMouseFocus(SDL_Window * window);
/* Update the mouse capture window */
extern int SDL_UpdateMouseCapture(SDL_bool force_release);
/* Send a mouse motion event */
extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
@@ -152,9 +143,6 @@ extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, U
/* Send a mouse wheel event */
extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);
/* Warp the mouse within the window, potentially overriding relative mode */
extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode);
/* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void);

View File

@@ -63,16 +63,6 @@ SDL_GetTouchDevice(int index)
return SDL_touchDevices[index]->id;
}
const char*
SDL_GetTouchName(int index)
{
if (index < 0 || index >= SDL_num_touch) {
SDL_SetError("Unknown touch device");
return NULL;
}
return SDL_touchDevices[index]->name;
}
static int
SDL_GetTouchIndex(SDL_TouchID id)
{
@@ -195,7 +185,6 @@ SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
SDL_touchDevices[index]->num_fingers = 0;
SDL_touchDevices[index]->max_fingers = 0;
SDL_touchDevices[index]->fingers = NULL;
SDL_touchDevices[index]->name = SDL_strdup(name ? name : "");
/* Record this touch device for gestures */
/* We could do this on the fly in the gesture code if we wanted */
@@ -265,13 +254,8 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window,
#if SYNTHESIZE_TOUCH_TO_MOUSE
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
/* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */
{
#if defined(__vita__)
if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2)) ) {
#else
if (mouse->touch_mouse_events) {
#endif
/* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */
if (id != SDL_MOUSE_TOUCHID) {
if (window) {
@@ -318,9 +302,8 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window,
finger = SDL_GetFinger(touch, fingerid);
if (down) {
if (finger) {
/* This finger is already down.
Assume the finger-up for the previous touch was lost, and send it. */
SDL_SendTouch(id, fingerid, window, SDL_FALSE, x, y, pressure);
/* This finger is already down */
return 0;
}
if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) {
@@ -468,7 +451,6 @@ SDL_DelTouch(SDL_TouchID id)
SDL_free(touch->fingers[i]);
}
SDL_free(touch->fingers);
SDL_free(touch->name);
SDL_free(touch);
SDL_num_touch--;

View File

@@ -31,7 +31,6 @@ typedef struct SDL_Touch
int num_fingers;
int max_fingers;
SDL_Finger** fingers;
char *name;
} SDL_Touch;

View File

@@ -25,7 +25,7 @@
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_mouse_c.h"
#include "SDL_hints.h"
static int SDLCALL
RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event)
@@ -201,9 +201,8 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
if (windowevent == SDL_WINDOWEVENT_CLOSE) {
if ( !window->prev && !window->next ) {
if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) {
SDL_SendQuit(); /* This is the last window in the list so send the SDL_QUIT event */
}
/* This is the last window in the list so send the SDL_QUIT event */
SDL_SendQuit();
}
}

View File

@@ -25,7 +25,7 @@
- Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
- experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
*/
/* *INDENT-OFF* */ /* clang-format off */
/* *INDENT-OFF* */
static const SDL_Scancode darwin_scancode_table[] = {
/* 0 */ SDL_SCANCODE_A,
/* 1 */ SDL_SCANCODE_S,
@@ -156,4 +156,4 @@ static const SDL_Scancode darwin_scancode_table[] = {
/* 126 */ SDL_SCANCODE_UP,
/* 127 */ SDL_SCANCODE_POWER
};
/* *INDENT-ON* */ /* clang-format on */
/* *INDENT-ON* */

View File

@@ -24,7 +24,7 @@
Sources:
- Linux kernel source input.h
*/
/* *INDENT-OFF* */ /* clang-format off */
/* *INDENT-OFF* */
static SDL_Scancode const linux_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
@@ -260,4 +260,4 @@ static SDL_Scancode const linux_scancode_table[] = {
/* 235 */ SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */
/* 236 */ SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */
};
/* *INDENT-ON* */ /* clang-format on */
/* *INDENT-ON* */

View File

@@ -23,7 +23,7 @@
/* Windows scancode to SDL scancode mapping table */
/* derived from Microsoft scan code document, http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc */
/* *INDENT-OFF* */ /* clang-format off */
/* *INDENT-OFF* */
static const SDL_Scancode windows_scancode_table[] =
{
/* 0 1 2 3 4 5 6 7 */
@@ -52,4 +52,4 @@ static const SDL_Scancode windows_scancode_table[] =
SDL_SCANCODE_INTERNATIONAL2, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL1, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL4, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL5, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL3, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */
};
/* *INDENT-ON* */ /* clang-format on */
/* *INDENT-ON* */

View File

@@ -28,7 +28,7 @@
Sources:
- atKeyNames.h from XFree86 source code
*/
/* *INDENT-OFF* */ /* clang-format off */
/* *INDENT-OFF* */
static const SDL_Scancode xfree86_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
@@ -509,4 +509,4 @@ static const SDL_Scancode xvnc_scancode_table[] = {
#endif /* scancodes_xfree86_h_ */
/* *INDENT-ON* */ /* clang-format on */
/* *INDENT-ON* */