Commit 2664e9a5 authored by Rustom Jehangir's avatar Rustom Jehangir

Make supportsJSButton a plugin option

parent a78ee55b
...@@ -67,3 +67,8 @@ bool ArduSubFirmwarePlugin::supportsRadio(void) ...@@ -67,3 +67,8 @@ bool ArduSubFirmwarePlugin::supportsRadio(void)
{ {
return false; return false;
} }
bool ArduSubFirmwarePlugin::supportsJSButton(void)
{
return true;
}
...@@ -74,6 +74,8 @@ public: ...@@ -74,6 +74,8 @@ public:
bool supportsManualControl(void); bool supportsManualControl(void);
bool supportsRadio(void); bool supportsRadio(void);
bool supportsJSButton(void);
}; };
#endif #endif
...@@ -99,6 +99,11 @@ bool FirmwarePlugin::supportsRadio(void) ...@@ -99,6 +99,11 @@ bool FirmwarePlugin::supportsRadio(void)
return true; return true;
} }
bool FirmwarePlugin::supportsJSButton(void)
{
return false;
}
bool FirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message) bool FirmwarePlugin::adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
{ {
Q_UNUSED(vehicle); Q_UNUSED(vehicle);
......
...@@ -141,6 +141,10 @@ public: ...@@ -141,6 +141,10 @@ public:
/// setup page. Returns true by default. /// setup page. Returns true by default.
virtual bool supportsRadio(void); 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 /// 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 /// 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. /// spec implementations such that the base code can remain mavlink generic.
......
...@@ -1530,6 +1530,11 @@ bool Vehicle::supportsRadio(void) const ...@@ -1530,6 +1530,11 @@ bool Vehicle::supportsRadio(void) const
return _firmwarePlugin->supportsRadio(); return _firmwarePlugin->supportsRadio();
} }
bool Vehicle::supportsJSButton(void) const
{
return _firmwarePlugin->supportsJSButton();
}
void Vehicle::_setCoordinateValid(bool coordinateValid) void Vehicle::_setCoordinateValid(bool coordinateValid)
{ {
if (coordinateValid != _coordinateValid) { if (coordinateValid != _coordinateValid) {
......
...@@ -277,6 +277,7 @@ public: ...@@ -277,6 +277,7 @@ public:
Q_PROPERTY(bool rover READ rover CONSTANT) Q_PROPERTY(bool rover READ rover CONSTANT)
Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT) Q_PROPERTY(bool supportsManualControl READ supportsManualControl CONSTANT)
Q_PROPERTY(bool supportsThrottleModeCenterZero READ supportsThrottleModeCenterZero 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 sub READ sub CONSTANT)
Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged) Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged)
Q_PROPERTY(QString prearmError READ prearmError WRITE setPrearmError NOTIFY prearmErrorChanged) 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 supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const; bool supportsThrottleModeCenterZero(void) const;
bool supportsRadio(void) const; bool supportsRadio(void) const;
bool supportsJSButton(void) const;
void setFlying(bool flying); void setFlying(bool flying);
void setGuidedMode(bool guidedMode); void setGuidedMode(bool guidedMode);
......
...@@ -381,7 +381,7 @@ QGCView { ...@@ -381,7 +381,7 @@ QGCView {
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
visible: !_activeVehicle.sub visible: _activeVehicle.supportsThrottleModeCenterZero
ExclusiveGroup { id: throttleModeExclusiveGroup } ExclusiveGroup { id: throttleModeExclusiveGroup }
...@@ -449,8 +449,8 @@ QGCView { ...@@ -449,8 +449,8 @@ QGCView {
if (buttonActionRepeater.itemAt(index)) { if (buttonActionRepeater.itemAt(index)) {
buttonActionRepeater.itemAt(index).pressed = pressed buttonActionRepeater.itemAt(index).pressed = pressed
} }
if (subButtonActionRepeater.itemAt(index)) { if (jsButtonActionRepeater.itemAt(index)) {
subButtonActionRepeater.itemAt(index).pressed = pressed jsButtonActionRepeater.itemAt(index).pressed = pressed
} }
} }
} }
...@@ -474,7 +474,7 @@ QGCView { ...@@ -474,7 +474,7 @@ QGCView {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth 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 property bool pressed
...@@ -516,7 +516,7 @@ QGCView { ...@@ -516,7 +516,7 @@ QGCView {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub visible: _activeVehicle.supportsJSButton
QGCLabel { QGCLabel {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
...@@ -536,12 +536,12 @@ QGCView { ...@@ -536,12 +536,12 @@ QGCView {
} // Row } // Row
Repeater { Repeater {
id: subButtonActionRepeater id: jsButtonActionRepeater
model: _activeJoystick.totalButtonCount model: _activeJoystick.totalButtonCount
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub visible: _activeVehicle.supportsJSButton
property bool pressed property bool pressed
...@@ -564,14 +564,14 @@ QGCView { ...@@ -564,14 +564,14 @@ QGCView {
} }
FactComboBox { FactComboBox {
id: mainSubButtonActionCombo id: mainJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15 width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null; fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false indexModel: false
} }
FactComboBox { FactComboBox {
id: shiftSubButtonActionCombo id: shiftJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15 width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null; fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false indexModel: false
......
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