新增滚轮
authorliangzhenying <867174124@qq.com>
Thu, 7 Nov 2024 08:28:09 +0000 (16:28 +0800)
committerliangzhenying <867174124@qq.com>
Thu, 7 Nov 2024 08:28:09 +0000 (16:28 +0800)
15 files changed:
Document/Mouse_Dongle通信协议_v1.3.docx
MouseSdk/AiMouseSdk/AiMouseSdk.xcodeproj/project.pbxproj
MouseSdk/AiMouseSdk/Manager/DeviceManger.m
MouseSdk/AiMouseSdk/NMouseSdk/NMouseSdk.m
MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.h
MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m
MouseSdk/MouseSdk.xcodeproj/project.pbxproj
MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
MouseSdk/MouseSdk/AiHidManager.h [deleted file]
MouseSdk/MouseSdk/AiHidManager.m [deleted file]
MouseSdk/MouseSdk/FrkVC.h [deleted file]
MouseSdk/MouseSdk/FrkVC.m [deleted file]
MouseSdk/MouseSdk/TlwVC.h [deleted file]
MouseSdk/MouseSdk/TlwVC.m [deleted file]
MouseSdk/MouseSdk/ViewController.m

index f0b8c74..5e43930 100644 (file)
Binary files "a/Document/Mouse_Dongle\351\200\232\344\277\241\345\215\217\350\256\256_v1.3.docx" and "b/Document/Mouse_Dongle\351\200\232\344\277\241\345\215\217\350\256\256_v1.3.docx" differ
index 484388d..dc8b476 100644 (file)
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+               18068CFA2CDC8E2F006B6EF5 /* libAiMouseSdk copy.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libAiMouseSdk copy.a"; path = "/Users/apple/Desktop/code/MouseSdk-MacOS/MouseSdk/AiMouseSdk/build/Debug/libAiMouseSdk copy.a"; sourceTree = "<absolute>"; };
                180E7AA62BD7BB12008558E8 /* libAiMouseManager.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAiMouseManager.a; sourceTree = BUILT_PRODUCTS_DIR; };
                180E7AA92BD7BB12008558E8 /* AiMouseSdk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AiMouseSdk.h; sourceTree = "<group>"; };
                180E7AAB2BD7BB12008558E8 /* AiMouseSdk.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AiMouseSdk.m; sourceTree = "<group>"; };
                180E7D102BD8FF11008558E8 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
                180E7D122BD8FF3A008558E8 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; };
                180E7D142BD8FF5C008558E8 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; };
-               181272BA2C81BF460046CCF2 /* libAiMouseSdk copy.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libAiMouseSdk copy.a"; path = "/Users/apple/Desktop/code/MouseSdk-MacOS/MouseSdk/AiMouseSdk/build/Debug/libAiMouseSdk copy.a"; sourceTree = "<absolute>"; };
                181CE5BF2C6EED9900EF8D07 /* AiAliAuthManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AiAliAuthManager.h; sourceTree = "<group>"; };
                181CE5C02C6EED9900EF8D07 /* AiAliAuthManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AiAliAuthManager.m; sourceTree = "<group>"; };
                184A70F42BDA4C040025A332 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSecurityPolicy.h; sourceTree = "<group>"; };
                        );
                        name = "AiMouseSdk copy";
                        productName = AiMouseSdk;
-                       productReference = 181272BA2C81BF460046CCF2 /* libAiMouseSdk copy.a */;
+                       productReference = 18068CFA2CDC8E2F006B6EF5 /* libAiMouseSdk copy.a */;
                        productType = "com.apple.product-type.library.static";
                };
 /* End PBXNativeTarget section */
index 55bfb64..35077ac 100644 (file)
         return;
     }
     if (self.productType == AiMouseProductType_tlw) {
-//        finished(false,[NSError errorWithDomain:@"AiMouse SDK Error" code:AiMouseErrorCode_unknown userInfo:@{@"NSLocalizedDescriptionKey":@"当前鼠标不支持该接口"}]);
         [self.tlwSdk setUrlState:state completation:finished];
     }
     else{
         return;
     }
     if (self.productType == AiMouseProductType_tlw) {
-        finished(false,[NSError errorWithDomain:@"AiMouse SDK Error" code:AiMouseErrorCode_unknown userInfo:@{@"NSLocalizedDescriptionKey":@"当前鼠标不支持该接口"}]);
+        [self.tlwSdk getUrlState:finished];
     }
     else{
         [self.frkSdk getUrlState:finished];
index dcbdf1d..00eb299 100644 (file)
 }
 
 //北科专属
