From 9e77da9f8c3b76e0a53ea25d0b8a04521b955376 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Sat, 6 May 2023 02:15:16 +0300 Subject: [PATCH] Android: minor update --- .github/workflows/android.yml | 4 +-- Android/app/build.gradle | 10 ++++--- .../main/java/org/libsdl/app/SDLActivity.java | 2 +- .../org/libsdl/app/SDLControllerManager.java | 26 +++++++++++++++++++ Android/build.gradle | 4 +-- Android/gradle.properties | 7 +++-- .../gradle/wrapper/gradle-wrapper.properties | 6 ++--- Android/native/build.gradle | 2 +- 8 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 95b5dd420..6d9f22d82 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -24,11 +24,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' - name: Install GNU gettext run: sudo apt install gettext - name: Build with Gradle diff --git a/Android/app/build.gradle b/Android/app/build.gradle index 0743a32cd..1a7ad64e9 100644 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -52,10 +52,12 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } + kotlinOptions.jvmTarget = "17" + buildFeatures { viewBinding true } @@ -120,7 +122,7 @@ dependencies { /* Third-party libraries */ implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat-resources:1.6.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' - implementation 'androidx.work:work-runtime-ktx:2.8.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.work:work-runtime-ktx:2.8.1' implementation 'com.google.android.material:material:1.8.0' } 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 f2371fc45..9ed0e7ce7 100644 --- a/Android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/Android/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 = 26; - private static final int SDL_MICRO_VERSION = 3; + private static final int SDL_MICRO_VERSION = 5; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java index 82373d9d6..cc6cc3b59 100644 --- a/Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java +++ b/Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java @@ -168,6 +168,32 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler { arg1Axis = MotionEvent.AXIS_GAS; } + // Make sure the AXIS_Z is sorted between AXIS_RY and AXIS_RZ. + // This is because the usual pairing are: + // - AXIS_X + AXIS_Y (left stick). + // - AXIS_RX, AXIS_RY (sometimes the right stick, sometimes triggers). + // - AXIS_Z, AXIS_RZ (sometimes the right stick, sometimes triggers). + // This sorts the axes in the above order, which tends to be correct + // for Xbox-ish game pads that have the right stick on RX/RY and the + // triggers on Z/RZ. + // + // Gamepads that don't have AXIS_Z/AXIS_RZ but use + // AXIS_LTRIGGER/AXIS_RTRIGGER are unaffected by this. + // + // References: + // - https://developer.android.com/develop/ui/views/touch-and-input/game-controllers/controller-input + // - https://www.kernel.org/doc/html/latest/input/gamepad.html + if (arg0Axis == MotionEvent.AXIS_Z) { + arg0Axis = MotionEvent.AXIS_RZ - 1; + } else if (arg0Axis > MotionEvent.AXIS_Z && arg0Axis < MotionEvent.AXIS_RZ) { + --arg0Axis; + } + if (arg1Axis == MotionEvent.AXIS_Z) { + arg1Axis = MotionEvent.AXIS_RZ - 1; + } else if (arg1Axis > MotionEvent.AXIS_Z && arg1Axis < MotionEvent.AXIS_RZ) { + --arg1Axis; + } + return arg0Axis - arg1Axis; } } diff --git a/Android/build.gradle b/Android/build.gradle index 6751fb27b..4faf685c6 100644 --- a/Android/build.gradle +++ b/Android/build.gradle @@ -16,10 +16,10 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.1' + classpath 'com.android.tools.build:gradle:8.0.1' //noinspection GradleDependency classpath 'de.undercouch:gradle-download-task:4.1.2' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/Android/gradle.properties b/Android/gradle.properties index 8d5c2efb6..62fecd9ab 100644 --- a/Android/gradle.properties +++ b/Android/gradle.properties @@ -1,7 +1,7 @@ <#if isLowMemory> -org.gradle.jvmargs=-Xmx4G -XX:MaxPermSize=2G -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError <#else> -org.gradle.jvmargs=-Xmx16G -XX:MaxPermSize=8G -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx16G -XX:MaxMetaspaceSize=8G -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true @@ -9,3 +9,6 @@ org.gradle.parallel.threads=8 org.gradle.configureondemand=true android.enableJetifier=false android.useAndroidX=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/Android/gradle/wrapper/gradle-wrapper.properties b/Android/gradle/wrapper/gradle-wrapper.properties index e3e6a280d..6d84bb784 100644 --- a/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 05 18:33:37 EET 2022 +#Fri May 05 22:26:30 TRT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Android/native/build.gradle b/Android/native/build.gradle index 27108992f..fd75d6e62 100644 --- a/Android/native/build.gradle +++ b/Android/native/build.gradle @@ -50,7 +50,7 @@ android { // get precompiled deps task downloadDeps(type: Download) { - def VERSION = "22022023" + def VERSION = "20042023" src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip" dest new File(buildDir, 'deps.zip') overwrite false