From 8a654b895c5eae54de7ae046eaec2c7e1bae6a82 Mon Sep 17 00:00:00 2001 From: Esme Povirk Date: Fri, 7 Jun 2024 16:14:12 +0000 Subject: [PATCH] SDL2: Update to 2.30.3. --- SDL2/CMakeLists.txt | 18 +--- SDL2/Makefile.os2 | 2 +- SDL2/Makefile.w32 | 2 +- SDL2/SDL2.spec | 2 +- SDL2/VERSION.txt | 2 +- SDL2/Xcode/SDL/Info-Framework.plist | 4 +- SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 +-- SDL2/Xcode/SDL/pkg-support/SDL.info | 2 +- .../main/java/org/libsdl/app/SDLActivity.java | 2 +- SDL2/configure | 78 +---------------- SDL2/configure.ac | 34 +------- SDL2/include/SDL_revision.h | 4 +- SDL2/include/SDL_stdinc.h | 2 +- SDL2/include/SDL_version.h | 2 +- SDL2/src/core/gdk/SDL_gdk.cpp | 21 +++++ SDL2/src/filesystem/gdk/SDL_sysfilesystem.cpp | 2 - SDL2/src/joystick/SDL_joystick.c | 2 + SDL2/src/joystick/linux/SDL_sysjoystick.c | 83 ++++++++++++++----- SDL2/src/main/windows/version.rc | 8 +- SDL2/src/video/kmsdrm/SDL_kmsdrmvideo.c | 3 +- SDL2/src/video/wayland/SDL_waylandevents.c | 6 +- SDL2/src/video/windows/SDL_windowsevents.c | 29 ++++++- SDL2/src/video/x11/SDL_x11mouse.c | 17 +++- SDL2/src/video/x11/SDL_x11video.c | 8 ++ SDL2/src/video/x11/SDL_x11video.h | 2 + SDL2/test/watcom.mif | 4 +- 26 files changed, 170 insertions(+), 181 deletions(-) diff --git a/SDL2/CMakeLists.txt b/SDL2/CMakeLists.txt index 8f9ab396..2a91824c 100644 --- a/SDL2/CMakeLists.txt +++ b/SDL2/CMakeLists.txt @@ -87,7 +87,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 30) -set(SDL_MICRO_VERSION 2) +set(SDL_MICRO_VERSION 3) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts @@ -926,22 +926,6 @@ if(SDL_ASSEMBLY) endif() endif() - if(SDL_LASX) - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "-mlasx") - check_c_source_compiles(" - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LASX) - check_include_file("lasxintrin.h" HAVE_LASXINTRIN_H) - cmake_pop_check_state() - if(CPU_SUPPORTS_LASX AND HAVE_LASXINTRIN_H) - list(APPEND EXTRA_CFLAGS "-mlasx") - set(HAVE_LASX TRUE) - endif() - endif() - if(SDL_ARMSIMD) set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp") diff --git a/SDL2/Makefile.os2 b/SDL2/Makefile.os2 index 805a613d..f2fe6d1c 100644 --- a/SDL2/Makefile.os2 +++ b/SDL2/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 2 +MICRO_VERSION = 3 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/SDL2/Makefile.w32 b/SDL2/Makefile.w32 index cfa35175..613884a5 100644 --- a/SDL2/Makefile.w32 +++ b/SDL2/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 2 +MICRO_VERSION = 3 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/SDL2/SDL2.spec b/SDL2/SDL2.spec index 0d7539de..f0c90471 100644 --- a/SDL2/SDL2.spec +++ b/SDL2/SDL2.spec @@ -1,6 +1,6 @@ Summary: Simple DirectMedia Layer Name: SDL2 -Version: 2.30.2 +Version: 2.30.3 Release: 2 Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz URL: http://www.libsdl.org/ diff --git a/SDL2/VERSION.txt b/SDL2/VERSION.txt index 3b16cc57..52b59a7d 100644 --- a/SDL2/VERSION.txt +++ b/SDL2/VERSION.txt @@ -1 +1 @@ -release-2.30.2-0-gf461d91cd +release-2.30.3-0-gfb1497566 diff --git a/SDL2/Xcode/SDL/Info-Framework.plist b/SDL2/Xcode/SDL/Info-Framework.plist index 088ca4f7..98152216 100644 --- a/SDL2/Xcode/SDL/Info-Framework.plist +++ b/SDL2/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.30.2 + 2.30.3 CFBundleSignature SDLX CFBundleVersion - 2.30.2 + 2.30.3 diff --git a/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 2505a877..670c98e8 100644 --- a/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.2.0; + DYLIB_CURRENT_VERSION = 3001.3.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.30.2; + MARKETING_VERSION = 2.30.3; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.2.0; + DYLIB_CURRENT_VERSION = 3001.3.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.30.2; + MARKETING_VERSION = 2.30.3; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.2.0; + DYLIB_CURRENT_VERSION = 3001.3.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 = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.2.0; + DYLIB_CURRENT_VERSION = 3001.3.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/SDL2/Xcode/SDL/pkg-support/SDL.info b/SDL2/Xcode/SDL/pkg-support/SDL.info index 705fcbc7..7808139c 100644 --- a/SDL2/Xcode/SDL/pkg-support/SDL.info +++ b/SDL2/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.30.2 +Title SDL 2.30.3 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 7cbf9d34..d762e4e9 100644 --- a/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 2; + private static final int SDL_MICRO_VERSION = 3; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/SDL2/configure b/SDL2/configure index 9489151e..8183ec88 100755 --- a/SDL2/configure +++ b/SDL2/configure @@ -873,7 +873,6 @@ enable_sse2 enable_sse3 enable_altivec enable_lsx -enable_lasx enable_oss enable_alsa with_alsa_prefix @@ -1675,7 +1674,6 @@ Optional Features: --enable-sse3 use SSE3 assembly routines [default=maybe] --enable-altivec use Altivec assembly routines [default=yes] --enable-lsx use LSX assembly routines [default=yes] - --enable-lasx use LASX assembly routines [default=yes] --enable-oss support the OSS audio API [default=maybe] --enable-alsa support the ALSA audio API [default=yes] --disable-alsatest Do not try to compile and run a test Alsa program @@ -3510,7 +3508,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=2 +SDL_MICRO_VERSION=3 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` @@ -21112,80 +21110,6 @@ printf "%s\n" "#define HAVE_LSXINTRIN_H 1" >>confdefs.h fi - # Check whether --enable-lasx was given. -if test ${enable_lasx+y} -then : - enableval=$enable_lasx; -else $as_nop - enable_LASX=yes -fi - - if test x$enable_LASX = xyes; then - save_CFLAGS="$CFLAGS" - have_gcc_lasx=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mlasx option" >&5 -printf %s "checking for GCC -mlasx option... " >&6; } - lasx_CFLAGS="-mlasx" - CFLAGS="$save_CFLAGS $lasx_CFLAGS" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - have_gcc_lasx=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lasx" >&5 -printf "%s\n" "$have_gcc_lasx" >&6; } - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_lasx = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS" - SUMMARY_math="${SUMMARY_math} lasx" - fi - fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lasxintrin.h" >&5 -printf %s "checking for lasxintrin.h... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - have_lasxintrin_h_hdr=yes -else $as_nop - have_lasxintrin_h_hdr=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_lasxintrin_h_hdr" >&5 -printf "%s\n" "$have_lasxintrin_h_hdr" >&6; } - if test x$have_lasxintrin_h_hdr = xyes; then - -printf "%s\n" "#define HAVE_LASXINTRIN_H 1" >>confdefs.h - - fi - CheckOSS() { # Check whether --enable-oss was given. diff --git a/SDL2/configure.ac b/SDL2/configure.ac index 2114e409..631ea773 100644 --- a/SDL2/configure.ac +++ b/SDL2/configure.ac @@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=2 +SDL_MICRO_VERSION=3 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` @@ -938,38 +938,6 @@ fi AC_DEFINE(HAVE_LSXINTRIN_H, 1, [ ]) fi - AC_ARG_ENABLE(lasx, -[AS_HELP_STRING([--enable-lasx], [use LASX assembly routines [default=yes]])], - , enable_LASX=yes) - if test x$enable_LASX = xyes; then - save_CFLAGS="$CFLAGS" - have_gcc_lasx=no - AC_MSG_CHECKING(for GCC -mlasx option) - lasx_CFLAGS="-mlasx" - CFLAGS="$save_CFLAGS $lasx_CFLAGS" - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - ]], [])], [have_gcc_lasx=yes], []) - AC_MSG_RESULT($have_gcc_lasx) - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_lasx = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS" - SUMMARY_math="${SUMMARY_math} lasx" - fi - fi - - AC_MSG_CHECKING(for lasxintrin.h) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]])], - [have_lasxintrin_h_hdr=yes],[have_lasxintrin_h_hdr=no]) - AC_MSG_RESULT($have_lasxintrin_h_hdr) - if test x$have_lasxintrin_h_hdr = xyes; then - AC_DEFINE(HAVE_LASXINTRIN_H, 1, [ ]) - fi - dnl See if the OSS audio interface is supported CheckOSS() { diff --git a/SDL2/include/SDL_revision.h b/SDL2/include/SDL_revision.h index c4358ffc..fea1e873 100644 --- a/SDL2/include/SDL_revision.h +++ b/SDL2/include/SDL_revision.h @@ -1,7 +1,7 @@ /* Generated by updaterev.sh, do not edit */ #ifdef SDL_VENDOR_INFO -#define SDL_REVISION "SDL-release-2.30.2-0-gf461d91cd (" SDL_VENDOR_INFO ")" +#define SDL_REVISION "SDL-release-2.30.3-0-gfb1497566 (" SDL_VENDOR_INFO ")" #else -#define SDL_REVISION "SDL-release-2.30.2-0-gf461d91cd" +#define SDL_REVISION "SDL-release-2.30.3-0-gfb1497566" #endif #define SDL_REVISION_NUMBER 0 diff --git a/SDL2/include/SDL_stdinc.h b/SDL2/include/SDL_stdinc.h index 0035a357..8c22283a 100644 --- a/SDL2/include/SDL_stdinc.h +++ b/SDL2/include/SDL_stdinc.h @@ -107,7 +107,7 @@ # elif defined(__MRC__) void *alloca(unsigned); # else -char *alloca(); +void *alloca(size_t); # endif #endif diff --git a/SDL2/include/SDL_version.h b/SDL2/include/SDL_version.h index c222d776..b7b7f39b 100644 --- a/SDL2/include/SDL_version.h +++ b/SDL2/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 30 -#define SDL_PATCHLEVEL 2 +#define SDL_PATCHLEVEL 3 /** * Macro to determine SDL version program was compiled against. diff --git a/SDL2/src/core/gdk/SDL_gdk.cpp b/SDL2/src/core/gdk/SDL_gdk.cpp index c5bac8aa..06995686 100644 --- a/SDL2/src/core/gdk/SDL_gdk.cpp +++ b/SDL2/src/core/gdk/SDL_gdk.cpp @@ -36,6 +36,7 @@ extern "C" { static XTaskQueueHandle GDK_GlobalTaskQueue; PAPPSTATE_REGISTRATION hPLM = {}; +PAPPCONSTRAIN_REGISTRATION hCPLM = {}; HANDLE plmSuspendComplete = nullptr; extern "C" DECLSPEC int @@ -177,6 +178,23 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) return -1; } + /* Register constrain/unconstrain handling */ + auto raccn = [](BOOLEAN constrained, PVOID context) { + SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler"); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (_this) { + if (constrained) { + SDL_SetKeyboardFocus(NULL); + } else { + SDL_SetKeyboardFocus(_this->windows); + } + } + }; + if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) { + SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification"); + return -1; + } + /* Run the application main() code */ result = mainFunction(argc, argv); @@ -184,6 +202,9 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) UnregisterAppStateChangeNotification(hPLM); CloseHandle(plmSuspendComplete); + /* Unregister constrain/unconstrain handling */ + UnregisterAppConstrainedChangeNotification(hCPLM); + /* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */ /* Terminate the task queue and dispatch any pending tasks */ XTaskQueueTerminate(taskQueue, false, nullptr, nullptr); diff --git a/SDL2/src/filesystem/gdk/SDL_sysfilesystem.cpp b/SDL2/src/filesystem/gdk/SDL_sysfilesystem.cpp index 601d352b..22cc9c28 100644 --- a/SDL2/src/filesystem/gdk/SDL_sysfilesystem.cpp +++ b/SDL2/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -20,7 +20,6 @@ */ #include "../../SDL_internal.h" -#ifdef SDL_FILESYSTEM_XBOX /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ @@ -135,6 +134,5 @@ SDL_GetPrefPath(const char *org, const char *app) return folderPath; } -#endif /* SDL_FILESYSTEM_XBOX */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/SDL2/src/joystick/SDL_joystick.c b/SDL2/src/joystick/SDL_joystick.c index c4e774c9..c4d43ec0 100644 --- a/SDL2/src/joystick/SDL_joystick.c +++ b/SDL2/src/joystick/SDL_joystick.c @@ -370,6 +370,8 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */ MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ + MAKE_VIDPID(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */ + MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */ MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */ MAKE_VIDPID(0x0eb7, 0x0001), /* Fanatec ClubSport Wheel Base V2 */ MAKE_VIDPID(0x0eb7, 0x0004), /* Fanatec ClubSport Wheel Base V2.5 */ diff --git a/SDL2/src/joystick/linux/SDL_sysjoystick.c b/SDL2/src/joystick/linux/SDL_sysjoystick.c index 75d25227..bb7c31ce 100644 --- a/SDL2/src/joystick/linux/SDL_sysjoystick.c +++ b/SDL2/src/joystick/linux/SDL_sysjoystick.c @@ -273,7 +273,7 @@ static int GuessIsSensor(int fd) return 0; } -static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid) +static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid) { struct input_id inpid; char *name; @@ -282,21 +282,32 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend SDL_zero(inpid); #ifdef SDL_USE_LIBUDEV - SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class); + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + !(class & SDL_UDEV_DEVICE_JOYSTICK)) { + return 0; + } #endif - if (ioctl(fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) { - /* When udev is enabled we only get joystick devices here, so there's no need to test them */ - if (enumeration_method != ENUMERATION_LIBUDEV && - !(class & SDL_UDEV_DEVICE_JOYSTICK) && ( class || !GuessIsJoystick(fd))) { + + if (fd && *fd < 0) { + *fd = open(path, O_RDONLY | O_CLOEXEC, 0); + } + if (!fd || *fd < 0) { + return 0; + } + + if (ioctl(*fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) { + /* When udev enumeration or classification, we only got joysticks here, so no need to test */ + if (enumeration_method != ENUMERATION_LIBUDEV && !class && !GuessIsJoystick(*fd)) { return 0; } /* Could have vendor and product already from udev, but should agree with evdev */ - if (ioctl(fd, EVIOCGID, &inpid) < 0) { + if (ioctl(*fd, EVIOCGID, &inpid) < 0) { return 0; } - if (ioctl(fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) { + if (ioctl(*fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) { return 0; } } @@ -315,7 +326,7 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend } #endif - FixupDeviceInfoForMapping(fd, &inpid); + FixupDeviceInfoForMapping(*fd, &inpid); #ifdef DEBUG_JOYSTICK SDL_Log("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", name, inpid.bustype, inpid.vendor, inpid.product, inpid.version); @@ -333,11 +344,32 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend return 1; } -static int IsSensor(const char *path, int fd) +static int IsSensor(const char *path, int *fd) { struct input_id inpid; + int class = 0; + + SDL_zero(inpid); +#ifdef SDL_USE_LIBUDEV + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + !(class & SDL_UDEV_DEVICE_ACCELEROMETER)) { + return 0; + } +#endif + + if (fd && *fd < 0) { + *fd = open(path, O_RDONLY | O_CLOEXEC, 0); + } + if (!fd || *fd < 0) { + return 0; + } - if (ioctl(fd, EVIOCGID, &inpid) < 0) { + if (!class && !GuessIsSensor(*fd)) { + return 0; + } + + if (ioctl(*fd, EVIOCGID, &inpid) < 0) { return 0; } @@ -347,7 +379,7 @@ static int IsSensor(const char *path, int fd) return 0; } - return GuessIsSensor(fd); + return 1; } #ifdef SDL_USE_LIBUDEV @@ -434,16 +466,11 @@ static void MaybeAddDevice(const char *path) } } - fd = open(path, O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) { - goto done; - } - #ifdef DEBUG_INPUT_EVENTS SDL_Log("Checking %s\n", path); #endif - if (IsJoystick(path, fd, &name, &vendor, &product, &guid)) { + if (IsJoystick(path, &fd, &name, &vendor, &product, &guid)) { #ifdef DEBUG_INPUT_EVENTS SDL_Log("found joystick: %s\n", path); #endif @@ -484,7 +511,7 @@ static void MaybeAddDevice(const char *path) goto done; } - if (IsSensor(path, fd)) { + if (IsSensor(path, &fd)) { #ifdef DEBUG_INPUT_EVENTS SDL_Log("found sensor: %s\n", path); #endif @@ -880,11 +907,24 @@ static void LINUX_ScanSteamVirtualGamepads(void) int num_virtual_gamepads = 0; int virtual_gamepad_slot; VirtualGamepadEntry *virtual_gamepads = NULL; +#ifdef SDL_USE_LIBUDEV + int class; +#endif count = scandir("/dev/input", &entries, filter_entries, NULL); for (i = 0; i < count; ++i) { (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); +#ifdef SDL_USE_LIBUDEV + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + class = 0; + SDL_zero(inpid); + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + (inpid.vendor != USB_VENDOR_VALVE || inpid.product != USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) { + free(entries[i]); /* This should NOT be SDL_free() */ + continue; + } +#endif fd = open(path, O_RDONLY | O_CLOEXEC, 0); if (fd >= 0) { if (ioctl(fd, EVIOCGID, &inpid) == 0 && @@ -986,6 +1026,9 @@ static void LINUX_JoystickDetect(void) static int LINUX_JoystickInit(void) { const char *devices = SDL_GetHint(SDL_HINT_JOYSTICK_DEVICE); +#ifdef SDL_USE_LIBUDEV + int udev_status = SDL_UDEV_Init(); +#endif SDL_classic_joysticks = SDL_GetHintBoolean(SDL_HINT_LINUX_JOYSTICK_CLASSIC, SDL_FALSE); @@ -1036,7 +1079,7 @@ static int LINUX_JoystickInit(void) } if (enumeration_method == ENUMERATION_LIBUDEV) { - if (SDL_UDEV_Init() == 0) { + if (udev_status == 0) { /* Set up the udev callback */ if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { SDL_UDEV_Quit(); diff --git a/SDL2/src/main/windows/version.rc b/SDL2/src/main/windows/version.rc index 7a1bddf3..01a21be5 100644 --- a/SDL2/src/main/windows/version.rc +++ b/SDL2/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,30,2,0 - PRODUCTVERSION 2,30,2,0 + FILEVERSION 2,30,3,0 + PRODUCTVERSION 2,30,3,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 30, 2, 0\0" + VALUE "FileVersion", "2, 30, 3, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 30, 2, 0\0" + VALUE "ProductVersion", "2, 30, 3, 0\0" END END BLOCK "VarFileInfo" diff --git a/SDL2/src/video/kmsdrm/SDL_kmsdrmvideo.c b/SDL2/src/video/kmsdrm/SDL_kmsdrmvideo.c index 69033b0e..bdcd2207 100644 --- a/SDL2/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/SDL2/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -77,6 +77,7 @@ static int get_driindex(void) int devindex = -1; DIR *folder; const char *hint; + struct dirent *res; hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX); if (hint && *hint) { @@ -96,7 +97,7 @@ static int get_driindex(void) SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname, sizeof(device) - kmsdrm_dri_devnamesize); - for (struct dirent *res; (res = readdir(folder));) { + while((res = readdir(folder)) != NULL) { if (SDL_memcmp(res->d_name, kmsdrm_dri_devname, kmsdrm_dri_devnamesize) == 0) { SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize, diff --git a/SDL2/src/video/wayland/SDL_waylandevents.c b/SDL2/src/video/wayland/SDL_waylandevents.c index a5105a2f..9e9c3934 100644 --- a/SDL2/src/video/wayland/SDL_waylandevents.c +++ b/SDL2/src/video/wayland/SDL_waylandevents.c @@ -1166,7 +1166,8 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, const SDL_Scancode scancode = Wayland_get_scancode_from_key(input, *key + 8); if (scancode != SDL_SCANCODE_UNKNOWN) { - for (uint32_t i = 0; i < SDL_arraysize(mod_scancodes); ++i) { + uint32_t i; + for (i = 0; i < SDL_arraysize(mod_scancodes); ++i) { if (mod_scancodes[i] == scancode) { SDL_SendKeyboardKey(SDL_PRESSED, scancode); break; @@ -1814,7 +1815,8 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d char **paths = SDL_DBus_DocumentsPortalRetrieveFiles(buffer, &path_count); /* If dropped files contain a directory the list is empty */ if (paths && path_count > 0) { - for (int i = 0; i < path_count; i++) { + int i; + for (i = 0; i < path_count; i++) { SDL_SendDropFile(data_device->dnd_window, paths[i]); } dbus->free_string_array(paths); diff --git a/SDL2/src/video/windows/SDL_windowsevents.c b/SDL2/src/video/windows/SDL_windowsevents.c index 360da2a7..cb2a44c5 100644 --- a/SDL2/src/video/windows/SDL_windowsevents.c +++ b/SDL2/src/video/windows/SDL_windowsevents.c @@ -128,6 +128,10 @@ static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) return SDL_SCANCODE_RIGHT; case VK_DOWN: return SDL_SCANCODE_DOWN; + case VK_CONTROL: + return SDL_SCANCODE_LCTRL; + case VK_V: + return SDL_SCANCODE_V; default: return SDL_SCANCODE_UNKNOWN; @@ -137,6 +141,11 @@ static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) static SDL_Scancode VKeytoScancode(WPARAM vkey) { switch (vkey) { + case VK_BACK: + return SDL_SCANCODE_BACKSPACE; + case VK_CAPITAL: + return SDL_SCANCODE_CAPSLOCK; + case VK_MODECHANGE: return SDL_SCANCODE_MODE; case VK_SELECT: @@ -1957,13 +1966,26 @@ static void WIN_CleanRegisterApp(WNDCLASSEX wcex) SDL_Appname = NULL; } +static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG_PTR lParam) +{ + WNDCLASSEX *wcex = (WNDCLASSEX *)lParam; + + (void)lpType; /* We already know that the resource type is RT_GROUP_ICON. */ + + /* We leave hIconSm as NULL as it will allow Windows to automatically + choose the appropriate small icon size to suit the current DPI. */ + wcex->hIcon = LoadIcon(hModule, lpName); + + /* Do not bother enumerating any more. */ + return FALSE; +} + /* Register the class for this application */ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { WNDCLASSEX wcex; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) const char *hint; - TCHAR path[MAX_PATH]; #endif /* Only do this once... */ @@ -2006,9 +2028,8 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) wcex.hIconSm = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); } } else { - /* Use the first icon as a default icon, like in the Explorer */ - GetModuleFileName(SDL_Instance, path, MAX_PATH); - ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1); + /* Use the first icon as a default icon, like in the Explorer. */ + EnumResourceNames(SDL_Instance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex); } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ diff --git a/SDL2/src/video/x11/SDL_x11mouse.c b/SDL2/src/video/x11/SDL_x11mouse.c index beb69417..0938de99 100644 --- a/SDL2/src/video/x11/SDL_x11mouse.c +++ b/SDL2/src/video/x11/SDL_x11mouse.c @@ -317,8 +317,19 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) { SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata; Display *display = videodata->display; -#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + SDL_Mouse *mouse = SDL_GetMouse(); int deviceid = 0; + SDL_bool warp_hack = SDL_FALSE; + + /* XWayland will only warp the cursor if it is hidden, so this workaround is required. */ + if (videodata->is_xwayland && mouse && mouse->cursor_shown) { + warp_hack = SDL_TRUE; + } + + if (warp_hack) { + X11_ShowCursor(NULL); + } +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 if (X11_Xinput2IsInitialized()) { /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea @@ -335,6 +346,10 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) { X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, x, y); } + + if (warp_hack) { + X11_ShowCursor(SDL_GetCursor()); + } X11_XSync(display, False); videodata->global_mouse_changed = SDL_TRUE; } diff --git a/SDL2/src/video/x11/SDL_x11video.c b/SDL2/src/video/x11/SDL_x11video.c index a9d7abe9..6a543c18 100644 --- a/SDL2/src/video/x11/SDL_x11video.c +++ b/SDL2/src/video/x11/SDL_x11video.c @@ -145,6 +145,12 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) return 0; } +static SDL_bool X11_IsXWayland(Display *d) +{ + int opcode, event, error; + return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True; +} + static SDL_VideoDevice *X11_CreateDevice(void) { SDL_VideoDevice *device; @@ -322,6 +328,8 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface; #endif + data->is_xwayland = X11_IsXWayland(x11_display); + return device; } diff --git a/SDL2/src/video/x11/SDL_x11video.h b/SDL2/src/video/x11/SDL_x11video.h index 07cb01e3..a12a34b9 100644 --- a/SDL2/src/video/x11/SDL_x11video.h +++ b/SDL2/src/video/x11/SDL_x11video.h @@ -156,6 +156,8 @@ typedef struct SDL_VideoData SDL_bool is_steam_deck; SDL_bool steam_keyboard_open; + SDL_bool is_xwayland; + } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void); diff --git a/SDL2/test/watcom.mif b/SDL2/test/watcom.mif index b81dad83..aa15f669 100644 --- a/SDL2/test/watcom.mif +++ b/SDL2/test/watcom.mif @@ -108,14 +108,14 @@ testutils.lib: testutils.obj check: .SYMBOLIC $(TESTS) @set SDL_AUDIODRIVER=dummy @set SDL_VIDEODRIVER=dummy - @copy "../SDL2.dll" . + @copy ..\SDL2.dll . @for %exe in ($(TESTS)) do %exe check-quick: .SYMBOLIC $(TESTS) @set SDL_TESTS_QUICK=1 @set SDL_AUDIODRIVER=dummy @set SDL_VIDEODRIVER=dummy - @copy "../SDL2.dll" . + @copy ..\SDL2.dll . @for %exe in ($(TESTS)) do %exe clean: .SYMBOLIC