mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Android: update used NDK and SDL support code
This commit is contained in:
parent
4b90e582b4
commit
0d85e826f4
5 changed files with 35 additions and 22 deletions
|
@ -277,6 +277,7 @@ public class HIDDeviceManager {
|
||||||
0x044f, // Thrustmaster
|
0x044f, // Thrustmaster
|
||||||
0x045e, // Microsoft
|
0x045e, // Microsoft
|
||||||
0x0738, // Mad Catz
|
0x0738, // Mad Catz
|
||||||
|
0x0b05, // ASUS
|
||||||
0x0e6f, // PDP
|
0x0e6f, // PDP
|
||||||
0x0f0d, // Hori
|
0x0f0d, // Hori
|
||||||
0x10f5, // Turtle Beach
|
0x10f5, // Turtle Beach
|
||||||
|
@ -590,7 +591,13 @@ public class HIDDeviceManager {
|
||||||
} else {
|
} else {
|
||||||
flags = 0;
|
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) {
|
} catch (Exception e) {
|
||||||
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
||||||
HIDDeviceOpenResult(deviceID, false);
|
HIDDeviceOpenResult(deviceID, false);
|
||||||
|
|
|
@ -38,6 +38,10 @@ public class SDL {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
|
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) {
|
if (libraryName == null) {
|
||||||
throw new NullPointerException("No library name provided.");
|
throw new NullPointerException("No library name provided.");
|
||||||
|
@ -53,10 +57,10 @@ public class SDL {
|
||||||
// To use ReLinker, just add it as a dependency. For more information, see
|
// To use ReLinker, just add it as a dependency. For more information, see
|
||||||
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
||||||
//
|
//
|
||||||
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
Class<?> relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
||||||
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
Class<?> relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
||||||
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
|
Class<?> contextClass = context.getClassLoader().loadClass("android.content.Context");
|
||||||
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");
|
Class<?> stringClass = context.getClassLoader().loadClass("java.lang.String");
|
||||||
|
|
||||||
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
||||||
// they've changed during updates.
|
// they've changed during updates.
|
||||||
|
@ -66,7 +70,7 @@ public class SDL {
|
||||||
|
|
||||||
// Actually load the library!
|
// Actually load the library!
|
||||||
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
|
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) {
|
catch (final Throwable e) {
|
||||||
// Fall back
|
// Fall back
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
private static final String TAG = "SDL";
|
private static final String TAG = "SDL";
|
||||||
private static final int SDL_MAJOR_VERSION = 2;
|
private static final int SDL_MAJOR_VERSION = 2;
|
||||||
private static final int SDL_MINOR_VERSION = 30;
|
private static final int SDL_MINOR_VERSION = 30;
|
||||||
private static final int SDL_MICRO_VERSION = 1;
|
private static final int SDL_MICRO_VERSION = 8;
|
||||||
/*
|
/*
|
||||||
// Display InputType.SOURCE/CLASS of events and devices
|
// 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_POSITION
|
||||||
| InputDevice.SOURCE_CLASS_TRACKBALL);
|
| 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;
|
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";
|
if (s == FLAG_TAINTED) src += " FLAG_TAINTED";
|
||||||
s2 &= ~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);
|
Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
// Load the .so
|
// Load the .so
|
||||||
public void loadLibraries() {
|
public void loadLibraries() {
|
||||||
for (String lib : getLibraries()) {
|
for (String lib : getLibraries()) {
|
||||||
SDL.loadLibrary(lib);
|
SDL.loadLibrary(lib, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,8 +995,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
/* No valid hint, nothing is explicitly allowed */
|
/* No valid hint, nothing is explicitly allowed */
|
||||||
if (!is_portrait_allowed && !is_landscape_allowed) {
|
if (!is_portrait_allowed && !is_landscape_allowed) {
|
||||||
if (resizable) {
|
if (resizable) {
|
||||||
/* All orientations are allowed */
|
/* All orientations are allowed, respecting user orientation lock setting */
|
||||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
|
||||||
} else {
|
} else {
|
||||||
/* Fixed window and nothing specified. Get orientation from w/h of created window */
|
/* 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);
|
req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||||
|
@ -1005,8 +1005,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
/* At least one orientation is allowed */
|
/* At least one orientation is allowed */
|
||||||
if (resizable) {
|
if (resizable) {
|
||||||
if (is_portrait_allowed && is_landscape_allowed) {
|
if (is_portrait_allowed && is_landscape_allowed) {
|
||||||
/* hint allows both landscape and portrait, promote to full sensor */
|
/* hint allows both landscape and portrait, promote to full user */
|
||||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
|
||||||
} else {
|
} else {
|
||||||
/* Use the only one allowed "orientation" */
|
/* Use the only one allowed "orientation" */
|
||||||
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
|
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
|
||||||
|
|
|
@ -546,13 +546,15 @@ class SDLHapticHandler {
|
||||||
if (haptic == null) {
|
if (haptic == null) {
|
||||||
InputDevice device = InputDevice.getDevice(deviceIds[i]);
|
InputDevice device = InputDevice.getDevice(deviceIds[i]);
|
||||||
Vibrator vib = device.getVibrator();
|
Vibrator vib = device.getVibrator();
|
||||||
if (vib.hasVibrator()) {
|
if (vib != null) {
|
||||||
haptic = new SDLHaptic();
|
if (vib.hasVibrator()) {
|
||||||
haptic.device_id = deviceIds[i];
|
haptic = new SDLHaptic();
|
||||||
haptic.name = device.getName();
|
haptic.device_id = deviceIds[i];
|
||||||
haptic.vib = vib;
|
haptic.name = device.getName();
|
||||||
mHaptics.add(haptic);
|
haptic.vib = vib;
|
||||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
mHaptics.add(haptic);
|
||||||
|
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ project.ext.set("versionBuild", 0) // Version Build
|
||||||
// ^ fourth version number to allow releasing Android-only fixes and beta versions
|
// ^ fourth version number to allow releasing Android-only fixes and beta versions
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.ndk_version = '26.2.11394342'
|
ext.ndk_version = '27.2.12479018'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue