diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-09 18:20:28 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-09 18:22:21 +0100 |
commit | e6412ba2e9dc6c56664dbcf81ef299499434891a (patch) | |
tree | 2d137792cd65e39ac4a66f52fd9b67aac54ee6eb /proto-mouse | |
parent | 6ba9498ddb1f5e4721cebef82cb098efa5f9e286 (diff) |
proto/mouse: fix some bad arithmetic
Diffstat (limited to 'proto-mouse')
-rw-r--r-- | proto-mouse/ftnoir_protocol_mouse.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
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) |