diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-16 17:31:19 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-16 17:53:40 +0200 |
commit | a781170550b4354e0f5551e0b20560d84e4108ce (patch) | |
tree | 2d845974432698cfcef21c87b3f5cef5ec1ecf60 | |
parent | 6200fa9bb156ad02e7c6055c8dbd92f8c9a10759 (diff) |
proto/vjoystick: unbreak
Nice braino.
-rw-r--r-- | proto-vjoystick/vjoystick.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/proto-vjoystick/vjoystick.cpp b/proto-vjoystick/vjoystick.cpp index 5a780222..d05c54c5 100644 --- a/proto-vjoystick/vjoystick.cpp +++ b/proto-vjoystick/vjoystick.cpp @@ -36,29 +36,19 @@ constexpr double handle::val_minmax[6]; void handle::init() { -#if 0 - bool ret = true; - for (unsigned i = 0; i < axis_count; i++) { - ret &= GetVJDAxisExist(OPENTRACK_VJOYSTICK_ID, axis_ids[i]); - if (!ret) { qDebug() << "axis" << i << "doesn't exist"; break; } - ret &= GetVJDAxisMin(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_min[i]); - if (!ret) { qDebug() << "axis" << i << "can't get min value"; break; }; - ret &= GetVJDAxisMax(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_max[i]); - if (!ret) { qDebug() << "axis" << i << "can't get max value"; break; }; - } - - if (!ret) - { - (void) RelinquishVJD(OPENTRACK_VJOYSTICK_ID); - joy_state = state_fail; + if (!GetVJDAxisExist(OPENTRACK_VJOYSTICK_ID, axis_ids[i])) + { + // avoid floating point division by zero + axis_min[i] = 0; + axis_max[i] = 1; + continue; + } + GetVJDAxisMin(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_min[i]); + GetVJDAxisMax(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_max[i]); } - else - (void) ResetVJD(OPENTRACK_VJOYSTICK_ID); -#else (void) ResetVJD(OPENTRACK_VJOYSTICK_ID); -#endif } handle::handle() |