From: liangzhenying <867174124@qq.com> Date: Thu, 5 Sep 2024 02:22:08 +0000 (+0800) Subject: 泰凌微DPI修改 X-Git-Tag: 千寻适配d9~11 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8640759f5958a2d71521990a26b7f16277c17999;p=mirrors%2FMouseSdk-MacOS.git 泰凌微DPI修改 --- diff --git a/MouseSdk/AiMouseSdk/Manager/DeviceManger.m b/MouseSdk/AiMouseSdk/Manager/DeviceManger.m index fde7184..529e8bc 100644 --- a/MouseSdk/AiMouseSdk/Manager/DeviceManger.m +++ b/MouseSdk/AiMouseSdk/Manager/DeviceManger.m @@ -222,21 +222,7 @@ /// 设置CPI - (void)setCPI:(NSInteger)value completation:(void (^)(BOOL isSuccess,NSError *error))finished{ if (self.productType == AiMouseProductType_tlw) { - NSDictionary *dict = @{ - @"800":@"0", - @"1200":@"1", - @"1600":@"2", - @"2400":@"3", - }; - - if (dict[[NSString stringWithFormat:@"%ld",value]]) { - int num = [dict[[NSString stringWithFormat:@"%ld",value]] intValue]; - [self.tlwSdk setDPI:num completation:finished]; - } - else{ - [self showLog:[NSString stringWithFormat:@"CPI值设置错误 %ld",value]]; - [self.tlwSdk setDPI:0 completation:finished]; - } + [self.tlwSdk setDPI:value completation:finished]; } else{ [self.frkSdk setCPI:value completation:finished]; diff --git a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.h b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.h index 005d5ef..4f38ca2 100644 --- a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.h +++ b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.h @@ -9,7 +9,7 @@ #import "AiMouseSdk.h" @interface TlwDeviceInfo : NSObject -@property (nonatomic, assign) int DPI;/// DPI值 数值1 ~ 4 (分别对应 800 1200 1800 2400) +@property (nonatomic, assign) int DPI;/// DPI值 数值1 ~ 4 (分别对应1200,1600,2400,4800) @property (nonatomic, assign) int version;///软件版本 @property (nonatomic, assign) int batteryState;/// 电池状态 @property (nonatomic, assign) int batteryValue;/// 电池百分百电量,0-100 @@ -100,9 +100,8 @@ typedef NS_ENUM(NSInteger,TlwMouseLogLevel) { /// 设置DPI /// - Parameters: -/// - value: 数值1 ~ 4 (分别对应 800 1200 1800 2400) /// - finished: 设置结果回调 -- (void)setDPI:(uint8_t)value completation:(void (^)(BOOL isSuccess,NSError *error))finished; +- (void)setDPI:(NSInteger)value completation:(void (^)(BOOL isSuccess,NSError *error))finished; /// 打开录音 /// - finished: 执行结果回调 diff --git a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m index d5ab773..786d336 100644 --- a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m +++ b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m @@ -204,7 +204,23 @@ } -- (void)setDPI:(uint8_t)value completation:(void (^)(BOOL isSuccess,NSError *error))finished{ +- (void)setDPI:(NSInteger)num completation:(void (^)(BOOL isSuccess,NSError *error))finished{ + NSDictionary *dict = @{ + @"1200":@"1", + @"1600":@"2", + @"2400":@"3", + @"4800":@"4", + }; + NSString *valueString = dict[[NSString stringWithFormat:@"%ld",num]]; + if (valueString == nil) { + valueString = @"1"; + [self showLog:[NSString stringWithFormat:@"CPI值设置错误 %ld",num]]; + } + uint8_t value = [valueString intValue]; + if (value < 1 || value > 4) { + value = 1; + } + if(self.connectType == AiMouseConnectType_hid){ self.setDpiCallBack = finished; uint8_t type = 0x06; @@ -292,18 +308,29 @@ __weak typeof(self) ws = self; [self getDeviceInfo:^(TlwDeviceInfo *deviceInfo, NSError *error) { if(deviceInfo != nil){ - NSString *CPI_list = @"800,1200,1600,2400";// 0-3,800 1200 1600 2400 - NSString *cpi = @"0"; + NSDictionary *dict = @{ + @"1200":@"1", + @"1600":@"2", + @"2400":@"3", + @"4800":@"4", + }; - if ([CPI_list componentsSeparatedByString:@","].count - 1 >= deviceInfo.DPI) { - cpi = [[CPI_list componentsSeparatedByString:@","] objectAtIndex:deviceInfo.DPI]; + NSString *CPI_list = [[dict allKeys] componentsJoinedByString:@","]; + NSString *level = [NSString stringWithFormat:@"%d",deviceInfo.DPI]; + NSString *dpiValue = @"1200"; + + for (NSString *key in dict) { + if ([dict[key] isEqualToString:level]) { + dpiValue = key; + break;; + } } AiMouseDeviceInfo *info = [[AiMouseDeviceInfo alloc] init]; info.battery_power = [NSString stringWithFormat:@"%d",deviceInfo.batteryValue] ; info.version = [NSString stringWithFormat:@"%d",deviceInfo.version]; info.CPI_list = CPI_list; - info.CPI = cpi; + info.CPI = dpiValue; ws.fullInfo = info; [ws getSnInfo:^(TlwSnInfo *snInfo, NSError *error) { diff --git a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate index 9f0e1a7..c7d5c48 100644 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/ViewController.m b/MouseSdk/MouseSdk/ViewController.m index 8bda9cd..4f1c465 100644 --- a/MouseSdk/MouseSdk/ViewController.m +++ b/MouseSdk/MouseSdk/ViewController.m @@ -2,6 +2,7 @@ #import "ViewController.h" #import "ScanVC.h" #import "DeviceManger.h" +#import "Config.h" @interface ViewController () @property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态 @property(nonatomic,strong)NSTextField *connectLabel;///连接状态 @@ -94,6 +95,9 @@ // [AiHidManager shared]; DeviceManger *manager = [DeviceManger shared]; __weak typeof(self) ws = self; + manager.aiMouseAddLogCallBack = ^(NSString * _Nonnull log) { + NSLog(@"%@",log); + }; manager.authCallBack = ^(BOOL isSuccess) { dispatch_async(dispatch_get_main_queue(), ^{ ws.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败"; @@ -144,7 +148,7 @@ }]; } - (void)setDPI:(NSMenuItem*)sender { - [[DeviceManger shared] setCPI:800 completation:^(BOOL isSuccess, NSError * _Nonnull error) { + [[DeviceManger shared] setCPI:1600 completation:^(BOOL isSuccess, NSError * _Nonnull error) { }]; }