- feat: functional buttons "toolbox" "widgetTool" "widgetProfiles" "softKeyboard"
This commit is contained in:
1 parent
e44504bc48
commit
8afce40e81
5 files changed
+41
-32
No files matched your search
@@ -121,7 +121,7 @@ import UIKit
|
||||
@objc public static let nonVectorStickPads: [String] = ["LSPAD", "RSPAD"]
|
||||
@objc public static let verticalTouchPads: [String] = ["LTPAD", "RTPAD", "MOUSEWHEEL", "WHEEL"]
|
||||
@objc public static let bidirectionalVerticalTouchPads: [String] = ["LTPAD", "RTPAD", "MOUSEWHEEL", "WHEEL"]
|
||||
@objc public static let functionalButtonCmds: [String] = ["SETTINGS"]
|
||||
@objc public static let functionalButtonCmds: [String] = ["SETTINGS", "TOOLBOX", "WIDGETTOOL", "WIDGETPROFILES", "PROFILES", "SOFTKEYBOARD"]
|
||||
@objc public static let motionControlButtonCmds: [String] = ["GYRO","GYROPAUSE","ACCEL","MOTION"]
|
||||
|
||||
// @objc public static let specialGameWidgets: [String] = ["YSRSV", "YSLT", "YSRT", "YSRB", "YSB", "YSRT2", "YSRB2", "YSB2", "YSEM", "YSML", "YSMR", "YSWASD"]
|
||||
|
||||
@@ -77,7 +77,10 @@ static CGFloat screenWidthInPoints;
|
||||
_gestureCaptured = false;
|
||||
self.state = UIGestureRecognizerStateFailed;
|
||||
}
|
||||
else if(_gestureCaptured && allTouchesCount == [touches count] && !_isOnScreenControllerBeingPressed && ![self isOnScreenWidgetViewBeingPressed]){ //must exclude virtual controller & onscreen button taps here to prevent stucked button, _areVirtualControllerTaps flag is set by onscreencontrols, containOnScreenButtonsTaps will be returned by iterating all widget views in streamframeview
|
||||
else if(_gestureCaptured
|
||||
&& allTouchesCount == [touches count]
|
||||
&& !_isOnScreenControllerBeingPressed
|
||||
&& (![self isOnScreenWidgetViewBeingPressed] || _numberOfTouchesRequired ==1)){ //must exclude virtual controller & onscreen button taps here to prevent stucked button, _areVirtualControllerTaps flag is set by onscreencontrols, containOnScreenButtonsTaps will be returned by iterating all widget views in streamframeview
|
||||
_gestureCaptured = false; //reset for next recognition
|
||||
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
|
||||
// lowestTouchPointYCoord = 0.0; //reset for next recognition
|
||||
@@ -89,10 +92,7 @@ static CGFloat screenWidthInPoints;
|
||||
}
|
||||
|
||||
|
||||
// it was a not a perfect choice to code OnScreenWidgetView in Swift...
|
||||
// we're unable to import this class to swift codebase by the bridging header,and have to exlucde the onscreen button taps here
|
||||
// by iterating every widget view instances. but it's basically ok since the number of widgetViews are always limited.
|
||||
// and this method will only be called when the recognizer is active & and the taps passes all the checks and is about to ge triggered.
|
||||
// this method will only be called when the recognizer is active & and the taps passes all the checks and is about to ge triggered.
|
||||
- (bool)isOnScreenWidgetViewBeingPressed {
|
||||
NSTimeInterval allFingersTapDownTime = CACurrentMediaTime() - _gestureCapturedTime; //RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S has been passed to this recognizer as _tapDownTimeShreshold, we'll decide how to deal with pressed flag of on-screen widget views based on tapDownTime
|
||||
bool gotOneWidgetPressed = false;
|
||||
@@ -101,12 +101,12 @@ static CGFloat screenWidthInPoints;
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
OnScreenWidgetView* widgetView = (OnScreenWidgetView*) view;
|
||||
if(gotOneWidgetPressed && allFingersTapDownTime <= _tapDownTimeThreshold){ // once we have just 1 button pressed already,& the tapDownTime has not exceeded the threshold, we'll reset pressed flag for the all the widgetViews.
|
||||
widgetView.pressed = false; //reset the flag for widgetView
|
||||
widgetView.pressedFlagForTapGesture = false; //reset the flag for widgetView
|
||||
continue;
|
||||
}
|
||||
if(widgetView.pressed){
|
||||
if(widgetView.pressedFlagForTapGesture){
|
||||
gotOneWidgetPressed = true; //got one button pressed
|
||||
if(allFingersTapDownTime <= _tapDownTimeThreshold) widgetView.pressed = false; // reset the flag for current widgetView if tapDowntime is still within the threshold, if not, leave the flag for mouse scroller gesture in relative touch mode.
|
||||
if(allFingersTapDownTime <= _tapDownTimeThreshold) widgetView.pressedFlagForTapGesture = false; // reset the flag for current widgetView if tapDowntime is still within the threshold, if not, leave the flag for mouse scroller gesture in relative touch mode.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,11 @@ import UIKit
|
||||
|
||||
@objc public weak var functionalButtonDelegate: OnScreenFunctionalButtonDelegate?
|
||||
@objc protocol OnScreenFunctionalButtonDelegate: AnyObject {
|
||||
func expandSettingsView()
|
||||
func bringUpToolboxMenu()
|
||||
func openWidgetLayoutTool()
|
||||
func switchWidgetProfile()
|
||||
func bringUpSoftKeyboard()
|
||||
func enterPip()
|
||||
func toggleStatsOverlay()
|
||||
func disconnectAndQuitApp()
|
||||
}
|
||||
|
||||
@objc enum WidgetTypeEnum: UInt8 {
|
||||
@@ -60,7 +59,7 @@ import UIKit
|
||||
@objc public var comboButtonStrings: [String] = []
|
||||
private var comboKeyTimeIntervalMs: UInt32 = 0
|
||||
|
||||
@objc public var pressed: Bool
|
||||
@objc public var pressedFlagForTapGesture: Bool
|
||||
@objc public var logicallyDown: Bool = false
|
||||
@objc public var widthFactor: CGFloat = 1.0
|
||||
@objc public var heightFactor: CGFloat = 1.0
|
||||
@@ -271,7 +270,7 @@ import UIKit
|
||||
self.shape = shape
|
||||
self.label = UILabel()
|
||||
// self.originalBackgroundColor = UIColor(white: 0.2, alpha: 0.7)
|
||||
self.pressed = false
|
||||
self.pressedFlagForTapGesture = false
|
||||
// self.widthFactor = 1.0
|
||||
// self.heightFactor = 1.0
|
||||
// self.backgroundAlpha = 0.5
|
||||
@@ -1133,9 +1132,16 @@ import UIKit
|
||||
|
||||
if !OnScreenWidgetView.editMode, !self.motionControlButtonString.isEmpty {self.handleMotionControlButtonDown()}
|
||||
|
||||
// sadflkasdfl;
|
||||
print("666 buttonDownVisualEffectLayer.borderColor: \(CACurrentMediaTime())")
|
||||
|
||||
self.buttonDownVisualEffect()
|
||||
|
||||
if vibrationOn {
|
||||
vibrationGenerator.prepare()
|
||||
vibrationGenerator.impactOccurred()
|
||||
}
|
||||
}
|
||||
|
||||
private func buttonDownVisualEffect(){
|
||||
logicallyDown = true
|
||||
if OnScreenWidgetView.buttonVisualFeedbackEnabled {
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
@@ -1143,23 +1149,18 @@ import UIKit
|
||||
buttonDownVisualEffectLayer.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)) // update position every time we press down the button
|
||||
// buttonDownVisualEffectLayer.borderWidth = self.buttonDownVisualEffectWidth // this will show the visual effect
|
||||
buttonDownVisualEffectLayer.borderColor = voidlinkPurple
|
||||
logicallyDown = true
|
||||
CATransaction.commit()
|
||||
}
|
||||
if vibrationOn {
|
||||
vibrationGenerator.prepare()
|
||||
vibrationGenerator.impactOccurred()
|
||||
}
|
||||
}
|
||||
|
||||
private func buttonUpVisualEffect(){
|
||||
logicallyDown = false
|
||||
if OnScreenWidgetView.buttonVisualFeedbackEnabled {
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
// self.layer.borderWidth = 1
|
||||
// buttonDownVisualEffectLayer.borderWidth = 0
|
||||
buttonDownVisualEffectLayer.borderColor = UIColor.clear.cgColor
|
||||
logicallyDown = false
|
||||
CATransaction.commit()
|
||||
}
|
||||
}
|
||||
@@ -1171,11 +1172,11 @@ import UIKit
|
||||
self.handleMotionControlButtonUp()
|
||||
}
|
||||
|
||||
self.buttonUpVisualEffect()
|
||||
|
||||
if !OnScreenWidgetView.editMode && !self.functionalButtonString.isEmpty{
|
||||
self.handleFunctionalButtonUp()
|
||||
}
|
||||
|
||||
self.buttonUpVisualEffect()
|
||||
}
|
||||
|
||||
private func setupLrudDirectionIndicatorlayers() {
|
||||
@@ -1380,7 +1381,7 @@ import UIKit
|
||||
self.twoTouchesDetected = true
|
||||
}
|
||||
|
||||
self.pressed = true
|
||||
self.pressedFlagForTapGesture = true
|
||||
|
||||
if !OnScreenWidgetView.editMode {
|
||||
if self.widgetType == WidgetTypeEnum.touchPad && touches.count == 1{ // don't use event?.allTouches?.count here, it will counts all touches including the ones captured by other UIViews
|
||||
@@ -1765,10 +1766,18 @@ import UIKit
|
||||
|
||||
private func handleFunctionalButtonUp(){
|
||||
let longPressed = CACurrentMediaTime() - self.touchTapTimeStamp > 0.3
|
||||
if longPressed, buttonMode == ButtonMode.movable.rawValue {return}
|
||||
switch self.functionalButtonString {
|
||||
case "SETTINGS":
|
||||
if longPressed, buttonMode == ButtonMode.movable.rawValue {break}
|
||||
NotificationCenter.default.post(name: Notification.Name("SettingsOverlayButtonPressedNotification"), object:nil) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification
|
||||
self.functionalButtonDelegate?.expandSettingsView()
|
||||
case "TOOLBOX":
|
||||
self.functionalButtonDelegate?.bringUpToolboxMenu()
|
||||
case "WIDGETTOOL":
|
||||
self.functionalButtonDelegate?.openWidgetLayoutTool()
|
||||
case "PROFILES","WIDGETPROFILES":
|
||||
self.functionalButtonDelegate?.switchWidgetProfile()
|
||||
case "SOFTKEYBOARD":
|
||||
self.functionalButtonDelegate?.bringUpSoftKeyboard()
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2;
|
||||
for(UIView* view in self->streamView.superview.subviews){ // iterates all on-screen widget views in StreamFrameView
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
OnScreenWidgetView* widgetView = (OnScreenWidgetView*) view;
|
||||
if(widgetView.pressed){
|
||||
if(widgetView.pressedFlagForTapGesture){
|
||||
gotOneButtonPressed = true; //got one button pressed
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2;
|
||||
for(UIView* view in self->streamView.superview.subviews){ // iterates all on-screen widget views in StreamFrameView
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
OnScreenWidgetView* widgetView = (OnScreenWidgetView*) view;
|
||||
widgetView.pressed = false;
|
||||
widgetView.pressedFlagForTapGesture = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@
|
||||
//NSLog(@"in osc streamview gestures: %d", (uint32_t)[_streamView.gestureRecognizers count]);
|
||||
}
|
||||
|
||||
- (void)presentToolboxViewController{
|
||||
- (void)bringUpToolboxMenu{
|
||||
[self configOscLayoutTool];
|
||||
ToolboxViewController* oldToolboxVC = toolBoxViewController;
|
||||
toolBoxViewController = [[ToolboxViewController alloc] init];
|
||||
@@ -288,7 +288,7 @@
|
||||
[self.view addGestureRecognizer:_slideToSettingsRecognizer];
|
||||
|
||||
|
||||
_slideToCmdToolRecognizer = [[CustomEdgeSlideGestureRecognizer alloc] initWithTarget:self action:@selector(presentToolboxViewController)];
|
||||
_slideToCmdToolRecognizer = [[CustomEdgeSlideGestureRecognizer alloc] initWithTarget:self action:@selector(bringUpToolboxMenu)];
|
||||
if(_settings.slideToSettingsScreenEdge.intValue == UIRectEdgeLeft) _slideToCmdToolRecognizer.edges = UIRectEdgeRight;
|
||||
else _slideToCmdToolRecognizer.edges = UIRectEdgeLeft; // _commandManager triggered by sliding from another side.
|
||||
_slideToCmdToolRecognizer.normalizedThresholdDistance = _settings.slideToSettingsDistance.floatValue;
|
||||
|
||||
Reference in new issue
Block a user