@@ -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);
@@ -248,7 +248,11 @@ private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterfa
248248 0x1689 , // Razer Onza
249249 0x1949 , // Lab126, Inc.
250250 0x1bad , // Harmonix
251+ 0x20d6 , // PowerA
251252 0x24c6 , // PowerA
253+ 0x2c22 , // Qanba
254+ 0x2dc8 , // 8BitDo
255+ 0x9886 , // ASTRO Gaming
252256 };
253257
254258 if (usbInterface .getInterfaceClass () == UsbConstants .USB_CLASS_VENDOR_SPEC &&
@@ -269,13 +273,20 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
269273 final int XB1_IFACE_SUBCLASS = 71 ;
270274 final int XB1_IFACE_PROTOCOL = 208 ;
271275 final int [] SUPPORTED_VENDORS = {
276+ 0x03f0 , // HP
277+ 0x044f , // Thrustmaster
272278 0x045e , // Microsoft
273279 0x0738 , // Mad Catz
280+ 0x0b05 , // ASUS
274281 0x0e6f , // PDP
275282 0x0f0d , // Hori
283+ 0x10f5 , // Turtle Beach
276284 0x1532 , // Razer Wildcat
285+ 0x20d6 , // PowerA
277286 0x24c6 , // PowerA
287+ 0x2dc8 , // 8BitDo
278288 0x2e24 , // Hyperkin
289+ 0x3537 , // GameSir
279290 };
280291
281292 if (usbInterface .getId () == 0 &&
@@ -349,13 +360,19 @@ private void connectHIDDeviceUSB(UsbDevice usbDevice) {
349360 private void initializeBluetooth () {
350361 Log .d (TAG , "Initializing Bluetooth" );
351362
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) */ &&
353370 mContext .getPackageManager ().checkPermission (android .Manifest .permission .BLUETOOTH , mContext .getPackageName ()) != PackageManager .PERMISSION_GRANTED ) {
354371 Log .d (TAG , "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH" );
355372 return ;
356373 }
357374
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) */ )) {
359376 Log .d (TAG , "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE" );
360377 return ;
361378 }
@@ -520,7 +537,7 @@ public void setFrozen(boolean frozen) {
520537 for (HIDDevice device : mDevicesById .values ()) {
521538 device .setFrozen (frozen );
522539 }
523- }
540+ }
524541 }
525542
526543 //////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -569,12 +586,18 @@ public boolean openDevice(int deviceID) {
569586 try {
570587 final int FLAG_MUTABLE = 0x02000000 ; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
571588 int flags ;
572- if (Build .VERSION .SDK_INT >= 31 ) {
589+ if (Build .VERSION .SDK_INT >= 31 /* Android 12.0 (S) */ ) {
573590 flags = FLAG_MUTABLE ;
574591 } else {
575592 flags = 0 ;
576593 }
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+ }
578601 } catch (Exception e ) {
579602 Log .v (TAG , "Couldn't request permission for USB device " + usbDevice );
580603 HIDDeviceOpenResult (deviceID , false );
0 commit comments