Fix first tap in touch mode not registering

This commit is contained in:
Cameron Gutman
2020-11-01 14:43:55 -06:00
parent 7270554153
commit a1f09f117f
3 changed files with 13 additions and 10 deletions
+2 -2
View File
@@ -57,7 +57,7 @@
if (touch.timestamp - lastTouchUp.timestamp > DOUBLE_TAP_DEAD_ZONE_DELAY || if (touch.timestamp - lastTouchUp.timestamp > DOUBLE_TAP_DEAD_ZONE_DELAY ||
sqrt(pow((touchLocation.x / view.bounds.size.width) - (lastTouchUpLocation.x / view.bounds.size.width), 2) + sqrt(pow((touchLocation.x / view.bounds.size.width) - (lastTouchUpLocation.x / view.bounds.size.width), 2) +
pow((touchLocation.y / view.bounds.size.height) - (lastTouchUpLocation.y / view.bounds.size.height), 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) { pow((touchLocation.y / view.bounds.size.height) - (lastTouchUpLocation.y / view.bounds.size.height), 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) {
[view updateCursorLocation:touchLocation]; [view updateCursorLocation:touchLocation isMouse:NO];
} }
// Press the left button down // Press the left button down
@@ -90,7 +90,7 @@
longPressTimer = nil; longPressTimer = nil;
} }
[view updateCursorLocation:[[touches anyObject] locationInView:view]]; [view updateCursorLocation:[[touches anyObject] locationInView:view] isMouse:NO];
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+1 -1
View File
@@ -40,7 +40,7 @@
- (OnScreenControlsLevel) getCurrentOscState; - (OnScreenControlsLevel) getCurrentOscState;
#if !TARGET_OS_TV #if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location; - (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
#endif #endif
@end @end
+10 -7
View File
@@ -265,7 +265,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// don't require this, but we do it anyway for them too. // don't require this, but we do it anyway for them too.
// Cursor movement without a button held down is handled // Cursor movement without a button held down is handled
// in pointerInteraction:regionForRequest:defaultRegion. // in pointerInteraction:regionForRequest:defaultRegion.
[self updateCursorLocation:[touch locationInView:self]]; [self updateCursorLocation:[touch locationInView:self] isMouse:YES];
return; return;
} }
} }
@@ -341,7 +341,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
#if !TARGET_OS_TV #if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location { - (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse {
// These are now relative to the StreamView, however we need to scale them // These are now relative to the StreamView, however we need to scale them
// further to make them relative to the actual video portion. // further to make them relative to the actual video portion.
float x = location.x - self.bounds.origin.x; float x = location.x - self.bounds.origin.x;
@@ -382,19 +382,22 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
y = MIN(MAX(y, videoOrigin.y), videoOrigin.y + videoSize.height); y = MIN(MAX(y, videoOrigin.y), videoOrigin.y + videoSize.height);
// Send the mouse position relative to the video region if it has changed // Send the mouse position relative to the video region if it has changed
// if we're receiving coordinates from a real mouse.
// //
// NB: It is important for functionality (not just optimization) to only // NB: It is important for functionality (not just optimization) to only
// send it if the value has changed. We will receive one of these events // send it if the value has changed. We will receive one of these events
// any time the user presses a modifier key, which can result in errant // any time the user presses a modifier key, which can result in errant
// mouse motion when using a Citrix X1 mouse. // mouse motion when using a Citrix X1 mouse.
if (x != lastMouseX || y != lastMouseY) { if (x != lastMouseX || y != lastMouseY || !isMouse) {
if (lastMouseX != 0 || lastMouseY != 0) { if (lastMouseX != 0 || lastMouseY != 0 || !isMouse) {
LiSendMousePositionEvent(x - videoOrigin.x, y - videoOrigin.y, LiSendMousePositionEvent(x - videoOrigin.x, y - videoOrigin.y,
videoSize.width, videoSize.height); videoSize.width, videoSize.height);
} }
lastMouseX = x; if (isMouse) {
lastMouseY = y; lastMouseX = x;
lastMouseY = y;
}
} }
} }
@@ -422,7 +425,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// Move the cursor on the host if no buttons are pressed. // Move the cursor on the host if no buttons are pressed.
// Motion with buttons pressed in handled in touchesMoved: // Motion with buttons pressed in handled in touchesMoved:
if (lastMouseButtonMask == 0) { if (lastMouseButtonMask == 0) {
[self updateCursorLocation:request.location]; [self updateCursorLocation:request.location isMouse:YES];
} }
// The pointer interaction should cover the video region only // The pointer interaction should cover the video region only