early-access version 2835
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_displayevents.c
vendored
2
externals/SDL/src/events/SDL_displayevents.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_dropevents.c
vendored
2
externals/SDL/src/events/SDL_dropevents.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_dropevents_c.h
vendored
2
externals/SDL/src/events/SDL_dropevents_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
214
externals/SDL/src/events/SDL_events.c
vendored
214
externals/SDL/src/events/SDL_events.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#undef SDL_PRIs64
|
||||
#ifdef __WIN32__
|
||||
#if defined(__WIN32__) && !defined(__CYGWIN__)
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#else
|
||||
#define SDL_PRIs64 "lld"
|
||||
@@ -59,6 +59,7 @@ static SDL_EventWatcher *SDL_event_watchers = NULL;
|
||||
static int SDL_event_watchers_count = 0;
|
||||
static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE;
|
||||
static SDL_bool SDL_event_watchers_removed = SDL_FALSE;
|
||||
static SDL_atomic_t SDL_sentinel_pending;
|
||||
|
||||
typedef struct {
|
||||
Uint32 bits[8];
|
||||
@@ -149,13 +150,19 @@ SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue,
|
||||
SDL_EventState(SDL_POLLSENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE) ? SDL_ENABLE : SDL_DISABLE);
|
||||
}
|
||||
|
||||
/* 0 (default) means no logging, 1 means logging, 2 means logging with mouse and finger motion */
|
||||
static int SDL_DoEventLogging = 0;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
static void SDLCALL
|
||||
SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_DoEventLogging = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 2) : 0;
|
||||
SDL_EventLoggingVerbosity = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 3) : 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -165,7 +172,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_DoEventLogging < 2) &&
|
||||
if ( (SDL_EventLoggingVerbosity < 2) &&
|
||||
( (event->type == SDL_MOUSEMOTION) ||
|
||||
(event->type == SDL_FINGERMOTION) ||
|
||||
(event->type == SDL_CONTROLLERTOUCHPADMOTION) ||
|
||||
@@ -174,6 +181,11 @@ 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
|
||||
|
||||
@@ -205,11 +217,28 @@ 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) {
|
||||
@@ -231,6 +260,8 @@ 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;
|
||||
}
|
||||
@@ -479,6 +510,7 @@ SDL_StopEventLoop(void)
|
||||
SDL_EventQ.free = NULL;
|
||||
SDL_EventQ.wmmsg_used = NULL;
|
||||
SDL_EventQ.wmmsg_free = NULL;
|
||||
SDL_AtomicSet(&SDL_sentinel_pending, 0);
|
||||
|
||||
/* Clear disabled event state */
|
||||
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
|
||||
@@ -569,12 +601,14 @@ SDL_AddEvent(SDL_Event * event)
|
||||
SDL_EventQ.free = entry->next;
|
||||
}
|
||||
|
||||
if (SDL_DoEventLogging) {
|
||||
if (SDL_EventLoggingVerbosity > 0) {
|
||||
SDL_LogEvent(event);
|
||||
}
|
||||
|
||||
entry->event = *event;
|
||||
if (event->type == SDL_SYSWMEVENT) {
|
||||
if (event->type == SDL_POLLSENTINEL) {
|
||||
SDL_AtomicAdd(&SDL_sentinel_pending, 1);
|
||||
} else if (event->type == SDL_SYSWMEVENT) {
|
||||
entry->msg = *event->syswm.msg;
|
||||
entry->event.syswm.msg = &entry->msg;
|
||||
}
|
||||
@@ -620,6 +654,10 @@ SDL_CutEvent(SDL_EventEntry *entry)
|
||||
SDL_EventQ.tail = entry->prev;
|
||||
}
|
||||
|
||||
if (entry->event.type == SDL_POLLSENTINEL) {
|
||||
SDL_AtomicAdd(&SDL_sentinel_pending, -1);
|
||||
}
|
||||
|
||||
entry->next = SDL_EventQ.free;
|
||||
SDL_EventQ.free = entry;
|
||||
SDL_assert(SDL_AtomicGet(&SDL_EventQ.count) > 0);
|
||||
@@ -648,16 +686,16 @@ SDL_SendWakeupEvent()
|
||||
}
|
||||
|
||||
/* Lock the event queue, take a peep at it, and unlock it */
|
||||
int
|
||||
SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||
Uint32 minType, Uint32 maxType)
|
||||
static int
|
||||
SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||
Uint32 minType, Uint32 maxType, SDL_bool include_sentinel)
|
||||
{
|
||||
int i, used;
|
||||
int i, used, sentinels_expected = 0;
|
||||
|
||||
/* 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_ADDEVENT) {
|
||||
if (action == SDL_GETEVENT) {
|
||||
SDL_SetError("The event system has been shut down");
|
||||
}
|
||||
return (-1);
|
||||
@@ -713,6 +751,20 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||
SDL_CutEvent(entry);
|
||||
}
|
||||
}
|
||||
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 */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++used;
|
||||
}
|
||||
}
|
||||
@@ -730,6 +782,12 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||
|
||||
return (used);
|
||||
}
|
||||
int
|
||||
SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||
Uint32 minType, Uint32 maxType)
|
||||
{
|
||||
return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, SDL_FALSE);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_HasEvent(Uint32 type)
|
||||
@@ -787,8 +845,8 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType)
|
||||
}
|
||||
|
||||
/* Run the system dependent event loops */
|
||||
void
|
||||
SDL_PumpEvents(void)
|
||||
static void
|
||||
SDL_PumpEventsInternal(SDL_bool push_sentinel)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
@@ -815,6 +873,20 @@ SDL_PumpEvents(void)
|
||||
#endif
|
||||
|
||||
SDL_SendPendingSignalEvents(); /* in case we had a signal handler fire, etc. */
|
||||
|
||||
if (push_sentinel && SDL_GetEventState(SDL_POLLSENTINEL) == SDL_ENABLE) {
|
||||
SDL_Event sentinel;
|
||||
|
||||
SDL_zero(sentinel);
|
||||
sentinel.type = SDL_POLLSENTINEL;
|
||||
SDL_PushEvent(&sentinel);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_PumpEvents()
|
||||
{
|
||||
SDL_PumpEventsInternal(SDL_FALSE);
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
@@ -856,7 +928,11 @@ 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
|
||||
*/
|
||||
SDL_PumpEvents();
|
||||
/* 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);
|
||||
|
||||
if (!_this->wakeup_lock || SDL_LockMutex(_this->wakeup_lock) == 0) {
|
||||
int status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
@@ -897,7 +973,10 @@ 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) {
|
||||
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) {
|
||||
/* There is either an error or the timeout is elapsed: return */
|
||||
return status;
|
||||
}
|
||||
@@ -950,30 +1029,59 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *wakeup_window;
|
||||
Uint32 start = 0;
|
||||
Uint32 expiration = 0;
|
||||
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) {
|
||||
SDL_PumpEventsInternal(SDL_TRUE);
|
||||
}
|
||||
|
||||
/* First check for existing events */
|
||||
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
|
||||
case -1:
|
||||
result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, include_sentinel);
|
||||
if (result < 0) {
|
||||
return 0;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
/* Check whether we have reached the end of the poll cycle, and no more events are left */
|
||||
if (timeout == 0 && event && event->type == SDL_POLLSENTINEL) {
|
||||
return (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1);
|
||||
}
|
||||
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) {
|
||||
if (timeout == 0) {
|
||||
/* No events available, and not willing to wait */
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* Has existing events */
|
||||
return 1;
|
||||
}
|
||||
/* We should have completely handled timeout == 0 above */
|
||||
SDL_assert(timeout != 0);
|
||||
|
||||
if (timeout > 0) {
|
||||
start = SDL_GetTicks();
|
||||
expiration = start + timeout;
|
||||
} else {
|
||||
start = 0;
|
||||
expiration = 0;
|
||||
}
|
||||
|
||||
if (timeout != 0 && _this && _this->WaitEventTimeout && _this->SendWakeupEvent && !SDL_events_need_polling()) {
|
||||
if (_this && _this->WaitEventTimeout && _this->SendWakeupEvent && !SDL_events_need_polling()) {
|
||||
/* Look if a shown window is available to send the wakeup event. */
|
||||
wakeup_window = SDL_find_active_window(_this);
|
||||
if (wakeup_window) {
|
||||
@@ -988,15 +1096,11 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
SDL_PumpEvents();
|
||||
SDL_PumpEventsInternal(SDL_TRUE);
|
||||
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
|
||||
case -1:
|
||||
return 0;
|
||||
case 0:
|
||||
if (timeout == 0) {
|
||||
/* Polling and no events, just return */
|
||||
return 0;
|
||||
}
|
||||
if (timeout > 0 && SDL_TICKS_PASSED(SDL_GetTicks(), expiration)) {
|
||||
/* Timeout expired and no events */
|
||||
return 0;
|
||||
@@ -1004,13 +1108,6 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
|
||||
SDL_Delay(1);
|
||||
break;
|
||||
default:
|
||||
if (timeout == 0 && SDL_GetEventState(SDL_POLLSENTINEL) == SDL_ENABLE) {
|
||||
/* We are at the start of a poll cycle with at least one new event.
|
||||
Add a sentinel event to mark the end of the cycle. */
|
||||
SDL_Event sentinel;
|
||||
sentinel.type = SDL_POLLSENTINEL;
|
||||
SDL_PushEvent(&sentinel);
|
||||
}
|
||||
/* Has events */
|
||||
return 1;
|
||||
}
|
||||
@@ -1181,8 +1278,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
|
||||
Uint8
|
||||
SDL_EventState(Uint32 type, int state)
|
||||
{
|
||||
const SDL_bool isdnd = ((state == SDL_DISABLE) || (state == SDL_ENABLE)) &&
|
||||
((type == SDL_DROPFILE) || (type == SDL_DROPTEXT));
|
||||
const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE);
|
||||
Uint8 current_state;
|
||||
Uint8 hi = ((type >> 8) & 0xff);
|
||||
Uint8 lo = (type & 0xff);
|
||||
@@ -1194,44 +1290,32 @@ SDL_EventState(Uint32 type, int state)
|
||||
current_state = SDL_ENABLE;
|
||||
}
|
||||
|
||||
if (state != current_state)
|
||||
{
|
||||
switch (state) {
|
||||
case SDL_DISABLE:
|
||||
if (isde && state != current_state) {
|
||||
if (state == 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;
|
||||
}
|
||||
}
|
||||
SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
|
||||
SDL_FlushEvent(type);
|
||||
break;
|
||||
case SDL_ENABLE:
|
||||
/* 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));
|
||||
break;
|
||||
default:
|
||||
/* Querying state... */
|
||||
break;
|
||||
}
|
||||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (state == SDL_DISABLE || state == SDL_ENABLE) {
|
||||
SDL_CalculateShouldUpdateJoysticks();
|
||||
}
|
||||
SDL_CalculateShouldUpdateJoysticks();
|
||||
#endif
|
||||
#if !SDL_SENSOR_DISABLED
|
||||
if (state == SDL_DISABLE || state == SDL_ENABLE) {
|
||||
SDL_CalculateShouldUpdateSensors();
|
||||
}
|
||||
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 (isdnd) {
|
||||
if (isde && ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT))) {
|
||||
SDL_ToggleDragAndDropSupport();
|
||||
}
|
||||
|
||||
|
2
externals/SDL/src/events/SDL_events_c.h
vendored
2
externals/SDL/src/events/SDL_events_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_gesture.c
vendored
2
externals/SDL/src/events/SDL_gesture.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_gesture_c.h
vendored
2
externals/SDL/src/events/SDL_gesture_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
35
externals/SDL/src/events/SDL_keyboard.c
vendored
35
externals/SDL/src/events/SDL_keyboard.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -282,6 +282,10 @@ 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] = {
|
||||
@@ -518,6 +522,10 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
|
||||
"App2",
|
||||
"AudioRewind",
|
||||
"AudioFastForward",
|
||||
"SoftLeft",
|
||||
"SoftRight",
|
||||
"Call",
|
||||
"EndCall",
|
||||
};
|
||||
|
||||
/* Taken from SDL_iconv() */
|
||||
@@ -638,6 +646,7 @@ 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));
|
||||
}
|
||||
|
||||
@@ -867,10 +876,14 @@ 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;
|
||||
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
while (i < length) {
|
||||
i += SDL_utf8strlcpy(event.text.text, text + i, SDL_arraysize(event.text.text));
|
||||
posted |= (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
}
|
||||
return (posted);
|
||||
}
|
||||
@@ -890,6 +903,22 @@ 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);
|
||||
|
2
externals/SDL/src/events/SDL_keyboard_c.h
vendored
2
externals/SDL/src/events/SDL_keyboard_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
206
externals/SDL/src/events/SDL_mouse.c
vendored
206
externals/SDL/src/events/SDL_mouse.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -109,6 +109,28 @@ 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)
|
||||
{
|
||||
@@ -127,6 +149,18 @@ 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)
|
||||
@@ -150,9 +184,17 @@ 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;
|
||||
@@ -248,23 +290,10 @@ 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
|
||||
printf("Mouse left window, synthesizing move & focus lost event\n");
|
||||
SDL_Log("Mouse left window, synthesizing move & focus lost event\n");
|
||||
#endif
|
||||
if (send_mouse_motion) {
|
||||
SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
|
||||
@@ -276,7 +305,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate, SDL_
|
||||
|
||||
if (window != mouse->focus) {
|
||||
#ifdef DEBUG_MOUSE
|
||||
printf("Mouse entered window, synthesizing focus gain & move event\n");
|
||||
SDL_Log("Mouse entered window, synthesizing focus gain & move event\n");
|
||||
#endif
|
||||
SDL_SetMouseFocus(window);
|
||||
if (send_mouse_motion) {
|
||||
@@ -378,14 +407,12 @@ 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
|
||||
printf("Mouse event didn't change state - dropped!\n");
|
||||
SDL_Log("Mouse event didn't change state - dropped!\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -533,7 +560,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;
|
||||
@@ -633,6 +660,11 @@ 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;
|
||||
}
|
||||
|
||||
@@ -727,6 +759,7 @@ SDL_MouseQuit(void)
|
||||
|
||||
if (mouse->CaptureMouse) {
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
SDL_UpdateMouseCapture(SDL_TRUE);
|
||||
}
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor(1);
|
||||
@@ -757,11 +790,26 @@ 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
|
||||
@@ -819,7 +867,7 @@ SDL_GetGlobalMouseState(int *x, int *y)
|
||||
}
|
||||
|
||||
void
|
||||
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
@@ -835,6 +883,20 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
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;
|
||||
|
||||
@@ -846,6 +908,12 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_PerformWarpMouseInWindow(window, x, y, SDL_FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
@@ -905,8 +973,9 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
|
||||
if (enabled && focusWindow) {
|
||||
SDL_SetMouseFocus(focusWindow);
|
||||
|
||||
if (mouse->relative_mode_warp)
|
||||
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
|
||||
if (mouse->relative_mode_warp) {
|
||||
SDL_PerformWarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (focusWindow) {
|
||||
@@ -914,8 +983,10 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
|
||||
|
||||
/* Put the cursor back to where the application expects it */
|
||||
if (!enabled) {
|
||||
SDL_WarpMouseInWindow(focusWindow, mouse->x, mouse->y);
|
||||
SDL_PerformWarpMouseInWindow(focusWindow, mouse->x, mouse->y, SDL_TRUE);
|
||||
}
|
||||
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
@@ -937,39 +1008,84 @@ 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();
|
||||
}
|
||||
|
||||
focusWindow = SDL_GetKeyboardFocus();
|
||||
|
||||
isCaptured = focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE);
|
||||
if (isCaptured == enabled) {
|
||||
return 0; /* already done! */
|
||||
#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__ */
|
||||
|
||||
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;
|
||||
if (enabled && SDL_GetKeyboardFocus() == NULL) {
|
||||
return SDL_SetError("No window has focus");
|
||||
}
|
||||
mouse->capture_desired = enabled;
|
||||
|
||||
return 0;
|
||||
return SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
|
||||
SDL_Cursor *
|
||||
@@ -1029,7 +1145,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
||||
SDL_Cursor *cursor;
|
||||
|
||||
if (!surface) {
|
||||
SDL_SetError("Passed NULL cursor surface");
|
||||
SDL_InvalidParamError("surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
14
externals/SDL/src/events/SDL_mouse_c.h
vendored
14
externals/SDL/src/events/SDL_mouse_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -100,6 +100,12 @@ 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;
|
||||
@@ -131,6 +137,9 @@ 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);
|
||||
|
||||
@@ -143,6 +152,9 @@ 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);
|
||||
|
||||
|
2
externals/SDL/src/events/SDL_quit.c
vendored
2
externals/SDL/src/events/SDL_quit.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/SDL_sysevents.h
vendored
2
externals/SDL/src/events/SDL_sysevents.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
24
externals/SDL/src/events/SDL_touch.c
vendored
24
externals/SDL/src/events/SDL_touch.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -63,6 +63,16 @@ 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)
|
||||
{
|
||||
@@ -185,6 +195,7 @@ 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 */
|
||||
@@ -254,8 +265,13 @@ 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) {
|
||||
@@ -302,8 +318,9 @@ 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 */
|
||||
return 0;
|
||||
/* 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);
|
||||
}
|
||||
|
||||
if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) {
|
||||
@@ -451,6 +468,7 @@ SDL_DelTouch(SDL_TouchID id)
|
||||
SDL_free(touch->fingers[i]);
|
||||
}
|
||||
SDL_free(touch->fingers);
|
||||
SDL_free(touch->name);
|
||||
SDL_free(touch);
|
||||
|
||||
SDL_num_touch--;
|
||||
|
3
externals/SDL/src/events/SDL_touch_c.h
vendored
3
externals/SDL/src/events/SDL_touch_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -31,6 +31,7 @@ typedef struct SDL_Touch
|
||||
int num_fingers;
|
||||
int max_fingers;
|
||||
SDL_Finger** fingers;
|
||||
char *name;
|
||||
} SDL_Touch;
|
||||
|
||||
|
||||
|
9
externals/SDL/src/events/SDL_windowevents.c
vendored
9
externals/SDL/src/events/SDL_windowevents.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -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,8 +201,9 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
|
||||
|
||||
if (windowevent == SDL_WINDOWEVENT_CLOSE) {
|
||||
if ( !window->prev && !window->next ) {
|
||||
/* This is the last window in the list so send the SDL_QUIT event */
|
||||
SDL_SendQuit();
|
||||
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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/events/blank_cursor.h
vendored
2
externals/SDL/src/events/blank_cursor.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
3
externals/SDL/src/events/default_cursor.h
vendored
3
externals/SDL/src/events/default_cursor.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -111,4 +111,5 @@ static const unsigned char default_cmask[] = {
|
||||
};
|
||||
|
||||
#endif /* USE_MACOS_CURSOR */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
6
externals/SDL/src/events/scancodes_darwin.h
vendored
6
externals/SDL/src/events/scancodes_darwin.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -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* */
|
||||
/* *INDENT-OFF* */ /* clang-format 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* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
6
externals/SDL/src/events/scancodes_linux.h
vendored
6
externals/SDL/src/events/scancodes_linux.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -24,7 +24,7 @@
|
||||
Sources:
|
||||
- Linux kernel source input.h
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format 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* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
6
externals/SDL/src/events/scancodes_windows.h
vendored
6
externals/SDL/src/events/scancodes_windows.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -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* */
|
||||
/* *INDENT-OFF* */ /* clang-format 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* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
6
externals/SDL/src/events/scancodes_xfree86.h
vendored
6
externals/SDL/src/events/scancodes_xfree86.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -28,7 +28,7 @@
|
||||
Sources:
|
||||
- atKeyNames.h from XFree86 source code
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format 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* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
Reference in New Issue
Block a user