diff --git a/Limelight/Input/CustomTapGestureRecognizer.h b/Limelight/Input/CustomTapGestureRecognizer.h index a4e8248b..08a06480 100644 --- a/Limelight/Input/CustomTapGestureRecognizer.h +++ b/Limelight/Input/CustomTapGestureRecognizer.h @@ -15,6 +15,8 @@ @property (nonatomic, assign) uint8_t numberOfTouchesRequired; @property (nonatomic, assign) double tapDownTimeThreshold; +@property (nonatomic, readonly) CGFloat lowestTouchPointHeight; + @end #endif /* CustomTapGestureRecognizer_h */ diff --git a/Limelight/Input/CustomTapGestureRecognizer.m b/Limelight/Input/CustomTapGestureRecognizer.m index 91493921..9add8f35 100644 --- a/Limelight/Input/CustomTapGestureRecognizer.m +++ b/Limelight/Input/CustomTapGestureRecognizer.m @@ -14,9 +14,12 @@ static NSTimeInterval multiFingerDownTime; static bool multiFingerDown; +static CGFloat screenHeightInPoints; +static CGFloat lowestTouchPointYCoord = 0.0; - (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action { self = [super initWithTarget:target action:action]; + screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]); return self; } @@ -25,15 +28,25 @@ static bool multiFingerDown; if ([[event allTouches] count] == _numberOfTouchesRequired) { multiFingerDownTime = CACurrentMediaTime(); multiFingerDown = true; + + for(UITouch *touch in [event allTouches]){ + if(lowestTouchPointYCoord < [touch locationInView:self.view].y) lowestTouchPointYCoord = [touch locationInView:self.view].y; + } + //NSLog(@"lowestTouchPointYCoord: %f ", lowestTouchPointYCoord); + _lowestTouchPointHeight = screenHeightInPoints - lowestTouchPointYCoord; self.state = UIGestureRecognizerStatePossible; } } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + // [super touchesEnded:touches withEvent:event]; if(multiFingerDown && [[event allTouches] count] == [touches count]){ multiFingerDown = false; - if((CACurrentMediaTime() - multiFingerDownTime) < _tapDownTimeThreshold / 1000) self.state = UIGestureRecognizerStateRecognized; + if((CACurrentMediaTime() - multiFingerDownTime) < _tapDownTimeThreshold / 1000){ + lowestTouchPointYCoord = 0.0; //reset for next recognition + self.state = UIGestureRecognizerStateRecognized; + } } } diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 2bb00293..8f2484cc 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -49,6 +49,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; NSDictionary *dictCodes; CustomTapGestureRecognizer *keyboardToggleRecognizer; + CGFloat liftViewToHeight; } - (void) setupStreamView:(ControllerSupport*)controllerSupport @@ -76,12 +77,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; keyboardToggleRecognizer.delaysTouchesBegan = NO; keyboardToggleRecognizer.delaysTouchesEnded = NO; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillShow) + selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillHide) + selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [self addGestureRecognizer:keyboardToggleRecognizer]; @@ -152,12 +153,27 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; [self becomeFirstResponder]; } -- (void)keyboardWillShow{ + +- (void)keyboardWillShow:(NSNotification *)notification{ + NSDictionary *userInfo = notification.userInfo; + // Get the keyboard size from the notification + CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + liftViewToHeight = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing. + if(liftViewToHeight < 0) liftViewToHeight = 0; // set liftViewtoHeight to 0 if it is high enough and not going to be covered by keyboard. + + CGRect liftedStreamFrame = self.frame; + liftedStreamFrame.origin.y -= liftViewToHeight; + self.frame = liftedStreamFrame; + isInputingText = true; // NSLog(@"keyboard will show"); } -- (void)keyboardWillHide{ +- (void)keyboardWillHide:(NSNotification *)notification{ + CGRect liftedStreamFrame = self.frame; + // recover view position in keyboard hiding. + liftedStreamFrame.origin.y += liftViewToHeight; + self.frame = liftedStreamFrame; isInputingText = false; // NSLog(@"keyboard will hide"); } @@ -170,6 +186,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; [keyInputField resignFirstResponder]; isInputingText = false; } else { + // NSLog(@"Opening the keyboard"); Log(LOG_D, @"Opening the keyboard"); // Prepare the textbox used to capture keyboard events. diff --git a/Limelight/Limelight-Info.plist b/Limelight/Limelight-Info.plist index 3b378ef6..e2f023a3 100644 --- a/Limelight/Limelight-Info.plist +++ b/Limelight/Limelight-Info.plist @@ -9,7 +9,7 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - Moonlight-ZWM + Moonlight-ZWM-Debug CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier diff --git a/Moonlight TV/Info.plist b/Moonlight TV/Info.plist index c4d8436e..9f1da799 100644 --- a/Moonlight TV/Info.plist +++ b/Moonlight TV/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Moonlight-ZWM + Moonlight-ZWM-Debug CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier