Commit d641b884 authored by Roman Bapst's avatar Roman Bapst

Merge pull request #2164 from mavlink/joystick_settings_fix

Fix Joystick instantitation from settings
parents f9d58d34 ef452045
...@@ -813,16 +813,25 @@ bool Vehicle::joystickEnabled(void) ...@@ -813,16 +813,25 @@ bool Vehicle::joystickEnabled(void)
void Vehicle::setJoystickEnabled(bool enabled) 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"); Fact* fact = _autopilotPlugin->getParameterFact(FactSystem::defaultComponentId, "COM_RC_IN_MODE");
if (!fact) { if (!fact) {
qCWarning(JoystickLog) << "Missing COM_RC_IN_MODE parameter"; 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); fact->setValue(enabled ? 1 : 0);
_joystickEnabled = enabled;
} }
_joystickEnabled = enabled;
_startJoystick(_joystickEnabled); _startJoystick(_joystickEnabled);
_saveSettings(); _saveSettings();
} }
...@@ -1032,6 +1041,10 @@ void Vehicle::_parametersReady(bool parametersReady) ...@@ -1032,6 +1041,10 @@ void Vehicle::_parametersReady(bool parametersReady)
_missionManagerInitialRequestComplete = true; _missionManagerInitialRequestComplete = true;
_missionManager->requestMissionItems(); _missionManager->requestMissionItems();
} }
if (parametersReady) {
setJoystickEnabled(_joystickEnabled);
}
} }
void Vehicle::_communicationInactivityTimedOut(void) void Vehicle::_communicationInactivityTimedOut(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment