Compare commits

...

44 Commits

Author SHA1 Message Date
Sam Lantinga
98d1f3a45a Updated to version 2.32.8 for release 2025-06-02 16:00:39 -07:00
Ryan C. Gordon
1226e6b2bc Revert "opengles2: Restore previous default texture_formats."
This reverts commit 9f7ccbe8d4.

Fixes #13109.

(cherry picked from commit 3c08172d06)
2025-06-02 09:38:50 -07:00
Francisco Javier Trujillo Mata
213b074697 Fix wrong callback type
(cherry picked from commit c89357bf60)
(cherry picked from commit d0c2d8bc40)
2025-05-20 11:12:16 -07:00
Sam Lantinga
4177e06c09 Fixed rare crash trying to interrupt SDL_WaitEvent()
Fixes https://github.com/libsdl-org/SDL/issues/12797

(cherry picked from commit 992e4c59bd)
(cherry picked from commit 33eb167da8)
2025-05-19 14:24:41 -07:00
Joe [ReRezd]
4318013777 Fix: GameCube controller adapter hotplug not working
SDL_PrivateJoystickAdded was called before setting the InstanceId in the adapters ctx->joysticks array.  This would eventually broadcast the SDL_EVENT_JOYSTICK_ADDED event with the new InstanceId, if your program listens for the added events and opens joysticks at that point it would always fail because there would be no matching InstanceId in the ctx->joysticks array.

(cherry picked from commit afd1e51023)
(cherry picked from commit 4b4f6b3e22)
2025-05-19 08:26:52 -07:00
Sam Lantinga
3364486f56 Define illegal_instruction() when it will be actually used
(cherry picked from commit 29d2116495)
(cherry picked from commit 2163887f29)
2025-05-08 13:10:28 -07:00
Sam Clegg
dc69988fdf [emscripten] Remove reference to Module['createContext']
Backported from https://github.com/libsdl-org/SDL/pull/12970

(cherry picked from commit c0f78dee5e)
2025-05-06 14:46:53 -07:00
A. Wilcox
4ed1fc5bff cpuinfo: Use auxv for AltiVec on Linux if possible
The SIGILL handler is not very reliable and can cause crashes.

Linux provides the CPU's AltiVec support status in getauxval.

(cherry picked from commit 7490471796)
(cherry picked from commit 17e6208c1b)
2025-05-04 14:02:12 -07:00
Ozkan Sezer
84081d884b don't prototype strdup() for __clang_analyzer__ case in windows builds.
Fixes:  https://github.com/libsdl-org/SDL/issues/12948.
(cherry picked from commit 17bba029ba)
2025-05-04 20:48:24 +03:00
Sam Lantinga
a5fad8b0cb Updated to version 2.32.7 for development 2025-05-04 09:18:06 -07:00
Sam Lantinga
6510d6ccbf Updated to version 2.32.6 for release 2025-05-04 08:52:05 -07:00
Derek Schuff
b0b50da4b6 Port #12581 to SDL2
This fixes undefined behavior resulting from adding offsets to nullptr.

(cherry picked from commit a220e7c422)
2025-05-01 21:36:53 -07:00
Sam Lantinga
8b7a088efc 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 2442c85cb8)
2025-04-29 11:24:27 -07:00
Sam Lantinga
7fc5edab8e Revert "Don't leak device handle in macOS 10.10 or newer"
This reverts commit 5925c27efb.

Fixes https://github.com/libsdl-org/SDL/issues/12807

(cherry picked from commit 5b951141d2)
2025-04-29 11:24:27 -07:00
Cameron Gutman
24ccde693e events: Fix undefined behavior when disabling some event types
Shifting a signed int left by 31 is UB.

(cherry picked from commit 15fd3fcdc2)
2025-04-29 00:32:43 -05:00
Sam Lantinga
f46ef5d76d 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 45b01d16b1)
2025-04-28 20:23:37 -07:00
Petar Popovic
5696677558 SDL_BlitSurface() comment: only dstrect is modified in function
(cherry picked from commit 035518d065)
2025-04-22 10:23:02 -07:00
Boris I. Bendovsky
093307f1f4 [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 40b1eac541)
2025-04-22 10:12:55 -07:00
Ozkan Sezer
f54014e173 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 bfab0a968f)
2025-04-03 19:55:04 +03:00
Sam Lantinga
64ad33884d Updated to version 2.32.5 for development 2025-03-31 12:58:50 -07:00
Sam Lantinga
2359383fc1 Updated to version 2.32.4 for release 2025-03-31 09:12:51 -07:00
Sam Lantinga
b2a95b2482 Default SDL_HINT_ACCELEROMETER_AS_JOYSTICK to 0 on Linux
The Linux joystick driver supports associating sensor devices with the related controller device, so enable that by default.

Fixes https://github.com/libsdl-org/SDL/issues/12043

(cherry picked from commit 3e47181800)
2025-03-25 09:09:59 -07:00
Carl Åstholm
2708e08f40 emscripten: Don't use legacy JS library functions for assertions
(cherry picked from commit 54f5b73333)
(cherry picked from commit a8f0eb4c33)
2025-03-20 16:36:25 -07:00
Dragon-Baroque
3f6efbf2df The posix4 library has been merged into the libc library
Backported from commit 07e4dea693.
Reference issue: https://github.com/libsdl-org/SDL/issues/12588.

