From a781170550b4354e0f5551e0b20560d84e4108ce Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 16 Sep 2016 17:31:19 +0200 Subject: proto/vjoystick: unbreak Nice braino. --- proto-vjoystick/vjoystick.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'proto-vjoystick') 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() -- cgit v1.2.3