From 8e4471fbc0c3d445e079175e664cc1572ddeb816 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 27 Mar 2020 23:05:53 -0700 Subject: [PATCH] Slow X1 mouse input by 2x to make it more usable --- Limelight/Input/StreamView.m | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 259f317..3102e38 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -13,6 +13,8 @@ #import "KeyboardSupport.h" #import "TextFieldKeyboardDelegate.h" +static const double X1_MOUSE_SPEED_DIVISOR = 2.0; + @implementation StreamView { CGPoint touchLocation, originalLocation; BOOL touchMoved; @@ -27,6 +29,9 @@ float yDeltaFactor; float screenFactor; + double mouseX; + double mouseY; + #if TARGET_OS_TV UIGestureRecognizer* remotePressRecognizer; UIGestureRecognizer* remoteLongPressRecognizer; @@ -374,7 +379,20 @@ } - (void)mouseDidMoveWithIdentifier:(NSUUID * _Nonnull)identifier deltaX:(int16_t)deltaX deltaY:(int16_t)deltaY { - LiSendMouseMoveEvent(deltaX, deltaY); + mouseX += deltaX / X1_MOUSE_SPEED_DIVISOR; + mouseY += deltaY / X1_MOUSE_SPEED_DIVISOR; + + short shortX = (short)mouseX; + short shortY = (short)mouseY; + + if (shortX == 0 && shortY == 0) { + return; + } + + LiSendMouseMoveEvent(shortX, shortY); + + mouseX -= shortX; + mouseY -= shortY; } - (int) buttonFromX1ButtonCode:(enum X1MouseButton)button {