fix touch interruption on the left side of screen under high pointer velocity (sensitivity)

This commit is contained in:
True Zhuanjia
2024-07-15 13:01:18 +08:00
parent b05c3c7e4a
commit ef5c77d8df
2 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -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]]);
}
+9 -3
View File
@@ -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];
}
}