- tweak widget templates

- minor improvements & fixes
This commit is contained in:
True Zhuanjia committed 2026-06-08 01:16:00 +08:00
1 parent becfc596c1
commit 1a719e11e6
9 files changed
+136 -22

No files matched your search

+37 -10
View File
@@ -400,6 +400,7 @@ import ObjectiveC.runtime
@objc private(set) var firstTouchMoved: Bool = false
private var mousePointerMoved: Bool
private var twoTouchesDetected: Bool
private var scrollEventSent: Bool = false
private var allSpawnedTouchesCount: Int = 0
// trackball
@@ -681,6 +682,10 @@ import ObjectiveC.runtime
self.isMagnifier = self.cmdString.contains("MAGNIFIER")
self.hasAnchorMode = isDisplacementBasedStickPad || isDirectionPad
self.isMultipleTouchEnabled = self.widgetType == WidgetTypeEnum.button
|| CommandManager.mousePadWithButtonActions.contains(self.touchPadString)
|| self.touchPadString == "MAGNIFIER"
}
// ======================================================================================================
@@ -1062,7 +1067,7 @@ import ObjectiveC.runtime
}
let attr = NSAttributedString(
string: self.folded ? "[\(text)]" : (self.isFolder ? " 🟡 \(text)" : "\(text)"),
string: (self.isFolder && self.folded) ? "[\(text)]" : (self.isFolder ? " 🟡 \(text)" : "\(text)"),
attributes: [
.foregroundColor: UIColor(white:labelAlpha>0 ? 1.0 : 0, alpha: abs(labelAlpha)), // 填充色
.strokeColor: (labelAlpha>0 ? UIColor.black : UIColor.white).withAlphaComponent(abs(labelAlpha)*0.43), // 描边色
@@ -2060,14 +2065,11 @@ import ObjectiveC.runtime
self.touchBegan = true
self.directionPadTouchBegan = true
self.firstTouchMoved = false
self.scrollEventSent = false
self.tickFlag = 0
// super.touchesBegan(touches, with: event)
if OnScreenWidgetView.editMode {self.parentViewController?.touchesBegan(touches, with: event)}
self.isMultipleTouchEnabled = self.widgetType == WidgetTypeEnum.button
|| CommandManager.mousePadWithButtonActions.contains(self.touchPadString)
|| self.touchPadString == "MAGNIFIER"
if !OnScreenWidgetView.editMode && self.touchPadString == "TRACKBALL" {
stopTrackballMomentum()
}
@@ -2553,14 +2555,15 @@ import ObjectiveC.runtime
private func handleTouchPadMoveEvent (_ touches: Set<UITouch>, with event: UIEvent?){
guard let touch = touches.first else { return }
if touches.count == 1{ // don't use event.alltouches.count here, it will counts all touches
let activeTouchesCount = UITouchUtil.touches(in: self, from: event).count
if activeTouchesCount == 1 { // don't use event.alltouches.count here, it will counts all touches
self.getVector(touch: touch)
switch self.touchPadString{
case "MOUSEPAD":
DispatchQueue.global(qos: .userInteractive).async {
self.weightedDeltaX = Int(self.deltaX * 1.7 * self.sensitivityFactorX)
self.weightedDeltaY = Int(self.deltaY * 1.7 * self.sensitivityFactorY)
if self.firstTouchMoved {LiSendMouseMoveEvent(Int16(self.weightedDeltaX), Int16(self.weightedDeltaY))}
if self.firstTouchMoved, !self.scrollEventSent {LiSendMouseMoveEvent(Int16(self.weightedDeltaX), Int16(self.weightedDeltaY))}
self.updateTouchLocation(touch: touch)
}
break
@@ -2672,6 +2675,25 @@ import ObjectiveC.runtime
break
}
}
if activeTouchesCount == 2 {
self.getVector(touch: touch)
switch self.touchPadString{
case "MOUSEPAD":
if self.mouseButtonAction == .hovering, firstTouchMoved {
mousePointerMoved = false
let touchesArr = Array(touches)
let vector = UITouchUtil.midPointVector(between: touchesArr.first, and: touchesArr.last, in: self)
self.scrollEventSent = true
if abs(vector.dx) > 1.2*abs(vector.dy) {
LiSendHighResHScrollEvent(-Int16(vector.dx*5))
}
else {
LiSendHighResScrollEvent(Int16(vector.dy*5))
}
}
default: break
}
}
if self.widgetType == WidgetTypeEnum.touchPad && self.touchPadString == "DS4TOUCH" {
self.handleControllerTouchesMove(touches: touches)
}
@@ -3029,12 +3051,15 @@ import ObjectiveC.runtime
if !OnScreenWidgetView.editMode && self.widgetType == WidgetTypeEnum.touchPad && CommandManager.mousePadWithButtonActions.contains(self.touchPadString) && allSpawnedTouchesCount == 1 && !twoTouchesDetected {
self.handleMousePadButtonActionUp()
}
if !OnScreenWidgetView.editMode && self.widgetType == WidgetTypeEnum.touchPad && CommandManager.mousePadWithButtonActions.contains(self.touchPadString) && twoTouchesDetected && touches.count == allSpawnedTouchesCount { // need to enable multi-touch first
// touches.count == allCapturedTouchesCount means allfingers are lifting
if(self.mouseButtonAction == MouseButtonAction.hovering) {self.sendMouseRightButtonClickEvent()}
twoTouchesDetected = false
if self.mouseButtonAction == MouseButtonAction.hovering, !scrollEventSent {self.sendMouseRightButtonClickEvent()}
}
if touches.count == allSpawnedTouchesCount {
firstTouchMoved = false
twoTouchesDetected = false
scrollEventSent = false
twoTouchesDetected = false
}
// then other types of pads or buttons with touchPad function
@@ -3279,10 +3304,12 @@ import ObjectiveC.runtime
if OnScreenWidgetView.capturer == nil, OnScreenWidgetView.editMode {
if OnScreenWidgetView.isVerticallyAligned {
self.center = CGPoint(x:OnScreenWidgetView.alignedX, y:self.center.y)
self.storedCenter = self.center
OnScreenWidgetView.isVerticallyAligned = false
}
if OnScreenWidgetView.isHorizontallyAligned {
self.center = CGPoint(x:self.center.x, y:OnScreenWidgetView.alignedY)
self.storedCenter = self.center
OnScreenWidgetView.isHorizontallyAligned = false
}
}