From 2a69a19dbd591bca29ef6e2f4ae94c5c171c3ad6 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 17 Jan 2021 03:11:41 +1100 Subject: [PATCH] [client] mouse: don't smooth large cursor jumps (ie, warp to align) --- client/src/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 881354f9..5c3ab5cb 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -895,8 +895,18 @@ static void cursorToInt(double ex, double ey, int *x, int *y) if (params.mouseSmoothing && !(g_cursor.grab && params.rawMouse)) { static struct DoublePoint last = { 0 }; - ex = last.x = (last.x + ex) / 2.0; - ey = last.y = (last.y + ey) / 2.0; + + /* only apply smoothing to small deltas */ + if (fabs(ex - last.x) < 5.0 && fabs(ey - last.y) < 5.0) + { + ex = last.x = (last.x + ex) / 2.0; + ey = last.y = (last.y + ey) / 2.0; + } + else + { + last.x = ex; + last.y = ey; + } } /* convert to int accumulating the fractional error */