(cherry picked from commit d63b3376a4)
2025-03-20 09:48:20 +03:00
Sam Lantinga
9b048e73a2 Fixed raw input device GUIDs changing randomly between runs
On Windows 11, apparently HidD_GetManufacturerString() and HidD_GetProductString() can return TRUE without actually filling in any string data.

Fixes https://github.com/libsdl-org/SDL/issues/12566

(cherry picked from commit 4fc9509ab7)
(cherry picked from commit 52146cf067)
2025-03-17 13:57:58 -07:00
Sam Lantinga
d3bb91522f Fixed crash if info->path is NULL
(cherry picked from commit 715301cef5)
(cherry picked from commit 46a51b4298)
2025-03-17 09:48:13 -07:00
SDL Wiki Bot
c8c4c97727 Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit fc536dcb7e)
2025-03-12 22:55:50 +03:00
Sam Lantinga
f08a5cfcab Fixed sscanf("026", "%1x%1x%1x", &r, &g, &b)
Fixes https://github.com/libsdl-org/SDL/issues/12510

(cherry picked from commit be6ed6e9c4)
(cherry picked from commit 1caae3e9e4)
2025-03-10 15:45:43 -07:00
SDL Wiki Bot
e9d2f60e1c Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit 22a87a22ca)
2025-03-07 22:45:02 +03:00
Neal Gompa
9e079fe9c7 pipewire: Ensure that the correct struct is used for enumeration APIs
PipeWire now requires the correct struct type is used, otherwise
it will fail to compile.

Reference: 188d920733

Fixes: https://github.com/libsdl-org/SDL/issues/12224
(cherry picked from commit d35bef64e9)
(cherry picked from commit 6be87ceb33)
2025-03-06 14:37:46 -05:00
Sam Lantinga
53c022c880 Updated to version 2.32.3 for development 2025-03-01 18:13:50 -08:00
Sam Lantinga
e11183ea6c Updated to version 2.32.2 for release 2025-03-01 18:03:11 -08:00
Sam Lantinga
024c27645a Added support for the "%n" sscanf format specifier
(cherry picked from commit 6980325310)
(cherry picked from commit ab44451578)
2025-02-25 08:08:55 -08:00
SDL Wiki Bot
c2047f0496 Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit 52ac07d327)
2025-02-25 08:08:55 -08:00
Tomasz Pakuła
220895d4d2 [SDL2] Add SDL_HINT_JOYSTICK_HAPTIC_AXES
Allows users to overwrite the number of haptic axes defined for a given
joystick. Also supports a "wildcard" VID:PID of 0xFFFF/0xFFFF

(cherry picked from commit 0809be4ec5)
2025-02-25 08:08:55 -08:00
Petter Reinholdtsen
282f7a84fc Changed PULSEAUDIO_FlushRecording() to only flush audio present when called.
When the flushing is not able to keep up with the audio stream coming in,
it will end up flushing forever and block API clients from getting any audio.

Fixes #9706

(cherry picked from commit 24693ac285)
2025-02-25 08:08:55 -08:00
Cameron Gutman
9be8c2a899 keyboard: Fix comment regarding implicit calls to SDL_StartTextInput()
It was always done inside SDL_VideoInit().

(cherry picked from commit 92cadaf917)
2025-02-25 08:08:55 -08:00
Anonymous Maarten
51e20f1666 ci: drop classic Intel compiler
1) The classic Intel compiler is depreated in favor of the oneapi compiler
2) SPA_FALLTHROUGH is used in pipewire's spa/utils/json.h, and causes build errors

(cherry picked from commit d2eb72fd14)
2025-02-23 21:40:48 +01:00
Anonymous Maarten
a34c8403e7 ci: GitHub is retiring Ubuntu 20.04 support
backport of 8d3db06ff2

(cherry picked from commit b4d733619a)
2025-02-23 21:40:48 +01:00
Anonymous Maarten
dc74448014 ci: clang32 on msys2 is EOL
backport of 70f657e520

(cherry picked from commit ed2c004c8a)
2025-02-23 21:40:40 +01:00
Paper
155f99a4e6 thread/windows: fix stack overflow in exception naming
(cherry picked from commit 1a853973ab)
(cherry picked from commit 6421f12d7f)
2025-02-20 08:20:58 -08:00
Ozkan Sezer
63bb1a8583 dynapi: use DosScanEnv() for os/2.
(cherry picked from commit ee49025f80)
2025-02-20 11:50:04 +03:00
Sam Lantinga
8b0c9e1dce Don't leak device handle in macOS 10.10 or newer
Merged upstream fix for macOS:
cdc473dfe4

In one of the early versions of macOS, when you try to close the device
with IOHIDDeviceClose() that is being physically disconnected.
Starting with some version of macOS, this crash bug was fixed,
and starting with macSO 10.15 the opposite effect took place:
in some environments crash happens if IOHIDDeviceClose() is _not_ called.

This patch is to keep a workaround for old versions of macOS,
and don't have a leak in new/tested environments.

Fixes https://github.com/libsdl-org/SDL/issues/12255

(cherry picked from commit 5925c27efb)
2025-02-19 17:00:05 -08:00
Sam Clegg
7f74c1ed63 Fix SDL_emscriptenaudio.c under wasm64
Verified locally by running `browser64.test_sdl2_mixer_wav` in
emscripten.

