Skip to content

Commit 4bdfb75

Browse files
authored
Merge pull request #3200 from carstene1ns/update/android-sdl
Update Android SDL project
2 parents 476b320 + db48494 commit 4bdfb75

File tree

10 files changed

+39
-12
lines changed

10 files changed

+39
-12
lines changed

.gitattributes

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ src/midisequencer.* -diff linguist-vendored
1717
src/midisynth.* -diff linguist-vendored
1818
src/picojson.h -diff linguist-vendored
1919
CMakePresets.json -diff linguist-generated
20-
builds/android/app/src/main/java/org/libsdl/app/SDL*.java -diff linguist-vendored
20+
builds/android/app/src/main/java/org/libsdl/app/*.java -diff linguist-vendored
2121
builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java diff
22-
builds/android/app/src/main/java/org/libsdl/app/SDLSurface.java diff
23-
builds/android/app/src/main/java/org/libsdl/app/HID*.java -diff linguist-vendored
2422
src/generated/* -diff linguist-generated

builds/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
android {
3+
namespace "org.easyrpg.player"
34
compileSdkVersion 33
45
buildToolsVersion '33.0.0'
56
ndkVersion '21.4.7075529'

builds/android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="org.easyrpg.player"
5-
android:installLocation="auto"
65
android:versionCode="1"
7-
android:versionName="1.0">
6+
android:versionName="1.0"
7+
android:installLocation="auto">
8+
89
<!-- OpenGL ES 2.0 -->
910
<uses-feature android:glEsVersion="0x00020000" />
1011
<!-- Touchscreen support -->
@@ -38,6 +39,10 @@
3839
android:label="@string/app_name"
3940
android:theme="@style/AppTheme">
4041

42+
<!-- Setting SDL hints from AndroidManifest.xml: -->
43+
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0" />
44+
<meta-data android:name="SDL_ENV.SDL_APP_NAME" android:value="EasyRPG Player" />
45+
4146
<!-- Startup Activity -->
4247
<activity
4348
android:name=".InitActivity"

builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ public class EasyRpgPlayerActivity extends SDLActivity implements NavigationView
8484
private boolean uiVisible = true;
8585
SurfaceView surface;
8686

87+
@Override
88+
protected String[] getLibraries() {
89+
return new String[] {
90+
"SDL2",
91+
"easyrpg_android"
92+
};
93+
}
94+
8795
@Override
8896
protected void onCreate(Bundle savedInstanceState) {
8997
super.onCreate(savedInstanceState);

builds/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
285285
0x24c6, // PowerA
286286
0x2dc8, // 8BitDo
287287
0x2e24, // Hyperkin
288+
0x3537, // GameSir
288289
};
289290

290291
if (usbInterface.getId() == 0 &&
@@ -358,6 +359,12 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
358359
private void initializeBluetooth() {
359360
Log.d(TAG, "Initializing Bluetooth");
360361

362+
if (Build.VERSION.SDK_INT >= 31 /* Android 12 */ &&
363+
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH_CONNECT, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
364+
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH_CONNECT");
365+
return;
366+
}
367+
361368
if (Build.VERSION.SDK_INT <= 30 /* Android 11.0 (R) */ &&
362369
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
363370
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");

builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
6363
private static final String TAG = "SDL";
6464
private static final int SDL_MAJOR_VERSION = 2;
65-
private static final int SDL_MINOR_VERSION = 28;
66-
private static final int SDL_MICRO_VERSION = 5;
65+
private static final int SDL_MINOR_VERSION = 30;
66+
private static final int SDL_MICRO_VERSION = 1;
6767
/*
6868
// Display InputType.SOURCE/CLASS of events and devices
6969
//
@@ -276,7 +276,7 @@ protected String[] getLibraries() {
276276
// "SDL2_mixer",
277277
// "SDL2_net",
278278
// "SDL2_ttf",
279-
"easyrpg_android"
279+
"main"
280280
};
281281
}
282282

builds/android/app/src/main/java/org/libsdl/app/SDLSurface.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ public void onSensorChanged(SensorEvent event) {
354354
SDLActivity.onNativeOrientationChanged(newOrientation);
355355
}
356356

357-
/* EasyRPG modification: prevent movement to be input
358357
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
359358
y / SensorManager.GRAVITY_EARTH,
360359
event.values[2] / SensorManager.GRAVITY_EARTH);
361-
*/
360+
361+
362362
}
363363
}
364364

builds/android/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
23
buildscript {
34
repositories {
45
mavenCentral()
56
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.2.2'
9+
classpath 'com.android.tools.build:gradle:8.1.1'
10+
11+
// NOTE: Do not place your application dependencies here; they belong
12+
// in the individual module build.gradle files
913
}
1014
}
1115

@@ -15,3 +19,7 @@ allprojects {
1519
google()
1620
}
1721
}
22+
23+
task clean(type: Delete) {
24+
delete rootProject.buildDir
25+
}
-5.2 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)