From 258f63e98c071a38a1fdd01a2b505e44b8fe0856 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Thu, 6 Mar 2025 10:50:18 +0900 Subject: [PATCH] Android/Windows: Update SDL to 2.32.2 --- CMakeLists.txt | 4 +- android/app/jni/CMakeLists.txt | 4 +- android/app/proguard-rules.pro | 81 +++++++++++++++++++ .../main/java/org/libsdl/app/SDLActivity.java | 11 ++- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a13a4e3..1114105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,8 +79,8 @@ else() # NOT (ANDROID OR EMSCRIPTEN) if (MSVC) include(FetchContent) FetchContent_Declare(sdl2 - URL https://github.com/libsdl-org/SDL/releases/download/release-2.30.6/SDL2-devel-2.30.6-VC.zip - URL_HASH SHA1=038ffed56e04fbc4c6236187472c671596963fdb) + URL https://github.com/libsdl-org/SDL/releases/download/release-2.32.2/SDL2-devel-2.32.2-VC.zip + URL_HASH SHA1=08737e7e813443e47b663be4d91f8a4d8de6916b) FetchContent_MakeAvailable(sdl2) find_package(SDL2 REQUIRED CONFIG PATHS ${sdl2_SOURCE_DIR}/cmake NO_DEFAULT_PATH) get_target_property(SDL2_DLL SDL2::SDL2 IMPORTED_LOCATION) diff --git a/android/app/jni/CMakeLists.txt b/android/app/jni/CMakeLists.txt index fa3b5f9..6beab8d 100644 --- a/android/app/jni/CMakeLists.txt +++ b/android/app/jni/CMakeLists.txt @@ -7,8 +7,8 @@ set(PROJECT_ROOT_DIR ../../..) include(FetchContent) FetchContent_Declare( SDL - URL https://github.com/libsdl-org/SDL/releases/download/release-2.30.6/SDL2-2.30.6.tar.gz - URL_HASH SHA1=76d70f28a0c044111b461a189f02196814fd116e + URL https://github.com/libsdl-org/SDL/releases/download/release-2.32.2/SDL2-2.32.2.tar.gz + URL_HASH SHA1=20bc6148186c2f610c71fd0838f51412b8ae74aa ) FetchContent_Declare( SDL_ttf diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index eaf0e91..a4c9886 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -15,3 +15,84 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLInputConnection { + void nativeCommitText(java.lang.String, int); + void nativeGenerateScancodeForUnichar(char); +} + +-keep,includedescriptorclasses class org.libsdl.app.SDLActivity { + # for some reason these aren't compatible with allowoptimization modifier + boolean supportsRelativeMouse(); + void setWindowStyle(boolean); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity { + java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it + boolean onNativeSoftReturnKey(); + void onNativeKeyboardFocusLost(); + boolean isScreenKeyboardShown(); + android.util.DisplayMetrics getDisplayDPI(); + java.lang.String clipboardGetText(); + boolean clipboardHasText(); + void clipboardSetText(java.lang.String); + int createCustomCursor(int[], int, int, int, int); + void destroyCustomCursor(int); + android.content.Context getContext(); + boolean getManifestEnvironmentVariables(); + android.view.Surface getNativeSurface(); + void initTouch(); + boolean isAndroidTV(); + boolean isChromebook(); + boolean isDeXMode(); + boolean isTablet(); + void manualBackButton(); + int messageboxShowMessageBox(int, java.lang.String, java.lang.String, int[], int[], java.lang.String[], int[]); + void minimizeWindow(); + int openURL(java.lang.String); + void requestPermission(java.lang.String, int); + int showToast(java.lang.String, int, int, int, int); + boolean sendMessage(int, int); + boolean setActivityTitle(java.lang.String); + boolean setCustomCursor(int); + void setOrientation(int, int, boolean, java.lang.String); + boolean setRelativeMouseEnabled(boolean); + boolean setSystemCursor(int); + boolean shouldMinimizeOnFocusLoss(); + boolean showTextInput(int, int, int, int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager { + boolean initialize(boolean, boolean); + boolean openDevice(int); + int sendOutputReport(int, byte[]); + int sendFeatureReport(int, byte[]); + boolean getFeatureReport(int, byte[]); + void closeDevice(int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLAudioManager { + int[] getAudioOutputDevices(); + int[] getAudioInputDevices(); + int[] audioOpen(int, int, int, int, int); + void audioWriteFloatBuffer(float[]); + void audioWriteShortBuffer(short[]); + void audioWriteByteBuffer(byte[]); + void audioClose(); + int[] captureOpen(int, int, int, int, int); + int captureReadFloatBuffer(float[], boolean); + int captureReadShortBuffer(short[], boolean); + int captureReadByteBuffer(byte[], boolean); + void captureClose(); + void audioSetThreadPriority(boolean, int); + native int nativeSetupJNI(); + native void removeAudioDevice(boolean, int); + native void addAudioDevice(boolean, int); +} + +-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLControllerManager { + void pollInputDevices(); + void pollHapticDevices(); + void hapticRun(int, float, int); + void hapticStop(int); +} diff --git a/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 976b1c3..c1c4c66 100644 --- a/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -60,8 +60,8 @@ import java.util.Locale; public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener { 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 = 6; + private static final int SDL_MINOR_VERSION = 32; + private static final int SDL_MICRO_VERSION = 2; /* // Display InputType.SOURCE/CLASS of events and devices // @@ -89,7 +89,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh | InputDevice.SOURCE_CLASS_POSITION | InputDevice.SOURCE_CLASS_TRACKBALL); - if (s2 != 0) cls += "Some_Unkown"; + if (s2 != 0) cls += "Some_Unknown"; s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class; @@ -163,7 +163,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh if (s == FLAG_TAINTED) src += " FLAG_TAINTED"; s2 &= ~FLAG_TAINTED; - if (s2 != 0) src += " Some_Unkown"; + if (s2 != 0) src += " Some_Unknown"; Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src); } @@ -790,6 +790,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); SDLActivity.mFullscreenModeActive = false; } + if (Build.VERSION.SDK_INT >= 28 /* Android 9 (Pie) */) { + window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + } } } else { Log.e(TAG, "error handling message, getContext() returned no Activity");