(cherry picked from commit aa00738a21)
2025-02-19 17:00:05 -08:00
44 changed files with 343 additions and 185 deletions

View File

@@ -28,7 +28,6 @@ class JobOs(Enum):
WindowsLatest = "windows-latest"
UbuntuLatest = "ubuntu-latest"
MacosLatest = "macos-latest"
Ubuntu20_04 = "ubuntu-20.04"
Ubuntu22_04 = "ubuntu-22.04"
Ubuntu24_04 = "ubuntu-24.04"
Macos13 = "macos-13"
@@ -57,13 +56,11 @@ class SdlPlatform(Enum):
class Msys2Platform(Enum):
Mingw32 = "mingw32"
Mingw64 = "mingw64"
Clang32 = "clang32"
Clang64 = "clang64"
Ucrt64 = "ucrt64"
class IntelCompiler(Enum):
Icc = "icc"
Icx = "icx"
@@ -107,7 +104,6 @@ class JobSpec:
JOB_SPECS = {
"msys2-mingw32": JobSpec(name="Windows (msys2, mingw32)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw32", msys2_platform=Msys2Platform.Mingw32, ),
"msys2-mingw64": JobSpec(name="Windows (msys2, mingw64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64", msys2_platform=Msys2Platform.Mingw64, ),
"msys2-clang32": JobSpec(name="Windows (msys2, clang32)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw32-clang", msys2_platform=Msys2Platform.Clang32, ),
"msys2-clang64": JobSpec(name="Windows (msys2, clang64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-clang", msys2_platform=Msys2Platform.Clang64, ),
"msys2-ucrt64": JobSpec(name="Windows (msys2, ucrt64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-ucrt", msys2_platform=Msys2Platform.Ucrt64, ),
"msvc-x64": JobSpec(name="Windows (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x64", msvc_arch=MsvcArch.X64, msvc_project="VisualC/SDL.sln", ),
@@ -120,11 +116,9 @@ JOB_SPECS = {
"msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ),
"msvc-uwp-x64": JobSpec(name="UWP (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-UWP", msvc_arch=MsvcArch.X64, msvc_project="VisualC-WinRT/SDL-UWP.sln", uwp=True, ),
"msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ),
"ubuntu-20.04": JobSpec(name="Ubuntu 20.04", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04", autotools=True),
"ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", autotools=True),
"steamrt-sniper": JobSpec(name="Steam Linux Runtime (Sniper)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-slrsniper", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta", ),
"ubuntu-intel-icx": JobSpec(name="Ubuntu 20.04 (Intel oneAPI)", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04-oneapi", intel=IntelCompiler.Icx, ),
"ubuntu-intel-icc": JobSpec(name="Ubuntu 20.04 (Intel Compiler)", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04-icc", intel=IntelCompiler.Icc, ),
"ubuntu-intel-icx": JobSpec(name="Ubuntu 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ),
"macos-gnu-arm64-x64": JobSpec(name="MacOS (GNU prefix)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact="SDL-macos-arm64-x64-gnu",autotools=True, apple_archs={AppleArch.X86_64, AppleArch.ARM64, }, ),
"ios": JobSpec(name="iOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Ios, artifact="SDL-ios-arm64", xcode=True, ),
"tvos": JobSpec(name="tvOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Tvos, artifact="SDL-tvos-arm64", xcode=True, ),
@@ -344,10 +338,6 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
case IntelCompiler.Icx:
job.cc = "icx"
job.cxx = "icpx"
case IntelCompiler.Icc:
job.cc = "icc"
job.cxx = "icpc"
job.cppflags.append("-diag-disable=10441")
case _:
raise ValueError(f"Invalid intel={spec.intel}")
job.source_cmd = f"source /opt/intel/oneapi/setvars.sh;"
@@ -627,7 +617,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
"clang64": "mingw-w64-clang-x86_64",
"ucrt64": "mingw-w64-ucrt-x86_64",
}[spec.msys2_platform.value]
job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, Msys2Platform.Clang32)
job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, )
job.shared_lib = SharedLibType.WIN32
job.static_lib = StaticLibType.A
case SdlPlatform.Riscos:

View File

@@ -89,7 +89,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 32)
set(SDL_MICRO_VERSION 0)
set(SDL_MICRO_VERSION 8)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@@ -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})

View File

@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 32
MICRO_VERSION = 0
MICRO_VERSION = 8
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2

View File

@@ -6,7 +6,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 32
MICRO_VERSION = 0
MICRO_VERSION = 8
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.32.0</string>
<string>2.32.8</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.32.0</string>
<string>2.32.8</string>
</dict>
</plist>

View File

@@ -9729,7 +9729,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.8.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.0;
MARKETING_VERSION = 2.32.8;
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.0.0;
DYLIB_CURRENT_VERSION = 3201.8.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.0;
MARKETING_VERSION = 2.32.8;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10063,7 +10063,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.8.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.0.0;
DYLIB_CURRENT_VERSION = 3201.8.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;

View File

@@ -1,4 +1,4 @@
Title SDL 2.32.0
Title SDL 2.32.8
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks

View File

@@ -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 = 0;
private static final int SDL_MICRO_VERSION = 8;
/*
// Display InputType.SOURCE/CLASS of events and devices
//

View File

@@ -966,7 +966,7 @@ macro(CheckPTHREAD)
if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
set(PTHREAD_LDFLAGS "-mt -lpthread")
else()
set(PTHREAD_LDFLAGS "-pthread -lposix4")
set(PTHREAD_LDFLAGS "-pthread")
endif()
elseif(SYSV5)
set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")

2
configure vendored
View File

@@ -3516,7 +3516,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=32
SDL_MICRO_VERSION=0
SDL_MICRO_VERSION=8
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -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=0
SDL_MICRO_VERSION=8
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -115,7 +115,8 @@ _m_prefetch(void *__P)
#include <lasxintrin.h>
#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 <immintrin.h>
#else
#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)

View File

@@ -1423,6 +1423,27 @@ extern "C" {
*/
#define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE"
/**
* A variable containing a list of devices and their desired number of haptic
* (force feedback) enabled axis.
*
* The format of the string is a comma separated list of USB VID/PID pairs in
* hexadecimal form plus the number of desired axes, e.g.
*
* `0xAAAA/0xBBBB/1,0xCCCC/0xDDDD/3`
*
* This hint supports a "wildcard" device that will set the number of haptic
* axes on all initialized haptic devices which were not defined explicitly in
* this hint.
*
* `0xFFFF/0xFFFF/1`
*
* This hint should be set before a controller is opened. The number of haptic
* axes won't exceed the number of real axes found on the device.
*/
#define SDL_HINT_JOYSTICK_HAPTIC_AXES "SDL_JOYSTICK_HAPTIC_AXES"
/**
* A variable controlling whether joysticks on Linux will always treat 'hat'
* axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking

View File

@@ -255,7 +255,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
* On some platforms using this function activates the screen keyboard.
*
* On desktop platforms, SDL_StartTextInput() is implicitly called on SDL
* window creation which will cause events SDL_TextInputEvent and
* video subsystem initialization which will cause SDL_TextInputEvent and
* SDL_TextEditingEvent to begin emitting.
*
* \since This function is available since SDL 2.0.0.

View File

@@ -244,7 +244,7 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateRenderer
* \sa SDL_CreateWindowRenderer
* \sa SDL_CreateWindowAndRenderer
* \sa SDL_DestroyRenderer
*/
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
@@ -787,7 +787,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
* Get the current render target.
*
* The default render target is the window for which the renderer was created,
* and is reported a NULL here.
* and is reported as NULL here.
*
* \param renderer the rendering context.
* \returns the current render target or NULL for the default render target.

View File

@@ -750,8 +750,12 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
#endif
#ifndef _WIN32
/* strdup is not ANSI but POSIX, and its prototype might be hidden... */
/* not for windows: might conflict with string.h where strdup may have
* dllimport attribute: https://github.com/libsdl-org/SDL/issues/12948 */
char *strdup(const char *str);
#endif
/* Starting LLVM 16, the analyser errors out if these functions do not have
their prototype defined (clang-diagnostic-implicit-function-declaration) */

View File

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

View File

@@ -58,7 +58,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 32
#define SDL_PATCHLEVEL 0
#define SDL_PATCHLEVEL 8
/**
* Macro to determine SDL version program was compiled against.

View File

@@ -42,15 +42,7 @@
#endif
#if defined(__EMSCRIPTEN__)
#include <emscripten.h>
/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
#ifndef MAIN_THREAD_EM_ASM_PTR
#ifdef __wasm64__
#error You need to upgrade your Emscripten compiler to support wasm64
#else
#define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
#endif
#endif
#include <emscripten.h>
#endif
/* The size of the stack buffer to use for rendering assert messages. */
@@ -259,7 +251,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
for (;;) {
SDL_bool okay = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
int reply = MAIN_THREAD_EM_ASM_INT({
var str =
UTF8ToString($0) + '\n\n' +
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
@@ -267,26 +259,31 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
if (reply === null) {
reply = "i";
}
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
return reply.length === 1 ? reply.charCodeAt(0) : -1;
}, message);
/* *INDENT-ON* */ /* clang-format on */
if (SDL_strcmp(buf, "a") == 0) {
switch (reply) {
case 'a':
state = SDL_ASSERTION_ABORT;
#if 0 /* (currently) no break functionality on Emscripten */
} else if (SDL_strcmp(buf, "b") == 0) {
case 'b':
state = SDL_ASSERTION_BREAK;
break;
#endif
} else if (SDL_strcmp(buf, "r") == 0) {
case 'r':
state = SDL_ASSERTION_RETRY;
} else if (SDL_strcmp(buf, "i") == 0) {
break;
case 'i':
state = SDL_ASSERTION_IGNORE;
} else if (SDL_strcmp(buf, "A") == 0) {
break;
case 'A':
state = SDL_ASSERTION_ALWAYS_IGNORE;
} else {
break;
default:
okay = SDL_FALSE;
break;
}
free(buf);
if (okay) {
break;

View File

@@ -310,7 +310,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; }
audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0);
SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer;
dynCall('vi', $2, [$3]);
dynCall('vp', $2, [$3]);
};
SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode);
SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination);
@@ -326,7 +326,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
var silence_callback = function() {
SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
dynCall('vi', $2, [$3]);
dynCall('vp', $2, [$3]);
};
SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000);
@@ -351,7 +351,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL2.audio.silenceBuffer = undefined;
}
SDL2.audio.currentOutputBuffer = e['outputBuffer'];
dynCall('vi', $2, [$3]);
dynCall('vp', $2, [$3]);
};
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
@@ -369,7 +369,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
// the buffer that gets filled here just gets ignored, so the app can make progress
// and/or avoid flooding audio queues until we can actually play audio.
SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer;
dynCall('vi', $2, [$3]);
dynCall('vp', $2, [$3]);
SDL2.audio.currentOutputBuffer = undefined;
};

