diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc index 1818b5cf23a8445d48142fcb3c9bb9121709be7b..e6dd01b74a9bfe83e11dd580bb8c6a82a8156c36 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc @@ -67,3 +67,8 @@ bool ArduSubFirmwarePlugin::supportsRadio(void) { return false; } + +bool ArduSubFirmwarePlugin::supportsJSButton(void) +{ + return true; +} diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h index 1f862ce4eeb7b34210812e2bfd10b2eac2cddb1d..5d63869512c48c6749041fb1a4a322bb39dc1841 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h @@ -74,6 +74,8 @@ public: bool supportsManualControl(void); bool supportsRadio(void); + + bool supportsJSButton(void); }; #endif diff --git a/src/FirmwarePlugin/FirmwarePlugin.cc b/src/FirmwarePlugin/FirmwarePlugin.cc index 5e835f5fdffd92c97152ab6e903be09597e9f3b1..9707264e9bed083ee08d0c7ab5d474c6f814652c 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.cc +++ b/src/FirmwarePlugin/FirmwarePlugin.cc @@ -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); diff --git a/src/FirmwarePlugin/FirmwarePlugin.h b/src/FirmwarePlugin/FirmwarePlugin.h index ecd6179e9d1b04b141a373bd49a3efaf025b5571..a4f580308ca29a268fe958284855c28a52ff57fe 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.h +++ b/src/FirmwarePlugin/FirmwarePlugin.h @@ -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. diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 40982010e6c699365dc2d47a3ac8f259e9bf87cd..f21c8710ae3dc91769e2b698e9b8547f97b6e3da 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -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) { diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 90df74f65aa2817cd57a0922c4a361a98e535903..e70c2981bb5c06c20bc119d0b8025380752a5dc8 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -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); diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index c53a742739e0dc6bec54b0204c3f352f3edc9252..91b68936292cbdaa5a69f4176aaf5ef8a013b391 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -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