From 48811d08a8edecea05c117022a38a91dd10f46f6 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 2 Dec 2023 14:16:23 -0400 Subject: [PATCH] Update SDL2 to 2.28.5 --- CMakeLists.txt | 2 +- libs/SDL2/CMakeLists.txt | 18 ++++- libs/SDL2/Makefile.os2 | 2 +- libs/SDL2/Makefile.w32 | 2 +- libs/SDL2/SDL2.spec | 2 +- libs/SDL2/VERSION.txt | 2 +- libs/SDL2/Xcode/SDL/Info-Framework.plist | 4 +- .../Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 +-- libs/SDL2/Xcode/SDL/pkg-support/SDL.info | 2 +- .../java/org/libsdl/app/HIDDeviceManager.java | 1 + .../main/java/org/libsdl/app/SDLActivity.java | 2 +- libs/SDL2/configure | 2 +- libs/SDL2/configure.ac | 2 +- libs/SDL2/include/SDL_revision.h | 4 +- libs/SDL2/include/SDL_version.h | 2 +- libs/SDL2/src/audio/arts/SDL_artsaudio.c | 4 +- libs/SDL2/src/core/android/SDL_android.c | 4 +- libs/SDL2/src/hidapi/libusb/hid.c | 1 + libs/SDL2/src/joystick/SDL_joystick.c | 4 + libs/SDL2/src/joystick/controller_list.h | 1 + .../src/joystick/hidapi/SDL_hidapijoystick.c | 7 ++ libs/SDL2/src/main/windows/version.rc | 8 +- libs/SDL2/src/render/software/SDL_triangle.c | 21 +++-- libs/SDL2/src/stdlib/SDL_string.c | 71 +++++++++++++++++ libs/SDL2/src/test/SDL_test_fuzzer.c | 4 +- libs/SDL2/src/video/SDL_blit_slow.c | 21 +++-- .../src/video/android/SDL_androidevents.c | 1 + .../src/video/wayland/SDL_waylandevents.c | 10 ++- .../src/video/wayland/SDL_waylandwindow.c | 26 +++---- libs/SDL2/src/video/x11/SDL_x11mouse.c | 29 +++---- libs/SDL2/test/testautomation_stdlib.c | 78 ++++++++++++++++++- 31 files changed, 265 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 554bfe488..7a65db6b0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,7 +173,7 @@ set(MEGA_LIBVORBIS_VER "1.3.5") set(MEGA_LIBTHEORA_VER "1.1.1") set(MEGA_MPG123_VER "1.25.6") set(MEGA_FREETYPE_VER "2.8.1") -set(MEGA_SDL2_VER "2.28.4") +set(MEGA_SDL2_VER "2.28.5") set(MEGA_OPENAL_VER "1.19.1") set(MEGA_MODPLUG_VER "0.8.8.4") diff --git a/libs/SDL2/CMakeLists.txt b/libs/SDL2/CMakeLists.txt index dd8f2113f..48a31f76a 100644 --- a/libs/SDL2/CMakeLists.txt +++ b/libs/SDL2/CMakeLists.txt @@ -87,7 +87,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 28) -set(SDL_MICRO_VERSION 4) +set(SDL_MICRO_VERSION 5) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts @@ -3089,9 +3089,17 @@ else() set(sdl_static_libname "SDL2") endif() -set(prefix ${CMAKE_INSTALL_PREFIX}) +# CMAKE_PREFIX_PATH and CMAKE_INSTALL_FULL_BINDIR can be a non-absolute path +# when a master-project does e.g. `set(CMAKE_INSTALL_PREFIX "libs/SDL2" CACHE PATH "prefix" FORCE)`. +if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") +endif() +if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_FULL_BINDIR}") + set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_FULL_BINDIR}") +endif() file(RELATIVE_PATH bin_prefix_relpath "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_PREFIX}") +set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}") @@ -3335,6 +3343,12 @@ if(ANDROID) endif() if(APPLE) + cmake_push_check_state(RESET) + check_c_compiler_flag(-fobjc-arc COMPILER_SUPPORTS_FOBJC_ARC) + cmake_pop_check_state() + if(NOT COMPILER_SUPPORTS_FOBJC_ARC) + message(FATAL_ERROR "Compiler does not support -fobjc-arc: this is required on Apple platforms") + endif() target_compile_options(sdl-build-options INTERFACE "-fobjc-arc") endif() diff --git a/libs/SDL2/Makefile.os2 b/libs/SDL2/Makefile.os2 index 9f4a61882..bb1b231a6 100644 --- a/libs/SDL2/Makefile.os2 +++ b/libs/SDL2/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 28 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/libs/SDL2/Makefile.w32 b/libs/SDL2/Makefile.w32 index d7b23927f..6b14fc317 100644 --- a/libs/SDL2/Makefile.w32 +++ b/libs/SDL2/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 28 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/libs/SDL2/SDL2.spec b/libs/SDL2/SDL2.spec index 472a530ca..50e3cb2ad 100644 --- a/libs/SDL2/SDL2.spec +++ b/libs/SDL2/SDL2.spec @@ -1,6 +1,6 @@ Summary: Simple DirectMedia Layer Name: SDL2 -Version: 2.28.4 +Version: 2.28.5 Release: 2 Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz URL: http://www.libsdl.org/ diff --git a/libs/SDL2/VERSION.txt b/libs/SDL2/VERSION.txt index 844e15cf2..a65892fff 100644 --- a/libs/SDL2/VERSION.txt +++ b/libs/SDL2/VERSION.txt @@ -1 +1 @@ -release-2.28.4-0-gcc016b004 +release-2.28.5-0-g15ead9a40 diff --git a/libs/SDL2/Xcode/SDL/Info-Framework.plist b/libs/SDL2/Xcode/SDL/Info-Framework.plist index b54c747b7..a0ddc4ef2 100644 --- a/libs/SDL2/Xcode/SDL/Info-Framework.plist +++ b/libs/SDL2/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.28.4 + 2.28.5 CFBundleSignature SDLX CFBundleVersion - 2.28.4 + 2.28.5 diff --git a/libs/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/libs/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 1dba648d5..816ef9784 100755 --- a/libs/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/libs/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9529,7 +9529,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.4.0; + DYLIB_CURRENT_VERSION = 2801.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9570,7 +9570,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.28.4; + MARKETING_VERSION = 2.28.5; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9614,7 +9614,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.4.0; + DYLIB_CURRENT_VERSION = 2801.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9656,7 +9656,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.28.4; + MARKETING_VERSION = 2.28.5; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -9863,7 +9863,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.4.0; + DYLIB_CURRENT_VERSION = 2801.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -9915,7 +9915,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.4.0; + DYLIB_CURRENT_VERSION = 2801.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/libs/SDL2/Xcode/SDL/pkg-support/SDL.info b/libs/SDL2/Xcode/SDL/pkg-support/SDL.info index 34a17eb12..637653bc6 100755 --- a/libs/SDL2/Xcode/SDL/pkg-support/SDL.info +++ b/libs/SDL2/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.28.4 +Title SDL 2.28.5 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index 6f7013b2f..5310d6016 100644 --- a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -273,6 +273,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa final int XB1_IFACE_SUBCLASS = 71; final int XB1_IFACE_PROTOCOL = 208; final int[] SUPPORTED_VENDORS = { + 0x03f0, // HP 0x044f, // Thrustmaster 0x045e, // Microsoft 0x0738, // Mad Catz diff --git a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index de7361d6d..a2b5ba873 100644 --- a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 28; - private static final int SDL_MICRO_VERSION = 4; + private static final int SDL_MICRO_VERSION = 5; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/libs/SDL2/configure b/libs/SDL2/configure index e290661ac..c5b466b5f 100755 --- a/libs/SDL2/configure +++ b/libs/SDL2/configure @@ -3507,7 +3507,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=28 -SDL_MICRO_VERSION=4 +SDL_MICRO_VERSION=5 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/libs/SDL2/configure.ac b/libs/SDL2/configure.ac index fc2fde5e5..558895859 100644 --- a/libs/SDL2/configure.ac +++ b/libs/SDL2/configure.ac @@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=28 -SDL_MICRO_VERSION=4 +SDL_MICRO_VERSION=5 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/libs/SDL2/include/SDL_revision.h b/libs/SDL2/include/SDL_revision.h index 453ccb3d2..4455a08b6 100644 --- a/libs/SDL2/include/SDL_revision.h +++ b/libs/SDL2/include/SDL_revision.h @@ -1,7 +1,7 @@ /* Generated by updaterev.sh, do not edit */ #ifdef SDL_VENDOR_INFO -#define SDL_REVISION "SDL-release-2.28.4-0-gcc016b004 (" SDL_VENDOR_INFO ")" +#define SDL_REVISION "SDL-release-2.28.5-0-g15ead9a40 (" SDL_VENDOR_INFO ")" #else -#define SDL_REVISION "SDL-release-2.28.4-0-gcc016b004" +#define SDL_REVISION "SDL-release-2.28.5-0-g15ead9a40" #endif #define SDL_REVISION_NUMBER 0 diff --git a/libs/SDL2/include/SDL_version.h b/libs/SDL2/include/SDL_version.h index 57c171ccd..7585eece5 100644 --- a/libs/SDL2/include/SDL_version.h +++ b/libs/SDL2/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 28 -#define SDL_PATCHLEVEL 4 +#define SDL_PATCHLEVEL 5 /** * Macro to determine SDL version program was compiled against. diff --git a/libs/SDL2/src/audio/arts/SDL_artsaudio.c b/libs/SDL2/src/audio/arts/SDL_artsaudio.c index ea4f3119b..f3aa94b15 100644 --- a/libs/SDL2/src/audio/arts/SDL_artsaudio.c +++ b/libs/SDL2/src/audio/arts/SDL_artsaudio.c @@ -300,12 +300,12 @@ static void ARTS_Deinitialize(void) } -static SDL_bool ARTS_Init(SDL_AudioDriverImpl * impl) +static SDL_bool ARTS_Init(SDL_AudioDriverImpl *impl) { if (LoadARTSLibrary() < 0) { return SDL_FALSE; } else { - if (SDL_NAME(arts_init) () != NULL) { + if (SDL_NAME(arts_init) () != 0) { UnloadARTSLibrary(); SDL_SetError("ARTS: arts_init failed (no audio server?)"); return SDL_FALSE; diff --git a/libs/SDL2/src/core/android/SDL_android.c b/libs/SDL2/src/core/android/SDL_android.c index 34dfdedf0..0c8811c99 100644 --- a/libs/SDL2/src/core/android/SDL_android.c +++ b/libs/SDL2/src/core/android/SDL_android.c @@ -1939,12 +1939,12 @@ int Android_JNI_FileOpen(SDL_RWops *ctx, } if (asset_manager == NULL) { - return -1; + return SDL_SetError("Couldn't create asset manager"); } asset = AAssetManager_open(asset_manager, fileName, AASSET_MODE_UNKNOWN); if (asset == NULL) { - return -1; + return SDL_SetError("Couldn't open asset '%s'", fileName); } ctx->hidden.androidio.asset = (void *)asset; diff --git a/libs/SDL2/src/hidapi/libusb/hid.c b/libs/SDL2/src/hidapi/libusb/hid.c index 98eaa0e69..e5ee31b9a 100644 --- a/libs/SDL2/src/hidapi/libusb/hid.c +++ b/libs/SDL2/src/hidapi/libusb/hid.c @@ -711,6 +711,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de static const int XB1_IFACE_SUBCLASS = 71; static const int XB1_IFACE_PROTOCOL = 208; static const int SUPPORTED_VENDORS[] = { + 0x03f0, /* HP */ 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ diff --git a/libs/SDL2/src/joystick/SDL_joystick.c b/libs/SDL2/src/joystick/SDL_joystick.c index face36985..834e83d99 100644 --- a/libs/SDL2/src/joystick/SDL_joystick.c +++ b/libs/SDL2/src/joystick/SDL_joystick.c @@ -2507,6 +2507,10 @@ static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) MAKE_VIDPID(0x0eb7, 0x038e), /* Fanatec ClubSport Wheel Base V1 */ MAKE_VIDPID(0x0eb7, 0x0e03), /* Fanatec CSL Elite Wheel Base */ MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ + MAKE_VIDPID(0x2433, 0xf300), /* Asetek SimSports Invicta Wheelbase */ + MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */ + MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ + MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ }; int i; diff --git a/libs/SDL2/src/joystick/controller_list.h b/libs/SDL2/src/joystick/controller_list.h index c7871c25e..a11107287 100644 --- a/libs/SDL2/src/joystick/controller_list.h +++ b/libs/SDL2/src/joystick/controller_list.h @@ -294,6 +294,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x24c6, 0xfafd ), k_eControllerType_XBox360Controller, NULL }, // Afterglow Gamepad 3 { MAKE_CONTROLLER_ID( 0x24c6, 0xfafe ), k_eControllerType_XBox360Controller, NULL }, // Rock Candy Gamepad for Xbox 360 + { MAKE_CONTROLLER_ID( 0x03f0, 0x0495 ), k_eControllerType_XBoxOneController, NULL }, // HP HyperX Clutch Gladiate { MAKE_CONTROLLER_ID( 0x044f, 0xd012 ), k_eControllerType_XBoxOneController, NULL }, // ThrustMaster eSwap PRO Controller Xbox { MAKE_CONTROLLER_ID( 0x045e, 0x02d1 ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad { MAKE_CONTROLLER_ID( 0x045e, 0x02dd ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad (Firmware 2015) diff --git a/libs/SDL2/src/joystick/hidapi/SDL_hidapijoystick.c b/libs/SDL2/src/joystick/hidapi/SDL_hidapijoystick.c index c0e5cd5d7..201db43e8 100644 --- a/libs/SDL2/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/libs/SDL2/src/joystick/hidapi/SDL_hidapijoystick.c @@ -265,6 +265,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char * interface_protocol == XBONE_IFACE_PROTOCOL) { static const int SUPPORTED_VENDORS[] = { + 0x03f0, /* HP */ 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ @@ -1436,6 +1437,12 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) device->updating = SDL_FALSE; SDL_UnlockMutex(device->dev_lock); + /* UpdateDevice() may have called HIDAPI_JoystickDisconnected() if the device went away */ + if (device->num_joysticks == 0) { + SDL_free(hwdata); + return SDL_SetError("HIDAPI device disconnected while opening"); + } + if (!device->driver->OpenJoystick(device, joystick)) { /* The open failed, mark this device as disconnected and update devices */ HIDAPI_JoystickDisconnected(device, joystickID); diff --git a/libs/SDL2/src/main/windows/version.rc b/libs/SDL2/src/main/windows/version.rc index 5924b7081..f69c755b4 100644 --- a/libs/SDL2/src/main/windows/version.rc +++ b/libs/SDL2/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,28,4,0 - PRODUCTVERSION 2,28,4,0 + FILEVERSION 2,28,5,0 + PRODUCTVERSION 2,28,5,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 28, 4, 0\0" + VALUE "FileVersion", "2, 28, 5, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 28, 4, 0\0" + VALUE "ProductVersion", "2, 28, 5, 0\0" END END BLOCK "VarFileInfo" diff --git a/libs/SDL2/src/render/software/SDL_triangle.c b/libs/SDL2/src/render/software/SDL_triangle.c index fc429db6e..a4c04b2dd 100644 --- a/libs/SDL2/src/render/software/SDL_triangle.c +++ b/libs/SDL2/src/render/software/SDL_triangle.c @@ -789,15 +789,20 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (!is_uniform) { diff --git a/libs/SDL2/src/stdlib/SDL_string.c b/libs/SDL2/src/stdlib/SDL_string.c index 09c4489fc..7353d4591 100644 --- a/libs/SDL2/src/stdlib/SDL_string.c +++ b/libs/SDL2/src/stdlib/SDL_string.c @@ -1114,6 +1114,39 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) return vsscanf(text, fmt, ap); } #else +static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len) +{ + SDL_bool invert = SDL_FALSE; + SDL_bool result = SDL_FALSE; + + if (*set == '^') { + invert = SDL_TRUE; + ++set; + --set_len; + } + while (set_len > 0 && !result) { + if (set_len >= 3 && set[1] == '-') { + char low_char = SDL_min(set[0], set[2]); + char high_char = SDL_max(set[0], set[2]); + if (c >= low_char && c <= high_char) { + result = SDL_TRUE; + } + set += 3; + set_len -= 3; + } else { + if (c == *set) { + result = SDL_TRUE; + } + ++set; + --set_len; + } + } + if (invert) { + result = result ? SDL_FALSE : SDL_TRUE; + } + return result; +} + /* NOLINTNEXTLINE(readability-non-const-parameter) */ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { @@ -1387,6 +1420,44 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) } done = SDL_TRUE; break; + case '[': + { + const char *set = fmt + 1; + while (*fmt && *fmt != ']') { + ++fmt; + } + if (*fmt) { + size_t set_len = (fmt - set); + if (suppress) { + while (CharacterMatchesSet(*text, set, set_len)) { + ++text; + if (count) { + if (--count == 0) { + break; + } + } + } + } else { + SDL_bool had_match = SDL_FALSE; + char *valuep = va_arg(ap, char *); + while (CharacterMatchesSet(*text, set, set_len)) { + had_match = SDL_TRUE; + *valuep++ = *text++; + if (count) { + if (--count == 0) { + break; + } + } + } + *valuep = '\0'; + if (had_match) { + ++retval; + } + } + } + } + done = SDL_TRUE; + break; default: done = SDL_TRUE; break; diff --git a/libs/SDL2/src/test/SDL_test_fuzzer.c b/libs/SDL2/src/test/SDL_test_fuzzer.c index b59cbb32d..9e2e757e4 100644 --- a/libs/SDL2/src/test/SDL_test_fuzzer.c +++ b/libs/SDL2/src/test/SDL_test_fuzzer.c @@ -471,7 +471,9 @@ char *SDLTest_RandomAsciiStringWithMaximumLength(int maxLength) } size = (SDLTest_RandomUint32() % (maxLength + 1)); - + if (size == 0) { + size = 1; + } return SDLTest_RandomAsciiStringOfSize(size); } diff --git a/libs/SDL2/src/video/SDL_blit_slow.c b/libs/SDL2/src/video/SDL_blit_slow.c index 9ea5c384d..fb8516bd8 100644 --- a/libs/SDL2/src/video/SDL_blit_slow.c +++ b/libs/SDL2/src/video/SDL_blit_slow.c @@ -106,15 +106,20 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (flags & SDL_COPY_MODULATE_COLOR) { diff --git a/libs/SDL2/src/video/android/SDL_androidevents.c b/libs/SDL2/src/video/android/SDL_androidevents.c index ad669f892..b15239828 100644 --- a/libs/SDL2/src/video/android/SDL_androidevents.c +++ b/libs/SDL2/src/video/android/SDL_androidevents.c @@ -74,6 +74,7 @@ static void android_egl_context_restore(SDL_Window *window) if (window) { SDL_Event event; SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_GL_MakeCurrent(window, NULL); if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) { /* The context is no longer valid, create a new one */ data->egl_context = (EGLContext)SDL_GL_CreateContext(window); diff --git a/libs/SDL2/src/video/wayland/SDL_waylandevents.c b/libs/SDL2/src/video/wayland/SDL_waylandevents.c index 160185ffc..65adff64c 100644 --- a/libs/SDL2/src/video/wayland/SDL_waylandevents.c +++ b/libs/SDL2/src/video/wayland/SDL_waylandevents.c @@ -2534,6 +2534,10 @@ static void lock_pointer_to_window(SDL_Window *window, SDL_VideoData *d = input->display; struct zwp_locked_pointer_v1 *locked_pointer; + if (!d->pointer_constraints || !input->pointer) { + return; + } + if (w->locked_pointer) { return; } @@ -2621,8 +2625,10 @@ int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input) w->locked_pointer = NULL; } - zwp_relative_pointer_v1_destroy(input->relative_pointer); - input->relative_pointer = NULL; + if (input->relative_pointer) { + zwp_relative_pointer_v1_destroy(input->relative_pointer); + input->relative_pointer = NULL; + } d->relative_mouse_mode = 0; diff --git a/libs/SDL2/src/video/wayland/SDL_waylandwindow.c b/libs/SDL2/src/video/wayland/SDL_waylandwindow.c index 303f5982b..ff323083e 100644 --- a/libs/SDL2/src/video/wayland/SDL_waylandwindow.c +++ b/libs/SDL2/src/video/wayland/SDL_waylandwindow.c @@ -1322,21 +1322,15 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) /* Create the shell surface and map the toplevel/popup */ #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame) { - /* If the frame already exists, just set the visibility. */ - libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true); - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, + data->surface, + &libdecor_frame_interface, + data); + if (data->shell_surface.libdecor.frame == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); } else { - data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, - data->surface, - &libdecor_frame_interface, - data); - if (data->shell_surface.libdecor.frame == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); - } else { - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); - libdecor_frame_map(data->shell_surface.libdecor.frame); - } + libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + libdecor_frame_map(data->shell_surface.libdecor.frame); } } else #endif @@ -1540,8 +1534,8 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (wind->shell_surface.libdecor.frame) { - libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false); - libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname); + libdecor_frame_unref(wind->shell_surface.libdecor.frame); + wind->shell_surface.libdecor.frame = NULL; } } else #endif diff --git a/libs/SDL2/src/video/x11/SDL_x11mouse.c b/libs/SDL2/src/video/x11/SDL_x11mouse.c index 978a30584..7c3d20216 100644 --- a/libs/SDL2/src/video/x11/SDL_x11mouse.c +++ b/libs/SDL2/src/video/x11/SDL_x11mouse.c @@ -330,13 +330,16 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) Display *display = videodata->display; #if SDL_VIDEO_DRIVER_X11_XINPUT2 int deviceid = 0; - /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: - * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea - */ - if (ScreenCount(display) == 1) { - X11_XIGetClientPointer(display, None, &deviceid); + if (X11_Xinput2IsInitialized()) { + /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: + * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea + */ + if (ScreenCount(display) == 1) { + X11_XIGetClientPointer(display, None, &deviceid); + } } if (deviceid != 0) { + SDL_assert(SDL_X11_HAVE_XINPUT2); X11_XIWarpPointer(display, deviceid, None, xwindow, 0.0, 0.0, 0, 0, (double)x, (double)y); } else #endif @@ -369,14 +372,7 @@ static int X11_WarpMouseGlobal(int x, int y) static int X11_SetRelativeMouseMode(SDL_bool enabled) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 - if (X11_Xinput2IsInitialized()) { - return 0; - } -#else - SDL_Unsupported(); -#endif - return -1; + return X11_Xinput2IsInitialized() ? 0 : SDL_Unsupported(); } static int X11_CaptureMouse(SDL_Window *window) @@ -414,12 +410,9 @@ static Uint32 X11_GetGlobalMouseState(int *x, int *y) /* !!! FIXME: should we XSync() here first? */ -#if !SDL_VIDEO_DRIVER_X11_XINPUT2 - videodata->global_mouse_changed = SDL_TRUE; -#else - if (!SDL_X11_HAVE_XINPUT2) + if (!X11_Xinput2IsInitialized()) { videodata->global_mouse_changed = SDL_TRUE; -#endif + } /* check if we have this cached since XInput last saw the mouse move. */ /* !!! FIXME: can we just calculate this from XInput's events? */ diff --git a/libs/SDL2/test/testautomation_stdlib.c b/libs/SDL2/test/testautomation_stdlib.c index ba7ba88f7..a75e4570b 100644 --- a/libs/SDL2/test/testautomation_stdlib.c +++ b/libs/SDL2/test/testautomation_stdlib.c @@ -339,7 +339,7 @@ int stdlib_sscanf(void *arg) long long_output, expected_long_output; long long long_long_output, expected_long_long_output; size_t size_output, expected_size_output; - char text[128]; + char text[128], text2[128]; expected_output = output = 123; expected_result = -1; @@ -403,6 +403,82 @@ int stdlib_sscanf(void *arg) SDLTest_AssertCheck(expected_size_output == size_output, "Check output, expected: %zu, got: %zu", expected_size_output, size_output); SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc def", "%s", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%s\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%s", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%s\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc,def") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[cba]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[cba]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[a-z]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[z-a]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[^,]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[^,]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 0; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[A-Z]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[A-Z]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "") == 0, "Check output, expected: \"\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc,def", "%[abc],%[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc],%%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc,def", "%[abc]%*[,]%[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc]%%*[,]%%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc def", "%[abc] %[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%[abc] %%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc123XYZ", "%[a-zA-Z0-9]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc123XYZ\", \"%%[a-zA-Z0-9]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc123XYZ") == 0, "Check output, expected: \"abc123XYZ\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + return TEST_COMPLETED; }