View File

@@ -590,7 +590,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
/* Need to parse the parameters to get the sample rate */
for (i = 0; i < info->n_params; ++i) {
pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL);
pw_node_enum_params((struct pw_node*)node->proxy, 0, info->params[i].id, 0, 0, NULL);
}
hotplug_core_sync(node);

View File

@@ -497,7 +497,7 @@ static void PULSEAUDIO_FlushCapture(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
const void *data = NULL;
size_t nbytes = 0;
size_t nbytes = 0, buflen = 0;
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
@@ -507,19 +507,19 @@ static void PULSEAUDIO_FlushCapture(_THIS)
h->capturelen = 0;
}
while (SDL_AtomicGet(&this->enabled) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) {
buflen = PULSEAUDIO_pa_stream_readable_size(h->stream);
while (SDL_AtomicGet(&this->enabled) && (buflen > 0)) {
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
/*printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n");*/
SDL_OpenedAudioDeviceDisconnected(this);
break;
}
if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) {
/* a new fragment is available! Just dump it. */
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
}
/* a fragment of audio present before FlushCapture was call is
available! Just drop it. */
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
PULSEAUDIO_pa_stream_drop(h->stream);
buflen -= nbytes;
}
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);

View File

@@ -424,9 +424,12 @@ static int device_class(struct udev_device *dev)
}
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
if (val && SDL_strcmp(val, "1") == 0) {
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_FALSE)) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
} else {
devclass |= SDL_UDEV_DEVICE_ACCELEROMETER;
}
}
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");

