From e6412ba2e9dc6c56664dbcf81ef299499434891a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 9 Dec 2017 18:20:28 +0100 Subject: proto/mouse: fix some bad arithmetic --- proto-mouse/ftnoir_protocol_mouse.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'proto-mouse/ftnoir_protocol_mouse.cpp') diff --git a/proto-mouse/ftnoir_protocol_mouse.cpp b/proto-mouse/ftnoir_protocol_mouse.cpp index 68d0ef28..3245adf4 100644 --- a/proto-mouse/ftnoir_protocol_mouse.cpp +++ b/proto-mouse/ftnoir_protocol_mouse.cpp @@ -64,12 +64,11 @@ int mouse::get_delta(int val, int prev) { using std::abs; - const int a = abs(val - prev), b = abs(val + prev), c = abs(val); - if (c < a && c < b) - return val; - if (b < a && b < c) + const int a = abs(val - prev), b = abs(val + prev); + if (b < a) return val + prev; - return val - prev; + else + return val - prev; } int mouse::get_value(double val, double sensitivity, bool is_rotation) -- cgit v1.2.3