diff --git a/VoidLink/Input/CommandManager.swift b/VoidLink/Input/CommandManager.swift index 6978ffc0..839c063e 100644 --- a/VoidLink/Input/CommandManager.swift +++ b/VoidLink/Input/CommandManager.swift @@ -600,12 +600,12 @@ import UIKit } } - @objc public func sendAutoReleaseComboCommand(cmdString: [String]?, delay: TimeInterval = 0.2, index: Int = 0, pressOnly: Bool = false, releaseOnly:Bool = false) { // we need a large delay for WAN streaming + @objc public func sendAutoReleaseComboCommand(cmdStrings: [String]?, delay: TimeInterval = 0.2, index: Int = 0, pressOnly: Bool = false, releaseOnly:Bool = false) { // we need a large delay for WAN streaming // 如果已处理完所有按键,则开始释放按键 - guard let cmdString = cmdString else { return } + guard let cmdStrings = cmdStrings else { return } if releaseOnly { - for keyStr in cmdString.reversed() { + for keyStr in cmdStrings.reversed() { if let keyCode = CommandManager.keyboardButtonMappings[keyStr] { LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_UP), 0) // 释放按键 } @@ -616,11 +616,11 @@ import UIKit return } - guard index < cmdString.count else { + guard index < cmdStrings.count else { // 释放按键 DispatchQueue.main.asyncAfter(deadline: .now()) { if pressOnly {return} - for keyStr in cmdString.reversed() { // 从后往前释放按键 + for keyStr in cmdStrings.reversed() { // 从后往前释放按键 if let keyCode = CommandManager.keyboardButtonMappings[keyStr] { LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_UP), 0) // 释放按键 } @@ -632,17 +632,17 @@ import UIKit return } // 获取当前按键的映射值 - if let keyCode = CommandManager.keyboardButtonMappings[cmdString[index]] { + if let keyCode = CommandManager.keyboardButtonMappings[cmdStrings[index]] { // 发送当前按键的按下事件 LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_DOWN), 0) - } else if let mouseButtonCode = CommandManager.mouseButtonMappings[cmdString[index]]{ + } else if let mouseButtonCode = CommandManager.mouseButtonMappings[cmdStrings[index]]{ LiSendMouseButtonEvent(CChar(BUTTON_ACTION_PRESS), mouseButtonCode) } else { - print("No mapping found for \(cmdString[index])") + print("No mapping found for \(cmdStrings[index])") } // 延迟后递归处理下一个按键 DispatchQueue.main.asyncAfter(deadline: .now() + delay) { - self.sendAutoReleaseComboCommand(cmdString: cmdString, delay: delay, index: index + 1) + self.sendAutoReleaseComboCommand(cmdStrings: cmdStrings, delay: delay, index: index + 1, pressOnly: pressOnly, releaseOnly: releaseOnly) } } diff --git a/VoidLink/Input/OnScreenWidgetView.swift b/VoidLink/Input/OnScreenWidgetView.swift index 61cad8fa..9b056b54 100644 --- a/VoidLink/Input/OnScreenWidgetView.swift +++ b/VoidLink/Input/OnScreenWidgetView.swift @@ -398,7 +398,7 @@ import SVGKit if self.cmdString.contains("ERASER"){ self.functionalButtonString = "ERASER" } - if !self.functionalButtonString.isEmpty { + if self.isFunctionalButton { self.buttonMode = .movable if self.functionalButtonString == "PENCILHOVER" {self.buttonMode = .regular} } @@ -460,7 +460,7 @@ import SVGKit self.hasAutoTap = self.widgetType == WidgetTypeEnum.button && self.functionalButtonString == "" && self.motionControlButtonString == "" self.isMousePadWithButtonActions = CommandManager.mousePadWithButtonActions.contains(self.touchPadString) && widgetType == WidgetTypeEnum.touchPad self.hasInertia = CommandManager.inertialTouchPads.contains(self.touchPadString) - self.isFunctionalButton = self.functionalButtonString != "" + self.isFunctionalButton = self.functionalButtonString != "" || self.cmdString.contains("+") self.hasHapticFeedback = !self.comboButtonStrings.isEmpty || CommandManager.directionPads.contains(self.touchPadString) self.isDirectionPad = self.widgetType == WidgetTypeEnum.touchPad && CommandManager.directionPads.contains(self.touchPadString) self.isStickWheel = self.widgetType == WidgetTypeEnum.touchPad && CommandManager.stickWheels.contains(self.touchPadString) @@ -1509,7 +1509,7 @@ import SVGKit autoReleaseComboButtons.removeAll{ Set(CommandManager.pencilProButtonCmds).contains($0) } - CommandManager.shared.sendAutoReleaseComboCommand(cmdString: autoReleaseComboButtons) // send multi-key command + CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: autoReleaseComboButtons) // send multi-key command DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.buttonUpVisualEffect() } diff --git a/VoidLink/Input/PencilHandler.swift b/VoidLink/Input/PencilHandler.swift index fcc6b217..6fde259a 100644 --- a/VoidLink/Input/PencilHandler.swift +++ b/VoidLink/Input/PencilHandler.swift @@ -259,7 +259,7 @@ import UIKit if !pencilProEnabled {return} if doubleTapShorcuts.isEmpty {return} let keyStrings = CommandManager.shared.extractAutoReleaseButtonStrings(from: doubleTapShorcuts[shortcutIndex]) - CommandManager.shared.sendAutoReleaseComboCommand(cmdString: keyStrings, delay: 0.1) + CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: keyStrings, delay: 0.1) shortcutIndex = (shortcutIndex + 1) % doubleTapShorcuts.count } @@ -278,12 +278,12 @@ import UIKit switch squeeze.phase { case .began: - if keepPressedUntilRelease {CommandManager.shared.sendAutoReleaseComboCommand(cmdString: squeezePressKeyStrings, delay: 0.1, pressOnly: true)} - else {CommandManager.shared.sendAutoReleaseComboCommand(cmdString: squeezePressKeyStrings, delay: 0.1)} + if keepPressedUntilRelease {CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: squeezePressKeyStrings, delay: 0.1, pressOnly: true)} + else {CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: squeezePressKeyStrings, delay: 0.1)} break case .ended, .cancelled: - if keepPressedUntilRelease {CommandManager.shared.sendAutoReleaseComboCommand(cmdString: squeezePressKeyStrings, releaseOnly: true)} - else {CommandManager.shared.sendAutoReleaseComboCommand(cmdString: squeezeReleaseKeyStrings, delay: 0.1)} + if keepPressedUntilRelease {CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: squeezePressKeyStrings, releaseOnly: true)} + else {CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: squeezeReleaseKeyStrings, delay: 0.1)} break default: break diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index 57a05767..0605ec5c 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -1338,7 +1338,7 @@ dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)); dispatch_after(delay, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSArray* hdrCommand = [CommandManager.shared extractAutoReleaseButtonStringsFrom:@"WIN+ALT+B"]; - [CommandManager.shared sendAutoReleaseComboCommandWithCmdString:hdrCommand delay:0.15 index:0 pressOnly:false releaseOnly:false]; + [CommandManager.shared sendAutoReleaseComboCommandWithCmdStrings:hdrCommand delay:0.15 index:0 pressOnly:false releaseOnly:false]; }); } } diff --git a/VoidLink/ViewControllers/ToolboxViewController.swift b/VoidLink/ViewControllers/ToolboxViewController.swift index 4fd6c809..be025115 100644 --- a/VoidLink/ViewControllers/ToolboxViewController.swift +++ b/VoidLink/ViewControllers/ToolboxViewController.swift @@ -406,7 +406,7 @@ import UIKit private func sendKeyboardCommand(_ cmd: RemoteCommand) { print("Sending key-value") let keyboardCmdStrings = CommandManager.shared.extractAutoReleaseButtonStrings(from: cmd.cmdString) - CommandManager.shared.sendAutoReleaseComboCommand(cmdString: keyboardCmdStrings!) + CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: keyboardCmdStrings!) } public func gestureRecognizer(