diff --git a/VoidLink/Base.lproj/iPad.storyboard b/VoidLink/Base.lproj/iPad.storyboard index ce88d87c..29cd4572 100644 --- a/VoidLink/Base.lproj/iPad.storyboard +++ b/VoidLink/Base.lproj/iPad.storyboard @@ -1023,13 +1023,13 @@ - + + + + + + + + + + + + + + + @@ -1919,6 +1939,8 @@ + + @@ -2782,7 +2804,7 @@ - + @@ -2791,13 +2813,13 @@ - + - + - + diff --git a/VoidLink/Base.lproj/iPhone.storyboard b/VoidLink/Base.lproj/iPhone.storyboard index 52dcad90..edbf6356 100644 --- a/VoidLink/Base.lproj/iPhone.storyboard +++ b/VoidLink/Base.lproj/iPhone.storyboard @@ -2036,13 +2036,13 @@ - + + + + + + + + + + + + + + + @@ -2751,6 +2771,8 @@ + + diff --git a/VoidLink/Database/DataManager.m b/VoidLink/Database/DataManager.m index 87e47fbb..404f675d 100644 --- a/VoidLink/Database/DataManager.m +++ b/VoidLink/Database/DataManager.m @@ -197,7 +197,6 @@ settingsToSave.mapControllerToMouse = mapControllerToMouse; settingsToSave.controllerMousePointerVelocity = [NSNumber numberWithFloat:controllerMousePointerVelocity]; settingsToSave.controllerMouseExpo = [NSNumber numberWithFloat:controllerMouseExpo]; - settingsToSave.controllerGyroSwitchMode = [NSNumber numberWithInteger:controllerGyroSwitchMode]; settingsToSave.rememberFoldState = rememberFoldState; [self saveData]; }]; diff --git a/VoidLink/Database/TemporarySettings.h b/VoidLink/Database/TemporarySettings.h index 86a8cd0d..3cb49b8e 100644 --- a/VoidLink/Database/TemporarySettings.h +++ b/VoidLink/Database/TemporarySettings.h @@ -102,9 +102,6 @@ @property (nonatomic) BOOL mapControllerToMouse; @property (nonatomic, retain) NSNumber * controllerMousePointerVelocity; @property (nonatomic, retain) NSNumber * controllerMouseExpo; -@property (nonatomic, retain) NSNumber * controllerGyroSwitchToggle; -@property (nonatomic, retain) NSNumber * controllerGyroSwitchHold; -@property (nonatomic, retain) NSNumber * controllerGyroSwitchMode; - (id) initFromSettings:(Settings*)settings; diff --git a/VoidLink/Database/TemporarySettings.m b/VoidLink/Database/TemporarySettings.m index 79e4dc42..2ba9712d 100644 --- a/VoidLink/Database/TemporarySettings.m +++ b/VoidLink/Database/TemporarySettings.m @@ -158,9 +158,6 @@ self.controllerMouseStick = settings.controllerMouseStick; self.controllerMousePointerVelocity = settings.controllerMousePointerVelocity; self.controllerMouseExpo = settings.controllerMouseExpo; - self.controllerGyroSwitchToggle = settings.controllerGyroSwitchToggle; - self.controllerGyroSwitchHold = settings.controllerGyroSwitchHold; - self.controllerGyroSwitchMode = settings.controllerGyroSwitchMode; #endif diff --git a/VoidLink/Input/ControllerSupport.m b/VoidLink/Input/ControllerSupport.m index 3453b306..31572b37 100644 --- a/VoidLink/Input/ControllerSupport.m +++ b/VoidLink/Input/ControllerSupport.m @@ -86,10 +86,11 @@ static const double MOUSE_SPEED_DIVISOR = 1.25; CGFloat _gyroSensitivity; bool _captureMouse; - bool _startGyroByController; + bool _controllerGyroSwitchEnabled; bool _gyroEnabledFlag; int _controllerGyroSwitchToggle; int _controllerGyroSwitchHold; + bool _reverseHoldButton; bool _controllerGyroSwitchTogglePressed; bool _controllerGyroSwitchHoldPressed; ControllerGyroSwitchMode _gyroSwitchMode; @@ -1047,6 +1048,15 @@ double rc_expo(double x, double expo) { ||self->tempSettings.gyroMode.intValue==GyroModeOff; } +- (void)switchGyroOnOffByControllerButton{ + self->_gyroEnabledFlag = self->_gyroEnabledFlag && self->_controllerGyroSwitchEnabled; + if([self useMotionHandler]){ + if(self->_gyroEnabledFlag) [self->motionHandler startGyroByControllerButton]; + else [self->motionHandler stopGyroUpdateWithInterruptNoneGyroInput:false resetLeftStick:true]; + } + else self->_gyroEnabledFlag = self->_gyroEnabledFlag || !self->_controllerGyroSwitchEnabled; +} + -(void) registerControllerCallbacks:(GCController*) controller { if (controller != NULL) { @@ -1157,24 +1167,22 @@ double rc_expo(double x, double expo) { } else self->_controllerMouseEnabledFlag = false; - if(self->_startGyroByController){ + // controller switch buttons + if(true){ if(button.pressed){ if (buttonFlagId.intValue == self->_controllerGyroSwitchToggle && !self->_controllerGyroSwitchTogglePressed) { self->_controllerGyroSwitchTogglePressed = true; + self->_gyroEnabledFlag = !self->_gyroEnabledFlag; - self->_gyroEnabledFlag = self->_gyroEnabledFlag && self->_gyroSwitchMode != ControllerGyroSwitchDisabled; - if([self useMotionHandler]){ - if(self->_gyroEnabledFlag) [self->motionHandler startGyroByControllerButton]; - else [self->motionHandler stopGyroUpdateWithInterruptNoneGyroInput:false resetLeftStick:true]; - } + [self switchGyroOnOffByControllerButton]; } if (buttonFlagId.intValue == self->_controllerGyroSwitchHold && !self->_controllerGyroSwitchHoldPressed) { self->_controllerGyroSwitchHoldPressed = true; - self->_gyroEnabledFlag = true; - self->_gyroEnabledFlag = self->_gyroEnabledFlag && self->_gyroSwitchMode != ControllerGyroSwitchDisabled; - if([self useMotionHandler] && self->_gyroEnabledFlag) [self->motionHandler startGyroByControllerButton]; + + self->_gyroEnabledFlag = !self->_reverseHoldButton; + [self switchGyroOnOffByControllerButton]; } } else{ @@ -1185,8 +1193,9 @@ double rc_expo(double x, double expo) { if (buttonFlagId.intValue == self->_controllerGyroSwitchHold && self->_controllerGyroSwitchHoldPressed) { self->_controllerGyroSwitchHoldPressed = false; - self->_gyroEnabledFlag = false; - if([self useMotionHandler]) [self->motionHandler stopGyroUpdateWithInterruptNoneGyroInput:false resetLeftStick:true]; + + self->_gyroEnabledFlag = self->_reverseHoldButton; + [self switchGyroOnOffByControllerButton]; } } } @@ -1733,13 +1742,16 @@ double rc_expo(double x, double expo) { [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; } - _startGyroByController = true; - _gyroSwitchMode = tempSettings.controllerGyroSwitchMode.intValue; + _controllerGyroSwitchEnabled = oscProfile.controllerGyroSwitchMode != ControllerGyroSwitchDisabled; + _gyroSwitchMode = oscProfile.controllerGyroSwitchMode; // _gyroSwitchMode = ControllerGyroSwitchHoldDownToActivate; - _controllerGyroSwitchToggle = tempSettings.controllerGyroSwitchToggle.intValue; - _controllerGyroSwitchHold = tempSettings.controllerGyroSwitchHold.intValue; + _controllerGyroSwitchToggle = oscProfile.controllerGyroSwitchToggle; + _controllerGyroSwitchHold = oscProfile.controllerGyroSwitchHold; + _reverseHoldButton = oscProfile.reverseGyroHoldButton; _controllerGyroSwitchTogglePressed = false; _controllerGyroSwitchHoldPressed = false; + + if(oscProfile.controllerGyroSwitchMode == ControllerGyroSwitchDisabled && ![self useMotionHandler]) _gyroEnabledFlag = true; if(![self useMotionHandler]) [self->motionHandler stopGyroUpdateWithInterruptNoneGyroInput:false resetLeftStick:true]; } diff --git a/VoidLink/Input/CustomOSC/OSCProfile.h b/VoidLink/Input/CustomOSC/OSCProfile.h index 1bfb780c..f394a190 100644 --- a/VoidLink/Input/CustomOSC/OSCProfile.h +++ b/VoidLink/Input/CustomOSC/OSCProfile.h @@ -42,6 +42,10 @@ typedef NS_ENUM(NSInteger, MapGyroTo) { @property (nonatomic, assign) CGFloat accelSensitivityY; @property (nonatomic, assign) CGFloat accelSensitivityZ; @property (nonatomic, assign) double gyroToStickMinOffset; +@property (nonatomic, assign) int controllerGyroSwitchMode; +@property (nonatomic, assign) bool reverseGyroHoldButton; +@property (nonatomic, assign) int controllerGyroSwitchHold; +@property (nonatomic, assign) int controllerGyroSwitchToggle; - (id) initWithName:(NSString*)name buttonStates:(NSMutableArray*)buttonStates isSelected:(BOOL)isSelected; diff --git a/VoidLink/Input/CustomOSC/OSCProfile.m b/VoidLink/Input/CustomOSC/OSCProfile.m index 8fb8ee31..1a25c9f9 100644 --- a/VoidLink/Input/CustomOSC/OSCProfile.m +++ b/VoidLink/Input/CustomOSC/OSCProfile.m @@ -10,6 +10,7 @@ // #import "OSCProfile.h" +#import "VoidLink-Swift.h" @implementation OSCProfile @@ -43,6 +44,10 @@ [encoder encodeFloat:self.accelSensitivityY forKey:@"accelSensitivityY"]; [encoder encodeFloat:self.accelSensitivityZ forKey:@"accelSensitivityZ"]; [encoder encodeDouble:self.gyroToStickMinOffset forKey:@"gyroToStickMinOffset"]; + [encoder encodeInt:self.controllerGyroSwitchMode forKey:@"controllerGyroSwitchMode"]; + [encoder encodeBool:self.reverseGyroHoldButton forKey:@"reverseGyroHoldButton"]; + [encoder encodeInt:self.controllerGyroSwitchHold forKey:@"controllerGyroSwitchHold"]; + [encoder encodeInt:self.controllerGyroSwitchToggle forKey:@"controllerGyroSwitchToggle"]; } - (id) initWithCoder:(NSCoder*)decoder { @@ -61,6 +66,10 @@ self.accelSensitivityY = [decoder containsValueForKey:@"accelSensitivityY"] ? [decoder decodeFloatForKey:@"accelSensitivityY"] : 1.0; self.accelSensitivityZ = [decoder containsValueForKey:@"accelSensitivityZ"] ? [decoder decodeFloatForKey:@"accelSensitivityZ"] : 1.0; self.gyroToStickMinOffset = [decoder containsValueForKey:@"gyroToStickMinOffset"] ? [decoder decodeDoubleForKey:@"gyroToStickMinOffset"] : 0; + self.controllerGyroSwitchMode = [decoder containsValueForKey:@"controllerGyroSwitchMode"] ? [decoder decodeIntForKey:@"controllerGyroSwitchMode"] : ControllerGyroSwitchDisabled; + self.reverseGyroHoldButton = [decoder containsValueForKey:@"reverseGyroHoldButton"] ? [decoder decodeBoolForKey:@"reverseGyroHoldButton"] : false; + self.controllerGyroSwitchHold = [decoder containsValueForKey:@"controllerGyroSwitchHold"] ? [decoder decodeIntForKey:@"controllerGyroSwitchHold"] : ControllerButtonNull; + self.controllerGyroSwitchToggle = [decoder containsValueForKey:@"controllerGyroSwitchToggle"] ? [decoder decodeIntForKey:@"controllerGyroSwitchToggle"] : ControllerButtonNull; } return self; @@ -82,6 +91,10 @@ copy.accelSensitivityY = self.accelSensitivityY; copy.accelSensitivityZ = self.accelSensitivityZ; copy.gyroToStickMinOffset = self.gyroToStickMinOffset; + copy.controllerGyroSwitchMode = self.controllerGyroSwitchMode; + copy.reverseGyroHoldButton = self.reverseGyroHoldButton; + copy.controllerGyroSwitchHold = self.controllerGyroSwitchHold; + copy.controllerGyroSwitchToggle = self.controllerGyroSwitchToggle; return copy; } diff --git a/VoidLink/Limelight.xcdatamodeld/VoidLink v1.0.xcdatamodel/contents b/VoidLink/Limelight.xcdatamodeld/VoidLink v1.0.xcdatamodel/contents index e97afbba..038aaa24 100644 --- a/VoidLink/Limelight.xcdatamodeld/VoidLink v1.0.xcdatamodel/contents +++ b/VoidLink/Limelight.xcdatamodeld/VoidLink v1.0.xcdatamodel/contents @@ -29,9 +29,6 @@ - - - diff --git a/VoidLink/ViewControllers/SettingsViewController.h b/VoidLink/ViewControllers/SettingsViewController.h index e4fcb616..5d12bed6 100644 --- a/VoidLink/ViewControllers/SettingsViewController.h +++ b/VoidLink/ViewControllers/SettingsViewController.h @@ -229,6 +229,9 @@ @property (strong, nonatomic) IBOutlet UIStackView *synthPhysicalInputStack; @property (strong, nonatomic) IBOutlet UISwitch *synthPhysicalInputSwitch; +@property (strong, nonatomic) IBOutlet UIStackView *reverseHoldButtonStack; +@property (strong, nonatomic) IBOutlet UISwitch *reverseHoldButtonSwitch; + @property (strong, nonatomic) IBOutlet UIStackView *testStack; @property (nonatomic, strong) MicHandler *micHandler; diff --git a/VoidLink/ViewControllers/SettingsViewController.m b/VoidLink/ViewControllers/SettingsViewController.m index 6cf22609..b61bf9e3 100644 --- a/VoidLink/ViewControllers/SettingsViewController.m +++ b/VoidLink/ViewControllers/SettingsViewController.m @@ -354,6 +354,16 @@ BOOL isCustomResolution(int resolutionSelected) { - (void)reloadMotionControlConfigs{ oscProfile = [oscProfileMan getSelectedProfile]; + + self.controllerGyroSwitchButtonSetter.selectedSegmentIndex = oscProfile.controllerGyroSwitchMode; + if(self.controllerGyroSwitchButtonSetter.selectedSegmentIndex != ControllerGyroSwitchDisabled){ + bool bothButtonsSet = oscProfile.controllerGyroSwitchHold != ControllerButtonNull && oscProfile.controllerGyroSwitchToggle != ControllerButtonNull; + [self findDynamicLabelFromStack:self.controllerGyroSwitchButtonStack].text = bothButtonsSet ? [LocalizationHelper localizedStringForKey:@" both set "] : @""; + } + [self setHidden:oscProfile.controllerGyroSwitchMode==ControllerGyroSwitchDisabled forStack:self.reverseHoldButtonStack]; + + [self.reverseHoldButtonSwitch setOn:oscProfile.reverseGyroHoldButton]; + [self.mapGyroToSelector setSelectedSegmentIndex:oscProfile.mapGyroTo]; [self mapGyroToChanged:self.mapGyroToSelector]; @@ -391,6 +401,8 @@ BOOL isCustomResolution(int resolutionSelected) { && (int16_t)(oscProfile.gyroSensitivityRoll*100) == (int16_t)rollSensitivityPercent && (int16_t)(oscProfile.gyroToStickMinOffset) == (int16_t)self.gyroToStickMinOffsetSlider.value && oscProfile.synthesizePhysicalStick == self.synthPhysicalInputSwitch.isOn + && oscProfile.controllerGyroSwitchMode == self.controllerGyroSwitchButtonSetter.selectedSegmentIndex + && oscProfile.reverseGyroHoldButton == self.reverseHoldButtonSwitch.isOn ); if(!configNotChanged){ @@ -402,6 +414,8 @@ BOOL isCustomResolution(int resolutionSelected) { oscProfile.gyroSensitivityRoll = rollSensitivityPercent/100; oscProfile.gyroToStickMinOffset = (int16_t)self.gyroToStickMinOffsetSlider.value; oscProfile.synthesizePhysicalStick = self.synthPhysicalInputSwitch.isOn; + oscProfile.controllerGyroSwitchMode = (int)self.controllerGyroSwitchButtonSetter.selectedSegmentIndex; + oscProfile.reverseGyroHoldButton = self.reverseHoldButtonSwitch.isOn; [oscProfileMan replaceSelectedProfileWith:oscProfile overwriteDefault:YES]; } } @@ -453,8 +467,10 @@ BOOL isCustomResolution(int resolutionSelected) { if(![self manuallyChangedFPS]) [self framerateChanged]; - self->motionControlSection.expandable = [self isCustomOswEnabled]; - [self->motionControlSection setExpanded:self->motionControlSection.expandable]; + /* + // self->motionControlSection.expandable = [self isCustomOswEnabled]; + self->motionControlSection.expandable = true; + // [self->motionControlSection setExpanded:self->motionControlSection.expandable]; __weak typeof(self) weakSelf = self; self->motionControlSection.lockedSectionHandler = ^{ [AlertControllerUtil showAlertIn:weakSelf @@ -478,6 +494,7 @@ BOOL isCustomResolution(int resolutionSelected) { } }]; }; + */ [self reloadMotionControlConfigs]; @@ -761,7 +778,7 @@ BOOL isCustomResolution(int resolutionSelected) { controllerSection.sectionTitle = [LocalizationHelper localizedStringForKey:@"Controller"]; controllerSection.identifier = @"SettingsSectionController"; if (@available(iOS 13.0, *)) { - [controllerSection setSectionWithIcon:[UIImage systemImageNamed:@"gamecontroller"] andSize:26]; + [controllerSection setSectionWithIcon:[UIImage systemImageNamed:@"gamecontroller"] andSize:30]; } [self addSetting:self.swapAbxyStack ofId:@"swapAbaxyStack" withInfoTag:NO withDynamicLabel:NO to:controllerSection]; [self addSetting:self.hapticEngineStack ofId:@"hapticEngineStack" withInfoTag:NO withDynamicLabel:NO to:controllerSection]; @@ -771,7 +788,6 @@ BOOL isCustomResolution(int resolutionSelected) { [self addSetting:self.controllerToMouseStack ofId:@"controllerToMouseStack" withInfoTag:YES withDynamicLabel:YES to:controllerSection]; [self addSetting:self.controllerMouseVelocityStack ofId:@"controllerMouseVelocityStack" withInfoTag:NO withDynamicLabel:YES to:controllerSection]; [self addSetting:self.controllerMouseExpoStack ofId:@"controllerMouseExpoStack" withInfoTag:YES withDynamicLabel:YES to:controllerSection]; - [self addSetting:self.controllerGyroSwitchButtonStack ofId:@"controllerGyroSwitchButtonStack" withInfoTag:YES withDynamicLabel:YES to:controllerSection]; [controllerSection addToParentStack:_parentStack]; motionControlSection = [[MenuSectionView alloc] init]; @@ -782,6 +798,8 @@ BOOL isCustomResolution(int resolutionSelected) { // [motionControlSection setSectionWithIcon:[UIImage imageNamed:@"gyroscope"] andSize:23]; [motionControlSection setSectionWithIcon:[UIImage imageNamed:@"gyroscope"] andSize:23]; } + [self addSetting:self.controllerGyroSwitchButtonStack ofId:@"controllerGyroSwitchButtonStack" withInfoTag:YES withDynamicLabel:YES to:motionControlSection]; + [self addSetting:self.reverseHoldButtonStack ofId:@"reverseHoldButtonStack" withInfoTag:YES withDynamicLabel:YES to:motionControlSection]; [self addSetting:self.mapGyroToStack ofId:@"mapGyroToStack" withInfoTag:NO withDynamicLabel:NO to:motionControlSection]; [self addSetting:self.gyroToStickSwitchStack ofId:@"gyroToStickStack" withInfoTag:NO withDynamicLabel:NO to:motionControlSection]; [self addSetting:self.yawPitchSensitivityStack ofId:@"yawPitchSensitivityStack" withInfoTag:NO withDynamicLabel:NO to:motionControlSection]; @@ -1357,13 +1375,13 @@ BOOL isCustomResolution(int resolutionSelected) { showOnlineDocAction = false; } if([sender.superview.accessibilityIdentifier isEqualToString: @"controllerGyroSwitchButtonStack"]){ - tempSettings = [dataMan getSettings]; - tipText = [LocalizationHelper localizedStringForKey:@"controllerGyroSwitchButtonStackTip", [ControllerUtil stringFor:tempSettings.controllerGyroSwitchToggle.intValue], [ControllerUtil stringFor:tempSettings.controllerGyroSwitchHold.intValue]]; + oscProfile = [oscProfileMan getSelectedProfile]; + tipText = [LocalizationHelper localizedStringForKey:@"controllerGyroSwitchButtonStackTip", [ControllerUtil stringFor:oscProfile.controllerGyroSwitchToggle], [ControllerUtil stringFor:oscProfile.controllerGyroSwitchHold]]; showOnlineDocAction = false; } if([sender.superview.accessibilityIdentifier isEqualToString: @"controllerToMouseStack"]){ tempSettings = [dataMan getSettings]; - tipText = [LocalizationHelper localizedStringForKey:@"controllerToMouseStackTip", [ControllerUtil stringFor:tempSettings.controllerMouseSwitch.intValue], [LocalizationHelper localizedStringForKey:tempSettings.controllerGyroSwitchHold.intValue == LeftStickToMouse ? @"Left stick" : @"Right stick"], [ControllerUtil stringFor:tempSettings.controllerMouseLeftButton.intValue], [ControllerUtil stringFor:tempSettings.controllerMouseRightButton.intValue]]; + tipText = [LocalizationHelper localizedStringForKey:@"controllerToMouseStackTip", [ControllerUtil stringFor:tempSettings.controllerMouseSwitch.intValue], [LocalizationHelper localizedStringForKey:tempSettings.controllerMouseStick.intValue == LeftStickToMouse ? @"Left stick" : @"Right stick"], [ControllerUtil stringFor:tempSettings.controllerMouseLeftButton.intValue], [ControllerUtil stringFor:tempSettings.controllerMouseRightButton.intValue]]; showOnlineDocAction = false; } @@ -1995,12 +2013,7 @@ BOOL isCustomResolution(int resolutionSelected) { [self.controllerToMouseSwitch addTarget:self action:@selector(controllerToMouseSwitchFlipped:) forControlEvents:UIControlEventValueChanged]; [self controllerToMouseSwitchFlipped:self.controllerToMouseSwitch]; - self.controllerGyroSwitchButtonSetter.selectedSegmentIndex = self->tempSettings.controllerGyroSwitchMode.intValue; [self.controllerGyroSwitchButtonSetter addTarget:self action:@selector(controllerGyroSwitchModeChanged:) forControlEvents:UIControlEventValueChanged]; - if(self.controllerGyroSwitchButtonSetter.selectedSegmentIndex != ControllerGyroSwitchDisabled){ - bool bothButtonsSet = self->tempSettings.controllerGyroSwitchHold.intValue != ControllerButtonNull && self->tempSettings.controllerGyroSwitchToggle.intValue != ControllerButtonNull; - [self findDynamicLabelFromStack:self.controllerGyroSwitchButtonStack].text = bothButtonsSet ? [LocalizationHelper localizedStringForKey:@" both set "] : @""; - } [self.controllerMouseVelocitySlider setValue:self->tempSettings.controllerMousePointerVelocity.floatValue]; [self.controllerMouseVelocitySlider addTarget:self action:@selector(controllerMouseVelocitySliderMoved:) forControlEvents:UIControlEventValueChanged]; @@ -2079,8 +2092,8 @@ BOOL isCustomResolution(int resolutionSelected) { - (bool)isCustomOswEnabled{ bool customOswEnabled = [self isOswEnabled] && self.onScreenWidgetSelector.selectedSegmentIndex == OnScreenControlsLevelCustom; - motionControlSection.expandable = customOswEnabled; - if(!(settingsViewJustExpanded || settingsViewJustLoaded)) [motionControlSection setExpanded:customOswEnabled]; + // motionControlSection.expandable = customOswEnabled; + // if(!(settingsViewJustExpanded || settingsViewJustLoaded)) [motionControlSection setExpanded:customOswEnabled]; return customOswEnabled; } @@ -2271,13 +2284,15 @@ BOOL isCustomResolution(int resolutionSelected) { } - (void)controllerGyroSwitchModeChanged:(UISegmentedControl* )sender{ + [self setHidden:sender.selectedSegmentIndex==ControllerGyroSwitchDisabled forStack:self.reverseHoldButtonStack]; + UILabel* tipLabel = [self findDynamicLabelFromStack:self.controllerGyroSwitchButtonStack]; if(sender.selectedSegmentIndex == ControllerGyroSwitchDisabled){ tipLabel.text = @""; } else{ __block bool switchButtonCaptured = false; - Settings* currentSettings = [dataMan retrieveSettings]; + oscProfile = [oscProfileMan getSelectedProfile]; [AlertControllerUtil showAlertIn:self title:[LocalizationHelper localizedStringForKey:@"Gyro button on controller"] @@ -2299,14 +2314,14 @@ BOOL isCustomResolution(int resolutionSelected) { for(NSNumber* buttonFlagId in buttonDict){ GCControllerButtonInput * button = (GCControllerButtonInput *)buttonDict[buttonFlagId]; if(button.isPressed){ - if(sender.selectedSegmentIndex == ControllerGyroSwitchPressToToggle) currentSettings.controllerGyroSwitchToggle = buttonFlagId; - if(sender.selectedSegmentIndex == ControllerGyroSwitchHoldDown) currentSettings.controllerGyroSwitchHold = buttonFlagId; + if(sender.selectedSegmentIndex == ControllerGyroSwitchPressToToggle) self->oscProfile.controllerGyroSwitchToggle = buttonFlagId.intValue; + if(sender.selectedSegmentIndex == ControllerGyroSwitchHoldDown) self->oscProfile.controllerGyroSwitchHold = buttonFlagId.intValue; switchButtonCaptured = true; AlertControllerUtil.alertController.message = [LocalizationHelper localizedStringForKey:@"Finished"]; gamepad.valueChangedHandler = nil; if(confirmAction) [confirmAction setValue:[LocalizationHelper localizedStringForKey:@"OK"] forKey:@"title"]; - [self->dataMan saveData]; + [self->oscProfileMan replaceSelectedProfileWith:self->oscProfile overwriteDefault:true]; } } }]; @@ -2322,7 +2337,8 @@ BOOL isCustomResolution(int resolutionSelected) { action:^{} completion:^{ if(AlertControllerUtil.actionCancelled){ - self.controllerGyroSwitchButtonSetter.selectedSegmentIndex = ControllerGyroSwitchDisabled; + self.controllerGyroSwitchButtonSetter.selectedSegmentIndex = self->oscProfile.controllerGyroSwitchMode; + [self setHidden:self.controllerGyroSwitchButtonSetter.selectedSegmentIndex==ControllerGyroSwitchDisabled forStack:self.reverseHoldButtonStack]; return; } [AlertControllerUtil.alertController dismissViewControllerAnimated:NO completion:^{}]; @@ -2333,25 +2349,28 @@ BOOL isCustomResolution(int resolutionSelected) { } completion:^{ if(!switchButtonCaptured){ - if(sender.selectedSegmentIndex == ControllerGyroSwitchPressToToggle) currentSettings.controllerGyroSwitchToggle = @(ControllerButtonNull); - if(sender.selectedSegmentIndex == ControllerGyroSwitchHoldDown) currentSettings.controllerGyroSwitchHold = @(ControllerButtonNull); + if(sender.selectedSegmentIndex == ControllerGyroSwitchPressToToggle) self->oscProfile.controllerGyroSwitchToggle = ControllerButtonNull; + if(sender.selectedSegmentIndex == ControllerGyroSwitchHoldDown) self->oscProfile.controllerGyroSwitchHold = ControllerButtonNull; + [self->oscProfileMan replaceSelectedProfileWith:self->oscProfile overwriteDefault:true]; } - bool noSwitchButtonSet = currentSettings.controllerGyroSwitchHold.intValue == ControllerButtonNull && currentSettings.controllerGyroSwitchToggle.intValue == ControllerButtonNull; - bool duplicatedButtons = currentSettings.controllerGyroSwitchHold.intValue == currentSettings.controllerGyroSwitchToggle.intValue && currentSettings.controllerGyroSwitchToggle.intValue != ControllerButtonNull; - bool bothButtonsSet = currentSettings.controllerGyroSwitchHold.intValue != ControllerButtonNull && currentSettings.controllerGyroSwitchToggle.intValue != ControllerButtonNull; + bool noSwitchButtonSet = self->oscProfile.controllerGyroSwitchHold == ControllerButtonNull && self->oscProfile.controllerGyroSwitchToggle == ControllerButtonNull; + bool duplicatedButtons = self->oscProfile.controllerGyroSwitchHold == self->oscProfile.controllerGyroSwitchToggle && self->oscProfile.controllerGyroSwitchToggle != ControllerButtonNull; + bool bothButtonsSet = self->oscProfile.controllerGyroSwitchHold != ControllerButtonNull && self->oscProfile.controllerGyroSwitchToggle != ControllerButtonNull && !duplicatedButtons; tipLabel.text = @""; if(bothButtonsSet) tipLabel.text = [LocalizationHelper localizedStringForKey:@" both set "]; if(duplicatedButtons){ sender.selectedSegmentIndex = ControllerGyroSwitchDisabled; tipLabel.text = [LocalizationHelper localizedStringForKey:@" duplicated ! "]; + [self->oscProfileMan replaceSelectedProfileWith:self->oscProfile overwriteDefault:true]; } if(noSwitchButtonSet) sender.selectedSegmentIndex = ControllerGyroSwitchDisabled; - if(!noSwitchButtonSet && !bothButtonsSet){ - sender.selectedSegmentIndex = currentSettings.controllerGyroSwitchToggle.intValue != ControllerButtonNull ? ControllerGyroSwitchPressToToggle : ControllerGyroSwitchHoldDown; + if(!noSwitchButtonSet && !bothButtonsSet && !duplicatedButtons){ + sender.selectedSegmentIndex = self->oscProfile.controllerGyroSwitchToggle != ControllerButtonNull ? ControllerGyroSwitchPressToToggle : ControllerGyroSwitchHoldDown; } - [self->dataMan saveData]; + [self setHidden:sender.selectedSegmentIndex==ControllerGyroSwitchDisabled forStack:self.reverseHoldButtonStack]; + if(self->capturedController && self->capturedController.extendedGamepad) self->capturedController.extendedGamepad.valueChangedHandler = nil; }]; } diff --git a/VoidLink/mul.lproj/iPad.xcstrings b/VoidLink/mul.lproj/iPad.xcstrings index 3d8bb151..35bae560 100644 --- a/VoidLink/mul.lproj/iPad.xcstrings +++ b/VoidLink/mul.lproj/iPad.xcstrings @@ -374,31 +374,31 @@ } }, "6gY-8I-NWq.text" : { - "comment" : "Class = \"UILabel\"; text = \"Map Gyro to\"; ObjectID = \"6gY-8I-NWq\";", + "comment" : "Class = \"UILabel\"; text = \"Map Built-in Gyro to\"; ObjectID = \"6gY-8I-NWq\";", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Map Gyro to" + "value" : "Map Built-in Gyro to" } }, "zh-Hans" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺仪映射为" + "state" : "needs_review", + "value" : "内置陀螺仪映射为" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺儀映射為" + "state" : "needs_review", + "value" : "内建陀螺儀映射為" } }, "zh-HK" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺儀映射為" + "state" : "needs_review", + "value" : "内建陀螺儀映射為" } } } @@ -1537,6 +1537,36 @@ } } }, + "BQH-nQ-IyM.text" : { + "comment" : "Class = \"UILabel\"; text = \"Reverse Hold Button\"; ObjectID = \"BQH-nQ-IyM\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Reverse Hold Button" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "反转保持按键" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "反轉保持按鍵" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "反轉保持按鍵" + } + } + } + }, "BsJ-eo-2Ac.text" : { "comment" : "Class = \"UILabel\"; text = \"Ctrl Down for Pinch\"; ObjectID = \"BsJ-eo-2Ac\";", "extractionState" : "extracted_with_value", diff --git a/VoidLink/mul.lproj/iPhone.xcstrings b/VoidLink/mul.lproj/iPhone.xcstrings index ad0752c6..0cfd91ba 100644 --- a/VoidLink/mul.lproj/iPhone.xcstrings +++ b/VoidLink/mul.lproj/iPhone.xcstrings @@ -1318,6 +1318,24 @@ "state" : "new", "value" : "Switch Gyro by Controller" } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "手柄开关陀螺仪" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "手把開關陀螺儀" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "手把開關陀螺儀" + } } } }, @@ -2270,31 +2288,31 @@ } }, "GX4-zV-pQ8.text" : { - "comment" : "Class = \"UILabel\"; text = \"Map Gyro to\"; ObjectID = \"GX4-zV-pQ8\";", + "comment" : "Class = \"UILabel\"; text = \"Map Built-in Gyro to\"; ObjectID = \"GX4-zV-pQ8\";", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Map Gyro to" + "value" : "Map Built-in Gyro to" } }, "zh-Hans" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺仪映射为" + "state" : "needs_review", + "value" : "内置陀螺仪映射为" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺儀映射為" + "state" : "needs_review", + "value" : "内建陀螺儀映射為" } }, "zh-HK" : { "stringUnit" : { - "state" : "translated", - "value" : "陀螺儀映射為" + "state" : "needs_review", + "value" : "内建陀螺儀映射為" } } } @@ -2839,6 +2857,36 @@ } } }, + "m3M-yS-Wt6.text" : { + "comment" : "Class = \"UILabel\"; text = \"Reverse Hold Button\"; ObjectID = \"m3M-yS-Wt6\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Reverse Hold Button" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "反转保持按键" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "反轉保持按鍵" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "反轉保持按鍵" + } + } + } + }, "mdA-jF-9Mf.text" : { "comment" : "Class = \"UILabel\"; text = \"Local Mouse Pointer\"; ObjectID = \"mdA-jF-9Mf\";", "extractionState" : "extracted_with_value",