synthesize physical stick input switch for built-in gyro motion control

This commit is contained in:
TrueZhuanjia
2025-11-26 16:41:08 +08:00
parent 379d965769
commit 1338b4fb85
9 changed files with 125 additions and 7 deletions
+22
View File
@@ -1782,6 +1782,26 @@
<constraint firstAttribute="width" constant="380" id="qOk-ee-a8A"/>
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="1yf-rP-jgt">
<rect key="frame" x="22" y="3254" width="346" height="31"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Synth Physical Stick Input" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.64999997615814209" adjustsLetterSpacingToFitWidth="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uFg-dv-6nT" userLabel="uiLabel">
<rect key="frame" x="0.0" y="0.0" width="196" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ixf-14-Du8">
<rect key="frame" x="216" y="0.0" width="132" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="130" id="Nie-vj-Gbe"/>
</constraints>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="31" id="5sn-ce-tev"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
@@ -1927,6 +1947,8 @@
<outlet property="statsOverlayStack" destination="UcP-0b-nJD" id="UdI-NS-O6k"/>
<outlet property="swapAbxyStack" destination="2rP-Ui-wVU" id="gUR-Vz-ORP"/>
<outlet property="swapAbxySwitch" destination="hv7-6b-rez" id="iKX-qk-Dep"/>
<outlet property="synthPhysicalInputStack" destination="1yf-rP-jgt" id="Mbn-eV-j3G"/>
<outlet property="synthPhysicalInputSwitch" destination="Ixf-14-Du8" id="wgc-mg-oGN"/>
<outlet property="testStack" destination="aP7-M9-psT" id="xAv-s6-rea"/>
<outlet property="touchModeLabel" destination="MUY-2Y-bHi" id="6jD-aq-rmE"/>
<outlet property="touchModeSelector1" destination="bhC-da-VGd" id="hna-Cr-kyd"/>
+22
View File
@@ -2615,6 +2615,26 @@
<constraint firstAttribute="height" constant="56.5" id="MNC-Cn-lnb"/>
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="gkU-Rq-gB0">
<rect key="frame" x="20" y="2862" width="346" height="31"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Synth Physical Stick Input" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.64999997615814209" adjustsLetterSpacingToFitWidth="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Bx3-CM-wet" userLabel="uiLabel">
<rect key="frame" x="0.0" y="0.0" width="196" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HUF-g8-GD3">
<rect key="frame" x="216" y="0.0" width="132" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="130" id="b8v-mZ-1xt"/>
</constraints>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="31" id="JWd-0U-BlR"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
@@ -2759,6 +2779,8 @@
<outlet property="statsOverlayStack" destination="dby-k3-aiH" id="1Ha-Y3-su4"/>
<outlet property="swapAbxyStack" destination="reE-vr-Mdk" id="y3v-ac-LHy"/>
<outlet property="swapAbxySwitch" destination="T5q-1k-zB3" id="153-6O-0Pv"/>
<outlet property="synthPhysicalInputStack" destination="gkU-Rq-gB0" id="GtQ-CM-8Qh"/>
<outlet property="synthPhysicalInputSwitch" destination="HUF-g8-GD3" id="z9c-dX-eqQ"/>
<outlet property="touchModeLabel" destination="v5B-5J-veL" id="ewI-fd-FnI"/>
<outlet property="touchModeSelector1" destination="A9r-dE-rT4" id="DBR-8D-QTL"/>
<outlet property="touchModeSelector2" destination="n8C-pt-nPE" id="N2Y-O4-zK6"/>
+1
View File
@@ -34,6 +34,7 @@ typedef NS_ENUM(NSInteger, MapGyroTo) {
@property (nonatomic, assign) MapGyroTo mapGyroTo;
@property (nonatomic, assign) bool yawPitchToRightStick;
@property (nonatomic, assign) bool rollToLeftStick;
@property (nonatomic, assign) bool synthesizePhysicalStick;
@property (nonatomic, assign) CGFloat gyroSensitivityYaw;
@property (nonatomic, assign) CGFloat gyroSensitivityPitch;
@property (nonatomic, assign) CGFloat gyroSensitivityRoll;
+3
View File
@@ -34,6 +34,7 @@
[encoder encodeInt64:self.mapGyroTo forKey:@"mapGyroTo"];
[encoder encodeBool:self.yawPitchToRightStick forKey:@"yawPitchToRightStick"];
[encoder encodeBool:self.rollToLeftStick forKey:@"rollToLeftStick"];
[encoder encodeBool:self.synthesizePhysicalStick forKey:@"synthesizePhysicalStick"];
[encoder encodeInt64:self.mapGyroTo forKey:@"mapGyroTo"];
[encoder encodeFloat:self.gyroSensitivityYaw forKey:@"gyroSensitivityYaw"];
[encoder encodeFloat:self.gyroSensitivityPitch forKey:@"gyroSensitivityPitch"];
@@ -52,6 +53,7 @@
self.mapGyroTo = [decoder containsValueForKey:@"mapGyroTo"] ? [decoder decodeInt64ForKey:@"mapGyroTo"] : mapGyroToMouse;
self.yawPitchToRightStick = [decoder containsValueForKey:@"yawPitchToRightStick"] ? [decoder decodeBoolForKey:@"yawPitchToRightStick"] : true;
self.rollToLeftStick = [decoder containsValueForKey:@"rollToLeftStick"] ? [decoder decodeBoolForKey:@"rollToLeftStick"] : false;
self.synthesizePhysicalStick = [decoder containsValueForKey:@"synthesizePhysicalStick"] ? [decoder decodeBoolForKey:@"synthesizePhysicalStick"] : true;
self.gyroSensitivityYaw = [decoder containsValueForKey:@"gyroSensitivityYaw"] ? [decoder decodeFloatForKey:@"gyroSensitivityYaw"] : 1.0;
self.gyroSensitivityPitch = [decoder containsValueForKey:@"gyroSensitivityPitch"] ? [decoder decodeFloatForKey:@"gyroSensitivityPitch"] : 1.0;
self.gyroSensitivityRoll = [decoder containsValueForKey:@"gyroSensitivityRoll"] ? [decoder decodeFloatForKey:@"gyroSensitivityRoll"] : 1.0;
@@ -72,6 +74,7 @@
copy.mapGyroTo = self.mapGyroTo;
copy.yawPitchToRightStick = self.yawPitchToRightStick;
copy.rollToLeftStick = self.rollToLeftStick;
copy.synthesizePhysicalStick = self.synthesizePhysicalStick;
copy.gyroSensitivityYaw = self.gyroSensitivityYaw;
copy.gyroSensitivityPitch = self.gyroSensitivityPitch;
copy.gyroSensitivityRoll = self.gyroSensitivityRoll;
+4 -4
View File
@@ -28,14 +28,14 @@ import CoreMotion
}
@objc public func mixPhysicalRightStickAndGyroInput(x: CGFloat, y: CGFloat) {
rightStickPhysicalInputX = x
rightStickPhysicalInputY = y
rightStickPhysicalInputX = oscProfile.synthesizePhysicalStick ? x : 0
rightStickPhysicalInputY = oscProfile.synthesizePhysicalStick ? y : 0
}
@objc public func mixPhysicalLeftStickAndGyroInput(x: CGFloat, y: CGFloat) {
// rollIntegral = 0
leftStickPhysicalInputX = x
leftStickPhysicalInputY = y
leftStickPhysicalInputX = oscProfile.synthesizePhysicalStick ? x : 0
leftStickPhysicalInputY = oscProfile.synthesizePhysicalStick ? y : 0
}
public func gyroMixInputStarted() -> Bool {
@@ -226,6 +226,8 @@
@property (strong, nonatomic) IBOutlet UIStackView *controllerGyroSwitchButtonStack;
@property (strong, nonatomic) IBOutlet UISegmentedControl *controllerGyroSwitchButtonSetter;
@property (strong, nonatomic) IBOutlet UIStackView *synthPhysicalInputStack;
@property (strong, nonatomic) IBOutlet UISwitch *synthPhysicalInputSwitch;
@property (strong, nonatomic) IBOutlet UIStackView *testStack;
@@ -373,6 +373,8 @@ BOOL isCustomResolution(int resolutionSelected) {
[self rollSensitivitySliderMoved:self.rollSensitivitySlider];
[self.gyroToStickMinOffsetSlider setValue:(uint16_t)oscProfile.gyroToStickMinOffset];
[self gyroMinStickOffsetSliderMoved:self.gyroToStickMinOffsetSlider];
[self.synthPhysicalInputSwitch setOn:oscProfile.synthesizePhysicalStick];
}
- (void)saveMotionControlConfigs{
@@ -387,7 +389,9 @@ BOOL isCustomResolution(int resolutionSelected) {
&& (int16_t)(oscProfile.gyroSensitivityYaw*100) == (int16_t)yawSensitivityPercent
&& (int16_t)(oscProfile.gyroSensitivityPitch*100) == (int16_t)pitchSensitivityPercent
&& (int16_t)(oscProfile.gyroSensitivityRoll*100) == (int16_t)rollSensitivityPercent
&& (int16_t)(oscProfile.gyroToStickMinOffset) == (int16_t)self.gyroToStickMinOffsetSlider.value);
&& (int16_t)(oscProfile.gyroToStickMinOffset) == (int16_t)self.gyroToStickMinOffsetSlider.value
&& oscProfile.synthesizePhysicalStick == self.synthPhysicalInputSwitch.isOn
);
if(!configNotChanged){
oscProfile.mapGyroTo = self.mapGyroToSelector.selectedSegmentIndex;
@@ -397,6 +401,7 @@ BOOL isCustomResolution(int resolutionSelected) {
oscProfile.gyroSensitivityPitch = pitchSensitivityPercent/100;
oscProfile.gyroSensitivityRoll = rollSensitivityPercent/100;
oscProfile.gyroToStickMinOffset = (int16_t)self.gyroToStickMinOffsetSlider.value;
oscProfile.synthesizePhysicalStick = self.synthPhysicalInputSwitch.isOn;
[oscProfileMan replaceSelectedProfileWith:oscProfile overwriteDefault:YES];
}
}
@@ -784,6 +789,7 @@ BOOL isCustomResolution(int resolutionSelected) {
[self addDynamicLabelForStack:self.pitchSensitivityStack];
[self addSetting:self.rollSensitivityStack ofId:@"rollSensitivityStack" withInfoTag:NO withDynamicLabel:YES to:motionControlSection];
[self addSetting:self.gyroToStickMinOffsetStack ofId:@"gyroToStickMinOffsetStack" withInfoTag:NO withDynamicLabel:YES to:motionControlSection];
[self addSetting:self.synthPhysicalInputStack ofId:@"synthPhysicalInputStack" withInfoTag:NO withDynamicLabel:NO to:motionControlSection];
[motionControlSection addToParentStack:_parentStack];
MenuSectionView *gesturesSection = [[MenuSectionView alloc] init];
@@ -2209,15 +2215,17 @@ BOOL isCustomResolution(int resolutionSelected) {
}
- (void)mapGyroToChanged:(UISegmentedControl* )sender{
[self setHidden:sender.selectedSegmentIndex != mapGyroToControllerStick forStack:_gyroToStickSwitchStack];
// [self setHidden:sender.selectedSegmentIndex != mapGyroToControllerStick forStack:_gyroToStickSwitchStack];
bool mapGyroToMouseEnabled = sender.selectedSegmentIndex == mapGyroToMouse;
bool mapGyroToControllerStickEnabled = sender.selectedSegmentIndex == mapGyroToControllerStick;
if(mapGyroToMouseEnabled){
[self setHidden:false forStack:_yawPitchSensitivityStack];
[self setHidden:true forStack:_rollSensitivityStack];
}
[self setHidden:!mapGyroToControllerStickEnabled forStack:_gyroToStickSwitchStack];
[self setHidden:!mapGyroToControllerStickEnabled forStack:self.gyroToStickMinOffsetStack];
[self setHidden:!mapGyroToControllerStickEnabled forStack:self.synthPhysicalInputStack];
if(mapGyroToControllerStickEnabled){
[self yawPitchToRightStickSwitchFlipped:self.yawPitchToRightStickSwitch];
[self rollToLeftStickSwitchFlipped:self.rollToLeftStickSwitch];
+30
View File
@@ -4873,6 +4873,36 @@
}
}
},
"uFg-dv-6nT.text" : {
"comment" : "Class = \"UILabel\"; text = \"Synth Physical Stick Input\"; ObjectID = \"uFg-dv-6nT\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Synth Physical Stick Input"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成实体摇杆输入"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成實體搖桿輸入"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成實體搖桿輸入"
}
}
}
},
"v8l-hf-kiR.text" : {
"comment" : "Class = \"UILabel\"; text = \"Rendering Mode (Experimental)\"; ObjectID = \"v8l-hf-kiR\";",
"extractionState" : "extracted_with_value",
+30
View File
@@ -1513,6 +1513,36 @@
}
}
},
"Bx3-CM-wet.text" : {
"comment" : "Class = \"UILabel\"; text = \"Synth Physical Stick Input\"; ObjectID = \"Bx3-CM-wet\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Synth Physical Stick Input"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成实体摇杆输入"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成實體搖桿輸入"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "合成實體搖桿輸入"
}
}
}
},
"C9B-Rx-YCP.text" : {
"comment" : "Class = \"UILabel\"; text = \"Physical Mouse Wheel Scroll\"; ObjectID = \"C9B-Rx-YCP\";",
"extractionState" : "extracted_with_value",