From 2fc4edb4c86ffed32bf38b1dcefa1c30c360993d Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 17 Jul 2024 01:29:00 +0100 Subject: [PATCH] Bump SDL to v2.30.5 --- .editorconfig | 3 +++ 3rdParty/SDL2/CMakeLists.txt | 4 ++-- Packaging/windows/mingw-prep.sh | 2 +- .../java/org/libsdl/app/HIDDeviceManager.java | 9 +++++++- .../app/src/main/java/org/libsdl/app/SDL.java | 14 +++++++---- .../main/java/org/libsdl/app/SDLActivity.java | 12 +++++----- tools/update_sdl_android_project.sh | 23 +++++++++++++++++++ 7 files changed, 52 insertions(+), 15 deletions(-) create mode 100755 tools/update_sdl_android_project.sh diff --git a/.editorconfig b/.editorconfig index 0311a34932b..0840d4bece8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,9 @@ insert_final_newline = true # Visual C++ Code Style settings cpp_generate_documentation_comments = doxygen_slash_star +[*.java] +end_of_line = lf + [*.pot] end_of_line = lf diff --git a/3rdParty/SDL2/CMakeLists.txt b/3rdParty/SDL2/CMakeLists.txt index 8e6036095a8..05ee3b515a9 100644 --- a/3rdParty/SDL2/CMakeLists.txt +++ b/3rdParty/SDL2/CMakeLists.txt @@ -70,8 +70,8 @@ endif() include(FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(SDL2 - #URL https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.0.18.tar.gz - #URL_HASH MD5=647e2890385e5f13b9aeee2e27fa26e7 + #URL https://github.com/libsdl-org/SDL/releases/download/release-2.30.5/SDL2-2.30.5.tar.gz + #URL_HASH SHA256=f374f3fa29c37dfcc20822d4a7d7dc57e58924d1a5f2ad511bfab4c8193de63b #URL https://github.com/libsdl-org/SDL/archive/5056b29b0f8611b470d8b8bdb313eab628f8bd6e.tar.gz #URL_HASH MD5=3fb6d72c33434082c32d2649c35c6502 GIT_REPOSITORY https://github.com/pionere/SDL.git diff --git a/Packaging/windows/mingw-prep.sh b/Packaging/windows/mingw-prep.sh index 6b92b4063a5..1320d3cd65e 100755 --- a/Packaging/windows/mingw-prep.sh +++ b/Packaging/windows/mingw-prep.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SDLDEV_VERS=2.30.3 +SDLDEV_VERS=2.30.5 SDLTTF_VERS=2.0.15 SDLMIXER_VERS=2.0.4 SODIUM_VERS=1.0.20 diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index e7281fdf26a..21a1c1d18ee 100644 --- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -277,6 +277,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa 0x044f, // Thrustmaster 0x045e, // Microsoft 0x0738, // Mad Catz + 0x0b05, // ASUS 0x0e6f, // PDP 0x0f0d, // Hori 0x10f5, // Turtle Beach @@ -590,7 +591,13 @@ public boolean openDevice(int deviceID) { } else { flags = 0; } - mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags)); + if (Build.VERSION.SDK_INT >= 33 /* Android 14.0 (U) */) { + Intent intent = new Intent(HIDDeviceManager.ACTION_USB_PERMISSION); + intent.setPackage(mContext.getPackageName()); + mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, intent, flags)); + } else { + mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags)); + } } catch (Exception e) { Log.v(TAG, "Couldn't request permission for USB device " + usbDevice); HIDDeviceOpenResult(deviceID, false); diff --git a/android-project/app/src/main/java/org/libsdl/app/SDL.java b/android-project/app/src/main/java/org/libsdl/app/SDL.java index 44c21c1c75c..139be9d151c 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDL.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDL.java @@ -38,6 +38,10 @@ public static Context getContext() { } public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { + loadLibrary(libraryName, mContext); + } + + public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException { if (libraryName == null) { throw new NullPointerException("No library name provided."); @@ -53,10 +57,10 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, // To use ReLinker, just add it as a dependency. For more information, see // https://github.com/KeepSafe/ReLinker for ReLinker's repository. // - Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); - Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); - Class contextClass = mContext.getClassLoader().loadClass("android.content.Context"); - Class stringClass = mContext.getClassLoader().loadClass("java.lang.String"); + Class relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); + Class relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); + Class contextClass = context.getClassLoader().loadClass("android.content.Context"); + Class stringClass = context.getClassLoader().loadClass("java.lang.String"); // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if // they've changed during updates. @@ -66,7 +70,7 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, // Actually load the library! Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); - loadMethod.invoke(relinkInstance, mContext, libraryName, null, null); + loadMethod.invoke(relinkInstance, context, libraryName, null, null); } catch (final Throwable e) { // Fall back 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 349771a44cc..88c5ea3038b 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 = 31; - private static final int SDL_MICRO_VERSION = 2; + private static final int SDL_MICRO_VERSION = 5; /* // Display InputType.SOURCE/CLASS of events and devices // @@ -281,7 +281,7 @@ protected String[] getLibraries() { // Load the .so public void loadLibraries() { for (String lib : getLibraries()) { - SDL.loadLibrary(lib); + SDL.loadLibrary(lib, this); } } @@ -995,8 +995,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint) /* No valid hint, nothing is explicitly allowed */ if (!is_portrait_allowed && !is_landscape_allowed) { if (resizable) { - /* All orientations are allowed */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* All orientations are allowed, respecting user orientation lock setting */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Fixed window and nothing specified. Get orientation from w/h of created window */ req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); @@ -1005,8 +1005,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint) /* At least one orientation is allowed */ if (resizable) { if (is_portrait_allowed && is_landscape_allowed) { - /* hint allows both landscape and portrait, promote to full sensor */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* hint allows both landscape and portrait, promote to full user */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Use the only one allowed "orientation" */ req = (is_landscape_allowed ? orientation_landscape : orientation_portrait); diff --git a/tools/update_sdl_android_project.sh b/tools/update_sdl_android_project.sh new file mode 100755 index 00000000000..c74dc9b87e5 --- /dev/null +++ b/tools/update_sdl_android_project.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +SDL_BASE=https://raw.githubusercontent.com/libsdl-org/SDL/release-2.30.5 +FILES=( + HIDDevice.java + HIDDeviceBLESteamController.java + HIDDeviceManager.java + HIDDeviceUSB.java + SDL.java + SDLActivity.java + SDLAudioManager.java + SDLControllerManager.java + SDLSurface.java +) + +for f in "${FILES[@]}"; do + set -x + curl -L -O -s "${SDL_BASE}/android-project/app/src/main/java/org/libsdl/app/${f}" \ + --output-dir android-project/app/src/main/java/org/libsdl/app/ + { set +x; } 2> /dev/null +done +>&2 echo "Done. Remember to manually check for and sync changes in XML files, such as AndroidManifest.xml"