Skip to content

Commit 689d1f4

Browse files
author
github-actions[bot]
committed
Update android-project
1 parent 6eb4b93 commit 689d1f4

12 files changed

+354
-362
lines changed

app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
boolean supportsRelativeMouse();
5151
int openFileDescriptor(java.lang.String, java.lang.String);
5252
boolean showFileDialog(java.lang.String[], boolean, boolean, int);
53+
java.lang.String getPreferredLocales();
54+
java.lang.String formatLocale(java.util.Locale);
5355
}
5456

5557
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager {

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Replace com.test.game with the identifier of your game below, e.g.
3-
com.gamemaker.game
4-
-->
52
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
63
android:versionCode="1"
74
android:versionName="1.0"

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
4444

4545
private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000;
4646

47-
static public final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
48-
static public final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
49-
static public final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
47+
static final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
48+
static final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
49+
static final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
5050
static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 };
5151

5252
static class GattOperation {
@@ -156,7 +156,7 @@ static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) {
156156
}
157157
}
158158

159-
public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
159+
HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
160160
mManager = manager;
161161
mDevice = device;
162162
mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
@@ -169,17 +169,17 @@ public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice dev
169169
// final HIDDeviceBLESteamController finalThis = this;
170170
// mHandler.postDelayed(new Runnable() {
171171
// @Override
172-
// public void run() {
172+
// void run() {
173173
// finalThis.checkConnectionForChromebookIssue();
174174
// }
175175
// }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
176176
}
177177

178-
public String getIdentifier() {
178+
String getIdentifier() {
179179
return String.format("SteamController.%s", mDevice.getAddress());
180180
}
181181

182-
public BluetoothGatt getGatt() {
182+
BluetoothGatt getGatt() {
183183
return mGatt;
184184
}
185185

@@ -219,7 +219,7 @@ protected int getConnectionState() {
219219
return btManager.getConnectionState(mDevice, BluetoothProfile.GATT);
220220
}
221221

222-
public void reconnect() {
222+
void reconnect() {
223223

224224
if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) {
225225
mGatt.disconnect();
@@ -401,12 +401,12 @@ private void enableNotification(UUID chrUuid) {
401401
queueGattOperation(op);
402402
}
403403

404-
public void writeCharacteristic(UUID uuid, byte[] value) {
404+
void writeCharacteristic(UUID uuid, byte[] value) {
405405
GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value);
406406
queueGattOperation(op);
407407
}
408408

409-
public void readCharacteristic(UUID uuid) {
409+
void readCharacteristic(UUID uuid) {
410410
GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid);
411411
queueGattOperation(op);
412412
}
@@ -415,6 +415,7 @@ public void readCharacteristic(UUID uuid) {
415415
////////////// BluetoothGattCallback overridden methods
416416
//////////////////////////////////////////////////////////////////////////////////////////////////////
417417

418+
@Override
418419
public void onConnectionStateChange(BluetoothGatt g, int status, int newState) {
419420
//Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState);
420421
mIsReconnecting = false;
@@ -437,6 +438,7 @@ else if (newState == 0) {
437438
// Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent.
438439
}
439440

441+
@Override
440442
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
441443
//Log.v(TAG, "onServicesDiscovered status=" + status);
442444
if (status == 0) {
@@ -453,6 +455,7 @@ public void onServicesDiscovered(BluetoothGatt gatt, int status) {
453455
}
454456
}
455457

458+
@Override
456459
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
457460
//Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid());
458461

@@ -463,21 +466,23 @@ public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic
463466
finishCurrentGattOperation();
464467
}
465468

469+
@Override
466470
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
467471
//Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid());
468472

469473
if (characteristic.getUuid().equals(reportCharacteristic)) {
470474
// Only register controller with the native side once it has been fully configured
471475
if (!isRegistered()) {
472476
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
473-
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0);
477+
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0, true);
474478
setRegistered();
475479
}
476480
}
477481

478482
finishCurrentGattOperation();
479483
}
480484

485+
@Override
481486
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
482487
// Enable this for verbose logging of controller input reports
483488
//Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue()));
@@ -487,10 +492,12 @@ public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteris
487492
}
488493
}
489494