View File

@@ -127,7 +127,11 @@
#define CPU_CFG2_LSX (1 << 6)
#define CPU_CFG2_LASX (1 << 7)
#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(__MACOSX__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
#if !defined(SDL_CPUINFO_DISABLED) && \
!((defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))) && \
!(defined(__FreeBSD__) && defined(__powerpc__)) && \
!(defined(__LINUX__) && defined(__powerpc__) && defined(HAVE_GETAUXVAL)) && \
defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
/* This is the brute force way of detecting instruction sets...
the idea is borrowed from the libmpeg2 library - thanks!
*/
@@ -356,6 +360,8 @@ static int CPU_haveAltiVec(void)
elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
return altivec;
#elif defined(__LINUX__) && defined(__powerpc__) && defined(HAVE_GETAUXVAL)
altivec = getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC;
#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
void (*handler)(int sig);
handler = signal(SIGILL, illegal_instruction);

View File

@@ -440,19 +440,24 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
static void SDL_InitDynamicAPILocked(void)
{
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
SDL_bool use_internal = SDL_TRUE;
/* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
/* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
char envbuf[512]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
const DWORD rc = GetEnvironmentVariableA(SDL_DYNAMIC_API_ENVVAR, envbuf, (DWORD) sizeof (envbuf));
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
#elif defined(__OS2__)
char * libname;
if (DosScanEnv(SDL_DYNAMIC_API_ENVVAR, &libname) != NO_ERROR) {
libname = NULL;
}
#else
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR);
#endif
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
SDL_bool use_internal = SDL_TRUE;
if (libname) {
while (*libname && !entry) {
char *ptr = libname;

View File

@@ -738,21 +738,17 @@ static void SDL_CutEvent(SDL_EventEntry *entry)
static int SDL_SendWakeupEvent(void)
{
SDL_Window *wakeup_window;
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL || !_this->SendWakeupEvent) {
return 0;
}
SDL_LockMutex(_this->wakeup_lock);
{
if (_this->wakeup_window) {
_this->SendWakeupEvent(_this, _this->wakeup_window);
/* No more wakeup events needed until we enter a new wait */
_this->wakeup_window = NULL;
}
/* We only want to do this once while waiting for an event, so set it to NULL atomically here */
wakeup_window = (SDL_Window *)SDL_AtomicSetPtr(&_this->wakeup_window, NULL);
if (wakeup_window) {
_this->SendWakeupEvent(_this, wakeup_window);
}
SDL_UnlockMutex(_this->wakeup_lock);
return 0;
}
@@ -1009,18 +1005,7 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
int status;
SDL_PumpEventsInternal(SDL_TRUE);
SDL_LockMutex(_this->wakeup_lock);
{
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
/* If status == 0 we are going to block so wakeup will be needed. */
if (status == 0) {
_this->wakeup_window = wakeup_window;
} else {
_this->wakeup_window = NULL;
}
}
SDL_UnlockMutex(_this->wakeup_lock);
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
if (status < 0) {
/* Got an error: return */
break;
@@ -1033,8 +1018,6 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
if (timeout > 0) {
Uint32 elapsed = SDL_GetTicks() - start;
if (elapsed >= (Uint32)timeout) {
/* Set wakeup_window to NULL without holding the lock. */
_this->wakeup_window = NULL;
return 0;
}
loop_timeout = (int)((Uint32)timeout - elapsed);
@@ -1049,9 +1032,9 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
}
}
SDL_AtomicSetPtr(&_this->wakeup_window, wakeup_window);
status = _this->WaitEventTimeout(_this, loop_timeout);
/* Set wakeup_window to NULL without holding the lock. */
_this->wakeup_window = NULL;
SDL_AtomicSetPtr(&_this->wakeup_window, NULL);
if (status == 0 && poll_interval != SDL_MAX_SINT16 && loop_timeout == poll_interval) {
/* We may have woken up to poll. Try again */
continue;
@@ -1318,7 +1301,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 +1315,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

View File

@@ -23,6 +23,85 @@
#include "SDL_syshaptic.h"
#include "SDL_haptic_c.h"
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
#include "SDL_hints.h"
#include "../SDL_hints_c.h"
typedef struct SDL_Haptic_VIDPID_Naxes {
Uint16 vid;
Uint16 pid;
Uint16 naxes;
} SDL_Haptic_VIDPID_Naxes;
static void SDL_HapticLoadAxesList(SDL_Haptic_VIDPID_Naxes **entries, int *num_entries)
{
SDL_Haptic_VIDPID_Naxes entry;
const char *spot;
int length = 0;
spot = SDL_GetHint(SDL_HINT_JOYSTICK_HAPTIC_AXES);
if (!spot)
return;
while (SDL_sscanf(spot, "0x%hx/0x%hx/%hu%n", &entry.vid, &entry.pid, &entry.naxes, &length) == 3) {
SDL_assert(length > 0);
spot += length;
length = 0;
if ((*num_entries % 8) == 0) {
int new_max = *num_entries + 8;
SDL_Haptic_VIDPID_Naxes *new_entries =
(SDL_Haptic_VIDPID_Naxes *)SDL_realloc(*entries, new_max * sizeof(**entries));
// Out of memory, go with what we have already
if (!new_entries)
break;
*entries = new_entries;
}
(*entries)[(*num_entries)++] = entry;
if (spot[0] == ',')
spot++;
}
}
// /* Return -1 if not found */
static int SDL_HapticNaxesListIndex(struct SDL_Haptic_VIDPID_Naxes *entries, int num_entries, Uint16 vid, Uint16 pid)
{
int i;
if (!entries)
return -1;
for (i = 0; i < num_entries; ++i) {
if (entries[i].vid == vid && entries[i].pid == pid)
return i;
}
return -1;
}
// Check if device needs a custom number of naxes
static int SDL_HapticGetNaxes(Uint16 vid, Uint16 pid)
{
int num_entries = 0, index = 0, naxes = -1;
SDL_Haptic_VIDPID_Naxes *naxes_list = NULL;
SDL_HapticLoadAxesList(&naxes_list, &num_entries);
if (!num_entries || !naxes_list)
return -1;
// Perform "wildcard" pass
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, 0xffff, 0xffff);
if (index >= 0)
naxes = naxes_list[index].naxes;
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, vid, pid);
if (index >= 0)
naxes = naxes_list[index].naxes;
SDL_free(naxes_list);
return naxes;
}
/* Global for SDL_windowshaptic.c */
#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT)
@@ -258,6 +337,8 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
{
SDL_Haptic *haptic;
SDL_Haptic *hapticlist;
int naxes, general_axes;
Uint16 vid, pid;
/* Make sure there is room. */
if (SDL_NumHaptics() <= 0) {
@@ -314,6 +395,18 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
}
SDL_UnlockJoysticks();
vid = SDL_JoystickGetVendor(joystick);
pid = SDL_JoystickGetProduct(joystick);
general_axes = SDL_JoystickNumAxes(joystick);
naxes = SDL_HapticGetNaxes(vid, pid);
if (naxes > 0)
haptic->naxes = naxes;
// Limit to the actual number of axes found on the device
if (general_axes >= 0 && naxes > general_axes)
haptic->naxes = general_axes;
/* Add haptic to list */
++haptic->ref_count;
/* Link the haptic in the list */

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -822,11 +822,12 @@ SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJo
++SDL_HIDAPI_numjoysticks;
SDL_PrivateJoystickAdded(joystickID);
if (pJoystickID) {
*pJoystickID = joystickID;
}
SDL_PrivateJoystickAdded(joystickID);
return SDL_TRUE;
}
@@ -890,10 +891,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
return NULL;
}
device->magic = &SDL_HIDAPI_device_magic;
device->path = SDL_strdup(info->path);
if (!device->path) {
SDL_free(device);
return NULL;
if (info->path) {
device->path = SDL_strdup(info->path);
}
device->seen = SDL_TRUE;
device->vendor_id = info->vendor_id;

View File

@@ -908,9 +908,11 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
char *product_string = NULL;
WCHAR string[128];
string[0] = 0;
if (SDL_HidD_GetManufacturerString(hFile, string, sizeof(string))) {
manufacturer_string = WIN_StringToUTF8W(string);
}
string[0] = 0;
if (SDL_HidD_GetProductString(hFile, string, sizeof(string))) {
product_string = WIN_StringToUTF8W(string);
}

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,32,0,0
PRODUCTVERSION 2,32,0,0
FILEVERSION 2,32,8,0
PRODUCTVERSION 2,32,8,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 32, 0, 0\0"
VALUE "FileVersion", "2, 32, 8, 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, 0, 0\0"
VALUE "ProductVersion", "2, 32, 8, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -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) {
@@ -2220,8 +2221,8 @@ SDL_RenderDriver GLES2_RenderDriver = {
{ "opengles2",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
4,
{ SDL_PIXELFORMAT_BGRA32,
SDL_PIXELFORMAT_ABGR32,
{ SDL_PIXELFORMAT_RGBA32,
SDL_PIXELFORMAT_BGRA32,
SDL_PIXELFORMAT_BGRX32,
SDL_PIXELFORMAT_RGBX32 },
0,

View File

@@ -55,7 +55,7 @@ typedef struct
static int vsync_sema_id = 0;
/* PRIVATE METHODS */
static int vsync_handler(void)
static int vsync_handler(int reason)
{
iSignalSema(vsync_sema_id);

View File

@@ -81,14 +81,12 @@ static size_t SDL_ScanUnsignedLongLongInternal(const char *text, int count, int
negative = *text == '-';
++text;
}
if ((radix == 0 || radix == 16) && *text == '0' && text[1] != '\0') {
if ((radix == 0 || radix == 16) && *text == '0' && (text[1] == 'x' || text[1] == 'X')) {
text += 2;
radix = 16;
} else if (radix == 0 && *text == '0' && (text[1] >= '0' && text[1] <= '9')) {
++text;
if (*text == 'x' || *text == 'X') {
radix = 16;
++text;
} else if (radix == 0) {
radix = 8;
}
radix = 8;
} else if (radix == 0) {
radix = 10;
}
@@ -1113,6 +1111,7 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len)
/* NOLINTNEXTLINE(readability-non-const-parameter) */
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
{
const char *start = text;
int retval = 0;
if (!text || !*text) {
@@ -1383,6 +1382,36 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
}
done = SDL_TRUE;
break;
case 'n':
switch (inttype) {
case DO_SHORT:
{
short *valuep = va_arg(ap, short *);
*valuep = (short)(text - start);
} break;
case DO_INT:
{
int *valuep = va_arg(ap, int *);
*valuep = (int)(text - start);
} break;
case DO_LONG:
{
long *valuep = va_arg(ap, long *);
*valuep = (long)(text - start);
} break;
case DO_LONGLONG:
{
long long *valuep = va_arg(ap, long long *);
*valuep = (long long)(text - start);
} break;
case DO_SIZE_T:
{
size_t *valuep = va_arg(ap, size_t *);
*valuep = (size_t)(text - start);
} break;
}
done = SDL_TRUE;
break;
case '[':
{
const char *set = fmt + 1;

View File

@@ -159,7 +159,7 @@ void SDL_SYS_SetupThread(const char *name)
inf.dwFlags = 0;
/* The debugger catches this, renames the thread, continues on. */
RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR *)&inf);
RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG_PTR), (const ULONG_PTR *)&inf);
}
}
}

