diff --git a/Limelight/Input/NativeTouchHandler.h b/Limelight/Input/NativeTouchHandler.h index b2147d28..f385a4ce 100644 --- a/Limelight/Input/NativeTouchHandler.h +++ b/Limelight/Input/NativeTouchHandler.h @@ -14,7 +14,9 @@ NS_ASSUME_NONNULL_BEGIN @interface NativeTouchHandler : UIResponder - +@property (nonatomic, assign) bool XBoundaryReached; +@property (nonatomic, assign) bool YBoundaryReached; +@property (nonatomic, assign) bool flipFlag; - (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings; @end diff --git a/Limelight/Input/NativeTouchHandler.m b/Limelight/Input/NativeTouchHandler.m index 3589ecdb..a8bf36b3 100644 --- a/Limelight/Input/NativeTouchHandler.m +++ b/Limelight/Input/NativeTouchHandler.m @@ -44,8 +44,8 @@ [NativeTouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue]; [NativeTouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue]; - [NativeTouchPointer initContextWithView:streamView]; - + [NativeTouchPointer initContextWithView:self->streamView andNativeTouchHandler:self]; + _flipFlag = true; return self; } @@ -83,7 +83,15 @@ else targetCoords = [touch locationInView:streamView]; CGPoint location = [streamView adjustCoordinatesForVideoArea:targetCoords]; CGSize videoSize = [streamView getVideoAreaSize]; - LiSendTouchEvent(touchType,[self retrievePointerIdFromDict:touch],location.x / videoSize.width, location.y / videoSize.height,(touch.force / touch.maximumPossibleForce) / sin(touch.altitudeAngle),0.0f, 0.0f,[streamView getRotationFromAzimuthAngle:[touch azimuthAngleInView:streamView]]); + CGFloat normalizedX = location.x / videoSize.width; + CGFloat normalizedY = location.y / videoSize.height; + uint8_t pointerId = [self retrievePointerIdFromDict:touch]; + + _XBoundaryReached = (normalizedX == 1.0f || normalizedX == 0.f); + _YBoundaryReached = (normalizedY == 1.0f || normalizedY == 0.f); + //if(_XBoundaryReached || _YBoundaryReached) LiSendTouchEvent(LI_TOUCH_EVENT_UP,pointerId, normalizedX, normalizedY, 0, 0, 0, 0); + if(_XBoundaryReached || _YBoundaryReached) LiSendTouchEvent(LI_TOUCH_EVENT_UP,pointerId, normalizedX, normalizedY, 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]]); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { diff --git a/Limelight/Input/NativeTouchPointer.h b/Limelight/Input/NativeTouchPointer.h index 8c06bdd3..e74d3662 100644 --- a/Limelight/Input/NativeTouchPointer.h +++ b/Limelight/Input/NativeTouchPointer.h @@ -7,13 +7,13 @@ // #import "StreamView.h" +#import "NativeTouchHandler.h" NS_ASSUME_NONNULL_BEGIN @interface NativeTouchPointer : NSObject -+ (void)initContextWithView:(StreamView *)view; - ++ (void)initContextWithView:(StreamView *)view andNativeTouchHandler:(NativeTouchHandler*)handler; + (void)setPointerVelocityDivider:(CGFloat)dividerLocation; + (void)setPointerVelocityFactor:(CGFloat)velocityFactor; + (void)populatePointerObjIntoDict:(UITouch*)touch; diff --git a/Limelight/Input/NativeTouchPointer.m b/Limelight/Input/NativeTouchPointer.m index e7ec5d63..717b03db 100644 --- a/Limelight/Input/NativeTouchPointer.m +++ b/Limelight/Input/NativeTouchPointer.m @@ -8,6 +8,7 @@ #import #import "NativeTouchPointer.h" +#import "NativeTouchHandler.h" #include // native touch pointer ojbect that stores & manipulates touch coordinates @@ -17,6 +18,9 @@ static NSMutableDictionary *pointerObjDict; static CGFloat pointerVelocityFactor; static CGFloat pointerVelocityDivider; static CGFloat pointerVelocityDividerLocationByPoints; +static NativeTouchHandler* nativeTouchHandler; +static CGFloat halfScreenHeightInPoints; +static CGFloat halfScreenWidthInPoints; StreamView *streamView; @@ -49,12 +53,20 @@ StreamView *streamView; previousPoint = latestPoint; latestPoint = [touch locationInView:streamView]; previousRelativePoint = latestRelativePoint; + if(nativeTouchHandler.XBoundaryReached || nativeTouchHandler.YBoundaryReached){ // reset + previousRelativePoint.x = halfScreenWidthInPoints; + previousRelativePoint.y = halfScreenHeightInPoints; + } latestRelativePoint.x = previousRelativePoint.x + pointerVelocityFactor * (latestPoint.x - previousPoint.x); latestRelativePoint.y = previousRelativePoint.y + pointerVelocityFactor * (latestPoint.y - previousPoint.y); + } -+ (void)initContextWithView:(StreamView *)view{ ++ (void)initContextWithView:(StreamView *)view andNativeTouchHandler:(NativeTouchHandler*)handler { streamView = view; + nativeTouchHandler = handler; + halfScreenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds])/2; + halfScreenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds])/2; pointerObjDict = [NSMutableDictionary dictionary]; pointerVelocityDividerLocationByPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]) * pointerVelocityDivider; NSLog(@"pointerVelocityDivider: %.2f", pointerVelocityDivider);