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)
{
return false;
}
bool ArduSubFirmwarePlugin::supportsJSButton(void)
{
return true;
}
......@@ -74,6 +74,8 @@ public:
bool supportsManualControl(void);
bool supportsRadio(void);
bool supportsJSButton(void);
};
#endif
......@@ -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);
......
......@@ -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.
......
......@@ -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) {
......
......@@ -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:
bool supportsManualControl(void) const;
bool supportsThrottleModeCenterZero(void) const;
bool supportsRadio(void) const;
bool supportsJSButton(void) const;
void setFlying(bool flying);
void setGuidedMode(bool guidedMode);
......
......@@ -381,7 +381,7 @@ QGCView {
Column {
spacing: ScreenTools.defaultFontPixelHeight / 3
visible: !_activeVehicle.sub
visible: _activeVehicle.supportsThrottleModeCenterZero
ExclusiveGroup { id: throttleModeExclusiveGroup }
......@@ -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 {
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 {
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.sub
visible: _activeVehicle.supportsJSButton
QGCLabel {
horizontalAlignment: Text.AlignHCenter
......@@ -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 {
}
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
......
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