- legacy osc vibration style

- vibration style ios13 compatibility
- low ios verision UI fixes
This commit is contained in:
TrueZhuanjia committed 2025-06-22 10:11:11 +08:00
1 parent 47bae92dd5
commit cd4c5bbc56
10 files changed
+229 -67

No files matched your search

+5
View File
@@ -484,6 +484,8 @@
<segment title="rigid"/> <segment title="rigid"/>
<segment title="off"/> <segment title="off"/>
</segments> </segments>
<color key="tintColor" systemColor="systemGray2Color"/>
<color key="selectedSegmentTintColor" red="0.23136288842322539" green="0.45776400812558971" blue="0.51492406781186773" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</segmentedControl> </segmentedControl>
</subviews> </subviews>
<constraints> <constraints>
@@ -1460,6 +1462,9 @@
<systemColor name="systemBrownColor"> <systemColor name="systemBrownColor">
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="systemGray2Color">
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemTealColor"> <systemColor name="systemTealColor">
<color red="0.18823529411764706" green="0.69019607843137254" blue="0.7803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.18823529411764706" green="0.69019607843137254" blue="0.7803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
@@ -41,6 +41,7 @@
_view = view; _view = view;
_view.multipleTouchEnabled = false; _view.multipleTouchEnabled = false;
self = [super initWithView:view controllerSup:controllerSupport streamConfig:streamConfig]; self = [super initWithView:view controllerSup:controllerSupport streamConfig:streamConfig];
self.isLayingOut = true; // make sure the super class have a flag to tell it's currently laying out the OSCs, intead play mode. self.isLayingOut = true; // make sure the super class have a flag to tell it's currently laying out the OSCs, intead play mode.
self._level = oscLevel; self._level = oscLevel;
@@ -337,6 +337,14 @@ static CGRect streamViewBounds;
buttonState.isHidden = oscButtonLayer.isHidden; buttonState.isHidden = oscButtonLayer.isHidden;
buttonState.oscLayerSizeFactor = [OnScreenControls getControllerLayerSizeFactor:oscButtonLayer]; buttonState.oscLayerSizeFactor = [OnScreenControls getControllerLayerSizeFactor:oscButtonLayer];
buttonState.backgroundAlpha = oscButtonLayer.opacity; buttonState.backgroundAlpha = oscButtonLayer.opacity;
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:oscButtonLayer.name];
if ([style isKindOfClass:[NSNumber class]]) {
buttonState.vibrationStyle = [style unsignedCharValue];
// 使用 val
}
else buttonState.vibrationStyle = UIImpactFeedbackStyleLight;
// NSLog(@"oscLayerName: %@, opacity: %f, ", oscButtonLayer.name, buttonState.backgroundAlpha); // NSLog(@"oscLayerName: %@, opacity: %f, ", oscButtonLayer.name, buttonState.backgroundAlpha);
+4
View File
@@ -36,6 +36,8 @@ static const float BUTTON_DIST = 20;
CGFloat _dPadSizeFactor; CGFloat _dPadSizeFactor;
} }
+ (NSMutableDictionary *)layerVibrationStyleDic;
typedef NS_ENUM(NSInteger, OnScreenControlsLevel) { typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
OnScreenControlsLevelOff, OnScreenControlsLevelOff,
OnScreenControlsLevelSimple, OnScreenControlsLevelSimple,
@@ -104,6 +106,8 @@ typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
@property OnScreenControlsLevel _level; @property OnScreenControlsLevel _level;
@property NSMutableArray *OSCButtonLayers; @property NSMutableArray *OSCButtonLayers;
@property NSMutableDictionary* layerVibrationStyleDic;
+ (NSMutableSet* )touchAddrsCapturedByOnScreenControls; + (NSMutableSet* )touchAddrsCapturedByOnScreenControls;
+53 -22
View File
@@ -56,6 +56,8 @@ static NSSet *validPositionButtonNames;
NSDate* l3TouchStart; NSDate* l3TouchStart;
NSDate* r3TouchStart; NSDate* r3TouchStart;
UIImpactFeedbackGenerator* vibrationGenerator;
BOOL l3Set; BOOL l3Set;
BOOL r3Set; BOOL r3Set;
@@ -219,7 +221,6 @@ static float L3_Y;
_originalControllerLayerOpacityDict = [[NSMutableDictionary alloc] init]; _originalControllerLayerOpacityDict = [[NSMutableDictionary alloc] init];
// we have to retrieve largerStickLR1 setting direct from the database, since streamConfig is invalid in LayoutOnScreenControls // we have to retrieve largerStickLR1 setting direct from the database, since streamConfig is invalid in LayoutOnScreenControls
DataManager* dataMan = [[DataManager alloc] init]; DataManager* dataMan = [[DataManager alloc] init];
Settings* settings = [dataMan retrieveSettings];
_largerStickLR1 = true; _largerStickLR1 = true;
_oscTapExlusionAreaSizeFactor = 1.05; _oscTapExlusionAreaSizeFactor = 1.05;
@@ -370,6 +371,7 @@ static float L3_Y;
for (NSData *buttonStateEncoded in oscProfile.buttonStates) { for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded]; OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
buttonState.position = [self denormalizeWidgetPosition:buttonState.position]; buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
[OnScreenControls.layerVibrationStyleDic setObject:@(buttonState.vibrationStyle) forKey:buttonState.name];
if(!buttonState.isHidden && [validPositionButtonNames containsObject:buttonState.name] && (buttonState.buttonType == LegacyOscButton || [profilesManager getIndexOfSelectedProfile] == 0 ) ){ if(!buttonState.isHidden && [validPositionButtonNames containsObject:buttonState.name] && (buttonState.buttonType == LegacyOscButton || [profilesManager getIndexOfSelectedProfile] == 0 ) ){
[_activeCustomOscButtonPositionDict setObject:[NSValue valueWithCGPoint:buttonState.position] forKey:buttonState.name]; // we got a buttonname -> position dict here [_activeCustomOscButtonPositionDict setObject:[NSValue valueWithCGPoint:buttonState.position] forKey:buttonState.name]; // we got a buttonname -> position dict here
// NSLog(@"_activeCustomOscButtonPositionDict update, button name:%@, position: %f, %f", buttonState.name, buttonState.position.x, buttonState.position.y); // NSLog(@"_activeCustomOscButtonPositionDict update, button name:%@, position: %f, %f", buttonState.name, buttonState.position.x, buttonState.position.y);
@@ -1098,7 +1100,7 @@ static float L3_Y;
// Allow the user to slide their finger to another d-pad button // Allow the user to slide their finger to another d-pad button
if ([_upButton.presentationLayer hitTest:touchLocation]) { if ([_upButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:UP_FLAG]; [_controllerSupport setButtonFlag:_controller flags:UP_FLAG];
[self oscButtonTouchDownVisualEffect:_upButton]; [self oscButtonTouchDownFeedback:_upButton];
updated = true; updated = true;
} else { } else {
_upButton.opacity = [_originalControllerLayerOpacityDict[_upButton.name] floatValue]; _upButton.opacity = [_originalControllerLayerOpacityDict[_upButton.name] floatValue];
@@ -1107,7 +1109,7 @@ static float L3_Y;
if ([_downButton.presentationLayer hitTest:touchLocation]) { if ([_downButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:DOWN_FLAG]; [_controllerSupport setButtonFlag:_controller flags:DOWN_FLAG];
[self oscButtonTouchDownVisualEffect:_downButton]; [self oscButtonTouchDownFeedback:_downButton];
updated = true; updated = true;
} else { } else {
_downButton.opacity = [_originalControllerLayerOpacityDict[_downButton.name] floatValue]; _downButton.opacity = [_originalControllerLayerOpacityDict[_downButton.name] floatValue];
@@ -1116,7 +1118,7 @@ static float L3_Y;
if ([_leftButton.presentationLayer hitTest:touchLocation]) { if ([_leftButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:LEFT_FLAG]; [_controllerSupport setButtonFlag:_controller flags:LEFT_FLAG];
[self oscButtonTouchDownVisualEffect:_leftButton]; [self oscButtonTouchDownFeedback:_leftButton];
updated = true; updated = true;
} else { } else {
_leftButton.opacity = [_originalControllerLayerOpacityDict[_leftButton.name] floatValue]; _leftButton.opacity = [_originalControllerLayerOpacityDict[_leftButton.name] floatValue];
@@ -1125,7 +1127,7 @@ static float L3_Y;
if ([_rightButton.presentationLayer hitTest:touchLocation]) { if ([_rightButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:RIGHT_FLAG]; [_controllerSupport setButtonFlag:_controller flags:RIGHT_FLAG];
[self oscButtonTouchDownVisualEffect:_rightButton]; [self oscButtonTouchDownFeedback:_rightButton];
updated = true; updated = true;
} else { } else {
_rightButton.opacity = [_originalControllerLayerOpacityDict[_rightButton.name] floatValue]; _rightButton.opacity = [_originalControllerLayerOpacityDict[_rightButton.name] floatValue];
@@ -1172,7 +1174,7 @@ static float L3_Y;
} }
- (void)oscButtonTouchDownVisualEffect:(CALayer* )button{ - (void)oscButtonTouchDownFeedback:(CALayer* )button{
[CATransaction begin]; [CATransaction begin];
[CATransaction setDisableActions:YES]; [CATransaction setDisableActions:YES];
@@ -1200,6 +1202,26 @@ static float L3_Y;
button.shadowOffset = CGSizeZero; button.shadowOffset = CGSizeZero;
button.shadowOpacity = 1.0; button.shadowOpacity = 1.0;
button.shadowRadius = 0.0; // Adjust the radius to simulate border thickness button.shadowRadius = 0.0; // Adjust the radius to simulate border thickness
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:button.name];
uint8_t vibrationStyle = [style unsignedCharValue];
bool vibraiontOn;
if (@available(iOS 13.0, *)) {
vibraiontOn = vibrationStyle < UIImpactFeedbackStyleRigid+1;
} else {
vibraiontOn = vibrationStyle < UIImpactFeedbackStyleHeavy+1;
}
// NSLog(@"vibration on: %d",vibraiontOn);
if(vibraiontOn){
vibrationGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:vibrationStyle];
[vibrationGenerator prepare];
[vibrationGenerator impactOccurred];
NSLog(@"vibration instance: %@",vibrationGenerator);
}
[CATransaction commit]; [CATransaction commit];
} }
@@ -1217,28 +1239,28 @@ static float L3_Y;
if ([_aButton.presentationLayer hitTest:touchLocation]) { if ([_aButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:A_FLAG]; [_controllerSupport setButtonFlag:_controller flags:A_FLAG];
_aTouch = touch; _aTouch = touch;
[self oscButtonTouchDownVisualEffect:_aButton]; [self oscButtonTouchDownFeedback:_aButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC A"); // NSLog(@"Captured OSC A");
} else if ([_bButton.presentationLayer hitTest:touchLocation]) { } else if ([_bButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:B_FLAG]; [_controllerSupport setButtonFlag:_controller flags:B_FLAG];
_bTouch = touch; _bTouch = touch;
[self oscButtonTouchDownVisualEffect:_bButton]; [self oscButtonTouchDownFeedback:_bButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC B"); // NSLog(@"Captured OSC B");
} else if ([_xButton.presentationLayer hitTest:touchLocation]) { } else if ([_xButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:X_FLAG]; [_controllerSupport setButtonFlag:_controller flags:X_FLAG];
_xTouch = touch; _xTouch = touch;
[self oscButtonTouchDownVisualEffect:_xButton]; [self oscButtonTouchDownFeedback:_xButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC X"); // NSLog(@"Captured OSC X");
} else if ([_yButton.presentationLayer hitTest:touchLocation]) { } else if ([_yButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:Y_FLAG]; [_controllerSupport setButtonFlag:_controller flags:Y_FLAG];
_yTouch = touch; _yTouch = touch;
[self oscButtonTouchDownVisualEffect:_yButton]; [self oscButtonTouchDownFeedback:_yButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC Y"); // NSLog(@"Captured OSC Y");
@@ -1246,7 +1268,7 @@ static float L3_Y;
[_controllerSupport setButtonFlag:_controller flags:UP_FLAG]; [_controllerSupport setButtonFlag:_controller flags:UP_FLAG];
_dpadTouch = touch; _dpadTouch = touch;
_upTouch = touch; _upTouch = touch;
[self oscButtonTouchDownVisualEffect:_upButton]; [self oscButtonTouchDownFeedback:_upButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC UP"); // NSLog(@"Captured OSC UP");
@@ -1254,14 +1276,14 @@ static float L3_Y;
[_controllerSupport setButtonFlag:_controller flags:DOWN_FLAG]; [_controllerSupport setButtonFlag:_controller flags:DOWN_FLAG];
_dpadTouch = touch; _dpadTouch = touch;
_downTouch = touch; _downTouch = touch;
[self oscButtonTouchDownVisualEffect:_downButton]; [self oscButtonTouchDownFeedback:_downButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
} else if ([_leftButton.presentationLayer hitTest:touchLocation]) { } else if ([_leftButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:LEFT_FLAG]; [_controllerSupport setButtonFlag:_controller flags:LEFT_FLAG];
_dpadTouch = touch; _dpadTouch = touch;
_leftTouch = touch; _leftTouch = touch;
[self oscButtonTouchDownVisualEffect:_leftButton]; [self oscButtonTouchDownFeedback:_leftButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC LEFT"); // NSLog(@"Captured OSC LEFT");
@@ -1269,49 +1291,49 @@ static float L3_Y;
[_controllerSupport setButtonFlag:_controller flags:RIGHT_FLAG]; [_controllerSupport setButtonFlag:_controller flags:RIGHT_FLAG];
_dpadTouch = touch; _dpadTouch = touch;
_rightTouch = touch; _rightTouch = touch;
[self oscButtonTouchDownVisualEffect:_rightButton]; [self oscButtonTouchDownFeedback:_rightButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC RIGHT"); // NSLog(@"Captured OSC RIGHT");
} else if ([_startButton.presentationLayer hitTest:touchLocation]) { } else if ([_startButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:PLAY_FLAG]; [_controllerSupport setButtonFlag:_controller flags:PLAY_FLAG];
_startTouch = touch; _startTouch = touch;
[self oscButtonTouchDownVisualEffect:_startButton]; [self oscButtonTouchDownFeedback:_startButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC PLAY"); // NSLog(@"Captured OSC PLAY");
} else if ([_selectButton.presentationLayer hitTest:touchLocation]) { } else if ([_selectButton.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:BACK_FLAG]; [_controllerSupport setButtonFlag:_controller flags:BACK_FLAG];
_selectTouch = touch; _selectTouch = touch;
[self oscButtonTouchDownVisualEffect:_selectButton]; [self oscButtonTouchDownFeedback:_selectButton];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC BACK"); // NSLog(@"Captured OSC BACK");
} else if ([_l1Button.presentationLayer hitTest:touchLocation]) { } else if ([_l1Button.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:LB_FLAG]; [_controllerSupport setButtonFlag:_controller flags:LB_FLAG];
_l1Touch = touch; _l1Touch = touch;
[self oscButtonTouchDownVisualEffect:_l1Button]; [self oscButtonTouchDownFeedback:_l1Button];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC LB"); // NSLog(@"Captured OSC LB");
} else if ([_r1Button.presentationLayer hitTest:touchLocation]) { } else if ([_r1Button.presentationLayer hitTest:touchLocation]) {
[_controllerSupport setButtonFlag:_controller flags:RB_FLAG]; [_controllerSupport setButtonFlag:_controller flags:RB_FLAG];
_r1Touch = touch; _r1Touch = touch;
[self oscButtonTouchDownVisualEffect:_r1Button]; [self oscButtonTouchDownFeedback:_r1Button];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC RB"); // NSLog(@"Captured OSC RB");
} else if ([_l2Button.presentationLayer hitTest:touchLocation]) { } else if ([_l2Button.presentationLayer hitTest:touchLocation]) {
[_controllerSupport updateLeftTrigger:_controller left:0xFF]; [_controllerSupport updateLeftTrigger:_controller left:0xFF];
_l2Touch = touch; _l2Touch = touch;
[self oscButtonTouchDownVisualEffect:_l2Button]; [self oscButtonTouchDownFeedback:_l2Button];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC LeftTrigger"); // NSLog(@"Captured OSC LeftTrigger");
} else if ([_r2Button.presentationLayer hitTest:touchLocation]) { } else if ([_r2Button.presentationLayer hitTest:touchLocation]) {
[_controllerSupport updateRightTrigger:_controller right:0xFF]; [_controllerSupport updateRightTrigger:_controller right:0xFF];
_r2Touch = touch; _r2Touch = touch;
[self oscButtonTouchDownVisualEffect:_r2Button]; [self oscButtonTouchDownFeedback:_r2Button];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC RightTrigger"); // NSLog(@"Captured OSC RightTrigger");
@@ -1351,7 +1373,7 @@ static float L3_Y;
double l3TouchTime = [l3TouchStart timeIntervalSinceNow] * -1000.0; double l3TouchTime = [l3TouchStart timeIntervalSinceNow] * -1000.0;
if (l3TouchTime < STICK_CLICK_RATE) { if (l3TouchTime < STICK_CLICK_RATE) {
[_controllerSupport setButtonFlag:_controller flags:LS_CLK_FLAG]; [_controllerSupport setButtonFlag:_controller flags:LS_CLK_FLAG];
[self oscButtonTouchDownVisualEffect:_leftStick]; [self oscButtonTouchDownFeedback:_leftStick];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC LS_CLK3"); // NSLog(@"Captured OSC LS_CLK3");
@@ -1369,7 +1391,7 @@ static float L3_Y;
double r3TouchTime = [r3TouchStart timeIntervalSinceNow] * -1000.0; double r3TouchTime = [r3TouchStart timeIntervalSinceNow] * -1000.0;
if (r3TouchTime < STICK_CLICK_RATE) { if (r3TouchTime < STICK_CLICK_RATE) {
[_controllerSupport setButtonFlag:_controller flags:RS_CLK_FLAG]; [_controllerSupport setButtonFlag:_controller flags:RS_CLK_FLAG];
[self oscButtonTouchDownVisualEffect:_rightStick]; [self oscButtonTouchDownFeedback:_rightStick];
updated = true; updated = true;
touchEventCapturedByOsc = true; touchEventCapturedByOsc = true;
// NSLog(@"Captured OSC LS_CLK4"); // NSLog(@"Captured OSC LS_CLK4");
@@ -1946,5 +1968,14 @@ static float L3_Y;
} }
} }
+ (NSMutableDictionary *)layerVibrationStyleDic{
static NSMutableDictionary *dict = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dict = [NSMutableDictionary dictionary];
});
return dict;
}
@end @end
+115 -23
View File
@@ -283,6 +283,29 @@
} }
} }
}, },
"About" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "关于"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "关于"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "关于"
}
}
}
},
"Add" : { "Add" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -381,6 +404,29 @@
} }
} }
}, },
"Add to favorite" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "收藏"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "收藏"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "收藏"
}
}
}
},
"Alias (optional)" : { "Alias (optional)" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -703,6 +749,29 @@
} }
} }
}, },
"Collapse" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "收起"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "收起"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "收起"
}
}
}
},
"Command" : { "Command" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -1635,29 +1704,6 @@
} }
} }
}, },
"Help" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "帮助"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "帮助"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "帮助"
}
}
}
},
"Hide App" : { "Hide App" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -2487,6 +2533,29 @@
} }
} }
}, },
"Options" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "选项"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "选项"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "选项"
}
}
}
},
"Others" : { "Others" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -2901,6 +2970,29 @@
} }
} }
}, },
"Remove" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "移除"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "移除"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "移除"
}
}
}
},
"Remove Host" : { "Remove Host" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -37,6 +37,7 @@
BOOL widgetPanelMovedByTouch; BOOL widgetPanelMovedByTouch;
CGPoint widgetPanelStoredCenter; CGPoint widgetPanelStoredCenter;
CGPoint latestTouchLocation; CGPoint latestTouchLocation;
UIImpactFeedbackGenerator *vibrationGenerator;
} }
@synthesize trashCanButton; @synthesize trashCanButton;
@@ -225,6 +226,8 @@
self.toolbarRootView.layer.shadowOffset = CGSizeMake(0, 0); self.toolbarRootView.layer.shadowOffset = CGSizeMake(0, 0);
self.toolbarRootView.layer.shadowOpacity = 0.5; self.toolbarRootView.layer.shadowOpacity = 0.5;
self.toolbarRootView.layer.shadowRadius = 7; self.toolbarRootView.layer.shadowRadius = 7;
vibrationGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium];
} }
@@ -561,6 +564,7 @@
newWidget.sensitivityFactor = widget.sensitivityFactor; newWidget.sensitivityFactor = widget.sensitivityFactor;
newWidget.stickIndicatorOffset = widget.stickIndicatorOffset; newWidget.stickIndicatorOffset = widget.stickIndicatorOffset;
newWidget.minStickOffset = [widgetInitParams[@"minStickOffsetString"] floatValue]; newWidget.minStickOffset = [widgetInitParams[@"minStickOffsetString"] floatValue];
[newWidget setVibrationWithStyle:widget.vibrationStyle];
// Add the widgetView to the view controller's view // Add the widgetView to the view controller's view
[self.view insertSubview:newWidget belowSubview:self.widgetPanelStack]; [self.view insertSubview:newWidget belowSubview:self.widgetPanelStack];
@@ -569,6 +573,7 @@
[newWidget resizeWidgetView]; // resize must be called after relocation [newWidget resizeWidgetView]; // resize must be called after relocation
[newWidget adjustTransparencyWithAlpha:widget.backgroundAlpha]; [newWidget adjustTransparencyWithAlpha:widget.backgroundAlpha];
[newWidget adjustBorderWithWidth:widget.borderWidth]; [newWidget adjustBorderWithWidth:widget.borderWidth];
[newWidget setVibrationWithStyle:widget.vibrationStyle];
[self.OnScreenWidgetViews addObject:newWidget]; [self.OnScreenWidgetViews addObject:newWidget];
self->selectedWidgetView = newWidget; self->selectedWidgetView = newWidget;
if(!createNew){ if(!createNew){
@@ -589,6 +594,7 @@
[self.view insertSubview:widgetView belowSubview:self.widgetPanelStack]; [self.view insertSubview:widgetView belowSubview:self.widgetPanelStack];
[widgetView setLocationWithPosition:CGPointMake(90, 130)]; [widgetView setLocationWithPosition:CGPointMake(90, 130)];
[widgetView resizeWidgetView]; [widgetView resizeWidgetView];
[widgetView setVibrationWithStyle:UIImpactFeedbackStyleLight];
} }
@@ -667,7 +673,6 @@
[self.widgetBorderWidthLabel setText:[LocalizationHelper localizedStringForKey:@"Border Width: %.2f", self->selectedWidgetView.borderWidth]]; [self.widgetBorderWidthLabel setText:[LocalizationHelper localizedStringForKey:@"Border Width: %.2f", self->selectedWidgetView.borderWidth]];
if([self isIPhone]){ if([self isIPhone]){
self.vibrationStyleSelector.selectedSegmentIndex = self->selectedWidgetView.vibrationStyle; self.vibrationStyleSelector.selectedSegmentIndex = self->selectedWidgetView.vibrationStyle;
//[self->selectedWidgetView setva]
} }
} }
@@ -696,6 +701,10 @@
[self.widgetSizeLabel setText:[LocalizationHelper localizedStringForKey:@"Size: %.2f", sizeFactor]]; [self.widgetSizeLabel setText:[LocalizationHelper localizedStringForKey:@"Size: %.2f", sizeFactor]];
[self.widgetHeightLabel setText:[LocalizationHelper localizedStringForKey:@"Height: %.2f", sizeFactor]]; [self.widgetHeightLabel setText:[LocalizationHelper localizedStringForKey:@"Height: %.2f", sizeFactor]];
[self.widgetAlphaLabel setText:[LocalizationHelper localizedStringForKey:@"Alpha: %.2f", alpha]]; [self.widgetAlphaLabel setText:[LocalizationHelper localizedStringForKey:@"Alpha: %.2f", alpha]];
if([self isIPhone]){
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:selectedControllerLayer.name];
self.vibrationStyleSelector.selectedSegmentIndex = [style unsignedCharValue];
}
} }
- (void)widgetSizeSliderMoved:(UISlider* )sender{ - (void)widgetSizeSliderMoved:(UISlider* )sender{
@@ -745,9 +754,24 @@
} }
- (void)vibrationStyleChanged:(UISegmentedControl* )sender{ - (void)vibrationStyleChanged:(UISegmentedControl* )sender{
bool vibraiontOn;
if (@available(iOS 13.0, *)) {
vibraiontOn = sender.selectedSegmentIndex < UIImpactFeedbackStyleRigid+1;
} else {
vibraiontOn = sender.selectedSegmentIndex < UIImpactFeedbackStyleHeavy+1;
}
if(vibraiontOn){
vibrationGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:sender.selectedSegmentIndex];
[vibrationGenerator prepare];
[vibrationGenerator impactOccurred];
NSLog(@"vibration instance: %@", vibrationGenerator);
}
if(self->selectedWidgetView != nil && self->widgetViewSelected){ if(self->selectedWidgetView != nil && self->widgetViewSelected){
[self->selectedWidgetView setVibrationWithStyle:sender.selectedSegmentIndex]; [self->selectedWidgetView setVibrationWithStyle:sender.selectedSegmentIndex];
} }
if(self->selectedControllerLayer != nil && self->controllerLayerSelected){
[OnScreenControls.layerVibrationStyleDic setObject:@(sender.selectedSegmentIndex) forKey:self->selectedControllerLayer.name];
}
} }
- (void)sensitivitySliderMoved:(UISlider* )sender{ - (void)sensitivitySliderMoved:(UISlider* )sender{
@@ -848,6 +872,11 @@
if([self isIPhone]){ if([self isIPhone]){
[self.vibrationStyleSelector addTarget:self action:@selector(vibrationStyleChanged:) forControlEvents:(UIControlEventValueChanged)]; [self.vibrationStyleSelector addTarget:self action:@selector(vibrationStyleChanged:) forControlEvents:(UIControlEventValueChanged)];
self.vibrationStyleStack.hidden = NO; self.vibrationStyleStack.hidden = NO;
NSDictionary *normalAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor]
};
[self.vibrationStyleSelector setTitleTextAttributes:normalAttributes forState:UIControlStateNormal];
} }
[self.view bringSubviewToFront:self.toolbarRootView]; [self.view bringSubviewToFront:self.toolbarRootView];
@@ -875,6 +904,12 @@
maskLayer.path = path.CGPath; maskLayer.path = path.CGPath;
self.widgetPanelStack.layer.mask = maskLayer; self.widgetPanelStack.layer.mask = maskLayer;
if (@available(iOS 13.0, *) && self.vibrationStyleSelector.numberOfSegments == 6) {
} else {
[self.vibrationStyleSelector removeSegmentAtIndex:3 animated:NO];
[self.vibrationStyleSelector removeSegmentAtIndex:3 animated:NO];
}
} }
} }
@@ -1295,7 +1295,7 @@ static NSMutableSet* hostList;
[button setImage:image forState:UIControlStateNormal]; [button setImage:image forState:UIControlStateNormal];
[button setTitle:[LocalizationHelper localizedStringForKey:@" Add Host"] forState:UIControlStateNormal]; // 注意空格用于间隔 [button setTitle:[LocalizationHelper localizedStringForKey:@" Add Host"] forState:UIControlStateNormal]; // 注意空格用于间隔
} else { } else {
[button setTitle:@"Add Host" forState:UIControlStateNormal]; // 注意空格用于间隔 [button setTitle:[LocalizationHelper localizedStringForKey:@"Add Host"] forState:UIControlStateNormal]; // 注意空格用于间隔
} }
// [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; // [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
@@ -1335,7 +1335,7 @@ static NSMutableSet* hostList;
[button setImage:image forState:UIControlStateNormal]; [button setImage:image forState:UIControlStateNormal];
[button setTitle:@"" forState:UIControlStateNormal]; // 注意空格用于间隔 [button setTitle:@"" forState:UIControlStateNormal]; // 注意空格用于间隔
} else { } else {
[button setTitle:@"Help" forState:UIControlStateNormal]; // 注意空格用于间隔 [button setTitle:[LocalizationHelper localizedStringForKey:@"About"] forState:UIControlStateNormal]; // 注意空格用于间隔
} }
// [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; // [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
@@ -875,6 +875,8 @@ const int FrontViewPositionNone = 0xff;
_separatorLine.hidden = _frontViewPosition == FrontViewPositionLeft; _separatorLine.hidden = _frontViewPosition == FrontViewPositionLeft;
_contentView.rearNavView.hidden = _frontViewPosition == FrontViewPositionLeft;
if(_frontViewPosition == FrontViewPositionLeft && currentMenuMode == RemoveSettingItem){ if(_frontViewPosition == FrontViewPositionLeft && currentMenuMode == RemoveSettingItem){
[self doneRemoveSettingItemSelected]; [self doneRemoveSettingItemSelected];
} }
@@ -2024,7 +2026,7 @@ const int FrontViewPositionNone = 0xff;
(newPosition >= FrontViewPositionRightMostRemoved || newPosition <= FrontViewPositionLeftSideMostRemoved ) && (newPosition >= FrontViewPositionRightMostRemoved || newPosition <= FrontViewPositionLeftSideMostRemoved ) &&
(_frontViewPosition < FrontViewPositionRightMostRemoved && _frontViewPosition > FrontViewPositionLeftSideMostRemoved && _frontViewPosition != FrontViewPositionNone); (_frontViewPosition < FrontViewPositionRightMostRemoved && _frontViewPosition > FrontViewPositionLeftSideMostRemoved && _frontViewPosition != FrontViewPositionNone);
if ( positionIsChanging ) if(positionIsChanging)
{ {
if ( [_delegate respondsToSelector:@selector(revealController:willMoveToPosition:)] ) if ( [_delegate respondsToSelector:@selector(revealController:willMoveToPosition:)] )
[_delegate revealController:self willMoveToPosition:newPosition]; [_delegate revealController:self willMoveToPosition:newPosition];
@@ -415,22 +415,6 @@ BOOL isCustomResolution(CGSize res) {
label1.hidden = NO; label1.hidden = NO;
} }
- (void)updateThemeForLabelsttt:(UIView *)view {
for (UIView *subview in view.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
UILabel *label = (UILabel *)subview;
if(label.accessibilityIdentifier != nil) break;
if (@available(iOS 13.0, *)) {
label.layer.filters = nil;
label.textColor = [ThemeManager textColor];
} else {
// Fallback on earlier versions
}
}
[self updateThemeForLabels:subview];
}
}
- (UIView *)findCommonSuperViewFor:(UIView *)view1 andView:(UIView *)view2 { - (UIView *)findCommonSuperViewFor:(UIView *)view1 andView:(UIView *)view2 {
if (!view1 || !view2) return nil; if (!view1 || !view2) return nil;
// 把 view1 的所有 superview 放入集合 // 把 view1 的所有 superview 放入集合
@@ -845,7 +829,7 @@ BOOL isCustomResolution(CGSize res) {
[self addSettingToFavorite:self->capturedStack]; [self addSettingToFavorite:self->capturedStack];
self->capturedStack.backgroundColor = [UIColor clearColor]; self->capturedStack.backgroundColor = [UIColor clearColor];
}]; }];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"" UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:[self isIPhone] ? [LocalizationHelper localizedStringForKey:@"Cancel"] : @""
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
self->capturedStack.backgroundColor = [UIColor clearColor]; self->capturedStack.backgroundColor = [UIColor clearColor];
@@ -952,7 +936,7 @@ BOOL isCustomResolution(CGSize res) {
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:16 weight:UIImageSymbolWeightMedium]; UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:16 weight:UIImageSymbolWeightMedium];
[button setImage:[UIImage systemImageNamed:@"minus.circle" withConfiguration:config] forState:UIControlStateNormal]; [button setImage:[UIImage systemImageNamed:@"minus.circle" withConfiguration:config] forState:UIControlStateNormal];
} else { } else {
[button setTitle:@"Remove" forState:UIControlStateNormal]; [button setTitle:[LocalizationHelper localizedStringForKey:@"Remove"] forState:UIControlStateNormal];
} }
button.accessibilityIdentifier = @"removeButton"; button.accessibilityIdentifier = @"removeButton";
button.translatesAutoresizingMaskIntoConstraints = NO; button.translatesAutoresizingMaskIntoConstraints = NO;