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..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 = 4; + private static final int SDL_MICRO_VERSION = 6; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/build.zig b/build.zig index 565ee5eb08ffb..2a8d5edf17c49 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void { const lib = b.addLibrary(.{ .name = "SDL2", - .version = .{ .major = 2, .minor = 32, .patch = 4 }, + .version = .{ .major = 2, .minor = 32, .patch = 6 }, .linkage = if (t.abi.isAndroid()) .dynamic else .static, .root_module = b.createModule(.{ .target = target, diff --git a/build.zig.zon b/build.zig.zon index f94163a05bb86..ffd720f23f647 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .SDL, - .version = "2.32.4", + .version = "2.32.6", .fingerprint = 0x7ac4ce41df223a25, .minimum_zig_version = "0.14.0", .dependencies = .{}, diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index c0230652b9493..3e2ef59a256f6 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -112,7 +112,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) 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. * diff --git a/include/SDL_version.h b/include/SDL_version.h index 1b57c9a3a5ffc..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 4 +#define SDL_PATCHLEVEL 6 /** * Macro to determine SDL version program was compiled against. 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 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..24e0b8ac2a0cc 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(); } @@ -1140,13 +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. - See comment below. - */ - if (is_macos_10_10_or_greater || !dev->disconnected) { + /* Disconnect the report callback before close. */ + disconnected = dev->disconnected; + if (!disconnected) { IOHIDDeviceRegisterInputReportCallback( dev->device_handle, dev->input_report_buf, dev->max_input_report_len, NULL, dev); @@ -1169,14 +1165,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 (!disconnected) { IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeNone); } 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; diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index a8861af3dd2ac..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,4,0 - PRODUCTVERSION 2,32,4,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, 4, 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, 4, 0\0" + VALUE "ProductVersion", "2, 32, 6, 0\0" END END BLOCK "VarFileInfo" 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) {