* Adjustment: Update libsdl to address a bug in compilation on MacOS devices.

This commit is contained in:
Robert MacGregor 2022-05-21 20:25:30 -04:00
parent 516163fd5d
commit eab544c8f3
270 changed files with 9531 additions and 3704 deletions

View file

@ -150,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
@ -166,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) ||
@ -175,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
@ -590,7 +601,7 @@ SDL_AddEvent(SDL_Event * event)
SDL_EventQ.free = entry->next;
}
if (SDL_DoEventLogging) {
if (SDL_EventLoggingVerbosity > 0) {
SDL_LogEvent(event);
}

View file

@ -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() */

View file

@ -867,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();
@ -883,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;
@ -894,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)
{
@ -953,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) {
@ -962,7 +983,7 @@ 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);
@ -998,7 +1019,8 @@ SDL_UpdateMouseCapture(SDL_bool force_release)
}
if (!force_release) {
if (mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0)) {
if (SDL_GetMessageBoxCount() == 0 &&
(mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0))) {
if (!mouse->relative_mode) {
capture_window = SDL_GetKeyboardFocus();
}
@ -1006,21 +1028,34 @@ SDL_UpdateMouseCapture(SDL_bool force_release)
}
if (capture_window != mouse->capture_window) {
if (mouse->capture_window) {
mouse->CaptureMouse(NULL);
mouse->capture_window->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
mouse->capture_window = NULL;
/* 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) {
if (mouse->CaptureMouse(capture_window) < 0) {
/* CaptureMouse() will have set an error */
return -1;
}
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;
}
@ -1034,6 +1069,17 @@ SDL_CaptureMouse(SDL_bool enabled)
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__ */
if (enabled && SDL_GetKeyboardFocus() == NULL) {
return SDL_SetError("No window has focus");
}

View file

@ -152,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);

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* */
/* *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 */

View file

@ -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 */

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* */
/* *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 */

View file

@ -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 */