From c3d44647f9964b43e6d0cbef9409e4b987c153a6 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Mon, 17 Jun 2024 22:56:55 +0800 Subject: [PATCH] CustomTapGestureRecognizer improvement --- Limelight/Input/CustomTapGestureRecognizer.m | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Limelight/Input/CustomTapGestureRecognizer.m b/Limelight/Input/CustomTapGestureRecognizer.m index e077c5ff..ef797089 100644 --- a/Limelight/Input/CustomTapGestureRecognizer.m +++ b/Limelight/Input/CustomTapGestureRecognizer.m @@ -10,6 +10,8 @@ #import #import "CustomTapGestureRecognizer.h" +// The most accurate & reliable tap gesture recognizer of iOS with almost 100% recoginition rate, instances of different numberOfTouchesRequired barely compete with each other. UITapGestureRecognizer of Apple API is just intractable. +// Known issue: not reliable in absolute touch mode, since it competes with 2 finger zoom-in & out gestures from original moonlight @implementation CustomTapGestureRecognizer static CGFloat screenHeightInPoints; @@ -40,8 +42,11 @@ static CGFloat screenHeightInPoints; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // [super touchesEnded:touches withEvent:event]; - if(_gestureCaptured && [[event allTouches] count] == [touches count]){ + if ([[event allTouches] count] > _numberOfTouchesRequired) { _gestureCaptured = false; + self.state = UIGestureRecognizerStateFailed; + } else if(_gestureCaptured && [[event allTouches] count] == [touches count]){ + _gestureCaptured = false; //reset for next recognition if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){ lowestTouchPointYCoord = 0.0; //reset for next recognition self.state = UIGestureRecognizerStateRecognized; @@ -49,11 +54,4 @@ static CGFloat screenHeightInPoints; } } -/* -+ (CGFloat)lowestTouchPointHeight{ - @synchronized (self){ - return self.lowestTouchPointHeight; - } -}*/ - @end