From ef452045a0d9e323fcdb084fd9833911bf86091d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 30 Oct 2015 20:38:41 +0100 Subject: [PATCH] Fix joystick for good --- src/Vehicle/Vehicle.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 46ccad12e..b68209948 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -765,7 +765,7 @@ void Vehicle::_loadSettings(void) _joystickMode = JoystickModeRC; } - setJoystickEnabled(settings.value(_joystickEnabledSettingsKey, false).toBool()); + _joystickEnabled = settings.value(_joystickEnabledSettingsKey, false).toBool(); _communicationInactivityTimeoutMSecs = settings.value(_communicationInactivityKey, _communicationInactivityTimeoutMSecsDefault).toInt(); } @@ -813,16 +813,25 @@ bool Vehicle::joystickEnabled(void) void Vehicle::setJoystickEnabled(bool enabled) { + // The magic parameter will go away, + // until then don't mess with the logic here! Fact* fact = _autopilotPlugin->getParameterFact(FactSystem::defaultComponentId, "COM_RC_IN_MODE"); if (!fact) { qCWarning(JoystickLog) << "Missing COM_RC_IN_MODE parameter"; } - if (fact->value().toInt() != 2) { + // Any value greater than one + // indicates special handling on + // the autopilot side. Force the + // joystick to on. + if (fact->value().toInt() > 1) { + // Mandatory in this setting + _joystickEnabled = true; + } else { fact->setValue(enabled ? 1 : 0); + _joystickEnabled = enabled; } - _joystickEnabled = enabled; _startJoystick(_joystickEnabled); _saveSettings(); } @@ -1032,6 +1041,10 @@ void Vehicle::_parametersReady(bool parametersReady) _missionManagerInitialRequestComplete = true; _missionManager->requestMissionItems(); } + + if (parametersReady) { + setJoystickEnabled(_joystickEnabled); + } } void Vehicle::_communicationInactivityTimedOut(void) -- 2.22.0