-//- (void)sendDeviceDataToSdk:(NSData *)data{
-//    
-//    NSString *text = [TlwTools dataToHexString:data];
-//   
-////  鼠标  0x020001f0ff0000
-////  sn1  0xb52c00bba30d5540
-////  sn2  0xb52c01bba30d5540
-////    62DF3D553297
-//   
-//    if ([text hasPrefix:@"B52C00"]) {
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        if (self.getSn1CallBack) {
-//            //北科加42专属
-//            self.getSn1CallBack([NSString stringWithFormat:@"42%@",[text substringWithRange:NSMakeRange(6, 8)]], nil);
-//        }
-//    }
-//    else if ([text hasPrefix:@"B52C01"]) {
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        if (self.getSn2CallBack) {
-//            //北科加42专属
-//            self.getSn2CallBack([text substringWithRange:NSMakeRange(6, 2)], nil);
-//        }
-//    }
-//    else if([text hasPrefix:@"B5200443"]){
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        uint8_t cmd = 0x42;
-//        NSMutableData *mData = [NSMutableData data];
-//        [mData appendBytes:&cmd length:1];
-//        [self.delegate nMouseSendCmdData:mData];
-//    }
-//    else if([text hasPrefix:@"B5200057"]){
-//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
-//        uint8_t cmd = 0x42;
-//        NSMutableData *mData = [NSMutableData data];
-//        [mData appendBytes:&cmd length:1];
-//        [self.delegate nMouseSendCmdData:mData];
-//    }
-//}
-
-//千寻
 - (void)sendDeviceDataToSdk:(NSData *)data{
+    
     NSString *text = [TlwTools dataToHexString:data];
    
 //  鼠标  0x020001f0ff0000
 //  sn1  0xb52c00bba30d5540
 //  sn2  0xb52c01bba30d5540
 //    62DF3D553297
-    [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
+   
     if ([text hasPrefix:@"B52C00"]) {
+        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
         [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
         if (self.getSn1CallBack) {
-            self.getSn1CallBack([text substringWithRange:NSMakeRange(6, 8)], nil);
+            //北科加42专属
+            self.getSn1CallBack([NSString stringWithFormat:@"42%@",[text substringWithRange:NSMakeRange(6, 8)]], nil);
         }
     }
     else if ([text hasPrefix:@"B52C01"]) {
+        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
         [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
         if (self.getSn2CallBack) {
-            self.getSn2CallBack([text substringWithRange:NSMakeRange(6, 4)], nil);
+            //北科加42专属
+            self.getSn2CallBack([text substringWithRange:NSMakeRange(6, 2)], nil);
         }
     }
     else if([text hasPrefix:@"B5200443"]){
+        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
         uint8_t cmd = 0x42;
         NSMutableData *mData = [NSMutableData data];
         [mData appendBytes:&cmd length:1];
         [self.delegate nMouseSendCmdData:mData];
     }
 }
+
+////千寻
+//- (void)sendDeviceDataToSdk:(NSData *)data{
+//    NSString *text = [TlwTools dataToHexString:data];
+//   
+////  鼠标  0x020001f0ff0000
+////  sn1  0xb52c00bba30d5540
+////  sn2  0xb52c01bba30d5540
+////    62DF3D553297
+//    [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
+//    if ([text hasPrefix:@"B52C00"]) {
+//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
+//        if (self.getSn1CallBack) {
+//            self.getSn1CallBack([text substringWithRange:NSMakeRange(6, 8)], nil);
+//        }
+//    }
+//    else if ([text hasPrefix:@"B52C01"]) {
+//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
+//        if (self.getSn2CallBack) {
+//            self.getSn2CallBack([text substringWithRange:NSMakeRange(6, 4)], nil);
+//        }
+//    }
+//    else if([text hasPrefix:@"B5200443"]){
+//        uint8_t cmd = 0x42;
+//        NSMutableData *mData = [NSMutableData data];
+//        [mData appendBytes:&cmd length:1];
+//        [self.delegate nMouseSendCmdData:mData];
+//    }
+//    else if([text hasPrefix:@"B5200057"]){
+//        [self showLog:[NSString stringWithFormat:@"[receive][usb][info] %@",text]];
+//        uint8_t cmd = 0x42;
+//        NSMutableData *mData = [NSMutableData data];
+//        [mData appendBytes:&cmd length:1];
+//        [self.delegate nMouseSendCmdData:mData];
+//    }
+//}
 - (void)getDeviceInfo:(void (^)(AiMouseDeviceInfo *deviceInfo,NSError *error))finished{
     [NSObject cancelPreviousPerformRequestsWithTarget:self];
     self.getDeviceInfoCallBack = finished;
index 0dee771..5e18c7d 100644 (file)
@@ -117,4 +117,8 @@ typedef NS_ENUM(NSInteger,TlwMouseLogLevel) {
 ///   - state: 0关闭,1打开
 ///   - finished: 设置结果回调
 - (void)setUrlState:(int)state completation:(void (^)(BOOL isSuccess,NSError *error))finished;
+
+/// 获取长按滚轮弹出的网页地址开关状态
+/// - Parameter complete: state 0关闭,1打开。 error为nil才代表获取成功
+- (void)getUrlState:(void (^)(int state,NSError *error))complete;
 @end
index da1bf64..3b40bec 100644 (file)
 @property (nonatomic,strong)void (^getMouseInfoCallBack)(TlwDeviceInfo *deviceInfo,NSError *error);
 @property (nonatomic,strong)void (^getSnInfoCallBack)(TlwSnInfo *snInfo,NSError *error);
 
+
+@property (nonatomic,strong)void (^setUrlStateCallBack)(BOOL isSuccess,NSError *error);//设置滚轮开关
+@property (nonatomic,strong)void (^getUrlStateCallBack)(int state,NSError *error);//获取滚轮开关
+
 @property (nonatomic,strong)void (^getFullInfoCallBack)(AiMouseDeviceInfo *info,NSError *error);
 @property (nonatomic,strong)AiMouseDeviceInfo *fullInfo;
 @property (nonatomic,assign)NSInteger questTimes;
 ///   - finished: 设置结果回调
 - (void)setUrlState:(int)state completation:(void (^)(BOOL isSuccess,NSError *error))finished{
     
+    if(self.connectType == AiMouseConnectType_hid){
+        self.setUrlStateCallBack  = finished;
+        uint8_t type = 0x14;
+        uint8_t len = 0x01;
+        uint8_t value = state;
+        uint8_t tail = 0xEF;
+        NSMutableData *mData = NSMutableData.data;
+        [mData appendData:[self getHidHeader]];
+        [mData appendBytes:&type length:1];
+        [mData appendBytes:&len length:1];
+        [mData appendBytes:&value length:1];
+        [mData appendBytes:&tail length:1];
+        [self sendToDevice:mData];
+    }
+    else if (self.connectType == AiMouseConnectType_bluetooth){
+        self.setUrlStateCallBack  = finished;
+        uint8_t cmd = 0x14;
+        uint8_t dir = 0x01;
+        uint8_t len = 0x01;
+        uint8_t value = state;
+        NSMutableData *mData = NSMutableData.data;
+        [mData appendBytes:&cmd length:1];
+        [mData appendBytes:&dir length:1];
+        [mData appendBytes:&len length:1];
+        [mData appendBytes:&value length:1];
+        [self sendToDevice:mData];
+    }
+}
+
+- (void)getUrlState:(void (^)(int state,NSError *error))finished{
+    if(self.connectType == AiMouseConnectType_hid){
+        self.getUrlStateCallBack  = finished;
+        uint8_t type = 0x15;
+        uint8_t len = 0x01;
+        uint8_t tail = 0xEF;
+        NSMutableData *mData = NSMutableData.data;
+        [mData appendData:[self getHidHeader]];
+        [mData appendBytes:&type length:1];
+        [mData appendBytes:&len length:1];
+        [mData appendBytes:&tail length:1];
+        [self sendToDevice:mData];
+    }
+    else if (self.connectType == AiMouseConnectType_bluetooth){
+        self.getUrlStateCallBack  = finished;
+        uint8_t cmd = 0x15;
+        uint8_t dir = 0x01;
+        uint8_t len = 0x01;
+        NSMutableData *mData = NSMutableData.data;
+        [mData appendBytes:&cmd length:1];
+        [mData appendBytes:&dir length:1];
+        [mData appendBytes:&len length:1];
+        [self sendToDevice:mData];
+    }
 }
 #pragma mark - check dongle
 - (void)checkDongleState{
         {
             //语音开启回复
             uint8 state;
-            [[data subdataWithRange:NSMakeRange(2, 1)] getBytes:&state length:1];
-            BOOL success = state == 0;
+            [[data subdataWithRange:NSMakeRange(1, 1)] getBytes:&state length:1];
+            BOOL success = state == 2;
             
             [self showLog:[NSString stringWithFormat:@"语音开启回复 %@",@(success)]];
             if(self.openRecordCallBack)self.openRecordCallBack(success, nil);
         {
             //语音停止回复
             uint8 state;
-            [[data subdataWithRange:NSMakeRange(2, 1)] getBytes:&state length:1];
-            BOOL success = state == 0;
+            [[data subdataWithRange:NSMakeRange(1, 1)] getBytes:&state length:1];
+            BOOL success = state == 2;
             [self showLog:[NSString stringWithFormat:@"语音停止回复 %@",@(success)]];
             if(self.closeRecordCallBaack)self.closeRecordCallBaack(success, nil);
             break;
         {
             //设置DPI回复
             uint8 state;
-            [[data subdataWithRange:NSMakeRange(2, 1)] getBytes:&state length:1];
-            BOOL success = state == 0;
+            [[data subdataWithRange:NSMakeRange(1, 1)] getBytes:&state length:1];
+            BOOL success = state == 2;
             [self showLog:[NSString stringWithFormat:@"设置DPI回复 %@",@(success)]];
             if(self.setDpiCallBack)self.setDpiCallBack(success, nil);
             break;
         }
+        case 0x24:
+        {
+            //设置滚轮开关
+            uint8 state;
+            [[data subdataWithRange:NSMakeRange(1, 1)] getBytes:&state length:1];
+            BOOL success = state == 2;
+            [self showLog:[NSString stringWithFormat:@"设置滚轮开关回复 %@",@(success)]];
+            if(self.setUrlStateCallBack)self.setUrlStateCallBack(success, nil);
+            break;
+        }
+        case 0x25:
+        {
+            //查询
+            uint8 state;
+            [[data subdataWithRange:NSMakeRange(3, 1)] getBytes:&state length:1];
+            [self showLog:[NSString stringWithFormat:@"查询滚轮设置回复 %@",@(state)]];
+            if(self.getUrlStateCallBack)self.getUrlStateCallBack(state, nil);
+            break;
+        }
         case 0x9c:
         { //鼠标状态查询回复
             uint16_t version;
             if(self.setDpiCallBack)self.setDpiCallBack(true, nil);
             break;
         }
+        case 0x24:
+        {
+            //设置滚轮开关
+            uint8 state;
+            [[data subdataWithRange:NSMakeRange(6, 1)] getBytes:&state length:1];
+            BOOL success = state == 0;
+            
+            [self showLog:[NSString stringWithFormat:@"设置滚轮开关回复 %@",@(success)]];
+            if(self.setUrlStateCallBack)self.setUrlStateCallBack(true, nil);
+            break;
+        }
+        case 0x25:
+        {
+            //查询
+            uint8 state;
+            [[data subdataWithRange:NSMakeRange(6, 1)] getBytes:&state length:1];
+            [self showLog:[NSString stringWithFormat:@"查询滚轮设置回复 %@",@(state)]];
+            if(self.getUrlStateCallBack)self.getUrlStateCallBack(state, nil);
+            break;
+        }
         case 0x9c:
         { //鼠标状态查询回复
             uint16_t version;
index b61f450..1f89104 100644 (file)
@@ -13,7 +13,6 @@
                180E7D192BD90029008558E8 /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18F324A52B93385100CABA2E /* VideoToolbox.framework */; };
                180E7D1A2BD90032008558E8 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18F325772B95737F00CABA2E /* CoreAudio.framework */; };
                180E7D1B2BD9005D008558E8 /* liblzma.5.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18CB080B2BA401D0005F5854 /* liblzma.5.tbd */; };
-               181F976D2C7C6E11002FCF68 /* AiHidManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 181F976B2C7C6E10002FCF68 /* AiHidManager.m */; };
                18862BE32C806D2500D3564D /* libAiMouseManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 18862BE22C806D2500D3564D /* libAiMouseManager.a */; };
                18BF1DCF2B81AB7C00B8D90F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DCE2B81AB7C00B8D90F /* AppDelegate.m */; };
                18BF1DD22B81AB7C00B8D90F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DD12B81AB7C00B8D90F /* ViewController.m */; };
@@ -24,8 +23,6 @@
                18BF1DEE2B81AB8000B8D90F /* MouseSdkUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DED2B81AB8000B8D90F /* MouseSdkUITests.m */; };
                18BF1DF02B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DEF2B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m */; };
                18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E752B832D2E00B8D90F /* ScanVC.m */; };
-               18EF7B0D2C76079E00AC5223 /* TlwVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EF7B0C2C76079E00AC5223 /* TlwVC.m */; };
-               18EF7B102C7607C100AC5223 /* FrkVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EF7B0F2C7607C100AC5223 /* FrkVC.m */; };
                18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */; };
                18EF7B1E2C760FF700AC5223 /* TlwScanVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */; };
                18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F3235C2B8ED78300CABA2E /* ScanCell.m */; };
