Skip to content

Commit

Permalink
Android: Update to SDL 2.28.2, NDK r23 (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka authored Nov 1, 2023
1 parent 7a0b2fe commit 626c52f
Show file tree
Hide file tree
Showing 12 changed files with 1,004 additions and 598 deletions.
2 changes: 1 addition & 1 deletion arch/android/Makefile.deps
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif
# the android project from the new SDL release (SDL/android-project/app/src/...).
#

SDL_VERSION ?= 2.0.20
SDL_VERSION ?= 2.28.2
LIBOGG_VERSION ?= 1.3.5
LIBVORBIS_VERSION ?= 1.3.7
WGET ?= wget
Expand Down
3 changes: 2 additions & 1 deletion arch/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ The build process for the MegaZeux port is as follows:

1. Install the latest version of both the Android SDK and NDK. The easiest way
to do this is to install these through Android Studio. MegaZeux requires
version 19 of the NDK or higher.
a version of the NDK between r19 and r23 (version r24 and above drop support
for Jelly Bean - APIs 16, 17, 18 - which we continue to support).
2. `export NDK_PATH=[the NDK path]`. As a hint, the directory should contain "ndk-build", among others.
* For Android Studio users, this will be `/home/.../Android/Sdk/ndk-bundle/`
Create the file `arch/android/project/local.properties` with the following lines:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public BluetoothGatt getGatt() {
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
private BluetoothGatt connectGatt(boolean managed) {
if (Build.VERSION.SDK_INT >= 23) {
if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
try {
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
} catch (Exception e) {
Expand Down Expand Up @@ -429,7 +429,7 @@ public void run() {
}
});
}
}
}
else if (newState == 0) {
mIsConnected = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private void initializeUSB() {
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
// Get endpoint details
// Get endpoint details
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
{
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
Expand Down Expand Up @@ -248,7 +248,11 @@ private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterfa
0x1689, // Razer Onza
0x1949, // Lab126, Inc.
0x1bad, // Harmonix
0x20d6, // PowerA
0x24c6, // PowerA
0x2c22, // Qanba
0x2dc8, // 8BitDo
0x9886, // ASTRO Gaming
};

if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
Expand All @@ -269,12 +273,16 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
final int XB1_IFACE_SUBCLASS = 71;
final int XB1_IFACE_PROTOCOL = 208;
final int[] SUPPORTED_VENDORS = {
0x044f, // Thrustmaster
0x045e, // Microsoft
0x0738, // Mad Catz
0x0e6f, // PDP
0x0f0d, // Hori
0x10f5, // Turtle Beach
0x1532, // Razer Wildcat
0x20d6, // PowerA
0x24c6, // PowerA
0x2dc8, // 8BitDo
0x2e24, // Hyperkin
};

Expand Down Expand Up @@ -349,13 +357,13 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
private void initializeBluetooth() {
Log.d(TAG, "Initializing Bluetooth");

if (Build.VERSION.SDK_INT <= 30 &&
if (Build.VERSION.SDK_INT <= 30 /* Android 11.0 (R) */ &&
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
return;
}

if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) {
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18 /* Android 4.3 (JELLY_BEAN_MR2) */)) {
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
return;
}
Expand Down Expand Up @@ -520,7 +528,7 @@ public void setFrozen(boolean frozen) {
for (HIDDevice device : mDevicesById.values()) {
device.setFrozen(frozen);
}
}
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -569,7 +577,7 @@ public boolean openDevice(int deviceID) {
try {
final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
int flags;
if (Build.VERSION.SDK_INT >= 31) {
if (Build.VERSION.SDK_INT >= 31 /* Android 12.0 (S) */) {
flags = FLAG_MUTABLE;
} else {
flags = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public int getProductId() {
@Override
public String getSerialNumber() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
try {
result = mDevice.getSerialNumber();
}
Expand All @@ -74,7 +74,7 @@ public int getVersion() {
@Override
public String getManufacturerName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
result = mDevice.getManufacturerName();
}
if (result == null) {
Expand All @@ -86,7 +86,7 @@ public String getManufacturerName() {
@Override
public String getProductName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
result = mDevice.getProductName();
}
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void initialize() {

// This function stores the current activity (SDL or not)
public static void setContext(Context context) {
SDLAudioManager.setContext(context);
mContext = context;
}

Expand Down
Loading

0 comments on commit 626c52f

Please sign in to comment.