@@ -170,7 +170,7 @@ private void initializeUSB() {
170
170
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
171
171
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
172
172
173
- // Get endpoint details
173
+ // Get endpoint details
174
174
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
175
175
{
176
176
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
@@ -248,7 +248,11 @@ private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterfa
248
248
0x1689 , // Razer Onza
249
249
0x1949 , // Lab126, Inc.
250
250
0x1bad , // Harmonix
251
+ 0x20d6 , // PowerA
251
252
0x24c6 , // PowerA
253
+ 0x2c22 , // Qanba
254
+ 0x2dc8 , // 8BitDo
255
+ 0x9886 , // ASTRO Gaming
252
256
};
253
257
254
258
if (usbInterface .getInterfaceClass () == UsbConstants .USB_CLASS_VENDOR_SPEC &&
@@ -269,13 +273,20 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
269
273
final int XB1_IFACE_SUBCLASS = 71 ;
270
274
final int XB1_IFACE_PROTOCOL = 208 ;
271
275
final int [] SUPPORTED_VENDORS = {
276
+ 0x03f0 , // HP
277
+ 0x044f , // Thrustmaster
272
278
0x045e , // Microsoft
273
279
0x0738 , // Mad Catz
280
+ 0x0b05 , // ASUS
274
281
0x0e6f , // PDP
275
282
0x0f0d , // Hori
283
+ 0x10f5 , // Turtle Beach
276
284
0x1532 , // Razer Wildcat
285
+ 0x20d6 , // PowerA
277
286
0x24c6 , // PowerA
287
+ 0x2dc8 , // 8BitDo
278
288
0x2e24 , // Hyperkin
289
+ 0x3537 , // GameSir
279
290
};
280
291
281
292
if (usbInterface .getId () == 0 &&
@@ -349,13 +360,19 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
349
360
private void initializeBluetooth () {
350
361
Log .d (TAG , "Initializing Bluetooth" );
351
362
352
- 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) */ &&
353
370
mContext .getPackageManager ().checkPermission (android .Manifest .permission .BLUETOOTH , mContext .getPackageName ()) != PackageManager .PERMISSION_GRANTED ) {
354
371
Log .d (TAG , "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH" );
355
372
return ;
356
373
}
357
374
358
- 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) */ )) {
359
376
Log .d (TAG , "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE" );
360
377
return ;
361
378
}
@@ -520,7 +537,7 @@ public void setFrozen(boolean frozen) {
520
537
for (HIDDevice device : mDevicesById .values ()) {
521
538
device .setFrozen (frozen );
522
539
}
523
- }
540
+ }
524
541
}
525
542
526
543
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -569,12 +586,18 @@ public boolean openDevice(int deviceID) {
569
586
try {
570
587
final int FLAG_MUTABLE = 0x02000000 ; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
571
588
int flags ;
572
- if (Build .VERSION .SDK_INT >= 31 ) {
589
+ if (Build .VERSION .SDK_INT >= 31 /* Android 12.0 (S) */ ) {
573
590
flags = FLAG_MUTABLE ;
574
591
} else {
575
592
flags = 0 ;
576
593
}
577
- 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
+ }
578
601
} catch (Exception e ) {
579
602
Log .v (TAG , "Couldn't request permission for USB device " + usbDevice );
580
603
HIDDeviceOpenResult (deviceID , false );
0 commit comments