From ef5c77d8dff1d35ffff98863d0b4ae514ee480a1 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Mon, 15 Jul 2024 13:01:18 +0800 Subject: [PATCH] fix touch interruption on the left side of screen under high pointer velocity (sensitivity) --- Limelight/Input/NativeTouchHandler.m | 2 +- Limelight/Input/NativeTouchPointer.m | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Limelight/Input/NativeTouchHandler.m b/Limelight/Input/NativeTouchHandler.m index 529344d3..754567de 100644 --- a/Limelight/Input/NativeTouchHandler.m +++ b/Limelight/Input/NativeTouchHandler.m @@ -89,7 +89,7 @@ if([NativeTouchPointer getPointerObjFromDict:touch].boundaryReached){ // access whether the current pointer has reached the boundary. LiSendTouchEvent(LI_TOUCH_EVENT_UP, pointerId, normalizedX, normalizedY, 0, 0, 0, 0); //event must sent from the lowest level directy by LiSendTouchEvent to simulate continous dragging to another point on screen - LiSendTouchEvent(LI_TOUCH_EVENT_DOWN, pointerId, 0.5, 0.4, 0, 0, 0, 0); + LiSendTouchEvent(LI_TOUCH_EVENT_DOWN, pointerId, 0.3, 0.4, 0, 0, 0, 0); }else LiSendTouchEvent(touchType, pointerId, normalizedX, normalizedY,(touch.force / touch.maximumPossibleForce) / sin(touch.altitudeAngle),0.0f, 0.0f,[streamView getRotationFromAzimuthAngle:[touch azimuthAngleInView:streamView]]); } diff --git a/Limelight/Input/NativeTouchPointer.m b/Limelight/Input/NativeTouchPointer.m index 1abf8d6b..dcb49a29 100644 --- a/Limelight/Input/NativeTouchPointer.m +++ b/Limelight/Input/NativeTouchPointer.m @@ -30,6 +30,7 @@ StreamView *streamView; CGPoint previousPoint; CGPoint latestRelativePoint; CGPoint previousRelativePoint; + bool useRelativeCoords; } - (instancetype)initWithTouch:(UITouch *)touch{ @@ -41,7 +42,8 @@ StreamView *streamView; } - (bool)doesReachBoundary{ - _boundaryReached = (pointerVelocityFactor > 1.0f) && (latestRelativePoint.x > screenWidthInPoints || latestRelativePoint.x < 0.0f || latestRelativePoint.y > screenHeightInPoints || latestRelativePoint.y < 0.0f); // boundary detection & coordinates reset to the central screen point for HK:StarTrail(needs a very high pointer velocity); // boundary detection & coordinates reset to the specific point for HK:StarTrail(needs a very high pointer velocity) + _boundaryReached = (pointerVelocityFactor > 1.0f) && self->useRelativeCoords && (latestRelativePoint.x > screenWidthInPoints || latestRelativePoint.x < 0.0f || latestRelativePoint.y > screenHeightInPoints || latestRelativePoint.y < 0.0f); // boundary detection & coordinates reset to the central screen point for HK:StarTrail(needs a very high pointer velocity); // boundary detection & coordinates reset to the specific point for HK:StarTrail(needs a very high pointer velocity) + // must exclude touch pointer that uses native coords instead of relative ones. return _boundaryReached; } @@ -60,7 +62,7 @@ StreamView *streamView; + (void)initContextWithView:(StreamView *)view { streamView = view; screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]); - fixedResetCoordX = screenWidthInPoints * 0.5; + fixedResetCoordX = screenWidthInPoints * 0.3; screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]); fixedResetCoordY = screenHeightInPoints * 0.4; pointerObjDict = [NSMutableDictionary dictionary]; @@ -104,9 +106,13 @@ StreamView *streamView; + (CGPoint)selectCoordsFor:(UITouch *)touch{ NativeTouchPointer *pointer = [pointerObjDict objectForKey:@((uintptr_t)touch)]; if((pointer -> initialPoint).x > pointerVelocityDividerLocationByPoints){ //if first contact coords locates on the right side of divider. + pointer -> useRelativeCoords = true; return pointer->latestRelativePoint; } - return [touch locationInView:streamView]; + else{ + pointer -> useRelativeCoords = false; + return[touch locationInView:streamView]; + } }