Skip to content

Commit 70b0ba3

Browse files
authored
[Android standalone] update SDL files to v2.32.10 (#2831)
* [Android standalone] update SDL files to v2.32.10 * fixed multiline comment I tried to selective update the file, butt there were a multiline comment I mislook. So I just updated he full file SDLActivity.java file. * [Android standalone] Restore custom virtual keyboard after SDL update [Gemini 2.5 Pro] The custom virtual keyboard on Android is no longer displayed after updating the underlying SDL library from v2.26.2 to v2.32.10. This was caused by a change in how the new version of `SDLActivity.java` handles text input. The newer SDL version more aggressively activates its own text input system (`SDL_StartTextInput()`) on Android. The TIC-80 C code in `src/system/sdl/main.c` has a function, `isKbdVisible()`, which determines whether to render the custom keyboard. This function contained a specific check for Android: `!SDL_IsTextInputActive()`. This line was intended to hide the custom keyboard when a native (e.g., system) keyboard was active. Because the newer SDL version keeps its text input system active by default, this check was causing the custom TIC-80 keyboard to be permanently hidden. This change resolves the issue by commenting out the `!SDL_IsTextInputActive()` check. This restores the intended behavior, ensuring that TIC-80's own integrated virtual keyboard is always used for input on touch devices, independent of the underlying SDL text input state. * Restore virtual keyboard and system keyboard toggle Tries to make the system keyboard show when it was previously working. * [Android standalone] The virtual keyboard was not appearing after updating SDL to v2.32.10. The new `SDLActivity.java` now enables text input on launch by default, which caused TIC-80's logic to hide its custom keyboard. This is fixed by adding an explicit `SDL_StopTextInput()` call during initialization to restore the correct default state. A redundant text input call was also removed from the `SDL_KEYDOWN` handler to ensure the system keyboard is only activated by its specific toggle key.
1 parent b98d07c commit 70b0ba3

File tree

9 files changed

+340
-106
lines changed

9 files changed

+340
-106
lines changed

build/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public BluetoothGatt getGatt() {
186186
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
187187
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
188188
private BluetoothGatt connectGatt(boolean managed) {
189-
if (Build.VERSION.SDK_INT >= 23) {
189+
if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
190190
try {
191191
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
192192
} catch (Exception e) {
@@ -429,7 +429,7 @@ public void run() {
429429
}
430430
});
431431
}
432-
}
432+
}
433433
else if (newState == 0) {
434434
mIsConnected = false;
435435
}

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

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private void initializeUSB() {
170170
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
171171
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
172172
173-
// Get endpoint details
173+
// Get endpoint details
174174
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
175175
{
176176
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
@@ -251,6 +251,8 @@ private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterfa
251251
0x20d6, // PowerA
252252
0x24c6, // PowerA
253253
0x2c22, // Qanba
254+
0x2dc8, // 8BitDo
255+
0x9886, // ASTRO Gaming
254256
};
255257

256258
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
@@ -271,15 +273,20 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
271273
final int XB1_IFACE_SUBCLASS = 71;
272274
final int XB1_IFACE_PROTOCOL = 208;
273275
final int[] SUPPORTED_VENDORS = {
276+
0x03f0, // HP
277+
0x044f, // Thrustmaster
274278
0x045e, // Microsoft
275279
0x0738, // Mad Catz
280+
0x0b05, // ASUS
276281
0x0e6f, // PDP
277282
0x0f0d, // Hori
283+
0x10f5, // Turtle Beach
278284
0x1532, // Razer Wildcat
279285
0x20d6, // PowerA
280286
0x24c6, // PowerA
281-
0x2dc8, /* 8BitDo */
287+
0x2dc8, // 8BitDo
282288
0x2e24, // Hyperkin
289+
0x3537, // GameSir
283290
};
284291

285292
if (usbInterface.getId() == 0 &&
@@ -353,13 +360,19 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
353360
private void initializeBluetooth() {
354361
Log.d(TAG, "Initializing Bluetooth");
355362

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

362-
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) {
375+
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18 /* Android 4.3 (JELLY_BEAN_MR2) */)) {
363376
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
364377
return;
365378
}
@@ -524,7 +537,7 @@ public void setFrozen(boolean frozen) {
524537
for (HIDDevice device : mDevicesById.values()) {
525538
device.setFrozen(frozen);
526539
}
527-
}
540+
}
528541
}
529542

530543
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -573,12 +586,18 @@ public boolean openDevice(int deviceID) {
573586
try {
574587
final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
575588
int flags;
576-
if (Build.VERSION.SDK_INT >= 31) {
589+
if (Build.VERSION.SDK_INT >= 31 /* Android 12.0 (S) */) {
577590
flags = FLAG_MUTABLE;
578591
} else {
579592
flags = 0;
580593
}
581-
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags));
594+
if (Build.VERSION.SDK_INT >= 33 /* Android 14.0 (U) */) {
595+
Intent intent = new Intent(HIDDeviceManager.ACTION_USB_PERMISSION);
596+
intent.setPackage(mContext.getPackageName());
597+
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, intent, flags));
598+
} else {
599+
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags));
600+
}
582601
} catch (Exception e) {
583602
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
584603
HIDDeviceOpenResult(deviceID, false);

build/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public int getProductId() {
5252
@Override
5353
public String getSerialNumber() {
5454
String result = null;
55-
if (Build.VERSION.SDK_INT >= 21) {
55+
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
5656
try {
5757
result = mDevice.getSerialNumber();
5858
}
@@ -74,7 +74,7 @@ public int getVersion() {
7474
@Override
7575
public String getManufacturerName() {
7676
String result = null;
77-
if (Build.VERSION.SDK_INT >= 21) {
77+
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
7878
result = mDevice.getManufacturerName();
7979
}
8080
if (result == null) {
@@ -86,7 +86,7 @@ public String getManufacturerName() {
8686
@Override
8787
public String getProductName() {
8888
String result = null;
89-
if (Build.VERSION.SDK_INT >= 21) {
89+
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
9090
result = mDevice.getProductName();
9191
}
9292
if (result == null) {

build/android/app/src/main/java/org/libsdl/app/SDL.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static void initialize() {
2929

3030
// This function stores the current activity (SDL or not)
3131
public static void setContext(Context context) {
32+
SDLAudioManager.setContext(context);
3233
mContext = context;
3334
}
3435

@@ -37,6 +38,10 @@ public static Context getContext() {
3738
}
3839

3940
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
41+
loadLibrary(libraryName, mContext);
42+
}
43+
44+
public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
4045

4146
if (libraryName == null) {
4247
throw new NullPointerException("No library name provided.");
@@ -52,10 +57,10 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError,
5257
// To use ReLinker, just add it as a dependency. For more information, see
5358
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
5459
//
55-
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
56-
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
57-
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
58-
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");
60+
Class<?> relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
61+
Class<?> relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
62+
Class<?> contextClass = context.getClassLoader().loadClass("android.content.Context");
63+
Class<?> stringClass = context.getClassLoader().loadClass("java.lang.String");
5964

6065
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
6166
// they've changed during updates.
@@ -65,7 +70,7 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError,
6570

6671
// Actually load the library!
6772
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
68-
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
73+
loadMethod.invoke(relinkInstance, context, libraryName, null, null);
6974
}
7075
catch (final Throwable e) {
7176
// Fall back

0 commit comments

Comments
 (0)