From 64ad33884d7060cfd896a98609a15fc4aa842bef Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Mar 2025 12:58:50 -0700 Subject: [PATCH 01/10] Updated to version 2.32.5 for development --- CMakeLists.txt | 2 +- Makefile.os2 | 2 +- Makefile.w32 | 2 +- Xcode/SDL/Info-Framework.plist | 4 ++-- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 ++++++------ Xcode/SDL/pkg-support/SDL.info | 2 +- .../src/main/java/org/libsdl/app/SDLActivity.java | 2 +- configure | 2 +- configure.ac | 2 +- include/SDL_version.h | 2 +- src/main/windows/version.rc | 8 ++++---- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d452f6c264cd9..8d2de3a5d462a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 32) -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 diff --git a/Makefile.os2 b/Makefile.os2 index 74702555090a2..7ef1cdbd5a079 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 32 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/Makefile.w32 b/Makefile.w32 index aeabc83f7eab3..200c6c67ee5e8 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 32 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index 80e07697f3e0a..fb653b7ac03d3 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.32.4 + 2.32.5 CFBundleSignature SDLX CFBundleVersion - 2.32.4 + 2.32.5 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 9bc1ef9b8252c..b19de7afc948b 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.4.0; + DYLIB_CURRENT_VERSION = 3201.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9770,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.32.4; + MARKETING_VERSION = 2.32.5; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.4.0; + DYLIB_CURRENT_VERSION = 3201.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9856,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.32.4; + MARKETING_VERSION = 2.32.5; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.4.0; + DYLIB_CURRENT_VERSION = 3201.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -10115,7 +10115,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.4.0; + DYLIB_CURRENT_VERSION = 3201.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info index 503e1de91fac7..b9938db33a619 100644 --- a/Xcode/SDL/pkg-support/SDL.info +++ b/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.32.4 +Title SDL 2.32.5 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 4bd92e27494af..3b3f555ed61b7 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/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 = 32; - 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/configure b/configure index 107c69081b7f0..6ecf58cda3c13 100755 --- a/configure +++ b/configure @@ -3516,7 +3516,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=32 -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/configure.ac b/configure.ac index eb006176a46b2..c4f831e5486a6 100644 --- a/configure.ac +++ b/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=32 -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/include/SDL_version.h b/include/SDL_version.h index 1b57c9a3a5ffc..dda62e1c9ace4 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -58,7 +58,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 32 -#define SDL_PATCHLEVEL 4 +#define SDL_PATCHLEVEL 5 /** * Macro to determine SDL version program was compiled against. diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index a8861af3dd2ac..e4c0dcdd26e82 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,32,4,0 - PRODUCTVERSION 2,32,4,0 + FILEVERSION 2,32,5,0 + PRODUCTVERSION 2,32,5,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 32, 4, 0\0" + VALUE "FileVersion", "2, 32, 5, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 32, 4, 0\0" + VALUE "ProductVersion", "2, 32, 5, 0\0" END END BLOCK "VarFileInfo" From f54014e173c33dc0cca63a534b1b82b28b69d9bc Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 3 Apr 2025 18:55:04 +0300 Subject: [PATCH 02/10] SDL_cpuinfo.h: only include immintrin.h for x86 targets. Reference issue: https://github.com/libsdl-org/SDL_image/issues/537 Reference issue: https://github.com/libsdl-org/SDL_mixer/issues/648 (cherry picked from commit bfab0a968fd54250377f65232df5982e46ecc712) --- include/SDL_cpuinfo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index f303112351977..696a03bf7bd77 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -115,7 +115,8 @@ _m_prefetch(void *__P) #include #define __LASX__ #endif -#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) +#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) && \ + (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)) #include #else #if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H) From 093307f1f4031aa1f916b6f5b64ecfc4847c1b4b Mon Sep 17 00:00:00 2001 From: "Boris I. Bendovsky" Date: Mon, 21 Apr 2025 12:31:57 +0300 Subject: [PATCH 03/10] [SDL2] Fix using of DXSDK_DIR in older CMake - Remove duplicate 'dollar' symbol in the path - Use command 'file' to normalize file paths (cherry picked from commit 40b1eac541fcf8a0cdf500e5ea0fa41c5168a29a) --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d2de3a5d462a..f08c51d647a37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1829,8 +1829,10 @@ elseif(WINDOWS) set(HAVE_DIRECTX TRUE) if(NOT MINGW AND NOT USE_WINSDK_DIRECTX) # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks - target_link_directories(sdl-build-options INTERFACE "$$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}") - target_include_directories(sdl-build-options INTERFACE "$ENV{DXSDK_DIR}\\Include") + file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}" SDL2_TMP_DXSDK_LIB_DIR) + target_link_directories(sdl-build-options INTERFACE "${SDL2_TMP_DXSDK_LIB_DIR}") + file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}\\Include" SDL2_TMP_DXSDK_INCLUDE_DIR) + target_include_directories(sdl-build-options INTERFACE "${SDL2_TMP_DXSDK_INCLUDE_DIR}") endif() endif() set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) From 56966775588f46e0f38d47a45561d5f2c5739870 Mon Sep 17 00:00:00 2001 From: Petar Popovic Date: Sun, 20 Apr 2025 21:40:47 +0200 Subject: [PATCH 04/10] SDL_BlitSurface() comment: only dstrect is modified in function (cherry picked from commit 035518d06502e144e3e52208adf8d0fb036194d8) --- include/SDL_surface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_surface.h b/include/SDL_surface.h index 6169e66ebe024..42ea5919af021 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -808,8 +808,8 @@ extern DECLSPEC int SDLCALL SDL_FillRects * * This assumes that the source and destination rectangles are the same size. * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or - * `dst`) is copied. The final blit rectangles are saved in `srcrect` and - * `dstrect` after all clipping is performed. + * `dst`) is copied. The final blit rectangle is saved in `dstrect` after + * all clipping is performed. * * The blit function should not be called on a locked surface. * From f46ef5d76d4928dbe7a2abc5a236a2dc022770c3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 26 Feb 2025 11:21:34 -0800 Subject: [PATCH 05/10] Fixed reliability of initializing Switch controllers on macOS It looks like both macOS (15.1.1) and SDL are trying to talk to the controller at the same time, which can cause interleaved replies or even locking up the controller. Waiting a bit before talking to the controller seems to take care of this. (cherry picked from commit 45b01d16b1132b586fb739748c574b13e7df147f) --- src/joystick/hidapi/SDL_hidapi_switch.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 54c6d96367ff7..253c4f95996d9 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -817,7 +817,9 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) SwitchSubcommandInputPacket_t *factory_reply = NULL; SwitchSPIOpData_t readUserParams; SwitchSPIOpData_t readFactoryParams; - + const int MAX_ATTEMPTS = 3; + int attempt; + /* Read User Calibration Info */ readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset; readUserParams.ucLength = k_unSPIStickUserCalibrationLength; @@ -829,8 +831,19 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset; readFactoryParams.ucLength = k_unSPIStickFactoryCalibrationLength; - if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) { - return SDL_FALSE; + for (attempt = 0; ; ++attempt) { + if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) { + return SDL_FALSE; + } + + if (factory_reply->stickFactoryCalibration.opData.unAddress == k_unSPIStickFactoryCalibrationStartOffset) { + /* We successfully read the calibration data */ + break; + } + + if (attempt == MAX_ATTEMPTS) { + return SDL_FALSE; + } } /* Automatically select the user calibration if magic bytes are set */ @@ -1426,6 +1439,10 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->m_bSyncWrite = SDL_TRUE; if (!ctx->m_bInputOnly) { +#ifdef SDL_PLATFORM_MACOS + // Wait for the OS to finish its handshake with the controller + SDL_Delay(250); +#endif GetInitialInputMode(ctx); ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode; From 24ccde693efec1a8bd7bcb0a09c034d1c6313138 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 29 Apr 2025 00:30:41 -0500 Subject: [PATCH 06/10] events: Fix undefined behavior when disabling some event types Shifting a signed int left by 31 is UB. (cherry picked from commit 15fd3fcdc214d06dd5c12daf4a29772e994c6b7a) --- src/events/SDL_events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 1d4d785f5d71a..3dcd9a8f66f57 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -1318,7 +1318,7 @@ Uint8 SDL_EventState(Uint32 type, int state) Uint8 lo = (type & 0xff); if (SDL_disabled_events[hi] && - (SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) { + (SDL_disabled_events[hi]->bits[lo / 32] & (1U << (lo & 31)))) { current_state = SDL_DISABLE; } else { current_state = SDL_ENABLE; @@ -1332,11 +1332,11 @@ Uint8 SDL_EventState(Uint32 type, int state) } /* Out of memory, nothing we can do... */ if (SDL_disabled_events[hi]) { - SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31)); + SDL_disabled_events[hi]->bits[lo / 32] |= (1U << (lo & 31)); SDL_FlushEvent(type); } } else { // state == SDL_ENABLE - SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31)); + SDL_disabled_events[hi]->bits[lo / 32] &= ~(1U << (lo & 31)); } #ifndef SDL_JOYSTICK_DISABLED From 7fc5edab8e939523dba9e10b6375fcdfb0f875f4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 29 Apr 2025 09:48:44 -0700 Subject: [PATCH 07/10] Revert "Don't leak device handle in macOS 10.10 or newer" This reverts commit 5925c27efb872be854bda4616ad5ce3e7db23927. Fixes https://github.com/libsdl-org/SDL/issues/12807 (cherry picked from commit 5b951141d2a56863b7f199b0952192a0cee53428) --- src/hidapi/configure.ac | 2 +- src/hidapi/mac/Makefile-manual | 2 +- src/hidapi/mac/hid.c | 21 ++++----------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/hidapi/configure.ac b/src/hidapi/configure.ac index c3d3dbc1b1dbb..c6747f906ac48 100644 --- a/src/hidapi/configure.ac +++ b/src/hidapi/configure.ac @@ -79,7 +79,7 @@ case $host in backend="mac" os="darwin" threads="pthreads" - LIBS="${LIBS} -framework IOKit -framework CoreFoundation -framework AppKit" + LIBS="${LIBS} -framework IOKit -framework CoreFoundation" ;; *-freebsd*) AC_MSG_RESULT([ (FreeBSD back-end)]) diff --git a/src/hidapi/mac/Makefile-manual b/src/hidapi/mac/Makefile-manual index 16052d143fc58..5399b5a70fc62 100644 --- a/src/hidapi/mac/Makefile-manual +++ b/src/hidapi/mac/Makefile-manual @@ -14,7 +14,7 @@ COBJS=hid.o CPPOBJS=../hidtest/hidtest.o OBJS=$(COBJS) $(CPPOBJS) CFLAGS+=-I../hidapi -Wall -g -c -LIBS=-framework IOKit -framework CoreFoundation -framework AppKit +LIBS=-framework IOKit -framework CoreFoundation hidtest: $(OBJS) diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c index b45767333740b..0dbe4227d21c3 100644 --- a/src/hidapi/mac/hid.c +++ b/src/hidapi/mac/hid.c @@ -37,9 +37,6 @@ #define VALVE_USB_VID 0x28DE -/* As defined in AppKit.h, but we don't need the entire AppKit for a single constant. */ -extern const double NSAppKitVersionNumber; - /* Barrier implementation because Mac OSX doesn't have pthread_barrier. It also doesn't have clock_gettime(). So much for POSIX and SUSv2. This implementation came from Brent Priddy and was posted on @@ -134,7 +131,6 @@ struct hid_device_list_node }; static IOHIDManagerRef hid_mgr = 0x0; -static int is_macos_10_10_or_greater = 0; static struct hid_device_list_node *device_list = 0x0; static hid_device *new_hid_device(void) @@ -489,7 +485,6 @@ static int init_hid_manager(void) int HID_API_EXPORT hid_init(void) { if (!hid_mgr) { - is_macos_10_10_or_greater = (NSAppKitVersionNumber >= 1343); /* NSAppKitVersionNumber10_10 */ return init_hid_manager(); } @@ -1143,10 +1138,8 @@ void HID_API_EXPORT hid_close(hid_device *dev) if (!dev) return; - /* Disconnect the report callback before close. - See comment below. - */ - if (is_macos_10_10_or_greater || !dev->disconnected) { + /* Disconnect the report callback before close. */ + if (!dev->disconnected) { IOHIDDeviceRegisterInputReportCallback( dev->device_handle, dev->input_report_buf, dev->max_input_report_len, NULL, dev); @@ -1169,14 +1162,8 @@ void HID_API_EXPORT hid_close(hid_device *dev) /* Close the OS handle to the device, but only if it's not been unplugged. If it's been unplugged, then calling - IOHIDDeviceClose() will crash. - - UPD: The crash part was true in/until some version of macOS. - Starting with macOS 10.15, there is an opposite effect in some environments: - crash happenes if IOHIDDeviceClose() is not called. - Not leaking a resource in all tested environments. - */ - if (is_macos_10_10_or_greater || !dev->disconnected) { + IOHIDDeviceClose() will crash. */ + if (!dev->disconnected) { IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeNone); } From 8b7a088efc1ebf5c2e53ab40fdff48e6c05f0d82 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 29 Apr 2025 11:21:26 -0700 Subject: [PATCH 08/10] Call IOHIDDeviceClose() if needed in hid_close() on macOS Unregistering the input report callback marks the device as disconnected, so IOHIDDeviceClose() would never be called if the device wasn't already disconnected when hid_close() was called. Fixes https://github.com/libsdl-org/SDL/issues/12255 (cherry picked from commit 2442c85cb89c262672b337b2555fff77cf770478) --- src/hidapi/mac/hid.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c index 0dbe4227d21c3..24e0b8ac2a0cc 100644 --- a/src/hidapi/mac/hid.c +++ b/src/hidapi/mac/hid.c @@ -1135,11 +1135,14 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, void HID_API_EXPORT hid_close(hid_device *dev) { + int disconnected; + if (!dev) return; /* Disconnect the report callback before close. */ - if (!dev->disconnected) { + disconnected = dev->disconnected; + if (!disconnected) { IOHIDDeviceRegisterInputReportCallback( dev->device_handle, dev->input_report_buf, dev->max_input_report_len, NULL, dev); @@ -1163,7 +1166,7 @@ void HID_API_EXPORT hid_close(hid_device *dev) /* Close the OS handle to the device, but only if it's not been unplugged. If it's been unplugged, then calling IOHIDDeviceClose() will crash. */ - if (!dev->disconnected) { + if (!disconnected) { IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeNone); } From b0b50da4b61bae62d863b0092c6f04a14f9d8d20 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 1 May 2025 23:19:50 +0000 Subject: [PATCH 09/10] Port #12581 to SDL2 This fixes undefined behavior resulting from adding offsets to nullptr. (cherry picked from commit a220e7c42271fa88d9ff92427c65894408d31e0e) --- src/render/opengles2/SDL_render_gles2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index f5f221c46b607..e8b6f206e3cab 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -975,8 +975,8 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co } if (texture) { - SDL_Vertex *verts = (SDL_Vertex *)(((Uint8 *)vertices) + cmd->data.draw.first); - data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->tex_coord); + uintptr_t base = (uintptr_t)vertices + cmd->data.draw.first; // address of first vertex, or base offset when using VBOs. + data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)(base + offsetof(SDL_Vertex, tex_coord))); } if (GLES2_SelectProgram(data, imgsrc, texture ? texture->w : 0, texture ? texture->h : 0) < 0) { @@ -1009,9 +1009,9 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co /* all drawing commands use this */ { - SDL_VertexSolid *verts = (SDL_VertexSolid *)(((Uint8 *)vertices) + cmd->data.draw.first); - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->position); - data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *)&verts->color); + uintptr_t base = (uintptr_t)vertices + cmd->data.draw.first; // address of first vertex, or base offset when using VBOs. + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)(base + offsetof(SDL_VertexSolid, position))); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *)(base + offsetof(SDL_VertexSolid, color))); } return 0; @@ -1200,7 +1200,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (data->current_vertex_buffer >= SDL_arraysize(data->vertex_buffers)) { data->current_vertex_buffer = 0; } - vertices = NULL; /* attrib pointers will be offsets into the VBO. */ + // attrib pointers will be offsets into the VBO. + vertices = (void *)(uintptr_t)0; // must be the exact value 0, not NULL (the representation of NULL is not guaranteed to be 0). #endif while (cmd) { From 6510d6ccbf446e058ae8ed95233f59057312df02 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 4 May 2025 08:52:05 -0700 Subject: [PATCH 10/10] Updated to version 2.32.6 for release --- CMakeLists.txt | 2 +- Makefile.os2 | 2 +- Makefile.w32 | 2 +- Xcode/SDL/Info-Framework.plist | 4 ++-- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 ++++++------ Xcode/SDL/pkg-support/SDL.info | 2 +- .../src/main/java/org/libsdl/app/SDLActivity.java | 2 +- configure | 2 +- configure.ac | 2 +- include/SDL_version.h | 2 +- src/main/windows/version.rc | 8 ++++---- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f08c51d647a37..7540bccaeeb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 32) -set(SDL_MICRO_VERSION 5) +set(SDL_MICRO_VERSION 6) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts diff --git a/Makefile.os2 b/Makefile.os2 index 7ef1cdbd5a079..16e96b3dfc224 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 32 -MICRO_VERSION = 5 +MICRO_VERSION = 6 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/Makefile.w32 b/Makefile.w32 index 200c6c67ee5e8..ea95919b4ef47 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 32 -MICRO_VERSION = 5 +MICRO_VERSION = 6 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index fb653b7ac03d3..a93da92bb152d 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.32.5 + 2.32.6 CFBundleSignature SDLX CFBundleVersion - 2.32.5 + 2.32.6 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index b19de7afc948b..025d5aaeaf02e 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.5.0; + DYLIB_CURRENT_VERSION = 3201.6.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9770,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.32.5; + MARKETING_VERSION = 2.32.6; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.5.0; + DYLIB_CURRENT_VERSION = 3201.6.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9856,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.32.5; + MARKETING_VERSION = 2.32.6; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.5.0; + DYLIB_CURRENT_VERSION = 3201.6.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -10115,7 +10115,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3201.0.0; - DYLIB_CURRENT_VERSION = 3201.5.0; + DYLIB_CURRENT_VERSION = 3201.6.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info index b9938db33a619..78598455d3579 100644 --- a/Xcode/SDL/pkg-support/SDL.info +++ b/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.32.5 +Title SDL 2.32.6 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 3b3f555ed61b7..823c98a269d76 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/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 = 32; - private static final int SDL_MICRO_VERSION = 5; + private static final int SDL_MICRO_VERSION = 6; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/configure b/configure index 6ecf58cda3c13..9c8573c297176 100755 --- a/configure +++ b/configure @@ -3516,7 +3516,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=32 -SDL_MICRO_VERSION=5 +SDL_MICRO_VERSION=6 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/configure.ac b/configure.ac index c4f831e5486a6..653ba831d4520 100644 --- a/configure.ac +++ b/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=32 -SDL_MICRO_VERSION=5 +SDL_MICRO_VERSION=6 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/include/SDL_version.h b/include/SDL_version.h index dda62e1c9ace4..daba05eab1c63 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -58,7 +58,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 32 -#define SDL_PATCHLEVEL 5 +#define SDL_PATCHLEVEL 6 /** * Macro to determine SDL version program was compiled against. diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index e4c0dcdd26e82..17f32e4031369 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,32,5,0 - PRODUCTVERSION 2,32,5,0 + FILEVERSION 2,32,6,0 + PRODUCTVERSION 2,32,6,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 32, 5, 0\0" + VALUE "FileVersion", "2, 32, 6, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 32, 5, 0\0" + VALUE "ProductVersion", "2, 32, 6, 0\0" END END BLOCK "VarFileInfo"