mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 22:23:52 +00:00
Don't update the mouse position if it hasn't moved from the last location
This commit is contained in:
@@ -21,7 +21,6 @@ static const int REFERENCE_HEIGHT = 720;
|
|||||||
CGPoint touchLocation, originalLocation;
|
CGPoint touchLocation, originalLocation;
|
||||||
BOOL touchMoved;
|
BOOL touchMoved;
|
||||||
OnScreenControls* onScreenControls;
|
OnScreenControls* onScreenControls;
|
||||||
X1Mouse* x1mouse;
|
|
||||||
|
|
||||||
BOOL isInputingText;
|
BOOL isInputingText;
|
||||||
BOOL isDragging;
|
BOOL isDragging;
|
||||||
@@ -29,9 +28,15 @@ static const int REFERENCE_HEIGHT = 720;
|
|||||||
|
|
||||||
float streamAspectRatio;
|
float streamAspectRatio;
|
||||||
|
|
||||||
|
// iOS 13.4 mouse support
|
||||||
NSInteger lastMouseButtonMask;
|
NSInteger lastMouseButtonMask;
|
||||||
double mouseX;
|
float lastMouseX;
|
||||||
double mouseY;
|
float lastMouseY;
|
||||||
|
|
||||||
|
// Citrix X1 mouse support
|
||||||
|
X1Mouse* x1mouse;
|
||||||
|
double accumulatedMouseDeltaX;
|
||||||
|
double accumulatedMouseDeltaY;
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
UIGestureRecognizer* remotePressRecognizer;
|
UIGestureRecognizer* remotePressRecognizer;
|
||||||
@@ -471,9 +476,21 @@ static const int REFERENCE_HEIGHT = 720;
|
|||||||
x = MIN(MAX(x, videoOrigin.x), videoOrigin.x + videoSize.width);
|
x = MIN(MAX(x, videoOrigin.x), videoOrigin.x + videoSize.width);
|
||||||
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
|
// Send the mouse position relative to the video region if it has changed
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// any time the user presses a modifier key, which can result in errant
|
||||||
|
// mouse motion when using a Citrix X1 mouse.
|
||||||
|
if (x != lastMouseX || y != lastMouseY) {
|
||||||
|
if (lastMouseX != 0 || lastMouseY != 0) {
|
||||||
LiSendMousePositionEvent(x - videoOrigin.x, y - videoOrigin.y,
|
LiSendMousePositionEvent(x - videoOrigin.x, y - videoOrigin.y,
|
||||||
videoSize.width, videoSize.height);
|
videoSize.width, videoSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastMouseX = x;
|
||||||
|
lastMouseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
// The pointer interaction should cover the video region only
|
// The pointer interaction should cover the video region only
|
||||||
return [UIPointerRegion regionWithRect:CGRectMake(videoOrigin.x, videoOrigin.y, videoSize.width, videoSize.height) identifier:nil];
|
return [UIPointerRegion regionWithRect:CGRectMake(videoOrigin.x, videoOrigin.y, videoSize.width, videoSize.height) identifier:nil];
|
||||||
@@ -629,11 +646,11 @@ static const int REFERENCE_HEIGHT = 720;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDidMoveWithIdentifier:(NSUUID * _Nonnull)identifier deltaX:(int16_t)deltaX deltaY:(int16_t)deltaY {
|
- (void)mouseDidMoveWithIdentifier:(NSUUID * _Nonnull)identifier deltaX:(int16_t)deltaX deltaY:(int16_t)deltaY {
|
||||||
mouseX += deltaX / X1_MOUSE_SPEED_DIVISOR;
|
accumulatedMouseDeltaX += deltaX / X1_MOUSE_SPEED_DIVISOR;
|
||||||
mouseY += deltaY / X1_MOUSE_SPEED_DIVISOR;
|
accumulatedMouseDeltaY += deltaY / X1_MOUSE_SPEED_DIVISOR;
|
||||||
|
|
||||||
short shortX = (short)mouseX;
|
short shortX = (short)accumulatedMouseDeltaX;
|
||||||
short shortY = (short)mouseY;
|
short shortY = (short)accumulatedMouseDeltaY;
|
||||||
|
|
||||||
if (shortX == 0 && shortY == 0) {
|
if (shortX == 0 && shortY == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -641,8 +658,8 @@ static const int REFERENCE_HEIGHT = 720;
|
|||||||
|
|
||||||
LiSendMouseMoveEvent(shortX, shortY);
|
LiSendMouseMoveEvent(shortX, shortY);
|
||||||
|
|
||||||
mouseX -= shortX;
|
accumulatedMouseDeltaX -= shortX;
|
||||||
mouseY -= shortY;
|
accumulatedMouseDeltaY -= shortY;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) buttonFromX1ButtonCode:(enum X1MouseButton)button {
|
- (int) buttonFromX1ButtonCode:(enum X1MouseButton)button {
|
||||||
|
|||||||
Reference in New Issue
Block a user