ソースを参照

修改了对s8xxx系列的连接

robbin 3 年 前
コミット
2315cd0ec6

+ 6 - 0
.idea/encodings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/app/build.gradle" charset="GBK" />
+  </component>
+</project>

+ 2 - 2
app/build.gradle

@@ -7,14 +7,14 @@ android {
         minSdkVersion 18
         targetSdkVersion 28
         versionCode 1
-        versionName "1.0"
+        versionName "1.0.1"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     android.applicationVariants.all {
         variant ->
             variant.outputs.all{
                 //´Ë´¦Ö¸¶¨Éú³ÉµÄapkÎļþÃû
-                outputFileName = "WingCoolAPK_V1.0_20210601.apk"
+                outputFileName = "WingCoolAPK_V1.0.1_20220216.apk"
             }
     }
     lintOptions {

+ 40 - 56
app/src/main/java/com/example/administrator/wingcool_gt9_apk/GT9MainActivity.java

@@ -572,7 +572,8 @@ public class GT9MainActivity extends AppCompatActivity
                             for (UsbDevice usbDevice : deviceList.values()) {
                                 //int productId = usbDevice.getProductId();
                                 int vendorId = usbDevice.getVendorId();
-                                if (( vendorId == 0x27C0)
+                                if ((vendorId == 0x27C0)
+                                        ||(vendorId == 0x27C6)
                                         ||(vendorId == 0x222A)    //奕力的VID
                                         ||(vendorId == 0x056A))   //8191主动笔和Wacom主动笔
                                 {
@@ -623,71 +624,54 @@ public class GT9MainActivity extends AppCompatActivity
         if (!values.isEmpty()) {
             for (UsbDevice usbDevice : values) {
                 //int productId = usbDevice.getProductId();
-                int vendorId = usbDevice.getVendorId();
+                int iVendorId = usbDevice.getVendorId();
                 //if (productId == 0x0818 || productId == 0x0001 )
-                if (( vendorId == 0x27C0)
-                        ||(vendorId == 0x222A)    //奕力的VID
-                        ||(vendorId == 0x056A))   //8191主动笔和Wacom主动笔
-                {  //0x0001是奕力的PID
+                if ((iVendorId == 0x27C0)          //之前VID错误了,做兼容
+                        ||(iVendorId == 0x27C6)    //汇顶的VID
+                        ||(iVendorId == 0x222A)    //奕力的VID
+                        ||(iVendorId == 0x056A))   //8191主动笔和Wacom主动笔
+                {
 
                     if (mUsbManager.hasPermission(usbDevice)) {
+                        UsbInterface usbInterface = usbDevice.getInterface(1);
 
-                        mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
-                        if (mUsbDeviceConnection != null) {
-
-                            {
-
-                                UsbInterface usbInterface = usbDevice.getInterface(1);
-
-                                if(UsbConstants.USB_CLASS_HID != usbInterface.getInterfaceClass())
-                                {
-                                    // continue;
-                                }
+                        for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
+                            UsbEndpoint ep = usbInterface.getEndpoint(i);
 
-                                for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
-                                    UsbEndpoint ep = usbInterface.getEndpoint(i);
-                                    if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
-                                        if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
-                                            //mUsbEndpointIn = ep;
-                                            mUsbEndpointOut = ep;
-                                        } else {
-                                            //mUsbEndpointOut = ep;
-                                            mUsbEndpointIn = ep;
-                                        }
-                                    }
-                                    else{
-                                        // mHandler.sendEmptyMessage(CONNECTED_SUCCESS);
-                                    }
-                                }
-                                if ((null == mUsbEndpointIn) || (null == mUsbEndpointOut)) {
+                            if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
+                                //mUsbEndpointIn = ep;
+                                mUsbEndpointOut = ep;
+                            } else {
+                                //mUsbEndpointOut = ep;
+                                mUsbEndpointIn = ep;
+                            }
+                        }
 
-                                    int i = mUsbDeviceConnection.controlTransfer(0x00, 0x09,
-                                            0x002, 0, null, 0, 100);
-                                    SystemClock.sleep(1000);
-                                    if(i>=0){
-                                        //mHandler.sendEmptyMessage(DEBUG_MESSAGE_SUCCESS);
-                                    }
-                                    else{
-                                        //mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
-                                    }
+                        if ((null == mUsbEndpointIn) || (null == mUsbEndpointOut)) {
+                            mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
+                            if (mUsbDeviceConnection!=null) {
+                                int i = mUsbDeviceConnection.controlTransfer(0x00, 0x09,
+                                        0x002, 0, null, 0, 100);
+                                SystemClock.sleep(1000);
+                                if (i >= 0) {
+                                    //mHandler.sendEmptyMessage(DEBUG_MESSAGE_SUCCESS);
                                 } else {
-                                    //if(0x80 == mUsbEndpointIn)
-                                    //mlog1.setEnabled(true);
-                                    mToggle = false;
-                                    isDetached = true;
-                                    isNeedFindDevice = false;
-                                    // mSendMessage.setEnabled(true);
-
-                                    mUsbInterface = usbInterface;
-                                    mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
-                                    if(null != mUsbEndpointIn){
-                                        mHandler.sendEmptyMessage(CONNECTED_SUCCESS);
-                                    }
-
+                                    //mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
                                 }
                             }
+                        } else {
+                            isNeedFindDevice = false;
+                            mUsbInterface = usbInterface;
+                            mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
+                            mUsbDeviceConnection.claimInterface(mUsbInterface, true);
+                            if(null != mUsbEndpointIn){
+                                //iProductId = usbDevice.getProductId();
+                                mHandler.sendEmptyMessage(CONNECTED_SUCCESS);
+                            }
                         }
-                    } else {
+
+                    }
+                    else {
                         mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mShowID, 0, new Intent(""), 0));
                     }
                 }

+ 1 - 1
app/src/main/res/values-en/strings.xml

@@ -79,7 +79,7 @@
     <string name="companyaddr">Address:Room 2008, Chuangxingda Business Building, No.36 Liuxian 3rd Road, Baoan District, Shenzhen</string>
     <string name="telephonenum">Telephone:186 8896 1937</string>
     <string name="emailaddr">Email:max@wingcool.cn</string>
-    <string name="version">APK Version:v1.0.0_20210601-Release Version</string>
+    <string name="version">APK Version:v1.0.1_20220216-Debug Version</string>
 
     <string name="app_name">WingCoolAPK</string>
     <string name="input_num_character">0123456789ABCDEFabcdef</string>

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -78,7 +78,7 @@
     <string name="companyaddr">地址:深圳市宝安区留仙三路 36 号创兴达商务大厦 2008 室</string>
     <string name="telephonenum">电话:186 8896 1937</string>
     <string name="emailaddr">邮箱:max@wingcool.cn</string>
-    <string name="version">APK版本:v1.0.0_20210601-发布版本</string>
+    <string name="version">APK版本:v1.0.1_20220216-Debug版本</string>
 
     <string name="app_name">WingCoolAPK</string>
     <string name="input_num_character">0123456789ABCDEFabcdef</string>