View File

@@ -355,8 +355,7 @@ struct SDL_VideoDevice
SDL_bool checked_texture_framebuffer;
SDL_bool is_dummy;
SDL_bool suspend_screensaver;
SDL_Window *wakeup_window;
SDL_mutex *wakeup_lock; /* Initialized only if WaitEventTimeout/SendWakeupEvent are supported */
void *wakeup_window;
int num_displays;
SDL_VideoDisplay *displays;
SDL_Window *windows;

View File

@@ -3368,9 +3368,7 @@ void SDL_DestroyWindow(SDL_Window *window)
_this->current_glwin = NULL;
}
if (_this->wakeup_window == window) {
_this->wakeup_window = NULL;
}
SDL_AtomicCASPtr(&_this->wakeup_window, window, NULL);
/* Now invalidate magic */
window->magic = NULL;

View File

@@ -48,9 +48,6 @@ static void Cocoa_VideoQuit(_THIS);
static void Cocoa_DeleteDevice(SDL_VideoDevice * device)
{ @autoreleasepool
{
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
CFBridgingRelease(device->driverdata);
SDL_free(device);
}}
@@ -76,7 +73,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
return NULL;
}
device->driverdata = (void *)CFBridgingRetain(data);
device->wakeup_lock = SDL_CreateMutex();
/* Set the function pointers */
device->VideoInit = Cocoa_VideoInit;

