feat: on-screen button "DisableTouch"

This commit is contained in:
True Zhuanjia committed 2026-03-21 22:06:40 +08:00
1 parent 924374bccd
commit 6204feefc0
6 files changed
+108 -16

No files matched your search

+2 -1
View File
@@ -144,7 +144,8 @@ import UIKit
"PENCILHOVER", "PENCILHOVER",
"BRUSH", "BRUSH",
"ERASER", "ERASER",
"NOSINGLETOUCH" "NOSINGLETOUCH",
"DISABLETOUCH",
] ]
@objc public static let pencilProButtonCmds: [String] = [ @objc public static let pencilProButtonCmds: [String] = [
"PENCILHOVER", "PENCILHOVER",
+22 -1
View File
@@ -54,6 +54,7 @@ import SVGKit
func replaceBrush(shortcut:String) func replaceBrush(shortcut:String)
func replaceEraser(shortcut:String) func replaceEraser(shortcut:String)
func presentPressureCurveVC() func presentPressureCurveVC()
func toggleTouch(disabled:Bool)
} }
@objc enum WidgetTypeEnum: UInt8 { @objc enum WidgetTypeEnum: UInt8 {
@@ -72,6 +73,7 @@ import SVGKit
@objc static public var editMode: Bool = false @objc static public var editMode: Bool = false
@objc static public var buttonVisualFeedbackEnabled: Bool = true @objc static public var buttonVisualFeedbackEnabled: Bool = true
@objc public var widgetLabel: String @objc public var widgetLabel: String
private var nonEditableWidgetLabel: String = ""
@objc public var cmdString: String @objc public var cmdString: String
@objc public var sequence: Int16 = -1 @objc public var sequence: Int16 = -1
private var buttonString: String = "" private var buttonString: String = ""
@@ -165,6 +167,7 @@ import SVGKit
@objc public var isStickWheel: Bool = false @objc public var isStickWheel: Bool = false
@objc public var isFolder: Bool = false @objc public var isFolder: Bool = false
@objc public var hasNonEditableLabel: Bool = false
// for all stick pads // for all stick pads
@objc public var minStickOffset: CGFloat = 0 @objc public var minStickOffset: CGFloat = 0
@@ -481,6 +484,7 @@ import SVGKit
|| (self.widgetType == WidgetTypeEnum.button || (self.widgetType == WidgetTypeEnum.button
&& (buttonMode == .slideAndHold || buttonMode == .slideToToggle)))*/ && (buttonMode == .slideAndHold || buttonMode == .slideToToggle)))*/
self.hasTrackPoint = true self.hasTrackPoint = true
self.hasNonEditableLabel = self.cmdString == "DISABLETOUCH"
} }
// ====================================================================================================== // ======================================================================================================
@@ -777,7 +781,15 @@ import SVGKit
} }
private func setupAtrributedText(){ private func setupAtrributedText(){
let text = self.widgetLabel.contains("#") ? "\(self.widgetLabel.split(separator: "#").first ?? "")" : SwiftLocalizationHelper.localizedString(forKey: self.widgetLabel) var text = self.widgetLabel.contains("#") ? "\(self.widgetLabel.split(separator: "#").first ?? "")" : SwiftLocalizationHelper.localizedString(forKey: self.widgetLabel)
if self.hasNonEditableLabel {
if cmdString == "DISABLETOUCH" {
self.nonEditableWidgetLabel = SwiftLocalizationHelper.localizedString(forKey: touchDisabledFLag ? "=EnableTouch" : "=DisableTouch" )
}
text = self.nonEditableWidgetLabel
}
let attr = NSAttributedString( let attr = NSAttributedString(
string: self.folded ? "[\(text)]" : text, string: self.folded ? "[\(text)]" : text,
attributes: [ attributes: [
@@ -2481,10 +2493,19 @@ import SVGKit
].contains(Bundle.main.bundleIdentifier) && GenericUtils.isIPad() { ].contains(Bundle.main.bundleIdentifier) && GenericUtils.isIPad() {
self.functionalButtonDelegate?.presentPressureCurveVC() self.functionalButtonDelegate?.presentPressureCurveVC()
} }
case "DISABLETOUCH":
self.handleTouchDisableButtonUp()
default: default:
break break
} }
} }
private var touchDisabledFLag:Bool = false
private func handleTouchDisableButtonUp(){
touchDisabledFLag = !touchDisabledFLag
self.setupAtrributedText()
self.functionalButtonDelegate?.toggleTouch(disabled: touchDisabledFLag)
}
private func temporaryDisableFolderButtonAnimation(){ private func temporaryDisableFolderButtonAnimation(){
OnScreenWidgetView.enableFolderAnimation = false OnScreenWidgetView.enableFolderAnimation = false
+1
View File
@@ -79,6 +79,7 @@
- (void)enablePencilHover; - (void)enablePencilHover;
- (void)disablePencilHover; - (void)disablePencilHover;
- (void)setAllowSingleTouchEnabled:(BOOL)enabled; - (void)setAllowSingleTouchEnabled:(BOOL)enabled;
- (void)toggleTouchDisabled:(bool)disabled;
#if !TARGET_OS_TV #if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse; - (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
+21 -14
View File
@@ -57,7 +57,9 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
int localMousePointerMode; int localMousePointerMode;
TouchMode touchMode;
UIResponder* touchHandler; UIResponder* touchHandler;
UIResponder* sessionTouchHandler;
NSTimer* interactionTimer; NSTimer* interactionTimer;
BOOL hasUserInteracted; BOOL hasUserInteracted;
@@ -121,7 +123,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
designatedSoftKeyboardHeight = settings.softKeyboardHeight * GenericUtils.screenHeight; designatedSoftKeyboardHeight = settings.softKeyboardHeight * GenericUtils.screenHeight;
keyboardHeightDesignatedForLandscape = designatedSoftKeyboardHeight != 0; keyboardHeightDesignatedForLandscape = designatedSoftKeyboardHeight != 0;
// if(settings.touchMode.intValue == NativeTouchOnly) [self addGestureRecognizer:keyboardToggleRecognizer]; //keep legacy approach in pure native mode // if(touchMode == NativeTouchOnly) [self addGestureRecognizer:keyboardToggleRecognizer]; //keep legacy approach in pure native mode
// else [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes // else [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes
// [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes // [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes
@@ -135,8 +137,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
_pencilHandler = PencilHandler.shared; _pencilHandler = PencilHandler.shared;
// iOS uses touch Mode depending on user preference // iOS uses touch Mode depending on user preference
touchMode = settings.touchMode.intValue;
switch (settings.touchMode.intValue) { switch (touchMode) {
case NativeTouch: case NativeTouch:
keyboardToggleRecognizer.immediateTriggering = false; keyboardToggleRecognizer.immediateTriggering = false;
self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings]; self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings];
@@ -161,19 +163,20 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
default: default:
break; break;
} }
sessionTouchHandler = touchHandler;
// we'll render on-screen controls on the toplayer too: // we'll render on-screen controls on the toplayer too:
_onScreenControls = [[OnScreenControls alloc] initWithView:self->_streamFrameTopLayerView controllerSup:controllerSupport streamConfig:streamConfig]; // don't delete, this is mandatory _onScreenControls = [[OnScreenControls alloc] initWithView:self->_streamFrameTopLayerView controllerSup:controllerSupport streamConfig:streamConfig]; // don't delete, this is mandatory
// OnScreenControls.shared = _onScreenControls; // OnScreenControls.shared = _onScreenControls;
/* /*
// here we pass the tap recognizer to the onscreencontrols obj // here we pass the tap recognizer to the onscreencontrols obj
if (settings.touchMode.intValue == RelativeTouch){ if (touchMode == RelativeTouch){
RelativeTouchHandler* relativeTouchHandler = (RelativeTouchHandler*) touchHandler; RelativeTouchHandler* relativeTouchHandler = (RelativeTouchHandler*) touchHandler;
onScreenControls.mouseRightClickTapRecognizer = relativeTouchHandler.mouseRightClickTapRecognizer; onScreenControls.mouseRightClickTapRecognizer = relativeTouchHandler.mouseRightClickTapRecognizer;
} */ } */
OnScreenControlsLevel level = (OnScreenControlsLevel)[settings.onscreenControls integerValue]; OnScreenControlsLevel level = (OnScreenControlsLevel)[settings.onscreenControls integerValue];
if (settings.touchMode.intValue != RelativeTouch && settings.touchMode.intValue != NativeTouch ) { if (touchMode != RelativeTouch && touchMode != NativeTouch ) {
Log(LOG_I, @"On-screen controls disabled in non-relative touch mode"); Log(LOG_I, @"On-screen controls disabled in non-relative touch mode");
[_onScreenControls setLevel:OnScreenControlsLevelOff]; [_onScreenControls setLevel:OnScreenControlsLevelOff];
@@ -181,7 +184,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[OnScreenControls.touchesCapturedByOnScreenControls removeAllObjects]; // reset the attribute to nil [OnScreenControls.touchesCapturedByOnScreenControls removeAllObjects]; // reset the attribute to nil
/* /*
if(settings.touchMode.intValue == NativeTouch){ if(touchMode == NativeTouch){
NativeTouchHandler* nativeTouchHandler = (NativeTouchHandler* )touchHandler; NativeTouchHandler* nativeTouchHandler = (NativeTouchHandler* )touchHandler;
nativeTouchHandler.touchesCapturedByOnScreenButtons = onScreenControls.touchesCapturedByOnScreenButtons; nativeTouchHandler.touchesCapturedByOnScreenButtons = onScreenControls.touchesCapturedByOnScreenButtons;
touchHandler = nativeTouchHandler; touchHandler = nativeTouchHandler;
@@ -486,7 +489,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// we'll enable on screen buttons, and disable on screen controllers for absolute touch // we'll enable on screen buttons, and disable on screen controllers for absolute touch
- (bool) isOscEnabled{ - (bool) isOscEnabled{
return (settings.touchMode.intValue == RelativeTouch || settings.touchMode.intValue == NativeTouch || settings.touchMode.intValue == AbsoluteTouch || settings.touchMode.intValue == TouchDisabled) && settings.onscreenControls.intValue != OnScreenControlsLevelOff; return (touchMode == RelativeTouch || touchMode == NativeTouch || touchMode == AbsoluteTouch || touchMode == TouchDisabled) && settings.onscreenControls.intValue != OnScreenControlsLevelOff;
} }
// we'll enable on screen buttons, and disable on screen controllers for absolute touch // we'll enable on screen buttons, and disable on screen controllers for absolute touch
@@ -920,7 +923,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
#if !TARGET_OS_TV #if !TARGET_OS_TV
// if (@available(iOS 13.4, *)) { // if (@available(iOS 13.4, *)) {
// cancel restriction of native touch for iOS13.3 & lower // cancel restriction of native touch for iOS13.3 & lower
if (settings.touchMode.intValue == NativeTouchOnly) { if (touchMode == NativeTouchOnly) {
[touchHandler touchesBegan:touches withEvent:event]; [touchHandler touchesBegan:touches withEvent:event];
return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only. return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only.
} }
@@ -951,7 +954,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self startInteractionTimer]; [self startInteractionTimer];
NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches; NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches;
if(settings.touchMode.intValue == NativeTouch || settings.touchMode.intValue == RelativeTouch){ if(touchMode == NativeTouch || touchMode == RelativeTouch){
[self->_onScreenControls handleTouchDownEvent:targetTouches]; [self->_onScreenControls handleTouchDownEvent:targetTouches];
[self->touchHandler touchesBegan:targetTouches withEvent:event]; [self->touchHandler touchesBegan:targetTouches withEvent:event];
} }
@@ -1087,7 +1090,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
#if !TARGET_OS_TV #if !TARGET_OS_TV
if (settings.touchMode.intValue == NativeTouchOnly) { if (touchMode == NativeTouchOnly) {
[touchHandler touchesMoved:touches withEvent:event]; [touchHandler touchesMoved:touches withEvent:event];
return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only. return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only.
} }
@@ -1128,7 +1131,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
hasUserInteracted = YES; hasUserInteracted = YES;
NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches; NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches;
if(self->settings.touchMode.intValue == NativeTouch || self->settings.touchMode.intValue == RelativeTouch){ if(self->touchMode == NativeTouch || self->touchMode == RelativeTouch){
[self->touchHandler touchesMoved:targetTouches withEvent:event]; [self->touchHandler touchesMoved:targetTouches withEvent:event];
[self->_onScreenControls handleTouchMovedEvent:targetTouches]; [self->_onScreenControls handleTouchMovedEvent:targetTouches];
} }
@@ -1202,7 +1205,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
#if !TARGET_OS_TV #if !TARGET_OS_TV
if (settings.touchMode.intValue == NativeTouchOnly) { if (touchMode == NativeTouchOnly) {
[touchHandler touchesEnded:touches withEvent:event]; [touchHandler touchesEnded:touches withEvent:event];
return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only. return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only.
} }
@@ -1233,7 +1236,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
hasUserInteracted = YES; hasUserInteracted = YES;
NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches; NSSet* targetTouches = nonPencilTouches ? nonPencilTouches : touches;
if(settings.touchMode.intValue == NativeTouch || settings.touchMode.intValue == RelativeTouch){ if(touchMode == NativeTouch || touchMode == RelativeTouch){
[self->touchHandler touchesEnded:targetTouches withEvent:event]; // when touches ended, must call the native touchhandler before onScreenControls, since the NSSet of touches captured by on screen button shall be updated later [self->touchHandler touchesEnded:targetTouches withEvent:event]; // when touches ended, must call the native touchhandler before onScreenControls, since the NSSet of touches captured by on screen button shall be updated later
[self->_onScreenControls handleTouchUpEvent:targetTouches]; [self->_onScreenControls handleTouchUpEvent:targetTouches];
} }
@@ -1243,7 +1246,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[touchHandler touchesCancelled:touches withEvent:event]; [touchHandler touchesCancelled:touches withEvent:event];
#if !TARGET_OS_TV #if !TARGET_OS_TV
if (settings.touchMode.intValue == NativeTouchOnly) return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only. if (touchMode == NativeTouchOnly) return; //This is a native touch oriented fork, in pure native touch mode, this call back method deals with native touch only.
for (UITouch* touch in touches) { for (UITouch* touch in touches) {
if (touch.type == UITouchTypePencil) { if (touch.type == UITouchTypePencil) {
[self touchesEnded:touches withEvent:event]; [self touchesEnded:touches withEvent:event];
@@ -1613,6 +1616,10 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
} }
- (void)toggleTouchDisabled:(bool)disabled{
touchHandler = disabled ? nil : sessionTouchHandler;
}
- (void)cleanUp{ - (void)cleanUp{
[keyInputField resignFirstResponder]; [keyInputField resignFirstResponder];
keyInputField.delegate = nil; keyInputField.delegate = nil;
@@ -617,6 +617,64 @@
} }
} }
}, },
"=DisableTouch" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "🚫 Touch"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "🚫 触摸"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "🚫 觸摸"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "🚫 觸摸"
}
}
}
},
"=EnableTouch" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "🟢 Touch"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "🟢 触摸"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "🟢 觸摸"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "🟢 觸摸"
}
}
}
},
"=gyroRsvpad" : { "=gyroRsvpad" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -1664,6 +1664,10 @@
} }
} }
- (void)toggleTouchWithDisabled:(BOOL)disabled{
[_streamView toggleTouchDisabled:disabled];
}
- (void)presentPressureCurveVC{ - (void)presentPressureCurveVC{
if(_oscProfile.pressureCurveEnabled){ if(_oscProfile.pressureCurveEnabled){
PressureCurveViewController* pressureCurveVC = [[PressureCurveViewController alloc] init]; PressureCurveViewController* pressureCurveVC = [[PressureCurveViewController alloc] init];