sensitivity & stick indicator settings in touchPad profile config

This commit is contained in:
TrueZhuangjia
2025-01-28 10:15:17 +08:00
parent 18fe545533
commit b7d8889180
8 changed files with 134 additions and 23 deletions
+19 -5
View File
@@ -870,24 +870,30 @@ ICAgICAgICAgICAgIA
<action selector="closeTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="U8V-Ry-ym9"/>
</connections>
</button>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="DGw-22-vUn" userLabel="Button Size Slider">
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="DGw-22-vUn" userLabel="Slider">
<rect key="frame" x="39" y="82" width="337" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="VLi-Mk-ESg" userLabel="Button Size Slider">
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.59999999999999998" maxValue="3.8999999999999999" id="VLi-Mk-ESg" userLabel="Slider">
<rect key="frame" x="39" y="117" width="337" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.83299999999999996" minValue="0.23000000000000001" maxValue="0.999" id="P6S-oW-Ewb" userLabel="Button Size Slider">
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.83299999999999996" minValue="0.23000000000000001" maxValue="0.999" id="P6S-oW-Ewb" userLabel="Slider">
<rect key="frame" x="39" y="152" width="337" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.83300000429153442" minValue="0.23000000417232513" maxValue="0.99900001287460327" id="QXI-Ex-JNV" userLabel="Slider">
<rect key="frame" x="39" y="187" width="337" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Profile:" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yJC-bq-EOU">
<rect key="frame" x="247" y="82" width="147" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -896,6 +902,12 @@ ICAgICAgICAgICAgIA
<color key="textColor" red="0.95132106540000005" green="0.97490358349999995" blue="0.99987185000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.83300000429153442" minValue="0.23000000417232513" maxValue="0.99900001287460327" id="OaL-Ph-J4n" userLabel="Slider">
<rect key="frame" x="39" y="222" width="337" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="secondaryLabelColor"/>
<color key="tintColor" red="0.6716768742" green="0.61711704730000005" blue="0.99902987480000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</slider>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@@ -910,6 +922,8 @@ ICAgICAgICAgICAgIA
<outlet property="chevronImageView" destination="76O-3K-aa8" id="yGv-fM-Ohf"/>
<outlet property="chevronView" destination="Zll-IP-PFt" id="MGR-C0-h57"/>
<outlet property="currentProfileLabel" destination="yJC-bq-EOU" id="6Sn-El-zPG"/>
<outlet property="sensitivityFactorSlider" destination="QXI-Ex-JNV" id="cH9-Ir-LIZ"/>
<outlet property="stickIndicatorOffsetSlider" destination="OaL-Ph-J4n" id="uF3-7W-mdG"/>
<outlet property="toolbarRootView" destination="Jnu-63-bcf" id="Y17-e2-18R"/>
<outlet property="toolbarStackView" destination="4he-pe-kYB" id="eVm-jM-dcv"/>
<outlet property="toolbarTopConstraintiPhone" destination="wNr-7F-S0i" id="iXe-d3-R7i"/>
@@ -997,13 +1011,13 @@ ICAgICAgICAgICAgIA
<image name="SquaresArrowUp" width="40" height="40"/>
<image name="Trash" width="40" height="40"/>
<systemColor name="secondaryLabelColor">
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="tintColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
@@ -290,6 +290,9 @@ static NSMutableDictionary *onScreenButtonViewsDict;
buttonState.widthFactor = buttonView.widthFactor;
buttonState.heightFactor = buttonView.heightFactor;
buttonState.backgroundAlpha = buttonView.backgroundAlpha;
buttonState.sensitivityFactor = buttonView.sensitivityFactor;
buttonState.stickIndicatorXOffset = buttonView.stickIndicatorXOffset;
NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil];
[buttonStatesEncoded addObject: buttonStateEncoded];
}];
@@ -27,7 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSTimeInterval timestamp;
@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat velocityFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat sensitivityFactor; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat stickIndicatorXOffset; // for OnScreenButtonView
@property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer
@property (nonatomic, assign) CGFloat backgroundAlpha; // for OnScreenController CALayer
@@ -35,7 +35,8 @@
[encoder encodeBool:self.isHidden forKey:@"isHidden"];
[encoder encodeFloat:self.widthFactor forKey:@"widthFactor"];
[encoder encodeFloat:self.heightFactor forKey:@"heightFactor"];
[encoder encodeFloat:self.velocityFactor forKey:@"velocityFactor"];
[encoder encodeFloat:self.sensitivityFactor forKey:@"velocityFactor"];
[encoder encodeFloat:self.stickIndicatorXOffset forKey:@"stickIndicatorOffset"];
[encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"];
[encoder encodeFloat:self.backgroundAlpha forKey:@"backgroundAlpha"];
}
@@ -50,7 +51,8 @@
self.isHidden = [decoder decodeBoolForKey:@"isHidden"];
self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"];
self.heightFactor = [decoder decodeFloatForKey:@"heightFactor"];
self.velocityFactor = [decoder decodeFloatForKey:@"velocityFactor"];
self.sensitivityFactor = [decoder decodeFloatForKey:@"velocityFactor"];
self.stickIndicatorXOffset = [decoder decodeFloatForKey:@"stickIndicatorOffset"];
self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"];
self.backgroundAlpha = [decoder decodeFloatForKey:@"backgroundAlpha"];
}
+13 -9
View File
@@ -120,6 +120,8 @@ import UIKit
self.mousePointerMoved = false
self.touchLockedForMoveEvent = UITouch()
self.twoTouchesDetected = false
self.stickIndicatorXOffset = 120
self.sensitivityFactor = 1.0
super.init(frame: .zero)
upIndicator = createLrudDirectionLayer()
@@ -305,7 +307,7 @@ import UIKit
// create stick indicator: the crossMark & stickBall:
@objc public func showStickIndicator(){
// tell if the self button is located on the left or right
self.selfViewOnTheRight = (self.storedLocation.x + self.frame.width/2 > self.appWindow.frame.width*0.5)
self.selfViewOnTheRight = (self.storedLocation.x > self.appWindow.frame.width*0.5)
let offsetSign = selfViewOnTheRight ? -1 : 1
let stickMarkerRelativeLocation:CGPoint
if !OnScreenButtonView.editMode {
@@ -356,7 +358,7 @@ import UIKit
let stickBallLayer = CAShapeLayer()
stickBallLayer.path = path.cgPath // Assign the circular path to the shape layer
self.layer.superlayer?.addSublayer(stickBallLayer)
stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame), CGRectGetMinY(self.crossMarkLayer.frame))
stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame), CGRectGetMidY(self.crossMarkLayer.frame))
// stickBallLayer.position = CG
@@ -373,18 +375,18 @@ import UIKit
return stickBallLayer
}
@objc public func updateStickBallPosition(){
@objc public func updateStickIndicator(){
CATransaction.begin()
CATransaction.setDisableActions(true)
self.stickBallLayer.removeAllAnimations()
if !OnScreenButtonView.editMode {
self.stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetX), CGRectGetMinY(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetY))
self.stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetX*sensitivityFactor), CGRectGetMidY(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetY*sensitivityFactor))
}
else{
// illustrate offset distance in edit mode
let offsetSign = self.selfViewOnTheRight ? -1 : 1
let illlustrationPoint = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMaxY(self.frame)/4)
self.stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame) + CGFloat(offsetSign) * stickIndicatorXOffset, CGRectGetMinY(self.crossMarkLayer.frame))
// let illlustrationPoint = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMaxY(self.frame)/4)
self.crossMarkLayer.position = CGPointMake(CGRectGetMidX(self.stickBallLayer.frame) + CGFloat(offsetSign) * stickIndicatorXOffset, CGRectGetMidY(self.stickBallLayer.frame))
}
CATransaction.commit()
}
@@ -816,10 +818,10 @@ import UIKit
break
case "LSPAD":
self.sendLeftStickTouchPadEvent(inputX: offSetX * sensitivityFactor, inputY: offSetY*sensitivityFactor)
updateStickBallPosition()
updateStickIndicator()
case "RSPAD":
self.sendRightStickTouchPadEvent(inputX: offSetX * sensitivityFactor, inputY: offSetY * sensitivityFactor);
updateStickBallPosition()
updateStickIndicator()
case "LSVPAD":
self.sendLeftStickTouchPadEvent(inputX: deltaX*1.5167*sensitivityFactor, inputY: deltaY*1.5167*sensitivityFactor)
case "RSVPAD":
@@ -942,7 +944,9 @@ import UIKit
if CommandManager.nonVectorStickPads.contains(self.keyString) {
self.crossMarkLayer.removeFromSuperlayer()
self.stickBallLayer.removeFromSuperlayer()
self.showStickIndicator()}
self.showStickIndicator()
self.updateStickIndicator()
}
}
}
}
+2
View File
@@ -401,6 +401,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
buttonView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
buttonView.widthFactor = buttonState.widthFactor;
buttonView.heightFactor = buttonState.heightFactor;
buttonView.sensitivityFactor = buttonState.sensitivityFactor;
buttonView.stickIndicatorXOffset = buttonState.stickIndicatorXOffset;
// Add the buttonView to the view controller's view
[self->streamFrameTopLayerView addSubview:buttonView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
[buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
@@ -191,6 +191,29 @@
}
}
},
"Ball: assumed touch point. Cross: indicator location" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "小球: 假定的触点 十字: 指示器偏离位置"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "灵敏度: %.2f"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "小球: 假定的触点 十字: 指示器偏离位置"
}
}
}
},
"Bitrate: %.1f Mbps" : {
"extractionState" : "manual",
"localizations" : {
@@ -962,6 +985,29 @@
}
}
},
"Indicator Offset: %.2f" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "指示器偏离: %.2f"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "小球: 假定的触点 十字: 指示器偏离位置"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "指示器偏离: %.2f"
}
}
}
},
"Key label (optional)" : {
"extractionState" : "manual",
"localizations" : {
@@ -2102,6 +2148,29 @@
}
}
},
"Sensitivity: %.2f" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "灵敏度: %.2f"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "指示器偏离: %.2f"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "灵敏度: %.2f"
}
}
}
},
"Set PC/Game resolution:" : {
"extractionState" : "manual",
"localizations" : {
@@ -47,6 +47,10 @@
- (void) viewWillDisappear:(BOOL)animated{
OnScreenButtonView.editMode = false;
for (OnScreenButtonView* buttonView in self.onScreenButtonViewsDict.allValues){
[buttonView.stickBallLayer removeFromSuperlayer];
[buttonView.crossMarkLayer removeFromSuperlayer];
}
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] postNotificationName:@"OscLayoutCloseNotification" object:self];
}
@@ -74,6 +78,8 @@
buttonView.timestamp = buttonState.timestamp; // will be set as key in in the dict.
buttonView.widthFactor = buttonState.widthFactor;
buttonView.heightFactor = buttonState.heightFactor;
buttonView.sensitivityFactor = buttonState.sensitivityFactor;
buttonView.stickIndicatorXOffset = buttonState.stickIndicatorXOffset;
// buttonView.backgroundAlpha = buttonState.backgroundAlpha;
// Add the buttonView to the view controller's view
[self.view addSubview:buttonView];
@@ -143,7 +149,7 @@
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(buttonViewSelected:)
selector:@selector(buttonViewTapped:)
name:@"OnScreenButtonViewSelected"
object:nil];
@@ -380,7 +386,7 @@
}
}
- (void)buttonViewSelected: (NSNotification *)notification{
- (void)buttonViewTapped: (NSNotification *)notification{
// receive the selected buttonView obj passed from the notification
OnScreenButtonView* buttonView = (OnScreenButtonView* )notification.object;
self->buttonViewSelected = true;
@@ -406,7 +412,9 @@
[selectedButtonView.crossMarkLayer removeFromSuperlayer];
selectedButtonView.touchBeganLocation = CGPointMake(CGRectGetWidth(selectedButtonView.frame)/2, CGRectGetHeight(selectedButtonView.frame)/4);
[selectedButtonView showStickIndicator];// this will create the indicator CAShapeLayers
[stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f \n", self->selectedButtonView.stickIndicatorXOffset]];
[self.stickIndicatorOffsetSlider setValue:self->selectedButtonView.stickIndicatorXOffset];
[stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f", self->selectedButtonView.stickIndicatorXOffset]];
[self->selectedButtonView updateStickIndicator];
}
[widgetSizeSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Size: %.2f", self->selectedButtonView.widthFactor]];
[widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self->selectedButtonView.heightFactor]];
@@ -417,6 +425,12 @@
// receive the selected buttonView obj passed from the notification
CALayer* controllerLayer = (CALayer* )notification.object;
self->buttonViewSelected = false;
self->stickIndicatorOffsetExplain.hidden = true;
self->stickIndicatorOffsetSliderLabel.hidden = true;
self.stickIndicatorOffsetSlider.hidden = true;
self->sensitivitySliderLabel.hidden = true;
self.sensitivityFactorSlider.hidden = true;
self->controllerLayerSelected = true;
self->selectedControllerLayer = controllerLayer;
self->controllerLoadedBounds = controllerLayer.bounds;
@@ -480,7 +494,7 @@
[stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f", self.stickIndicatorOffsetSlider.value]];
if(self->selectedButtonView != nil && self->buttonViewSelected){
self->selectedButtonView.stickIndicatorXOffset = self.stickIndicatorOffsetSlider.value;
[self->selectedButtonView updateStickBallPosition];
[self->selectedButtonView updateStickIndicator];
}
return;
}
@@ -569,7 +583,7 @@
widgetAlphaSliderLabel.hidden = NO;
// sensivity slider
// sensitivity slider
self.sensitivityFactorSlider.hidden = YES;
self.sensitivityFactorSlider.frame = CGRectMake(sliderXPosition, self.sensitivityFactorSlider.frame.origin.y, self.sensitivityFactorSlider.frame.size.width, self.sensitivityFactorSlider.frame.size.height);
[self.sensitivityFactorSlider addTarget:self action:@selector(sensitivitySliderMoved) forControlEvents:(UIControlEventValueChanged)];
@@ -599,7 +613,7 @@
stickIndicatorOffsetSliderLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
stickIndicatorOffsetSliderLabel.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for Auto Layout
// tips for stick indicator
stickIndicatorOffsetExplain.text = [LocalizationHelper localizedStringForKey:@"Cross: assumed touch point. Ball: indicator location"];
stickIndicatorOffsetExplain.text = [LocalizationHelper localizedStringForKey:@"Ball: assumed touch point. Cross: indicator location"];
//stickIndicatorOffsetExplain.frame = CGRectMake(sliderXPosition, self.stickIndicatorOffsetSlider.frame.origin.y + self.stickIndicatorOffsetSlider.frame.size.height, self.stickIndicatorOffsetSlider.frame.size.width, self.stickIndicatorOffsetSlider.frame.size.height); // label bigger show some tips
stickIndicatorOffsetExplain.font = [UIFont systemFontOfSize:18];
stickIndicatorOffsetExplain.textColor = [UIColor whiteColor];
@@ -750,6 +764,8 @@
if([self touchWithinTashcanButton:touch]){
[self.onScreenButtonViewsDict[@(OnScreenButtonView.timestampOfButtonBeingDragged)] removeFromSuperview];
[self.onScreenButtonViewsDict removeObjectForKey:@(OnScreenButtonView.timestampOfButtonBeingDragged)];
[selectedButtonView.stickBallLayer removeFromSuperlayer];
[selectedButtonView.crossMarkLayer removeFromSuperlayer];
OnScreenButtonView.timestampOfButtonBeingDragged = 0; //reset thie timestamp
}