View File

@@ -79,7 +79,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
if (!Module['SDL2']) Module['SDL2'] = {};
var SDL2 = Module['SDL2'];
if (SDL2.ctxCanvas !== Module['canvas']) {
SDL2.ctx = Module['createContext'](Module['canvas'], false, true);
SDL2.ctx = Browser.createContext(Module['canvas'], false, true);
SDL2.ctxCanvas = Module['canvas'];
}
if (SDL2.w !== w || SDL2.h !== h || SDL2.imageCtx !== SDL2.ctx) {

View File

@@ -162,9 +162,6 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
WAYLAND_wl_display_flush(data->display);
WAYLAND_wl_display_disconnect(data->display);
}
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
SDL_free(data);
SDL_free(device);
SDL_WAYLAND_UnloadSymbols();
@@ -233,7 +230,6 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
}
device->driverdata = data;
device->wakeup_lock = SDL_CreateMutex();
/* Set the function pointers */
device->VideoInit = Wayland_VideoInit;

View File

@@ -93,9 +93,6 @@ static void WIN_DeleteDevice(SDL_VideoDevice *device)
SDL_UnloadObject(data->shcoreDLL);
}
#endif
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
SDL_free(device->driverdata);
SDL_free(device);
}
@@ -120,7 +117,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
return NULL;
}
device->driverdata = data;
device->wakeup_lock = SDL_CreateMutex();
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
data->userDLL = SDL_LoadObject("USER32.DLL");

