Browse Source

Make supportsJSButton a plugin option

QGC4.4
Rustom Jehangir 9 years ago
parent
commit
2664e9a5a6
  1. 5
      src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc
  2. 2
      src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h
  3. 5
      src/FirmwarePlugin/FirmwarePlugin.cc
  4. 4
      src/FirmwarePlugin/FirmwarePlugin.h
  5. 5
      src/Vehicle/Vehicle.cc
  6. 2
      src/Vehicle/Vehicle.h
  7. 18
      src/VehicleSetup/JoystickConfig.qml

5
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc

@ -67,3 +67,8 @@ bool ArduSubFirmwarePlugin::supportsRadio(void) @@ -67,3 +67,8 @@ bool ArduSubFirmwarePlugin::supportsRadio(void)
{
return false;
}
bool ArduSubFirmwarePlugin::supportsJSButton(void)
{
return true;
}

2
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h

@ -74,6 +74,8 @@ public: @@ -74,6 +74,8 @@ public:
bool supportsManualControl(void);
bool supportsRadio(void);
bool supportsJSButton(void);
};
#endif

5
src/FirmwarePlugin/FirmwarePlugin.cc

@ -99,6 +99,11 @@ bool FirmwarePlugin::supportsRadio(void) @@ -99,6 +99,11 @@ bool FirmwarePlugin::supportsRadio(void)
return true;
}
bool FirmwarePlugin::supportsJSButton(void)
{
return false;
}
bool FirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
{
Q_UNUSED(vehicle);

4
src/FirmwarePlugin/FirmwarePlugin.h

@ -141,6 +141,10 @@ public: @@ -141,6 +141,10 @@ public:
/// setup page. Returns true by default.
virtual bool supportsRadio(void);
/// Returns true if the firmware supports the AP_JSButton library, which allows joystick buttons
/// to be assigned via parameters in firmware. Default is false.
virtual bool supportsJSButton(void);
/// Called before any mavlink message is processed by Vehicle such that the firmwre plugin
/// can adjust any message characteristics. This is handy to adjust or differences in mavlink
/// spec implementations such that the base code can remain mavlink generic.

5
src/Vehicle/Vehicle.cc

@ -1530,6 +1530,11 @@ bool Vehicle::supportsRadio(void) const @@ -1530,6 +1530,11 @@ bool Vehicle::supportsRadio(void) const
return _firmwarePlugin->supportsRadio();
}
bool Vehicle::supportsJSButton(void) const
{
return _firmwarePlugin->supportsJSButton();
}
void Vehicle::_setCoordinateValid(bool coordinateValid)
{
if (coordinateValid != _coordinateValid) {

2
src/Vehicle/Vehicle.h

@ -277,6 +277,7 @@ public: @@ -277,6 +277,7 @@ public:
Q_PROPERTY(bool rover READ rover CONSTANT)
Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT)
Q_PROPERTY(bool supportsThrottleModeCenterZero READ supportsThrottleModeCenterZero CONSTANT)
Q_PROPERTY(bool supportsJSButton READ supportsJSButton CONSTANT)
Q_PROPERTY(bool sub READ sub CONSTANT)
Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged)
Q_PROPERTY(QString prearmError READ prearmError WRITE setPrearmError NOTIFY prearmErrorChanged)
@ -476,6 +477,7 @@ public: @@ -476,6 +477,7 @@ public:
bool supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const;
bool supportsRadio(void) const;
bool supportsJSButton(void) const;
void setFlying(bool flying);
void setGuidedMode(bool guidedMode);

18
src/VehicleSetup/JoystickConfig.qml

@ -381,7 +381,7 @@ QGCView { @@ -381,7 +381,7 @@ QGCView {
Column {
spacing: ScreenTools.defaultFontPixelHeight / 3
visible: !_activeVehicle.sub
visible: _activeVehicle.supportsThrottleModeCenterZero
ExclusiveGroup { id: throttleModeExclusiveGroup }
@ -449,8 +449,8 @@ QGCView { @@ -449,8 +449,8 @@ QGCView {
if (buttonActionRepeater.itemAt(index)) {
buttonActionRepeater.itemAt(index).pressed = pressed
}
if (subButtonActionRepeater.itemAt(index)) {
subButtonActionRepeater.itemAt(index).pressed = pressed
if (jsButtonActionRepeater.itemAt(index)) {
jsButtonActionRepeater.itemAt(index).pressed = pressed
}
}
}
@ -474,7 +474,7 @@ QGCView { @@ -474,7 +474,7 @@ QGCView {
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.sub
visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
property bool pressed
@ -516,7 +516,7 @@ QGCView { @@ -516,7 +516,7 @@ QGCView {
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub
visible: _activeVehicle.supportsJSButton
QGCLabel {
horizontalAlignment: Text.AlignHCenter
@ -536,12 +536,12 @@ QGCView { @@ -536,12 +536,12 @@ QGCView {
} // Row
Repeater {
id: subButtonActionRepeater
id: jsButtonActionRepeater
model: _activeJoystick.totalButtonCount
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub
visible: _activeVehicle.supportsJSButton
property bool pressed
@ -564,14 +564,14 @@ QGCView { @@ -564,14 +564,14 @@ QGCView {
}
FactComboBox {
id: mainSubButtonActionCombo
id: mainJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false
}
FactComboBox {
id: shiftSubButtonActionCombo
id: shiftJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false

Loading…
Cancel
Save