From c38dfc2c201a594e5bcd9ab596622355d459c955 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Tue, 16 Jul 2024 20:56:06 +0800 Subject: [PATCH] exclude bottom right corner for coord reset in high touch pointer velocity condition --- Limelight/Input/NativeTouchHandler.m | 5 ++--- Limelight/Input/NativeTouchPointer.h | 4 ++-- Limelight/Input/NativeTouchPointer.m | 15 ++++++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Limelight/Input/NativeTouchHandler.m b/Limelight/Input/NativeTouchHandler.m index 754567de..e15778cc 100644 --- a/Limelight/Input/NativeTouchHandler.m +++ b/Limelight/Input/NativeTouchHandler.m @@ -86,8 +86,7 @@ CGFloat normalizedY = location.y / videoSize.height; uint8_t pointerId = [self retrievePointerIdFromDict:touch]; - - if([NativeTouchPointer getPointerObjFromDict:touch].boundaryReached){ // access whether the current pointer has reached the boundary. + if([NativeTouchPointer getPointerObjFromDict:touch].needResetCoords){ // access whether the current pointer has reached the boundary, and need a coord reset. 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.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]]); @@ -105,7 +104,7 @@ for (UITouch* touch in touches){ if(activateCoordSelector) [NativeTouchPointer updatePointerObjInDict:touch]; [self sendTouchEvent:touch withTouchtype:LI_TOUCH_EVENT_MOVE]; - [[NativeTouchPointer getPointerObjFromDict:touch] doesReachBoundary]; // execute the judging of doesReachBoundary for current pointer instance. (happens after the event is sent to Sunshine service) + [[NativeTouchPointer getPointerObjFromDict:touch] doesNeedResetCoords]; // execute the judging of doesReachBoundary for current pointer instance. (happens after the event is sent to Sunshine service) } return; } diff --git a/Limelight/Input/NativeTouchPointer.h b/Limelight/Input/NativeTouchPointer.h index 4ce0033e..8d06ae07 100644 --- a/Limelight/Input/NativeTouchPointer.h +++ b/Limelight/Input/NativeTouchPointer.h @@ -12,14 +12,14 @@ NS_ASSUME_NONNULL_BEGIN @interface NativeTouchPointer : NSObject -@property (nonatomic, assign) bool boundaryReached; +@property (nonatomic, assign) bool needResetCoords; + (void)initContextWithView:(StreamView *)view; + (void)setPointerVelocityDivider:(CGFloat)dividerLocation; + (void)setPointerVelocityFactor:(CGFloat)velocityFactor; + (NativeTouchPointer* )getPointerObjFromDict:(UITouch*)touch; -- (bool)doesReachBoundary; +- (bool)doesNeedResetCoords; + (void)populatePointerObjIntoDict:(UITouch*)touch; + (void)removePointerObjFromDict:(UITouch*)touch; diff --git a/Limelight/Input/NativeTouchPointer.m b/Limelight/Input/NativeTouchPointer.m index dcb49a29..ede183ee 100644 --- a/Limelight/Input/NativeTouchPointer.m +++ b/Limelight/Input/NativeTouchPointer.m @@ -41,17 +41,22 @@ StreamView *streamView; return self; } -- (bool)doesReachBoundary{ - _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; +- (bool)doesNeedResetCoords{ + bool boundaryReached = (latestRelativePoint.x > screenWidthInPoints || latestRelativePoint.x < 0.0f || latestRelativePoint.y > screenHeightInPoints || latestRelativePoint.y < 0.0f); + bool withinExcludedArea = (initialPoint.x > screenWidthInPoints * (0.75) && initialPoint.x < screenWidthInPoints) && (initialPoint.y > screenHeightInPoints * (0.8) && initialPoint.y < screenHeightInPoints); + _needResetCoords = (pointerVelocityFactor > 1.0f) && self->useRelativeCoords && boundaryReached && !withinExcludedArea; + // 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. + // also exclude touch pointer created within the bottom right corner + + return _needResetCoords; } - (void)updatePointerCoords:(UITouch *)touch{ previousPoint = latestPoint; latestPoint = [touch locationInView:streamView]; previousRelativePoint = latestRelativePoint; - if(_boundaryReached){// boundary detection & coordinates reset to the central screen point for HK:StarTrail(needs a very high pointer velocity); // boundary detection & coordinates reset to specific point for HK:StarTrail(needs a very high pointer velocity) + if(_needResetCoords){// boundary detection & coordinates reset to the central screen point for HK:StarTrail(needs a very high pointer velocity); // boundary detection & coordinates reset to specific point for HK:StarTrail(needs a very high pointer velocity) previousRelativePoint.x = fixedResetCoordX; previousRelativePoint.y = fixedResetCoordY; }