Browse Source

joystick: handle dynamic flight mode updates

QGC4.4
Beat Küng 2 years ago
parent
commit
427a5c43fc
  1. 7
      src/Joystick/Joystick.cc
  2. 2
      src/Joystick/Joystick.h

7
src/Joystick/Joystick.cc

@ -222,6 +222,10 @@ void Joystick::_activeVehicleChanged(Vehicle* activeVehicle) @@ -222,6 +222,10 @@ void Joystick::_activeVehicleChanged(Vehicle* activeVehicle)
setTXMode(mode);
}
}
void Joystick::_flightModesChanged()
{
_buildActionList(_activeVehicle);
}
void Joystick::_vehicleCountChanged(int count)
{
@ -717,6 +721,7 @@ void Joystick::startPolling(Vehicle* vehicle) @@ -717,6 +721,7 @@ void Joystick::startPolling(Vehicle* vehicle)
disconnect(this, &Joystick::gimbalControlValue, _activeVehicle, &Vehicle::gimbalControlValue);
disconnect(this, &Joystick::emergencyStop, _activeVehicle, &Vehicle::emergencyStop);
disconnect(this, &Joystick::gripperAction, _activeVehicle, &Vehicle::setGripperAction);
disconnect(_activeVehicle, &Vehicle::flightModesChanged, this, &Joystick::_flightModesChanged);
}
// Always set up the new vehicle
_activeVehicle = vehicle;
@ -740,6 +745,7 @@ void Joystick::startPolling(Vehicle* vehicle) @@ -740,6 +745,7 @@ void Joystick::startPolling(Vehicle* vehicle)
connect(this, &Joystick::gimbalControlValue, _activeVehicle, &Vehicle::gimbalControlValue);
connect(this, &Joystick::emergencyStop, _activeVehicle, &Vehicle::emergencyStop);
connect(this, &Joystick::gripperAction, _activeVehicle, &Vehicle::setGripperAction);
connect(_activeVehicle, &Vehicle::flightModesChanged, this, &Joystick::_flightModesChanged);
}
}
if (!isRunning()) {
@ -760,6 +766,7 @@ void Joystick::stopPolling(void) @@ -760,6 +766,7 @@ void Joystick::stopPolling(void)
disconnect(this, &Joystick::centerGimbal, _activeVehicle, &Vehicle::centerGimbal);
disconnect(this, &Joystick::gimbalControlValue, _activeVehicle, &Vehicle::gimbalControlValue);
disconnect(this, &Joystick::gripperAction, _activeVehicle, &Vehicle::setGripperAction);
disconnect(_activeVehicle, &Vehicle::flightModesChanged, this, &Joystick::_flightModesChanged);
}
_exitThread = true;
}

2
src/Joystick/Joystick.h

@ -366,5 +366,5 @@ private: @@ -366,5 +366,5 @@ private:
private slots:
void _activeVehicleChanged(Vehicle* activeVehicle);
void _vehicleCountChanged(int count);
void _flightModesChanged();
};

Loading…
Cancel
Save