From fa5198975bf20a738fb794de6fa86db6559ee0ac Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 23 Sep 2015 15:44:43 +0200 Subject: [PATCH] Joystick: Fix magic numbers with integer overflow --- src/Joystick/Joystick.cc | 2 +- src/VehicleSetup/JoystickConfigController.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index fb69ea88e..e5abd1445 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -124,7 +124,7 @@ void Joystick::_loadSettings(void) calibration->min = settings.value(minTpl.arg(axis), -32768).toInt(&convertOk); badSettings |= !convertOk; - calibration->max = settings.value(maxTpl.arg(axis), 32768).toInt(&convertOk); + calibration->max = settings.value(maxTpl.arg(axis), 32767).toInt(&convertOk); badSettings |= !convertOk; calibration->reversed = settings.value(revTpl.arg(axis), false).toBool(); diff --git a/src/VehicleSetup/JoystickConfigController.cc b/src/VehicleSetup/JoystickConfigController.cc index 41dc552dd..cec3c9b83 100644 --- a/src/VehicleSetup/JoystickConfigController.cc +++ b/src/VehicleSetup/JoystickConfigController.cc @@ -32,9 +32,9 @@ QGC_LOGGING_CATEGORY(JoystickConfigControllerLog, "JoystickConfigControllerLog") const int JoystickConfigController::_updateInterval = 150; ///< Interval for timer which updates radio channel widgets const int JoystickConfigController::_calCenterPoint = 0; const int JoystickConfigController::_calValidMinValue = -32768; ///< Largest valid minimum axis value -const int JoystickConfigController::_calValidMaxValue = 32768; ///< Smallest valid maximum axis value +const int JoystickConfigController::_calValidMaxValue = 32767; ///< Smallest valid maximum axis value const int JoystickConfigController::_calDefaultMinValue = -32768; ///< Default value for Min if not set -const int JoystickConfigController::_calDefaultMaxValue = 32768; ///< Default value for Max if not set +const int JoystickConfigController::_calDefaultMaxValue = 32767; ///< Default value for Max if not set const int JoystickConfigController::_calRoughCenterDelta = 500; ///< Delta around center point which is considered to be roughly centered const int JoystickConfigController::_calMoveDelta = 32768/2; ///< Amount of delta past center which is considered stick movement const int JoystickConfigController::_calSettleDelta = 100; ///< Amount of delta which is considered no stick movement -- 2.22.0