summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-03 11:11:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-03 11:12:03 +0100
commite26830bf71ca5968fc9d9d473966ea4b75120b56 (patch)
tree27ade992facd45b2746b167dc031adfd96537035 /logic
parent2dc57da89cdc56a61ec8da1c7fa7770448f3d3f6 (diff)
logic/tracker, dinput, tracker/joystick: fix rounding errors
Issue: #487 Reported-by: @H-Bear-22 Closes #487 Also use a power of two for joy_axis_size. Floats are base 2. axis_max in tracker/joystick had a fencepost error.
Diffstat (limited to 'logic')
-rw-r--r--logic/tracker.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/logic/tracker.cpp b/logic/tracker.cpp
index dc148eba..fd6ecfe7 100644
--- a/logic/tracker.cpp
+++ b/logic/tracker.cpp
@@ -141,9 +141,13 @@ void Tracker::logic()
{
using std::fmod;
using std::copysign;
+ using std::fabs;
const double x = value(i);
- value(i) = fmod(x + copysign(180, x), 360) - copysign(180, x);
+ if (fabs(x) - 1e-2 > 180)
+ value(i) = fmod(x - copysign(180, -x), 360) + copysign(180, x);
+ else
+ value(i) = clamp(x, -180, 180);
}
logger.write_pose(raw); // raw