diff --git a/Limelight/Input/CustomOSC/LayoutOnScreenControls.h b/Limelight/Input/CustomOSC/LayoutOnScreenControls.h index 957ab5ba..c0573605 100644 --- a/Limelight/Input/CustomOSC/LayoutOnScreenControls.h +++ b/Limelight/Input/CustomOSC/LayoutOnScreenControls.h @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN @property UIView* _view; @property NSMutableArray *layoutChanges; @property CALayer *layerBeingDragged; +@property UIViewController *layoutToolVC; - (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport streamConfig:(StreamConfiguration*)streamConfig oscLevel:(int)oscLevel; diff --git a/Limelight/Input/CustomOSC/LayoutOnScreenControls.m b/Limelight/Input/CustomOSC/LayoutOnScreenControls.m index 0c69cdb5..eb56037e 100644 --- a/Limelight/Input/CustomOSC/LayoutOnScreenControls.m +++ b/Limelight/Input/CustomOSC/LayoutOnScreenControls.m @@ -10,7 +10,7 @@ #import "OSCProfilesTableViewController.h" #import "OnScreenButtonState.h" #import "OSCProfilesManager.h" - +#import "Moonlight-Swift.h" @interface LayoutOnScreenControls () @end @@ -209,30 +209,44 @@ -Change horizontal guideline color to white if its y-position is almost equal to that of one of the buttons on screen. -Change vertical guideline color to white if its x-position is almost equal to that of one of the buttons on screen. */ + horizontalGuideline.backgroundColor = [UIColor blueColor]; // change horizontal guideline back to blue if it doesn't line up with one of the on screen buttons for (CALayer *button in self.OSCButtonLayers) { // horizontal guideline position check - if ((layerBeingDragged != button) && !button.isHidden) { if ((horizontalGuideline.center.y < button.position.y + 1) && (horizontalGuideline.center.y > button.position.y - 1)) { - horizontalGuideline.backgroundColor = [UIColor whiteColor]; + horizontalGuideline.backgroundColor = [UIColor yellowColor]; break; } } - - horizontalGuideline.backgroundColor = [UIColor blueColor]; // change horizontal guideline back to blue if it doesn't line up with one of the on screen buttons } + for(UIView* view in self.layoutToolVC.view.subviews){ + if ([view isKindOfClass:[OnScreenWidgetView class]]) { + if ((horizontalGuideline.center.y < view.center.y + 1) && (horizontalGuideline.center.y > view.center.y - 1)) { + horizontalGuideline.backgroundColor = [UIColor yellowColor]; + break; + } + } + } + + verticalGuideline.backgroundColor = [UIColor blueColor]; // change vertical guideline back to blue if it doesn't line up with one of the on screen buttons for (CALayer *button in self.OSCButtonLayers) { // vertical guideline position check - if ((layerBeingDragged != button) && !button.isHidden) { if ((verticalGuideline.center.x < button.position.x + 1) && (verticalGuideline.center.x > button.position.x - 1)) { - verticalGuideline.backgroundColor = [UIColor whiteColor]; + verticalGuideline.backgroundColor = [UIColor yellowColor]; break; } } - - verticalGuideline.backgroundColor = [UIColor blueColor]; // change vertical guideline back to blue if it doesn't line up with one of the on screen buttons } + for(UIView* view in self.layoutToolVC.view.subviews){ + if ([view isKindOfClass:[OnScreenWidgetView class]]) { + if ((verticalGuideline.center.x < view.center.x + 1) && (verticalGuideline.center.x > view.center.x - 1)) { + verticalGuideline.backgroundColor = [UIColor yellowColor]; + break; + } + } + } + } - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.h b/Limelight/Input/CustomOSC/OSCProfilesManager.h index cc036f1a..dd3c5de6 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.h +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN + (OSCProfilesManager *) sharedManager; -+ (void) setOnScreenButtonViewsDict:(NSMutableDictionary* )dict; ++ (void) setOnScreenWidgetViewsDict:(NSMutableDictionary* )dict; #pragma mark - Getters /** diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.m b/Limelight/Input/CustomOSC/OSCProfilesManager.m index b7fc9834..69b6da4d 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.m +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.m @@ -14,7 +14,7 @@ @implementation OSCProfilesManager -static NSMutableDictionary *onScreenButtonViewsDict; +static NSMutableDictionary *OnScreenWidgetViewsDict; #pragma mark - Initializer @@ -32,8 +32,8 @@ static NSMutableDictionary *onScreenButtonViewsDict; #pragma mark - Class Helper Methods -+ (void) setOnScreenButtonViewsDict:(NSMutableDictionary* )dict{ - onScreenButtonViewsDict = dict; ++ (void) setOnScreenWidgetViewsDict:(NSMutableDictionary* )dict{ + OnScreenWidgetViewsDict = dict; } /** @@ -281,17 +281,17 @@ static NSMutableDictionary *onScreenButtonViewsDict; [buttonStatesEncoded addObject: buttonStateEncoded]; } - // save on-screen button views (keyboard & mouse command) as buttonstate: - [onScreenButtonViewsDict enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { // this dict is passed from the layout tool VC, as a static obj in this class. - OnScreenButtonView *buttonView = value; - OnScreenButtonState *buttonState = [[OnScreenButtonState alloc] initWithButtonName:buttonView.keyString buttonType:KeyboardOrMouseButton andPosition:buttonView.frame.origin]; - buttonState.alias = buttonView.keyLabel; - buttonState.timestamp = buttonView.timestamp; - buttonState.widthFactor = buttonView.widthFactor; - buttonState.heightFactor = buttonView.heightFactor; - buttonState.backgroundAlpha = buttonView.backgroundAlpha; - buttonState.sensitivityFactor = buttonView.sensitivityFactor; - buttonState.stickIndicatorXOffset = buttonView.stickIndicatorXOffset; + // save on-screen widget views (keyboard & mouse command) as buttonstate: + [OnScreenWidgetViewsDict enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { // this dict is passed from the layout tool VC, as a static obj in this class. + OnScreenWidgetView *widgetView = value; + OnScreenButtonState *buttonState = [[OnScreenButtonState alloc] initWithButtonName:widgetView.keyString buttonType:KeyboardOrMouseButton andPosition:widgetView.frame.origin]; + buttonState.alias = widgetView.keyLabel; + buttonState.timestamp = widgetView.timestamp; + buttonState.widthFactor = widgetView.widthFactor; + buttonState.heightFactor = widgetView.heightFactor; + buttonState.backgroundAlpha = widgetView.backgroundAlpha; + buttonState.sensitivityFactor = widgetView.sensitivityFactor; + buttonState.stickIndicatorXOffset = widgetView.stickIndicatorXOffset; NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil]; [buttonStatesEncoded addObject: buttonStateEncoded]; diff --git a/Limelight/Input/CustomOSC/OnScreenButtonState.h b/Limelight/Input/CustomOSC/OnScreenButtonState.h index 2394defe..bec0e14c 100644 --- a/Limelight/Input/CustomOSC/OnScreenButtonState.h +++ b/Limelight/Input/CustomOSC/OnScreenButtonState.h @@ -25,10 +25,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL isHidden; @property (nonatomic, assign) uint8_t buttonType; @property (nonatomic, assign) NSTimeInterval timestamp; -@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenButtonView -@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenButtonView -@property (nonatomic, assign) CGFloat sensitivityFactor; // for OnScreenButtonView -@property (nonatomic, assign) CGFloat stickIndicatorXOffset; // for OnScreenButtonView +@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenWidgetView +@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenWidgetView +@property (nonatomic, assign) CGFloat sensitivityFactor; // for OnScreenWidgetView +@property (nonatomic, assign) CGFloat stickIndicatorXOffset; // for OnScreenWidgetView @property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer @property (nonatomic, assign) CGFloat backgroundAlpha; // for OnScreenController CALayer diff --git a/Limelight/Input/CustomTapGestureRecognizer.m b/Limelight/Input/CustomTapGestureRecognizer.m index a55fed85..9e27ef64 100644 --- a/Limelight/Input/CustomTapGestureRecognizer.m +++ b/Limelight/Input/CustomTapGestureRecognizer.m @@ -74,7 +74,7 @@ static CGFloat screenWidthInPoints; _gestureCaptured = false; self.state = UIGestureRecognizerStateFailed; } - else if(_gestureCaptured && allTouchesCount == [touches count] && !_isOnScreenControllerBeingPressed && ![self isOnScreenButtonViewBeingPressed]){ //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 button views in streamframeview + 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 _gestureCaptured = false; //reset for next recognition if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){ lowestTouchPointYCoord = 0.0; //reset for next recognition @@ -85,28 +85,28 @@ static CGFloat screenWidthInPoints; } -// it was a not a perfect choice to code OnScreenButtonView in Swift... +// 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 button view instances. but it's basically ok since the number of buttonViews are always limited. +// 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. -- (bool)isOnScreenButtonViewBeingPressed { - 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 button views based on tapDownTime - bool gotOneButtonPressed = false; - // the tap gestures are all added to the streamFrameTopLayerView, where all the onScreenButtonViews are added. so we can iterate them in this way: +- (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; + // the tap gestures are all added to the streamFrameTopLayerView, where all the OnScreenWidgetViews are added. so we can iterate them in this way: for(UIView* view in self.view.subviews){ - if ([view isKindOfClass:[OnScreenButtonView class]]) { - OnScreenButtonView* buttonView = (OnScreenButtonView*) view; - if(gotOneButtonPressed && 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 buttonViews. - buttonView.pressed = false; //reset the flag for buttonView + 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 continue; } - if(buttonView.pressed){ - gotOneButtonPressed = true; //got one button pressed - if(allFingersTapDownTime <= _tapDownTimeThreshold) buttonView.pressed = false; // reset the flag for current buttonView if tapDowntime is still within the threshold, if not, leave the flag for mouse scroller gesture in relative touch mode. + if(widgetView.pressed){ + 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. } } } - return gotOneButtonPressed; + return gotOneWidgetPressed; } @end diff --git a/Limelight/Input/OnScreenControls.h b/Limelight/Input/OnScreenControls.h index 73914977..949a9a8c 100644 --- a/Limelight/Input/OnScreenControls.h +++ b/Limelight/Input/OnScreenControls.h @@ -15,7 +15,7 @@ @class ControllerSupport; @class StreamConfiguration; -// sending self as an instance to OnScreenButtonView or other related classes +// sending self as an instance to OnScreenWidgetView or other related classes @protocol InstanceProviderDelegate - (void)getOnScreenControlsInstance:(id)sender; // Renamed delegate method @end diff --git a/Limelight/Input/OnScreenControls.m b/Limelight/Input/OnScreenControls.m index 8a17ccb7..a4cb8477 100644 --- a/Limelight/Input/OnScreenControls.m +++ b/Limelight/Input/OnScreenControls.m @@ -189,7 +189,7 @@ static float L3_Y; [_controllerSupport updateFinished:_controller]; } -// sending self as an instance to OnScreenButtonView +// sending self as an instance to OnScreenWidgetView - (void)sendInstance{ NSLog(@"OnScreenControls is sending its instance..."); if ([self.delegate respondsToSelector:@selector(getOnScreenControlsInstance:)]) { diff --git a/Limelight/Input/OnScreenButtonView.swift b/Limelight/Input/OnScreenWidgetView.swift similarity index 97% rename from Limelight/Input/OnScreenButtonView.swift rename to Limelight/Input/OnScreenWidgetView.swift index 12519898..44622e60 100644 --- a/Limelight/Input/OnScreenButtonView.swift +++ b/Limelight/Input/OnScreenWidgetView.swift @@ -8,7 +8,7 @@ import UIKit -@objc class OnScreenButtonView: UIView, InstanceProviderDelegate { +@objc class OnScreenWidgetView: UIView, InstanceProviderDelegate { // receiving the OnScreenControls instance from delegate @objc func getOnScreenControlsInstance(_ sender: Any) { if let controls = sender as? OnScreenControls { @@ -150,7 +150,7 @@ import UIKit } @objc public func enableRelocationMode(enabled: Bool){ - OnScreenButtonView.editMode = enabled + OnScreenWidgetView.editMode = enabled } @objc public func adjustButtonTransparency(alpha: CGFloat){ @@ -163,7 +163,7 @@ import UIKit self.tweakAlpha() } - @objc public func resizeButtonView(){ + @objc public func resizeWidgetView(){ guard let superview = superview else { return } @@ -185,7 +185,7 @@ import UIKit // Trigger layout update superview.layoutIfNeeded() - // Re-setup buttonView style + // Re-setup widgetView style setupView() } @@ -258,7 +258,7 @@ import UIKit if CommandManager.touchPadCmds.contains(self.keyString){ label.text = "" // make touchPad display no text - if OnScreenButtonView.editMode { //display label in edit mode to make the pad more visible + if OnScreenWidgetView.editMode { //display label in edit mode to make the pad more visible label.text = self.keyString } } @@ -315,7 +315,7 @@ import UIKit self.selfViewOnTheRight = (self.storedLocation.x > self.appWindow.frame.width*0.5) let offsetSign = selfViewOnTheRight ? -1 : 1 let stickMarkerRelativeLocation:CGPoint - if !OnScreenButtonView.editMode { + if !OnScreenWidgetView.editMode { stickMarkerRelativeLocation = CGPointMake(touchBeganLocation.x + CGFloat(offsetSign) * self.stickIndicatorXOffset, touchBeganLocation.y) } else{ @@ -384,7 +384,7 @@ import UIKit CATransaction.begin() CATransaction.setDisableActions(true) self.stickBallLayer.removeAllAnimations() - if !OnScreenButtonView.editMode { + if !OnScreenWidgetView.editMode { self.stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetX*sensitivityFactor), CGRectGetMidY(self.crossMarkLayer.frame) + touchInputToStickBallCoord(input: offSetY*sensitivityFactor)) } else{ @@ -701,14 +701,14 @@ import UIKit self.latestTouchLocation = touchBeganLocation } - let allCapturedTouchesCount = event?.allTouches?.filter({ $0.view == self }).count // this will counts all valid touches within the self buttonView, and excludes touches in other buttonViews + let allCapturedTouchesCount = event?.allTouches?.filter({ $0.view == self }).count // this will counts all valid touches within the self widgetView, and excludes touches in other widgetViews if allCapturedTouchesCount == 2 { self.twoTouchesDetected = true } self.pressed = true - if !OnScreenButtonView.editMode { + if !OnScreenWidgetView.editMode { if CommandManager.touchPadCmds.contains(self.keyString) && touches.count == 1{ // don't use event?.allTouches?.count here, it will counts all touches including the ones captured by other UIViews switch self.keyString { case "LSPAD": @@ -770,7 +770,7 @@ import UIKit } // here is in edit mode: else{ - NotificationCenter.default.post(name: Notification.Name("OnScreenButtonViewSelected"),object: self) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification + NotificationCenter.default.post(name: Notification.Name("OnScreenWidgetViewSelected"),object: self) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification if let touch = touches.first { let touchLocation = touch.location(in: superview) storedLocation = touchLocation @@ -790,9 +790,9 @@ import UIKit override func touchesMoved(_ touches: Set, with event: UIEvent?) { super.touchesMoved(touches, with: event) - OnScreenButtonView.timestampOfButtonBeingDragged = self.timestamp + OnScreenWidgetView.timestampOfButtonBeingDragged = self.timestamp - if !OnScreenButtonView.editMode { + if !OnScreenWidgetView.editMode { if CommandManager.touchPadCmds.contains(self.keyString){ handleTouchPadMoveEvent(touches, with: event) } @@ -808,8 +808,8 @@ import UIKit } } - // Move the buttonView based on touch movement in relocation mode - if OnScreenButtonView.editMode { + // Move the widgetView based on touch movement in relocation mode + if OnScreenWidgetView.editMode { if let touch = touches.first { self.moveByTouch(touch: touch) } @@ -858,10 +858,10 @@ import UIKit if self.keyString != "MOUSEPAD" {quickDoubleTapDetected = false} //do not reset this flag here in mousePad mode - let allCapturedTouchesCount = event?.allTouches?.filter({ $0.view == self }).count // this will counts all valid touches within the self buttonView, and excludes touches in other buttonViews + let allCapturedTouchesCount = event?.allTouches?.filter({ $0.view == self }).count // this will counts all valid touches within the self widgetView, and excludes touches in other widgetViews // deal with MOUSPAD first - if !OnScreenButtonView.editMode && self.keyString == "MOUSEPAD" && allCapturedTouchesCount == 1 && !twoTouchesDetected { + if !OnScreenWidgetView.editMode && self.keyString == "MOUSEPAD" && allCapturedTouchesCount == 1 && !twoTouchesDetected { if !mousePointerMoved && !quickDoubleTapDetected {self.sendLongMouseLeftButtonClickEvent()} // deal with single tap(click) if quickDoubleTapDetected { //deal with quick double tap LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_LEFT) //must release the button anyway, because the button is likely being held down since the long click turned into a dragging event. @@ -871,14 +871,14 @@ import UIKit mousePointerMoved = false // reset this flag } - if !OnScreenButtonView.editMode && self.keyString == "MOUSEPAD" && twoTouchesDetected && touches.count == allCapturedTouchesCount { // need to enable multi-touch first + if !OnScreenWidgetView.editMode && self.keyString == "MOUSEPAD" && twoTouchesDetected && touches.count == allCapturedTouchesCount { // need to enable multi-touch first // touches.count == allCapturedTouchesCount means allfingers are lifting self.sendMouseRightButtonClickEvent() twoTouchesDetected = false } // then other types of pads - if !OnScreenButtonView.editMode && CommandManager.touchPadCmds.contains(self.keyString) { + if !OnScreenWidgetView.editMode && CommandManager.touchPadCmds.contains(self.keyString) { switch self.keyString{ case "LSPAD": self.onScreenControls.clearLeftStickTouchPadFlag() @@ -912,7 +912,7 @@ import UIKit } } - if !OnScreenButtonView.editMode && CommandManager.specialOverlayButtonCmds.contains(self.keyString){ + if !OnScreenWidgetView.editMode && CommandManager.specialOverlayButtonCmds.contains(self.keyString){ if CACurrentMediaTime() - self.touchTapTimeStamp < 0.3 { switch self.keyString { case "SETTINGS": @@ -940,7 +940,7 @@ import UIKit if self.keyString == "OSCR2" {self.onScreenControls.updateRightTrigger(0x00)} } - if !OnScreenButtonView.editMode && !self.keyString.contains("+") { // if the command(keystring contains "+", it's a multi-key command rather than a single key button + if !OnScreenWidgetView.editMode && !self.keyString.contains("+") { // if the command(keystring contains "+", it's a multi-key command rather than a single key button if CommandManager.mouseButtonMappings.keys.contains(self.keyString){ LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), Int32(CommandManager.mouseButtonMappings[self.keyString]!)) @@ -950,7 +950,7 @@ import UIKit } } - if OnScreenButtonView.editMode { + if OnScreenWidgetView.editMode { guard let superview = superview else { return } // Deactivate existing constraints if necessary @@ -969,7 +969,7 @@ import UIKit // Trigger layout update superview.layoutIfNeeded() - setupView(); //re-setup buttonView style + setupView(); //re-setup widgetView style if CommandManager.nonVectorStickPads.contains(self.keyString) { self.crossMarkLayer.removeFromSuperlayer() diff --git a/Limelight/Input/RelativeTouchHandler.m b/Limelight/Input/RelativeTouchHandler.m index 9ee6e255..8ab391c4 100644 --- a/Limelight/Input/RelativeTouchHandler.m +++ b/Limelight/Input/RelativeTouchHandler.m @@ -91,12 +91,12 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; } -- (bool)isOnScreenButtonViewBeingPressed { +- (bool)isOnScreenWidgetViewBeingPressed { bool gotOneButtonPressed = false; - for(UIView* view in self->streamView.superview.subviews){ // iterates all on-screen button views in StreamFrameView - if ([view isKindOfClass:[OnScreenButtonView class]]) { - OnScreenButtonView* buttonView = (OnScreenButtonView*) view; - if(buttonView.pressed){ + 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){ gotOneButtonPressed = true; //got one button pressed } } @@ -104,11 +104,11 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; return gotOneButtonPressed; } -- (void)resetAllPressedFlagsForOnscreenButtonViews { - for(UIView* view in self->streamView.superview.subviews){ // iterates all on-screen button views in StreamFrameView - if ([view isKindOfClass:[OnScreenButtonView class]]) { - OnScreenButtonView* buttonView = (OnScreenButtonView*) view; - buttonView.pressed = false; +- (void)resetAllPressedFlagsForOnScreenWidgetViews { + 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; } } } @@ -146,7 +146,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; touchPointSpawnedAtUpperScreenEdge = false; // reset this flag immediately if we get a touch event passing the check above, this fixes irresponsive touch after closing the command tool menu. - if([[event allTouches] count] == 2 && ![self isOnScreenButtonViewBeingPressed] && ![self isOnScreenControllerBeingPressed:[event allTouches]]){ + if([[event allTouches] count] == 2 && ![self isOnScreenWidgetViewBeingPressed] && ![self isOnScreenControllerBeingPressed:[event allTouches]]){ NSLog(@"get in scrolling mode"); isInMouseWheelScrollingMode = true; return; // if we got 2 touches on the blank area, it's gonna be a mouse scroll touch, and must prevent UITtouch object for mouse pointer being captured & locked @@ -190,7 +190,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; //NSLog(@"%f, touchesMoved callback, is scrolling: %d, touches count: %d", CACurrentMediaTime(), isInMouseWheelScrollingMode, (uint32_t)[touches count]); - if(isInMouseWheelScrollingMode && [[event allTouches] count] == 2 && ![self isOnScreenButtonViewBeingPressed] && ![self isOnScreenControllerBeingPressed:touches]){ + if(isInMouseWheelScrollingMode && [[event allTouches] count] == 2 && ![self isOnScreenWidgetViewBeingPressed] && ![self isOnScreenControllerBeingPressed:touches]){ NSSet* twoTouches = [event allTouches]; CGPoint firstLocation = [[[twoTouches allObjects] objectAtIndex:0] locationInView:streamView]; CGPoint secondLocation = [[[twoTouches allObjects] objectAtIndex:1] locationInView:streamView]; @@ -237,7 +237,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; isInMouseWheelScrollingMode = false; touchLockedForMouseMove = nil; mousePointerMoved = false; // need to reset this anyway - [self resetAllPressedFlagsForOnscreenButtonViews]; // reset all pressed flag for on-screen button views after all fingers lifted from screen. + [self resetAllPressedFlagsForOnScreenWidgetViews]; // reset all pressed flag for on-screen widget views after all fingers lifted from screen. touchPointSpawnedAtUpperScreenEdge = false; } } diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index 8b8709d2..c32bca5e 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -43,7 +43,7 @@ - (void) reloadOnScreenControlsWith:(ControllerSupport*)controllerSupport andConfig:(StreamConfiguration*)streamConfig; - (void) clearOnScreenKeyboardButtons; -- (void) reloadOnScreenButtonViews; +- (void) reloadOnScreenWidgetViews; - (CGSize) getVideoAreaSize; - (CGPoint) adjustCoordinatesForVideoArea:(CGPoint)point; diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index f51f8df2..bde9bdb0 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -368,18 +368,18 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void) clearOnScreenKeyboardButtons{ for (UIView *subview in self->streamFrameTopLayerView.subviews) { // 检查子视图是否是特定类型的实例 - if ([subview isKindOfClass:[OnScreenButtonView class]]) { + if ([subview isKindOfClass:[OnScreenWidgetView class]]) { // 如果是,就添加到将要被移除的数组中 [subview removeFromSuperview]; } } } -- (void) reloadOnScreenButtonViews{ +- (void) reloadOnScreenWidgetViews{ NSLog(@"reload on screen keyboard buttons here"); - // remove all keyboard button views first + // remove all keyboard widget views first [self clearOnScreenKeyboardButtons]; // bool customOscEnabled = [self isOscEnabled] && settings.onscreenControls.intValue == OnScreenControlsLevelCustom; @@ -389,25 +389,25 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; OSCProfilesManager* profilesManager = [OSCProfilesManager sharedManager]; OSCProfile *oscProfile = [profilesManager getSelectedProfile]; //returns the currently selected OSCProfile - if(!OnScreenButtonView.editMode){ // in edit mode, keyboard button view will be updated within layoutool view controller. + if(!OnScreenWidgetView.editMode){ // in edit mode, keyboard widget view will be updated within layoutool view controller. for (NSData *buttonStateEncoded in oscProfile.buttonStates) { OnScreenButtonState* buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil]; if(buttonState.buttonType == KeyboardOrMouseButton){ - OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct buttonView + OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct widgetView //-------------------------------------------------- - onScreenControls.delegate = buttonView; // connecting onScreenControls to OnScreenButtonView, sending the active instance for touchPad stick control + onScreenControls.delegate = widgetView; // connecting onScreenControls to OnScreenWidgetView, sending the active instance for touchPad stick control [onScreenControls sendInstance]; //-------------------------------------------------- - 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]; - [buttonView resizeButtonView]; // resize must be called after relocation - [buttonView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha]; + widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place + widgetView.widthFactor = buttonState.widthFactor; + widgetView.heightFactor = buttonState.heightFactor; + widgetView.sensitivityFactor = buttonState.sensitivityFactor; + widgetView.stickIndicatorXOffset = buttonState.stickIndicatorXOffset; + // Add the widgetView to the view controller's view + [self->streamFrameTopLayerView addSubview:widgetView]; // add keyboard button to the stream frame view. must add it to the target view before setting location. + [widgetView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y]; + [widgetView resizeWidgetView]; // resize must be called after relocation + [widgetView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha]; } } } diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h index 83621485..5998fc9e 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h @@ -20,10 +20,10 @@ NS_ASSUME_NONNULL_BEGIN */ @interface LayoutOnScreenControlsViewController : UIViewController - (void)profileRefresh; -- (void)reloadOnScreenButtonViews; +- (void)reloadOnScreenWidgetViews; @property LayoutOnScreenControls *layoutOSC; // object that contains a view which contains the on screen controller buttons that allows the user to drag and positions each button on the screen using touch -@property (nonatomic) NSMutableDictionary* onScreenButtonViewsDict; +@property (nonatomic) NSMutableDictionary* OnScreenWidgetViewsDict; @property int OSCSegmentSelected; diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m index c3d8a40e..65515333 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m @@ -22,10 +22,10 @@ @implementation LayoutOnScreenControlsViewController { BOOL isToolbarHidden; OSCProfilesManager* profilesManager; - OnScreenButtonView* selectedButtonView; + OnScreenWidgetView* selectedWidgetView; CALayer* selectedControllerLayer; CGRect controllerLoadedBounds; - bool buttonViewSelected; + bool widgetViewSelected; bool controllerLayerSelected; __weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPhone; __weak IBOutlet NSLayoutConstraint *toolbarTopConstraintiPad; @@ -46,25 +46,25 @@ - (void) viewWillDisappear:(BOOL)animated{ - OnScreenButtonView.editMode = false; - for (OnScreenButtonView* buttonView in self.onScreenButtonViewsDict.allValues){ - [buttonView.stickBallLayer removeFromSuperlayer]; - [buttonView.crossMarkLayer removeFromSuperlayer]; + OnScreenWidgetView.editMode = false; + for (OnScreenWidgetView* widgetView in self.OnScreenWidgetViewsDict.allValues){ + [widgetView.stickBallLayer removeFromSuperlayer]; + [widgetView.crossMarkLayer removeFromSuperlayer]; } [super viewWillDisappear:animated]; [[NSNotificationCenter defaultCenter] postNotificationName:@"OscLayoutCloseNotification" object:self]; } -- (void) reloadOnScreenButtonViews { +- (void) reloadOnScreenWidgetViews { for (UIView *subview in self.view.subviews) { // 检查子视图是否是特定类型的实例 - if ([subview isKindOfClass:[OnScreenButtonView class]]) { + if ([subview isKindOfClass:[OnScreenWidgetView class]]) { // 如果是,就添加到将要被移除的数组中 [subview removeFromSuperview]; } } - [self.onScreenButtonViewsDict removeAllObjects]; + [self.OnScreenWidgetViewsDict removeAllObjects]; NSLog(@"reload os Key here"); @@ -73,20 +73,20 @@ for (NSData *buttonStateEncoded in oscProfile.buttonStates) { OnScreenButtonState* buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil]; if(buttonState.buttonType == KeyboardOrMouseButton){ - OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct buttonView - buttonView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place - 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]; - [buttonView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y]; - [buttonView resizeButtonView]; // resize must be called after relocation - [buttonView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha]; - [self.onScreenButtonViewsDict setObject:buttonView forKey:@(buttonView.timestamp)]; + OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct widgetView + widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place + widgetView.timestamp = buttonState.timestamp; // will be set as key in in the dict. + widgetView.widthFactor = buttonState.widthFactor; + widgetView.heightFactor = buttonState.heightFactor; + widgetView.sensitivityFactor = buttonState.sensitivityFactor; + widgetView.stickIndicatorXOffset = buttonState.stickIndicatorXOffset; + // widgetView.backgroundAlpha = buttonState.backgroundAlpha; + // Add the widgetView to the view controller's view + [self.view addSubview:widgetView]; + [widgetView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y]; + [widgetView resizeWidgetView]; // resize must be called after relocation + [widgetView adjustButtonTransparencyWithAlpha:buttonState.backgroundAlpha]; + [self.OnScreenWidgetViewsDict setObject:widgetView forKey:@(widgetView.timestamp)]; } } } @@ -95,8 +95,8 @@ - (void) viewDidLoad { [super viewDidLoad]; profilesManager = [OSCProfilesManager sharedManager]; - self.onScreenButtonViewsDict = [[NSMutableDictionary alloc] init]; // will be revised to read persisted data , somewhere else - [OSCProfilesManager setOnScreenButtonViewsDict:self.onScreenButtonViewsDict]; // pass the keyboard button dict to profiles manager + self.OnScreenWidgetViewsDict = [[NSMutableDictionary alloc] init]; // will be revised to read persisted data , somewhere else + [OSCProfilesManager setOnScreenWidgetViewsDict:self.OnScreenWidgetViewsDict]; // pass the keyboard button dict to profiles manager isToolbarHidden = NO; // keeps track if the toolbar is hidden up above the screen so that we know whether to hide or show it when the user taps the toolbar's hide/show button @@ -127,6 +127,7 @@ self.layoutOSC = [[LayoutOnScreenControls alloc] initWithView:self.view controllerSup:nil streamConfig:nil oscLevel:OSCSegmentSelected]; self.layoutOSC._level = OnScreenControlsLevelCustom; + self.layoutOSC.layoutToolVC = self; [self.layoutOSC show]; // draw on screen controls [self addInnerAnalogSticksToOuterAnalogLayers]; // allows inner and analog sticks to be dragged together around the screen together as one unit which is the expected behavior @@ -144,13 +145,13 @@ [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(reloadOnScreenButtonViews) + selector:@selector(reloadOnScreenWidgetViews) name:@"OscLayoutProfileSelctedInTableView" // This is a special notification for reloading the on screen keyboard buttons. which can't be executed by _oscProfilesTableViewController.needToUpdateOscLayoutTVC code block, and has to be triggered by a notification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(buttonViewTapped:) - name:@"OnScreenButtonViewSelected" + selector:@selector(widgetViewTapped:) + name:@"OnScreenWidgetViewSelected" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -190,7 +191,7 @@ - (void) viewDidAppear:(BOOL)animated { - OnScreenButtonView.editMode = true; + OnScreenWidgetView.editMode = true; [super viewWillAppear:animated]; [self profileRefresh]; } @@ -354,14 +355,14 @@ if(noValidKeyboardString && noValidMouseButtonString && noValidTouchPadString && noValidOscButtonString && noValidSpecialButtonString) return; //saving & present the keyboard button: - OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:cmdString keyLabel:keyLabel]; - buttonView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place - buttonView.timestamp = CACurrentMediaTime(); // will be set as key in in the dict. - [self.onScreenButtonViewsDict setObject:buttonView forKey:@(buttonView.timestamp)]; - // Add the buttonView to the view controller's view - [self.view addSubview:buttonView]; - [buttonView setLocationWithXOffset:50 yOffset:50]; - [buttonView resizeButtonView]; + OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithKeyString:cmdString keyLabel:keyLabel]; + widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place + widgetView.timestamp = CACurrentMediaTime(); // will be set as key in in the dict. + [self.OnScreenWidgetViewsDict setObject:widgetView forKey:@(widgetView.timestamp)]; + // Add the widgetView to the view controller's view + [self.view addSubview:widgetView]; + [widgetView setLocationWithXOffset:50 yOffset:50]; + [widgetView resizeWidgetView]; }]; [alertController addAction:cancelAction]; [alertController addAction:okAction]; @@ -388,48 +389,48 @@ } } -- (void)buttonViewTapped: (NSNotification *)notification{ - // receive the selected buttonView obj passed from the notification - OnScreenButtonView* buttonView = (OnScreenButtonView* )notification.object; - self->buttonViewSelected = true; +- (void)widgetViewTapped: (NSNotification *)notification{ + // receive the selected widgetView obj passed from the notification + OnScreenWidgetView* widgetView = (OnScreenWidgetView* )notification.object; + self->widgetViewSelected = true; self->controllerLayerSelected = false; - self->selectedButtonView = buttonView; + self->selectedWidgetView = widgetView; // setup slider values - [self.widgetSizeSlider setValue: self->selectedButtonView.widthFactor]; - [self.widgetHeightSlider setValue: self->selectedButtonView.heightFactor]; - [self.widgetAlphaSlider setValue: self->selectedButtonView.backgroundAlpha]; + [self.widgetSizeSlider setValue: self->selectedWidgetView.widthFactor]; + [self.widgetHeightSlider setValue: self->selectedWidgetView.heightFactor]; + [self.widgetAlphaSlider setValue: self->selectedWidgetView.backgroundAlpha]; NSSet *stickAndMouseTouchpads = [NSSet setWithObjects:@"LSPAD", @"RSPAD", @"LSVPAD", @"RSVPAD", @"MOUSEPAD", nil]; NSSet *nonVectorStickPads = [NSSet setWithObjects:@"LSPAD", @"RSPAD", nil]; - bool showSensitivityFactorSlider = [stickAndMouseTouchpads containsObject:self->selectedButtonView.keyString]; - bool showStickIndicatorOffsetSlider = [nonVectorStickPads containsObject:self->selectedButtonView.keyString]; + bool showSensitivityFactorSlider = [stickAndMouseTouchpads containsObject:self->selectedWidgetView.keyString]; + bool showStickIndicatorOffsetSlider = [nonVectorStickPads containsObject:self->selectedWidgetView.keyString]; self.sensitivityFactorSlider.hidden = self->sensitivitySliderLabel.hidden = !showSensitivityFactorSlider; self.stickIndicatorOffsetSlider.hidden = self->stickIndicatorOffsetExplain.hidden = self->stickIndicatorOffsetSliderLabel.hidden = !showStickIndicatorOffsetSlider; if(showSensitivityFactorSlider){ - [self.sensitivityFactorSlider setValue:self->selectedButtonView.sensitivityFactor]; - [sensitivitySliderLabel setText:[LocalizationHelper localizedStringForKey:@"Sensitivity: %.2f", self->selectedButtonView.sensitivityFactor]]; + [self.sensitivityFactorSlider setValue:self->selectedWidgetView.sensitivityFactor]; + [sensitivitySliderLabel setText:[LocalizationHelper localizedStringForKey:@"Sensitivity: %.2f", self->selectedWidgetView.sensitivityFactor]]; } if(showStickIndicatorOffsetSlider){ // illustrating the indicator offset, - [selectedButtonView.stickBallLayer removeFromSuperlayer]; - [selectedButtonView.crossMarkLayer removeFromSuperlayer]; - selectedButtonView.touchBeganLocation = CGPointMake(CGRectGetWidth(selectedButtonView.frame)/2, CGRectGetHeight(selectedButtonView.frame)/4); - [selectedButtonView showStickIndicator];// this will create the indicator CAShapeLayers - [self.stickIndicatorOffsetSlider setValue:self->selectedButtonView.stickIndicatorXOffset]; - [stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f", self->selectedButtonView.stickIndicatorXOffset]]; - [self->selectedButtonView updateStickIndicator]; + [selectedWidgetView.stickBallLayer removeFromSuperlayer]; + [selectedWidgetView.crossMarkLayer removeFromSuperlayer]; + selectedWidgetView.touchBeganLocation = CGPointMake(CGRectGetWidth(selectedWidgetView.frame)/2, CGRectGetHeight(selectedWidgetView.frame)/4); + [selectedWidgetView showStickIndicator];// this will create the indicator CAShapeLayers + [self.stickIndicatorOffsetSlider setValue:self->selectedWidgetView.stickIndicatorXOffset]; + [stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f", self->selectedWidgetView.stickIndicatorXOffset]]; + [self->selectedWidgetView updateStickIndicator]; } - [widgetSizeSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Size: %.2f", self->selectedButtonView.widthFactor]]; - [widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self->selectedButtonView.heightFactor]]; - [widgetAlphaSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Alpha: %.2f", self->selectedButtonView.backgroundAlpha]]; + [widgetSizeSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Size: %.2f", self->selectedWidgetView.widthFactor]]; + [widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self->selectedWidgetView.heightFactor]]; + [widgetAlphaSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Alpha: %.2f", self->selectedWidgetView.backgroundAlpha]]; } - (void)setControllerCALayerSliderValues: (NSNotification *)notification{ - // receive the selected buttonView obj passed from the notification + // receive the selected widgetView obj passed from the notification CALayer* controllerLayer = (CALayer* )notification.object; - self->buttonViewSelected = false; + self->widgetViewSelected = false; self->stickIndicatorOffsetExplain.hidden = true; self->stickIndicatorOffsetSliderLabel.hidden = true; self.stickIndicatorOffsetSlider.hidden = true; @@ -457,11 +458,11 @@ [widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self.widgetSizeSlider.value]]; // resizing the whole button [self.widgetHeightSlider setValue: self.widgetSizeSlider.value]; - if(self->selectedButtonView != nil && self->buttonViewSelected){ - self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change - // when adjusting width, the buttonView height will be syncronized - self->selectedButtonView.widthFactor = self->selectedButtonView.heightFactor = self.widgetSizeSlider.value; - [self->selectedButtonView resizeButtonView]; + if(self->selectedWidgetView != nil && self->widgetViewSelected){ + self->selectedWidgetView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change + // when adjusting width, the widgetView height will be syncronized + self->selectedWidgetView.widthFactor = self->selectedWidgetView.heightFactor = self.widgetSizeSlider.value; + [self->selectedWidgetView resizeWidgetView]; } if(self->selectedControllerLayer != nil && self->controllerLayerSelected){ [self.layoutOSC resizeControllerLayerWith:self->selectedControllerLayer and:self.widgetSizeSlider.value]; @@ -470,18 +471,18 @@ - (void)widgetHeightSliderMoved{ [widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self.widgetHeightSlider.value]]; - if(self->selectedButtonView != nil && self->buttonViewSelected){ - self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change - if([CommandManager.oscButtonMappings.allKeys containsObject:selectedButtonView.keyString]) return; // don't change custom osc button height - self->selectedButtonView.heightFactor = self.widgetHeightSlider.value; - [self->selectedButtonView resizeButtonView]; + if(self->selectedWidgetView != nil && self->widgetViewSelected){ + self->selectedWidgetView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change + if([CommandManager.oscButtonMappings.allKeys containsObject:selectedWidgetView.keyString]) return; // don't change custom osc button height + self->selectedWidgetView.heightFactor = self.widgetHeightSlider.value; + [self->selectedWidgetView resizeWidgetView]; } } - (void)widgetAlphaSliderMoved{ [widgetAlphaSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Alpha: %.2f", self.widgetAlphaSlider.value]]; - if(self->selectedButtonView != nil && self->buttonViewSelected){ - [self->selectedButtonView adjustButtonTransparencyWithAlpha:self.widgetAlphaSlider.value]; + if(self->selectedWidgetView != nil && self->widgetViewSelected){ + [self->selectedWidgetView adjustButtonTransparencyWithAlpha:self.widgetAlphaSlider.value]; } if(self->selectedControllerLayer != nil && self->controllerLayerSelected){ @@ -492,22 +493,22 @@ - (void)sensitivitySliderMoved{ [sensitivitySliderLabel setText:[LocalizationHelper localizedStringForKey:@"Sensitivity: %.2f", self.sensitivityFactorSlider.value]]; - if(self->selectedButtonView != nil && self->buttonViewSelected) self->selectedButtonView.sensitivityFactor = self.sensitivityFactorSlider.value; + if(self->selectedWidgetView != nil && self->widgetViewSelected) self->selectedWidgetView.sensitivityFactor = self.sensitivityFactorSlider.value; return; } - (void)stickIndicatorOffsetSliderMoved{ [stickIndicatorOffsetSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Indicator Offset: %.2f", self.stickIndicatorOffsetSlider.value]]; - if(self->selectedButtonView != nil && self->buttonViewSelected){ - self->selectedButtonView.stickIndicatorXOffset = self.stickIndicatorOffsetSlider.value; - [self->selectedButtonView updateStickIndicator]; + if(self->selectedWidgetView != nil && self->widgetViewSelected){ + self->selectedWidgetView.stickIndicatorXOffset = self.stickIndicatorOffsetSlider.value; + [self->selectedWidgetView updateStickIndicator]; } return; } - (void)showIndicatorOffset{ - selectedButtonView.touchBeganLocation = CGPointMake(CGRectGetWidth(selectedButtonView.frame)/2, CGRectGetHeight(selectedButtonView.frame)/4); - [selectedButtonView showStickIndicator]; + selectedWidgetView.touchBeganLocation = CGPointMake(CGRectGetWidth(selectedWidgetView.frame)/2, CGRectGetHeight(selectedWidgetView.frame)/4); + [selectedWidgetView showStickIndicator]; } - (void)setupProfileLableAndSliders{ @@ -671,7 +672,7 @@ }; [self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache. - [self reloadOnScreenButtonViews]; + [self reloadOnScreenWidgetViews]; // [self presentViewController:vc animated:YES completion:nil]; } @@ -768,11 +769,11 @@ // removing keyboard buttons objs UITouch *touch = [touches anyObject]; // Get the first touch in the set 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 + [self.OnScreenWidgetViewsDict[@(OnScreenWidgetView.timestampOfButtonBeingDragged)] removeFromSuperview]; + [self.OnScreenWidgetViewsDict removeObjectForKey:@(OnScreenWidgetView.timestampOfButtonBeingDragged)]; + [selectedWidgetView.stickBallLayer removeFromSuperlayer]; + [selectedWidgetView.crossMarkLayer removeFromSuperlayer]; + OnScreenWidgetView.timestampOfButtonBeingDragged = 0; //reset thie timestamp } diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index fca44e3a..d46e5714 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -58,7 +58,7 @@ UIView *_streamVideoRenderView; /* * View architecture of this viewController: - * self.view (named `streamFrameTopLayerView` in StreamView.m, where slide & tap gestures, and onScreenControls & onScreenButtonView buttons are registered) + * self.view (named `streamFrameTopLayerView` in StreamView.m, where slide & tap gestures, and onScreenControls & OnScreenWidgetView buttons are registered) * - streamView (where touchHandlers are registered) * - streamVideoRenderView (where stream view is rendered) */ @@ -171,7 +171,7 @@ // we got self.view passed to streamView class as the topLayerView, will be useful in many cases [self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here. - [self->_streamView reloadOnScreenButtonViews]; //reload keyboard buttons here. the keyboard button view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering + [self->_streamView reloadOnScreenWidgetViews]; //reload keyboard buttons here. the keyboard widget view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering [self reloadAirPlayConfig]; [self mousePresenceChanged]; @@ -400,7 +400,7 @@ [self->_streamView reloadOnScreenControlsWith:(ControllerSupport*)_controllerSupport andConfig:(StreamConfiguration*)_streamConfig]; [self->_streamView showOnScreenControls]; - [self->_streamView reloadOnScreenButtonViews]; //update keyboard buttons here + [self->_streamView reloadOnScreenWidgetViews]; //update keyboard buttons here } diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 22ab7a13..ec96a55d 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 840751B32BF49C050096B657 /* CustomTapGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 840751B22BF49C050096B657 /* CustomTapGestureRecognizer.m */; }; - 84203F232C5F24C00032EEED /* OnScreenButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84203F222C5F24C00032EEED /* OnScreenButtonView.swift */; }; + 84203F232C5F24C00032EEED /* OnScreenWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84203F222C5F24C00032EEED /* OnScreenWidgetView.swift */; }; 84351B0E2C29ACCB00A77989 /* LayoutOnScreenControls.m in Sources */ = {isa = PBXBuildFile; fileRef = 84351B072C29ACCA00A77989 /* LayoutOnScreenControls.m */; }; 84351B0F2C29ACCB00A77989 /* OnScreenButtonState.m in Sources */ = {isa = PBXBuildFile; fileRef = 84351B092C29ACCA00A77989 /* OnScreenButtonState.m */; }; 84351B102C29ACCB00A77989 /* OSCProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = 84351B0A2C29ACCA00A77989 /* OSCProfile.m */; }; @@ -127,7 +127,7 @@ 693B3A9A218638CD00982F7B /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = ""; }; 840751B12BF49B5A0096B657 /* CustomTapGestureRecognizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomTapGestureRecognizer.h; sourceTree = ""; }; 840751B22BF49C050096B657 /* CustomTapGestureRecognizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomTapGestureRecognizer.m; sourceTree = ""; }; - 84203F222C5F24C00032EEED /* OnScreenButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnScreenButtonView.swift; sourceTree = ""; }; + 84203F222C5F24C00032EEED /* OnScreenWidgetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnScreenWidgetView.swift; sourceTree = ""; }; 84351B062C29ACCA00A77989 /* OnScreenButtonState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnScreenButtonState.h; sourceTree = ""; }; 84351B072C29ACCA00A77989 /* LayoutOnScreenControls.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutOnScreenControls.m; sourceTree = ""; }; 84351B082C29ACCA00A77989 /* OSCProfilesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSCProfilesManager.h; sourceTree = ""; }; @@ -630,7 +630,7 @@ 988FCD3F293B091B003050E2 /* KeyboardInputField.h */, 988FCD40293B091B003050E2 /* KeyboardInputField.m */, 84E1CDEB2C4F67D300547904 /* CommandManager.swift */, - 84203F222C5F24C00032EEED /* OnScreenButtonView.swift */, + 84203F222C5F24C00032EEED /* OnScreenWidgetView.swift */, ); path = Input; sourceTree = ""; @@ -1036,7 +1036,7 @@ FBDE86E019F7A837001C18A8 /* UIComputerView.m in Sources */, FB89463019F646E200339C8A /* StreamConfiguration.m in Sources */, FBD3495319FF36FB002D2A60 /* SWRevealViewController.m in Sources */, - 84203F232C5F24C00032EEED /* OnScreenButtonView.swift in Sources */, + 84203F232C5F24C00032EEED /* OnScreenWidgetView.swift in Sources */, 84FD0B512C31338D006B5BE5 /* LocalizationHelper.m in Sources */, FB1D59971BBCCB6400F482CA /* ComputerScrollView.m in Sources */, FBD3495019FF2174002D2A60 /* SettingsViewController.m in Sources */,