@@ -66,8 +63,6 @@
 /* Begin PBXFileReference section */
                0311DF3AD67ED792549B96BD /* libPods-MouseSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MouseSdk.a"; sourceTree = BUILT_PRODUCTS_DIR; };
                180E7AB22BD7BBD9008558E8 /* libAiMouseSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libAiMouseSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
-               181F976B2C7C6E10002FCF68 /* AiHidManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AiHidManager.m; sourceTree = "<group>"; };
-               181F976C2C7C6E10002FCF68 /* AiHidManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AiHidManager.h; sourceTree = "<group>"; };
                18862BE22C806D2500D3564D /* libAiMouseManager.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libAiMouseManager.a; sourceTree = BUILT_PRODUCTS_DIR; };
                18BF1DCA2B81AB7C00B8D90F /* AiMouseSdk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AiMouseSdk.app; sourceTree = BUILT_PRODUCTS_DIR; };
                18BF1DCD2B81AB7C00B8D90F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
                18BF1E752B832D2E00B8D90F /* ScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanVC.m; sourceTree = "<group>"; };
                18C31D6F2BBAA6CC0089D656 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
                18CB080B2BA401D0005F5854 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; };
-               18EF7B0B2C76079E00AC5223 /* TlwVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TlwVC.h; sourceTree = "<group>"; };
-               18EF7B0C2C76079E00AC5223 /* TlwVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TlwVC.m; sourceTree = "<group>"; };
-               18EF7B0E2C7607C100AC5223 /* FrkVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FrkVC.h; sourceTree = "<group>"; };
-               18EF7B0F2C7607C100AC5223 /* FrkVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FrkVC.m; sourceTree = "<group>"; };
                18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TlwScanVC.h; sourceTree = "<group>"; };
                18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TlwScanVC.m; sourceTree = "<group>"; };
                18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TlwScanVC.xib; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                18C31D6F2BBAA6CC0089D656 /* Info.plist */,
