Browse Source

Merge pull request #8201 from DonLakeFlyer/JoystickFlightModes

Allow plugin to add flight modes to joystick button actions
QGC4.4
Don Gagne 5 years ago committed by GitHub
parent
commit
ef161bcdfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/FirmwarePlugin/FirmwarePlugin.h
  2. 6
      src/Joystick/Joystick.cc
  3. 5
      src/Vehicle/Vehicle.cc
  4. 10
      src/Vehicle/Vehicle.h

11
src/FirmwarePlugin/FirmwarePlugin.h

@ -81,12 +81,13 @@ public: @@ -81,12 +81,13 @@ public:
/// free when no longer needed.
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle);
/// Returns the list of available flight modes. Flight modes can be different in normal/advanced ui mode.
/// Returns the list of available flight modes for the Fly View dropdown. This may or may not be the full
/// list available from the firmware. Call will be made again if advanced mode changes.
virtual QStringList flightModes(Vehicle* /*vehicle*/) { return QStringList(); }
/// Returns the list of additional flight modes to add to the list for joystick button actions.
/// Call will be made again if advanced mode changes.
virtual QStringList flightModes(Vehicle* vehicle) {
Q_UNUSED(vehicle);
return QStringList();
}
virtual QStringList extraJoystickFlightModes(Vehicle* /*vehicle*/) { return QStringList(); }
/// Returns the name for this flight mode. Flight mode names must be human readable as well as audio speakable.
/// @param base_mode Base mode from mavlink HEARTBEAT message

6
src/Joystick/Joystick.cc

@ -972,7 +972,7 @@ void Joystick::_executeButtonAction(const QString& action, bool buttonDown) @@ -972,7 +972,7 @@ void Joystick::_executeButtonAction(const QString& action, bool buttonDown)
if (buttonDown) emit setVtolInFwdFlight(true);
} else if (action == _buttonActionVTOLMultiRotor) {
if (buttonDown) emit setVtolInFwdFlight(false);
} else if (_activeVehicle->flightModes().contains(action)) {
} else if (_activeVehicle->flightModes().contains(action) || _activeVehicle->extraJoystickFlightModes().contains(action)) {
if (buttonDown) emit setFlightMode(action);
} else if(action == _buttonActionContinuousZoomIn || action == _buttonActionContinuousZoomOut) {
if (buttonDown) {
@ -1072,6 +1072,10 @@ void Joystick::_buildActionList(Vehicle* activeVehicle) @@ -1072,6 +1072,10 @@ void Joystick::_buildActionList(Vehicle* activeVehicle)
foreach(auto mode, list) {
_assignableButtonActions.append(new AssignableButtonAction(this, mode));
}
list = activeVehicle->extraJoystickFlightModes();
foreach(auto mode, list) {
_assignableButtonActions.append(new AssignableButtonAction(this, mode));
}
}
_assignableButtonActions.append(new AssignableButtonAction(this, _buttonActionVTOLFixedWing));
_assignableButtonActions.append(new AssignableButtonAction(this, _buttonActionVTOLMultiRotor));

5
src/Vehicle/Vehicle.cc

@ -2375,6 +2375,11 @@ QStringList Vehicle::flightModes(void) @@ -2375,6 +2375,11 @@ QStringList Vehicle::flightModes(void)
return _firmwarePlugin->flightModes(this);
}
QStringList Vehicle::extraJoystickFlightModes(void)
{
return _firmwarePlugin->extraJoystickFlightModes(this);
}
QString Vehicle::flightMode(void) const
{
return _firmwarePlugin->flightMode(_base_mode, _custom_mode);

10
src/Vehicle/Vehicle.h

@ -542,6 +542,7 @@ public: @@ -542,6 +542,7 @@ public:
Q_PROPERTY(bool autoDisarm READ autoDisarm NOTIFY autoDisarmChanged)
Q_PROPERTY(bool flightModeSetAvailable READ flightModeSetAvailable CONSTANT)
Q_PROPERTY(QStringList flightModes READ flightModes NOTIFY flightModesChanged)
Q_PROPERTY(QStringList extraJoystickFlightModes READ extraJoystickFlightModes NOTIFY flightModesChanged)
Q_PROPERTY(QString flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeChanged)
Q_PROPERTY(bool hilMode READ hilMode WRITE setHilMode NOTIFY hilModeChanged)
Q_PROPERTY(TrajectoryPoints* trajectoryPoints MEMBER _trajectoryPoints CONSTANT)
@ -851,10 +852,11 @@ public: @@ -851,10 +852,11 @@ public:
bool armed () { return _armed; }
void setArmed (bool armed);
bool flightModeSetAvailable(void);
QStringList flightModes(void);
QString flightMode(void) const;
void setFlightMode(const QString& flightMode);
bool flightModeSetAvailable (void);
QStringList flightModes (void);
QStringList extraJoystickFlightModes (void);
QString flightMode (void) const;
void setFlightMode (const QString& flightMode);
QString priorityLinkName(void) const;
QVariantList links(void) const;

Loading…
Cancel
Save