View File

@@ -108,9 +108,6 @@ static void X11_DeleteDevice(SDL_VideoDevice *device)
X11_XCloseDisplay(data->request_display);
}
SDL_free(data->windowlist);
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
SDL_free(device->driverdata);
SDL_free(device);
@@ -204,8 +201,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
return NULL;
}
device->wakeup_lock = SDL_CreateMutex();
#ifdef X11_DEBUG
X11_XSynchronize(data->display, True);
#endif

View File

@@ -393,6 +393,7 @@ int stdlib_getsetenv(void *arg)
#endif
#define FMT_PRILLd "%lld"
#define FMT_PRILLdn "%lld%lln"
#define FMT_PRILLu "%llu"
/**
@@ -403,13 +404,15 @@ int stdlib_sscanf(void *arg)
{
int output;
int result;
int length;
int expected_output;
int expected_result;
short short_output, expected_short_output;
long long_output, expected_long_output;
long long long_long_output, expected_long_long_output;
short short_output, expected_short_output, short_length;
long long_output, expected_long_output, long_length;
long long long_long_output, expected_long_long_output, long_long_length;
size_t size_output, expected_size_output;
char text[128], text2[128];
unsigned int r = 0, g = 0, b = 0;
expected_output = output = 123;
expected_result = -1;
@@ -426,43 +429,62 @@ int stdlib_sscanf(void *arg)
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
output = 123;
length = 0;
expected_output = 2;
expected_result = 1;
result = SDL_sscanf("2", "%i", &output);
SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)");
result = SDL_sscanf("2", "%i%n", &output, &length);
SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i%%n\", &output, &length)");
SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
SDLTest_AssertCheck(length == 1, "Check length, expected: 1, got: %i", length);
output = 123;
length = 0;
expected_output = 0xa;
expected_result = 1;
result = SDL_sscanf("aa", "%1x", &output);
SDLTest_AssertPass("Call to SDL_sscanf(\"aa\", \"%%1x\", &output)");
result = SDL_sscanf("aa", "%1x%n", &output, &length);
SDLTest_AssertPass("Call to SDL_sscanf(\"aa\", \"%%1x%%n\", &output, &length)");
SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
SDLTest_AssertCheck(length == 1, "Check length, expected: 1, got: %i", length);
#define SIZED_TEST_CASE(type, var, format_specifier) \
var##_output = 123; \
expected_##var##_output = (type)(((unsigned type)(~0)) >> 1); \
expected_result = 1; \
result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \
result = SDL_sscanf(text, format_specifier, &var##_output); \
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
\
var##_output = 123; \
expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \
expected_result = 1; \
result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \
result = SDL_sscanf(text, format_specifier, &var##_output); \
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \
expected_result = 3;
result = SDL_sscanf("#026", "#%1x%1x%1x", &r, &g, &b);
SDLTest_AssertPass("Call to SDL_sscanf(\"#026\", \"#%%1x%%1x%%1x\", &r, &g, &b)");
expected_output = 0;
SDLTest_AssertCheck(r == expected_output, "Check output for r, expected: %i, got: %i", expected_output, r);
expected_output = 2;
SDLTest_AssertCheck(g == expected_output, "Check output for g, expected: %i, got: %i", expected_output, g);
expected_output = 6;
SDLTest_AssertCheck(b == expected_output, "Check output for b, expected: %i, got: %i", expected_output, b);
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
SIZED_TEST_CASE(short, short, "%hd")
SIZED_TEST_CASE(long, long, "%ld")
SIZED_TEST_CASE(long long, long_long, "%lld")
#define SIZED_TEST_CASE(type, var, printf_specifier, scanf_specifier) \
var##_output = 123; \
var##_length = 0; \
expected_##var##_output = (type)(((unsigned type)(~0)) >> 1); \
expected_result = 1; \
result = SDL_snprintf(text, sizeof(text), printf_specifier, expected_##var##_output); \
result = SDL_sscanf(text, scanf_specifier, &var##_output, &var##_length); \
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", %s, &output, &length)", text, #scanf_specifier); \
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " printf_specifier ", got: " printf_specifier, expected_##var##_output, var##_output); \
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
SDLTest_AssertCheck(var##_length == (type)SDL_strlen(text), "Check length, expected: %i, got: %i", (int)SDL_strlen(text), (int)var##_length); \
\
var##_output = 123; \
var##_length = 0; \
expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \
expected_result = 1; \
result = SDL_snprintf(text, sizeof(text), printf_specifier, expected_##var##_output); \
result = SDL_sscanf(text, scanf_specifier, &var##_output, &var##_length); \
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", %s, &output, &length)", text, #scanf_specifier); \
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " printf_specifier ", got: " printf_specifier, expected_##var##_output, var##_output); \
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
SDLTest_AssertCheck(var##_length == (type)SDL_strlen(text), "Check length, expected: %i, got: %i", (int)SDL_strlen(text), (int)var##_length); \
SIZED_TEST_CASE(short, short, "%hd", "%hd%hn")
SIZED_TEST_CASE(long, long, "%ld", "%ld%ln")
SIZED_TEST_CASE(long long, long_long, FMT_PRILLd, FMT_PRILLdn)
size_output = 123;
expected_size_output = ~((size_t)0);