-                               181F976C2C7C6E10002FCF68 /* AiHidManager.h */,
-                               181F976B2C7C6E10002FCF68 /* AiHidManager.m */,
                                18BF1DCD2B81AB7C00B8D90F /* AppDelegate.h */,
                                18BF1DCE2B81AB7C00B8D90F /* AppDelegate.m */,
                                18BF1DD02B81AB7C00B8D90F /* ViewController.h */,
                                18BF1DD12B81AB7C00B8D90F /* ViewController.m */,
-                               18EF7B0E2C7607C100AC5223 /* FrkVC.h */,
-                               18EF7B0F2C7607C100AC5223 /* FrkVC.m */,
-                               18EF7B0B2C76079E00AC5223 /* TlwVC.h */,
-                               18EF7B0C2C76079E00AC5223 /* TlwVC.m */,
                                18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */,
                                18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */,
                                18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */,
                        files = (
                                18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */,
                                18BF1DD22B81AB7C00B8D90F /* ViewController.m in Sources */,
-                               181F976D2C7C6E11002FCF68 /* AiHidManager.m in Sources */,
                                18BF1DD92B81AB7F00B8D90F /* main.m in Sources */,
                                18F328D52B98569D00CABA2E /* Config.m in Sources */,
-                               18EF7B0D2C76079E00AC5223 /* TlwVC.m in Sources */,
-                               18EF7B102C7607C100AC5223 /* FrkVC.m in Sources */,
                                18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */,
                                18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */,
                                18BF1DCF2B81AB7C00B8D90F /* AppDelegate.m in Sources */,
index 1260723..990fa48 100644 (file)
Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/MouseSdk/MouseSdk/AiHidManager.h b/MouseSdk/MouseSdk/AiHidManager.h
deleted file mode 100644 (file)
index 1d0711d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-////
-////  HidManager.h
-////  MouseSdk
-////
-////  Created by incar on 2024/3/26.
-////
-//
-//#import <Foundation/Foundation.h>
-//
-//NS_ASSUME_NONNULL_BEGIN
-//
-//@interface AiHidManager : NSObject
-//@property (nonatomic,strong)void (^connectStateCallBack)(BOOL isConnnect);/// 设备是否连上
-//
-//+(AiHidManager *)shared;
-//
-//@end
-//
-//NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/AiHidManager.m b/MouseSdk/MouseSdk/AiHidManager.m
deleted file mode 100644 (file)
index 15d73c8..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-////
-////  HidManager.m
-////  MouseSdk
-////
-////  Created by incar on 2024/3/26.
-////
-//
-//#import "AiHidManager.h"
-//#include <IOKit/hid/IOHIDLib.h>
-//#include <IOKit/hid/IOHIDKeys.h>
-//
-//
-//
-////供应商id
-////const long vendorID = 0x6675;
-////const long productID = 0x8601;
-//
-//@interface AiHidManager ()
-//
-//@property(nonatomic, assign) IOHIDManagerRef hidManager;///hid管理
-//@property(nonatomic, assign) IOHIDDeviceRef deviceInfoCha;//设备信息通道
-//@property (nonatomic,strong) NSMutableData *recordData;//录音的数据
-//@end
-//
-//@implementation AiHidManager
-//+(AiHidManager *)shared{
-//    static AiHidManager *manager = nil;
-//    static dispatch_once_t oncePredicate;
-//    dispatch_once(&oncePredicate, ^{
-//        manager = [[AiHidManager alloc]init];
-//    });
-//    return manager;
-//}
-//
-//- (instancetype)init{
-//    self = [super init];
-//    if (self) {
-//        [self initHid];
-//        [self open];
-//    }
-//    return self;
-//}
-//
-//- (void)initHid{
-//
-//}
-//
-//- (void)open{
-//    self.hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
-//    IOHIDManagerScheduleWithRunLoop(self.hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
-//    IOReturn ret = IOHIDManagerOpen(self.hidManager, 0L);
-//    if (ret != kIOReturnSuccess) {
-//        NSLog(@"打开设备失败!");
-//    }else{
-//        NSLog(@"打开设备成功!");
-//    }
-//    //供应商id
-//    const long vendorID = 0x10D6;
-//    //产品id
-//    const long productID = 0xB008;
-//    //设置匹配设备
-//    NSMutableDictionary* dict= [NSMutableDictionary dictionary];
-//    [dict setValue:[NSNumber numberWithLong:productID] forKey:[NSString stringWithCString:kIOHIDProductIDKey encoding:NSUTF8StringEncoding]];
-//    [dict setValue:[NSNumber numberWithLong:vendorID] forKey:[NSString stringWithCString:kIOHIDVendorIDKey encoding:NSUTF8StringEncoding]];
-//    IOHIDManagerSetDeviceMatching(self.hidManager, (__bridge CFMutableDictionaryRef)dict);
-//    //设置匹配到设备回调
-//    IOHIDManagerRegisterDeviceMatchingCallback(self.hidManager, &hidAppearDevice, NULL);
-//    //设置移除设备回调
-//    IOHIDManagerRegisterDeviceRemovalCallback(self.hidManager, &hidDisAppearDevice, NULL);
-//}
-//
-//- (void)close{
-//    IOReturn ret = IOHIDManagerClose(self.hidManager, 0);
-//    if (ret != kIOReturnSuccess) {
-//        NSLog(@"关闭设备失败!");
-//    }else{
-//        NSLog(@"关闭设备成功!");
-//    }
-//}
-//
-//#pragma mark - Hid CallBack
-///// 匹配到设备回调
-//static void hidAppearDevice(void *inContext,IOReturn inResult,void *inSender,IOHIDDeviceRef inIOHIDDeviceRef) {
-//    [[AiHidManager shared] showLog:[NSString stringWithFormat:@"发现设备 %@\n ",inIOHIDDeviceRef]];
-////    if(PrimaryUsagePage == 1 && PrimaryUsage == 0){
-//        //设备信息
-//        [AiHidManager shared].deviceInfoCha = inIOHIDDeviceRef;
-//        //注册消息回调
-//        unsigned char InputBuffer[128];
-//        IOHIDDeviceRegisterInputReportCallback(inIOHIDDeviceRef, InputBuffer, sizeof(InputBuffer), hidReceiveData, NULL);
-//        IOReturn ret = IOHIDDeviceOpen(inIOHIDDeviceRef, kIOHIDOptionsTypeNone);
-//        if (ret != kIOReturnSuccess) {
-//            NSLog(@"打开设备信息失败!");
-//        }else{
-//            NSLog(@"打开设备信息成功!");
-//        }
-//        CFRetain(inIOHIDDeviceRef);
-//        IOHIDDeviceScheduleWithRunLoop(inIOHIDDeviceRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
-////    }
-////    else if(PrimaryUsagePage == 65283 && PrimaryUsage == 0){
-////        //ai
-////        [AiHidManager shared].aiCha = inIOHIDDeviceRef;
-////        //注册消息回调
-////        unsigned char InputBuffer[128];
-////        IOHIDDeviceRegisterInputReportCallback(inIOHIDDeviceRef, InputBuffer, sizeof(InputBuffer), hidReceiveData, NULL);
-////        IOReturn ret = IOHIDDeviceOpen(inIOHIDDeviceRef, 0);
-////        if (ret != kIOReturnSuccess) {
-////            NSLog(@"打开AI失败!");
-////        }else{
-////            NSLog(@"打开AI成功!");
-////        }
-////        CFRetain(inIOHIDDeviceRef);
-////        IOHIDDeviceScheduleWithRunLoop(inIOHIDDeviceRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
-////    }
-//}
-//
-///// 设备移除回调
-//static void hidDisAppearDevice(void *inContext,IOReturn inResult,void *inSender,IOHIDDeviceRef inIOHIDDeviceRef) {
-//    [[AiHidManager shared] showLog:[NSString stringWithFormat:@"拔出设备 %@ ",inIOHIDDeviceRef]];
-////    uint32_t PrimaryUsagePage = IOHIDDevGetUInt32Property(inIOHIDDeviceRef, CFSTR(kIOHIDPrimaryUsagePageKey));
-////    uint32_t PrimaryUsage = IOHIDDevGetUInt32Property(inIOHIDDeviceRef, CFSTR(kIOHIDPrimaryUsageKey));
-////
-////    if(PrimaryUsagePage == 1 && PrimaryUsage == 0){
-////        [AiHidManager shared].deviceInfoCha = nil;
-//////        [AiHidManager shared].aiCha = nil;
-////        [[AiMouse shared] didDisconnect];
-////    }
-//}
-//
-//static void hidReceiveData(void* context, IOReturn result, void* sender, IOHIDReportType type, uint32_t reportID, uint8_t *report,CFIndex reportLength){
-////    [[AiHidManager shared] showLog:[NSString stringWithFormat:@"[receive] 处理前 %@",[AiMouseTools dataToHexString:[[NSData alloc] initWithBytes:report length:reportLength]]]];
-//    
-////    NSInteger len = get_data_len(report, 64);
-//    NSData *data = [[NSData alloc] initWithBytes:report length:64];
-//    [[AiHidManager shared] showLog:[NSString stringWithFormat:@"[receive] 处理后 %@",data]];
-//    
-////    uint32_t PrimaryUsagePage = IOHIDDevGetUInt32Property(sender, CFSTR(kIOHIDPrimaryUsagePageKey));
-////    uint32_t PrimaryUsage = IOHIDDevGetUInt32Property(sender, CFSTR(kIOHIDPrimaryUsageKey));
-////
-////    if(PrimaryUsagePage == 1 && PrimaryUsage == 0){
-////        [[AiMouse shared] sendDeviceDataToSdk:data];
-////        
-////    }
-////    else if(PrimaryUsagePage == 65283 && PrimaryUsage == 0){
-////        [[AiMouse shared] sendAiDataToSdk:data];
-////    }
-//}
-//
-//
-//- (void)showLog:(NSString *)log{
-//    NSLog(@"%@",log);
-//}
-//
-//@end
diff --git a/MouseSdk/MouseSdk/FrkVC.h b/MouseSdk/MouseSdk/FrkVC.h
deleted file mode 100644 (file)
index 26d0149..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-//  FrkVC.h
-//  MouseSdk
-//
-//  Created by incar on 2024/8/21.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface FrkVC : NSViewController
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/FrkVC.m b/MouseSdk/MouseSdk/FrkVC.m
deleted file mode 100644 (file)
index 2fa7e02..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-//
-//  FrkVC.m
-//  MouseSdk
-//
-//  Created by incar on 2024/8/21.
-//
-
-#import "FrkVC.h"
-#import "ScanVC.h"
-#import "DeviceManger.h"
-
-@interface FrkVC ()
-@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
-@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
-@property(nonatomic,strong)NSTextField *authLabel;///鉴权状态
-@property(nonatomic,strong)NSTextField *deviceInfoLabel;///设备信息
-@end
-
-@implementation FrkVC
-
--(instancetype)init{
-    if (self = [super init]) {
-//        [[DeviceManger shared] start];
-    }
-    return self;
-}
-
--(void)dealloc{
-//    [[DeviceManger shared] stop];
-}
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    
-    // Do any additional setup after loading the view.
-//    [[DeviceManger shared] start];
-    [self setupUI];
-    [self setupDeviceManger];
-}
-
-- (void)loadView{
-    self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
-    CALayer *viewLayer = [CALayer layer];
-    NSView *backgroundView= [[NSView alloc]init];
-    [backgroundView setWantsLayer:YES];
-    [backgroundView setLayer:viewLayer];
-    backgroundView.layer.backgroundColor = [NSColor greenColor].CGColor;
-    [backgroundView setNeedsDisplay:YES];
-    [self.view addSubview:backgroundView];
-    
-    self.title = @"AI SDK";
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 80, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"蓝牙扫描";
-        [btn setTarget:self];
-        [btn setAction:@selector(scanAction)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 180, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"获取设备信息";
-        [btn setTarget:self];
-        [btn setAction:@selector(geviceInfoAction)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 280, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"更多指令";
-        [btn setTarget:self];
-        [btn setAction:@selector(moreAction:)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 80, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"连接模式:--";
-        label.backgroundColor = NSColor.clearColor;
-        self.typeLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 120, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"连接状态:未连接";
-        label.backgroundColor = NSColor.clearColor;
-        self.connectLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 160, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"鉴权状态:unknow";
-        label.backgroundColor = NSColor.clearColor;
-        self.authLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 260, 300, 100)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"";
-        label.backgroundColor = NSColor.clearColor;
-        self.deviceInfoLabel = label;
-        [self.view addSubview:label];
-    }
-}
-
-#pragma mark - action
-- (void)scanAction{
-    ScanVC *vc = [[ScanVC alloc] initWithNibName:nil bundle:nil];
-    [self presentViewControllerAsModalWindow:vc];
-}
-
-- (void)geviceInfoAction{
-    [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
-        if (deviceInfo) {
-            NSString *info = deviceInfo.description;
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-        else{
-            NSString *info = [NSString stringWithFormat:@"error == %@",error.description];
-            NSLog(@"%@",info);
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-    }];
-}
-
-- (void)setupDeviceManger{
-    DeviceManger *manager = [DeviceManger shared];
-    __weak typeof(self) ws = self;
-    manager.authCallBack = ^(BOOL isSuccess) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            ws.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败";
-            if(isSuccess){
-                [ws geviceInfoAction];
-            }
-        });
-    };
-    [manager begainMonitorAiMouseConnectStateDidChange:@"NMMouse" callBack:^(int connectType, BOOL connected) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            if(connected){
-                ws.typeLabel.stringValue = connectType == 0 ?@"连接模式:蓝牙":@"连接模式:hid";
-                ws.connectLabel.stringValue = connected?@"连接状态:已连接":@"连接状态:未连接";
-                [ws geviceInfoAction];
-            }
-            else{
-                ws.typeLabel.stringValue = @"连接模式:--";
-                ws.connectLabel.stringValue = @"连接状态:未连接";
-            }
-        });
-    }];
-
-}
-
-- (void)moreAction:(NSButton *)sender {
-    NSMenu *popupMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
-    NSMenuItem *item1 = [[NSMenuItem alloc] initWithTitle:@"语音开启" action:@selector(voiceStart:) keyEquivalent:@"1"];
-    NSMenuItem *item2 = [[NSMenuItem alloc] initWithTitle:@"语音停止" action:@selector(voiceStop:) keyEquivalent:@"2"];
-    NSMenuItem *item3 = [[NSMenuItem alloc] initWithTitle:@"设置DPI" action:@selector(setDPI:) keyEquivalent:@"3"];
-    NSMenuItem *item4 = [[NSMenuItem alloc] initWithTitle:@"鼠标状态查询" action:@selector(searchState:) keyEquivalent:@"3"];
-
-    [popupMenu addItem:item1];
-    [popupMenu addItem:item2];
-    [popupMenu addItem:item3];
-    [popupMenu addItem:item4];
-
-    NSPoint buttonLocation = [sender convertPoint:NSZeroPoint toView:self.view];
-    [popupMenu popUpMenuPositioningItem:nil atLocation:buttonLocation inView:self.view];
-}
-
-- (void)voiceStart:(NSMenuItem*)sender {
-    [[DeviceManger shared] openRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)voiceStop:(NSMenuItem*)sender {
-    [[DeviceManger shared] closeRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)setDPI:(NSMenuItem*)sender {
-    [[DeviceManger shared] setCPI:2 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)searchState:(NSMenuItem*)sender {
-    [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
-        if (deviceInfo) {
-            NSString *info = deviceInfo.description;
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-        else{
-            NSString *info = [NSString stringWithFormat:@"error == %@",error.description];
-            NSLog(@"%@",info);
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-    }];
-}
-@end
diff --git a/MouseSdk/MouseSdk/TlwVC.h b/MouseSdk/MouseSdk/TlwVC.h
deleted file mode 100644 (file)
index e5f0f4d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-//  TlwVC.h
-//  MouseSdk
-//
-//  Created by incar on 2024/8/21.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface TlwVC : NSViewController
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/TlwVC.m b/MouseSdk/MouseSdk/TlwVC.m
deleted file mode 100644 (file)
index a66b79c..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-////
-////  TlwVC.m
-////  MouseSdk
-////
-////  Created by incar on 2024/8/21.
-////
-//
-//#import "TlwVC.h"
-//#import "TlwScanVC.h"
-//#import "TlwDeviceManger.h"
-//
-//@interface TlwVC ()
-//@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
-//@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
-//@property(nonatomic,strong)NSTextField *authLabel;///鉴权状态
-//@property(nonatomic,strong)NSTextField *deviceInfoLabel;///设备信息
-//@end
-//
-//@implementation TlwVC
-//
-////-(instancetype)init{
-////    if (self = [super init]) {
-////        
-////    }
-////    return self;
-////}
-//
-//-(void)dealloc{
-////    [[TlwDeviceManger shared] stop];
-//}
-//
-//- (void)viewDidLoad {
-//    [super viewDidLoad];
-//    
-//    // Do any additional setup after loading the view.
-//    
-//    [self setupUI];
-//    [self setupTlwDeviceManger];
-//}
-//
-//- (void)loadView{
-//    self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-//}
-//
-//- (void)setupUI{
-//    CALayer *viewLayer = [CALayer layer];
-//    NSView *backgroundView= [[NSView alloc]init];
-//    [backgroundView setWantsLayer:YES];
-//    [backgroundView setLayer:viewLayer];
-//    backgroundView.layer.backgroundColor = [NSColor greenColor].CGColor;
-//    [backgroundView setNeedsDisplay:YES];
-//    [self.view addSubview:backgroundView];
-//    self.title = @"AI SDK";
-//    {
-//        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 80, 100, 45)];
-//        btn.bordered = true;
-//        btn.title = @"蓝牙扫描";
-//        [btn setTarget:self];
-//        [btn setAction:@selector(scanAction)];
-//        btn.state = 1;
-//        [self.view addSubview:btn];
-//    }
-//    {
-//        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 180, 100, 45)];
-//        btn.bordered = true;
-//        btn.title = @"选择指令";
-//        [btn setTarget:self];
-//        [btn setAction:@selector(showPopupMenu:)];
-//        
-//        btn.state = 1;
-//        [self.view addSubview:btn];
-//    }
-//    {
-//        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 80, 300, 35)];
-//        label.editable = NO;
-//        label.bordered = NO;
-//        label.stringValue = @"连接模式:--";
-//        label.backgroundColor = NSColor.clearColor;
-//        self.typeLabel = label;
-//        [self.view addSubview:label];
-//    }
-//    {
-//        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 120, 300, 35)];
-//        label.editable = NO;
-//        label.bordered = NO;
-//        label.stringValue = @"连接状态:未连接";
-//        label.backgroundColor = NSColor.clearColor;
-//        self.connectLabel = label;
-//        [self.view addSubview:label];
-//    }
-//    {
-//        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 160, 300, 35)];
-//        label.editable = NO;
-//        label.bordered = NO;
-//        label.stringValue = @"鉴权状态:unknow";
-//        label.backgroundColor = NSColor.clearColor;
-//        self.authLabel = label;
-//        [self.view addSubview:label];
-//    }
-//    {
-//        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 260, 300, 100)];
-//        label.editable = NO;
-//        label.bordered = NO;
-//        label.stringValue = @"";
-//        label.backgroundColor = NSColor.clearColor;
-//        self.deviceInfoLabel = label;
-//        [self.view addSubview:label];
-//    }
-//}
-//
-//#pragma mark - action
-//- (void)scanAction{
-//    TlwScanVC *vc = [[TlwScanVC alloc] initWithNibName:nil bundle:nil];
-//    [self presentViewControllerAsModalWindow:vc];
-//}
-//
-//- (void)connectStateDidChange:(AiMouseConnectType)type connectState:(BOOL)isConnected{
-//    dispatch_async(dispatch_get_main_queue(), ^{
-//        if(isConnected){
-//            self.typeLabel.stringValue = type == AiMouseConnectType_bluetooth ?@"连接模式:蓝牙":@"连接模式:hid";
-//            self.connectLabel.stringValue = isConnected?@"连接状态:已连接":@"连接状态:未连接";
-//        }
-//        else{
-//            self.typeLabel.stringValue = @"连接模式:--";
-//            self.connectLabel.stringValue = @"连接状态:未连接";
-//        }
-//    });
-//}
-//
-//- (void)setupTlwDeviceManger{
-//    TlwDeviceManger *manager = [TlwDeviceManger shared];
-////    [manager start];
-//    __weak typeof(self) ws = self;
-//    manager.connectStateCallBack = ^(AiMouseConnectType type,BOOL isConnected) {
-//        [ws connectStateDidChange:type connectState:isConnected];
-//    };
-//}
-//
-//
-//- (void)showPopupMenu:(NSButton *)sender {
-//    NSMenu *popupMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
-//    NSMenuItem *item1 = [[NSMenuItem alloc] initWithTitle:@"语音开启" action:@selector(voiceStart:) keyEquivalent:@"1"];
-//    NSMenuItem *item2 = [[NSMenuItem alloc] initWithTitle:@"语音停止" action:@selector(voiceStop:) keyEquivalent:@"2"];
-//    NSMenuItem *item3 = [[NSMenuItem alloc] initWithTitle:@"设置DPI" action:@selector(setDPI:) keyEquivalent:@"3"];
-//    NSMenuItem *item4 = [[NSMenuItem alloc] initWithTitle:@"鼠标状态查询" action:@selector(searchState:) keyEquivalent:@"3"];
-////    NSMenuItem *item5 = [[NSMenuItem alloc] initWithTitle:@"向鼠标告知APP下载地址" action:@selector(setDownLoadURL:) keyEquivalent:@"3"];
-////    NSMenuItem *item8 = [[NSMenuItem alloc] initWithTitle:@":读取鼠标序列号" action:@selector(getSN:) keyEquivalent:@"3"];
-////    NSMenuItem *item9 = [[NSMenuItem alloc] initWithTitle:@":发送弹UR开关命令" action:@selector(sendUR:) keyEquivalent:@"3"];
-//
-//    [popupMenu addItem:item1];
-//    [popupMenu addItem:item2];
-//    [popupMenu addItem:item3];
-//    [popupMenu addItem:item4];
-//
-//    NSPoint buttonLocation = [sender convertPoint:NSZeroPoint toView:self.view];
-//    [popupMenu popUpMenuPositioningItem:nil atLocation:buttonLocation inView:self.view];
-//}
-//
-//- (void)voiceStart:(NSMenuItem*)sender {
-//    [[TlwDeviceManger shared] openRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-//        
-//    }];
-//}
-//- (void)voiceStop:(NSMenuItem*)sender {
-//    [[TlwDeviceManger shared] closeRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-//        
-//    }];
-//}
-//- (void)setDPI:(NSMenuItem*)sender {
-//    [[TlwDeviceManger shared] setDPI:2 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
-//        
-//    }];
-//}
-//- (void)searchState:(NSMenuItem*)sender {
-//    [[TlwDeviceManger shared] getDeviceInfo:^(TlwDeviceInfo *deviceInfo, NSError *error) {
-////        if (deviceInfo) {
-////            NSString *info = deviceInfo.description;
-////            dispatch_async(dispatch_get_main_queue(), ^{
-////                self.deviceInfoLabel.stringValue = info;
-////            });
-////        }
-////        else{
-////            NSString *info = [NSString stringWithFormat:@"error == %@",error.description];
-////            NSLog(@"%@",info);
-////            dispatch_async(dispatch_get_main_queue(), ^{
-////                self.deviceInfoLabel.stringValue = info;
-////            });
-////        }
-//    }];
-//}
-//
-//@end
-#import "TlwVC.h"
-#import "ScanVC.h"
-#import "DeviceManger.h"
-
-@interface TlwVC ()
-@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
-@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
-@property(nonatomic,strong)NSTextField *authLabel;///鉴权状态
-@property(nonatomic,strong)NSTextField *deviceInfoLabel;///设备信息
-@end
-
-@implementation TlwVC
-
--(instancetype)init{
-    if (self = [super init]) {
-//        [[DeviceManger shared] start];
-    }
-    return self;
-}
-
--(void)dealloc{
-//    [[DeviceManger shared] stop];
-}
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    
-    // Do any additional setup after loading the view.
-//    [[DeviceManger shared] start];
-    [self setupUI];
-    [self setupDeviceManger];
-}
-
-- (void)loadView{
-    self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
-    CALayer *viewLayer = [CALayer layer];
-    NSView *backgroundView= [[NSView alloc]init];
-    [backgroundView setWantsLayer:YES];
-    [backgroundView setLayer:viewLayer];
-    backgroundView.layer.backgroundColor = [NSColor greenColor].CGColor;
-    [backgroundView setNeedsDisplay:YES];
-    [self.view addSubview:backgroundView];
-    
-    self.title = @"AI SDK";
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 80, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"蓝牙扫描";
-        [btn setTarget:self];
-        [btn setAction:@selector(scanAction)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 180, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"获取设备信息";
-        [btn setTarget:self];
-        [btn setAction:@selector(geviceInfoAction)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 280, 100, 45)];
-        btn.bordered = true;
-        btn.title = @"更多指令";
-        [btn setTarget:self];
-        [btn setAction:@selector(moreAction:)];
-        btn.state = 1;
-        [self.view addSubview:btn];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 80, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"连接模式:--";
-        label.backgroundColor = NSColor.clearColor;
-        self.typeLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 120, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"连接状态:未连接";
-        label.backgroundColor = NSColor.clearColor;
-        self.connectLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 160, 300, 35)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"鉴权状态:unknow";
-        label.backgroundColor = NSColor.clearColor;
-        self.authLabel = label;
-        [self.view addSubview:label];
-    }
-    {
-        NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 260, 300, 100)];
-        label.editable = NO;
-        label.bordered = NO;
-        label.stringValue = @"";
-        label.backgroundColor = NSColor.clearColor;
-        self.deviceInfoLabel = label;
-        [self.view addSubview:label];
-    }
-}
-
-#pragma mark - action
-- (void)scanAction{
-    ScanVC *vc = [[ScanVC alloc] initWithNibName:nil bundle:nil];
-    [self presentViewControllerAsModalWindow:vc];
-}
-
-/// 获取设备信息
-- (void)geviceInfoAction{
-    [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
-        if (deviceInfo) {
-            NSString *info = deviceInfo.description;
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-        else{
-            NSString *info = [NSString stringWithFormat:@"error == %@",error.description];
-            NSLog(@"%@",info);
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-    }];
-}
-- (void)showAuthResult:(BOOL)isSuccess{
-    dispatch_async(dispatch_get_main_queue(), ^{
-        self.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败";
-        if(isSuccess){
-            [self geviceInfoAction];
-        }
-    });
-}
-- (void)connectStateDidChange:(AiMouseConnectType)type connectState:(BOOL)isConnected{
-    dispatch_async(dispatch_get_main_queue(), ^{
-        if(isConnected){
-            self.typeLabel.stringValue = type == AiMouseConnectType_bluetooth ?@"连接模式:蓝牙":@"连接模式:hid";
-            self.connectLabel.stringValue = isConnected?@"连接状态:已连接":@"连接状态:未连接";
-            [self geviceInfoAction];
-        }
-        else{
-            self.typeLabel.stringValue = @"连接模式:--";
-            self.connectLabel.stringValue = @"连接状态:未连接";
-        }
-    });
-}
-
-- (void)setupDeviceManger{
-    DeviceManger *manager = [DeviceManger shared];
-    __weak typeof(self) ws = self;
-    manager.authCallBack = ^(BOOL isSuccess) {
-        [ws showAuthResult:isSuccess];
-    };
-//    manager.connectStateCallBack = ^(AiMouseConnectType type,BOOL isConnected) {
-//        [ws connectStateDidChange:type connectState:isConnected];
-//    };
-    
-    [manager begainMonitorAiMouseConnectStateDidChange:@"VMouse" callBack:^(int connectType, BOOL connected) {
-        [ws connectStateDidChange:connectType connectState:connected];
-    }];
-}
-
-- (void)moreAction:(NSButton *)sender {
-    NSMenu *popupMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
-    NSMenuItem *item1 = [[NSMenuItem alloc] initWithTitle:@"语音开启" action:@selector(voiceStart:) keyEquivalent:@"1"];
-    NSMenuItem *item2 = [[NSMenuItem alloc] initWithTitle:@"语音停止" action:@selector(voiceStop:) keyEquivalent:@"2"];
-    NSMenuItem *item3 = [[NSMenuItem alloc] initWithTitle:@"设置DPI" action:@selector(setDPI:) keyEquivalent:@"3"];
-    NSMenuItem *item4 = [[NSMenuItem alloc] initWithTitle:@"鼠标状态查询" action:@selector(searchState:) keyEquivalent:@"3"];
-
-    [popupMenu addItem:item1];
-    [popupMenu addItem:item2];
-    [popupMenu addItem:item3];
-    [popupMenu addItem:item4];
-
-    NSPoint buttonLocation = [sender convertPoint:NSZeroPoint toView:self.view];
-    [popupMenu popUpMenuPositioningItem:nil atLocation:buttonLocation inView:self.view];
-}
-
-- (void)voiceStart:(NSMenuItem*)sender {
-    [[DeviceManger shared] openRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)voiceStop:(NSMenuItem*)sender {
-    [[DeviceManger shared] closeRecord:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)setDPI:(NSMenuItem*)sender {
-    [[DeviceManger shared] setCPI:2 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
-        
-    }];
-}
-- (void)searchState:(NSMenuItem*)sender {
-    [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
-        if (deviceInfo) {
-            NSString *info = deviceInfo.description;
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-        else{
-            NSString *info = [NSString stringWithFormat:@"error == %@",error.description];
-            NSLog(@"%@",info);
-            dispatch_async(dispatch_get_main_queue(), ^{
-                self.deviceInfoLabel.stringValue = info;
-            });
-        }
-    }];
-}
-@end
index be41ad4..f7ea11e 100644 (file)
     NSMenuItem *item2 = [[NSMenuItem alloc] initWithTitle:@"语音停止" action:@selector(voiceStop:) keyEquivalent:@"2"];
     NSMenuItem *item3 = [[NSMenuItem alloc] initWithTitle:@"设置DPI" action:@selector(setDPI:) keyEquivalent:@"3"];
     NSMenuItem *item4 = [[NSMenuItem alloc] initWithTitle:@"鼠标状态查询" action:@selector(searchState:) keyEquivalent:@"4"];
-    NSMenuItem *item5 = [[NSMenuItem alloc] initWithTitle:@"设置网址" action:@selector(setUrl:) keyEquivalent:@"5"];
+    NSMenuItem *item5 = [[NSMenuItem alloc] initWithTitle:@"设置滚轮开关" action:@selector(setUrlState:) keyEquivalent:@"5"];
+    NSMenuItem *item6 = [[NSMenuItem alloc] initWithTitle:@"获取滚轮开关" action:@selector(getUrlState:) keyEquivalent:@"6"];
 
     [popupMenu addItem:item1];
     [popupMenu addItem:item2];
     [popupMenu addItem:item3];
     [popupMenu addItem:item4];
     [popupMenu addItem:item5];
+    [popupMenu addItem:item6];
 
     NSPoint buttonLocation = [sender convertPoint:NSZeroPoint toView:self.view];
     [popupMenu popUpMenuPositioningItem:nil atLocation:buttonLocation inView:self.view];
     [self geviceInfoAction];
 }
 
-- (void)setUrl:(NSMenuItem*)sender{
+- (void)setUrlState:(NSMenuItem*)sender{
     [[DeviceManger shared] setUrlState:1 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
-        NSLog(isSuccess? @"设置网址成功":@"设置网址失败");
+        NSLog(isSuccess? @"设置滚轮开关成功":@"设置滚轮开关失败");
     }];
 }
+
+- (void)getUrlState:(NSMenuItem*)sender{
+    [[DeviceManger shared] getUrlState:^(int state, NSError * _Nonnull error) {
+        if (error == nil) {
+            NSLog(@"滚轮开关 %d",state);
+        }
+        else{
+            NSLog(error.description);
+        }
+    }];
+}
+
+
+
+
 - (void)geviceInfoAction{
 //    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent"]];
 //    return;