495+
@Override
490496
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
491497
//Log.v(TAG, "onDescriptorRead status=" + status);
492498
}
493499

500+
@Override
494501
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
495502
BluetoothGattCharacteristic chr = descriptor.getCharacteristic();
496503
//Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid());
@@ -508,14 +515,17 @@ public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descri
508515
finishCurrentGattOperation();
509516
}
510517

518+
@Override
511519
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
512520
//Log.v(TAG, "onReliableWriteCompleted status=" + status);
513521
}
514522

523+
@Override
515524
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
516525
//Log.v(TAG, "onReadRemoteRssi status=" + status);
517526
}
518527

528+
@Override
519529
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
520530
//Log.v(TAG, "onMtuChanged status=" + status);
521531
}

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public class HIDDeviceManager {
3232
private static HIDDeviceManager sManager;
3333
private static int sManagerRefCount = 0;
3434

35-
public static HIDDeviceManager acquire(Context context) {
35+
static public HIDDeviceManager acquire(Context context) {
3636
if (sManagerRefCount == 0) {
3737
sManager = new HIDDeviceManager(context);
3838
}
3939
++sManagerRefCount;
4040
return sManager;
4141
}
4242

43-
public static void release(HIDDeviceManager manager) {
43+
static public void release(HIDDeviceManager manager) {
4444
if (manager == sManager) {
4545
--sManagerRefCount;
4646
if (sManagerRefCount == 0) {
@@ -121,11 +121,11 @@ private HIDDeviceManager(final Context context) {
121121
}
122122
}
123123

124-
public Context getContext() {
124+
Context getContext() {
125125
return mContext;
126126
}
127127

128-
public int getDeviceIDForIdentifier(String identifier) {
128+
int getDeviceIDForIdentifier(String identifier) {
129129
SharedPreferences.Editor spedit = mSharedPreferences.edit();
130130

131131
int result = mSharedPreferences.getInt(identifier, 0);
@@ -288,9 +288,13 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
288288
0x1532, // Razer Wildcat
289289
0x20d6, // PowerA
290290
0x24c6, // PowerA
291+
0x294b, // Snakebyte
291292
0x2dc8, // 8BitDo
292293
0x2e24, // Hyperkin
294+
0x2e95, // SCUF
295+
0x3285, // Nacon
293296
0x3537, // GameSir
297+
0x366c, // ByoWave
294298
};
295299

296300
if (usbInterface.getId() == 0 &&
@@ -355,7 +359,7 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
355359
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
356360
int id = device.getId();
357361
mDevicesById.put(id, device);
358-
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol());
362+
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol(), false);
359363
}
360364
}
361365
}
@@ -439,7 +443,7 @@ private void shutdownBluetooth() {
439443
// Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly.
440444
// This function provides a sort of dummy version of that, watching for changes in the
441445
// connected devices and attempting to add controllers as things change.
442-
public void chromebookConnectionHandler() {
446+
void chromebookConnectionHandler() {
443447
if (!mIsChromebook) {
444448
return;
445449
}
@@ -478,7 +482,7 @@ public void run() {
478482
}, 10000);
479483
}
480484

481-
public boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
485+
boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
482486
Log.v(TAG, "connectBluetoothDevice device=" + bluetoothDevice);
483487
synchronized (this) {
484488
if (mBluetoothDevices.containsKey(bluetoothDevice)) {
@@ -499,7 +503,7 @@ public boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
499503
return true;
500504
}
501505

502-
public void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
506+
void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
503507
synchronized (this) {
504508
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
505509
if (device == null)
@@ -513,7 +517,7 @@ public void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
513517
}
514518
}
515519

516-
public boolean isSteamController(BluetoothDevice bluetoothDevice) {
520+
boolean isSteamController(BluetoothDevice bluetoothDevice) {
517521
// Sanity check. If you pass in a null device, by definition it is never a Steam Controller.
518522
if (bluetoothDevice == null) {
519523
return false;
@@ -567,7 +571,7 @@ private HIDDevice getDevice(int id) {
567571
////////// JNI interface functions
568572
//////////////////////////////////////////////////////////////////////////////////////////////////////
569573

570-
public boolean initialize(boolean usb, boolean bluetooth) {
574+
boolean initialize(boolean usb, boolean bluetooth) {
571575
Log.v(TAG, "initialize(" + usb + ", " + bluetooth + ")");
572576

573577
if (usb) {
@@ -579,7 +583,7 @@ public boolean initialize(boolean usb, boolean bluetooth) {
579583
return true;
580584
}
581585

582-
public boolean openDevice(int deviceID) {
586+
boolean openDevice(int deviceID) {
583587
Log.v(TAG, "openDevice deviceID=" + deviceID);
584588
HIDDevice device = getDevice(deviceID);
585589
if (device == null) {
@@ -621,7 +625,7 @@ public boolean openDevice(int deviceID) {
621625
return false;
622626
}
623627

624-
public int writeReport(int deviceID, byte[] report, boolean feature) {
628+
int writeReport(int deviceID, byte[] report, boolean feature) {
625629
try {
626630
//Log.v(TAG, "writeReport deviceID=" + deviceID + " length=" + report.length);
627631
HIDDevice device;
@@ -638,7 +642,7 @@ public int writeReport(int deviceID, byte[] report, boolean feature) {
638642
return -1;
639643
}
640644

641-
public boolean readReport(int deviceID, byte[] report, boolean feature) {
645+
boolean readReport(int deviceID, byte[] report, boolean feature) {
642646
try {
643647
//Log.v(TAG, "readReport deviceID=" + deviceID);
644648
HIDDevice device;
@@ -655,7 +659,7 @@ public boolean readReport(int deviceID, byte[] report, boolean feature) {
655659
return false;
656660
}
657661

658-
public void closeDevice(int deviceID) {
662+
void closeDevice(int deviceID) {
659663
try {
660664
Log.v(TAG, "closeDevice deviceID=" + deviceID);
661665
HIDDevice device;
@@ -679,7 +683,7 @@ public void closeDevice(int deviceID) {
679683
private native void HIDDeviceRegisterCallback();
680684
private native void HIDDeviceReleaseCallback();
681685

682-
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol);
686+
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol, boolean bBluetooth);
683687
native void HIDDeviceOpenPending(int deviceID);
684688
native void HIDDeviceOpenResult(int deviceID, boolean opened);
685689
native void HIDDeviceDisconnected(int deviceID);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface
3030
mRunning = false;
3131
}
3232

33-
public String getIdentifier() {
33+
String getIdentifier() {
3434
return String.format("%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex);
3535
}
3636

@@ -100,7 +100,7 @@ public UsbDevice getDevice() {
100100
return mDevice;
101101
}
102102

103-
public String getDeviceName() {
103+
String getDeviceName() {
104104
return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")";
105105
}
106106

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public class SDL {
1212

1313
// This function should be called first and sets up the native code
1414
// so it can call into the Java classes
15-
public static void setupJNI() {
15+
static public void setupJNI() {
1616
SDLActivity.nativeSetupJNI();
1717
SDLAudioManager.nativeSetupJNI();
1818
SDLControllerManager.nativeSetupJNI();
1919
}
2020

2121
// This function should be called each time the activity is started
22-
public static void initialize() {
22+
static public void initialize() {
2323
setContext(null);
2424

2525
SDLActivity.initialize();
@@ -28,20 +28,20 @@ public static void initialize() {
2828
}
2929

3030
// This function stores the current activity (SDL or not)
31-
public static void setContext(Context context) {
31+
static public void setContext(Context context) {
3232
SDLAudioManager.setContext(context);
3333
mContext = context;
3434
}
3535

36-
public static Context getContext() {
36+
static public Context getContext() {
3737
return mContext;
3838
}
3939

40-
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
40+
static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
4141
loadLibrary(libraryName, mContext);
4242
}
4343

44-
public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
44+
static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
4545

4646
if (libraryName == null) {
4747
throw new NullPointerException("No library name provided.");

0 commit comments

Comments
 (0)