From d96940f7370df1d0b7212f76682472ba64b25713 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Wed, 27 Jul 2016 18:32:15 -0700 Subject: [PATCH] Add joystick button function mapper for ArduSub --- src/VehicleSetup/JoystickConfig.qml | 71 ++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index 33d783afe..c53a74273 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -18,6 +18,7 @@ import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 /// Joystick Config QGCView { @@ -448,6 +449,9 @@ QGCView { if (buttonActionRepeater.itemAt(index)) { buttonActionRepeater.itemAt(index).pressed = pressed } + if (subButtonActionRepeater.itemAt(index)) { + subButtonActionRepeater.itemAt(index).pressed = pressed + } } } @@ -470,7 +474,7 @@ QGCView { Row { spacing: ScreenTools.defaultFontPixelWidth - visible: _activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount + visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.sub property bool pressed @@ -509,6 +513,71 @@ QGCView { } } } // Repeater + + Row { + spacing: ScreenTools.defaultFontPixelWidth + visible: _activeVehicle.sub + + QGCLabel { + horizontalAlignment: Text.AlignHCenter + width: ScreenTools.defaultFontPixelHeight * 1.5 + text: qsTr("#") + } + + QGCLabel { + width: ScreenTools.defaultFontPixelWidth * 15 + text: qsTr("Function: ") + } + + QGCLabel { + width: ScreenTools.defaultFontPixelWidth * 15 + text: qsTr("Shift Function: ") + } + } // Row + + Repeater { + id: subButtonActionRepeater + model: _activeJoystick.totalButtonCount + + Row { + spacing: ScreenTools.defaultFontPixelWidth + visible: _activeVehicle.sub + + property bool pressed + + Rectangle { + anchors.verticalCenter: parent.verticalCenter + width: ScreenTools.defaultFontPixelHeight * 1.5 + height: width + border.width: 1 + border.color: qgcPal.text + color: pressed ? qgcPal.buttonHighlight : qgcPal.button + + + QGCLabel { + anchors.fill: parent + color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: modelData + } + } + + FactComboBox { + id: mainSubButtonActionCombo + width: ScreenTools.defaultFontPixelWidth * 15 + fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null; + indexModel: false + } + + FactComboBox { + id: shiftSubButtonActionCombo + width: ScreenTools.defaultFontPixelWidth * 15 + fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null; + indexModel: false + } + } // Row + } // Repeater } // Column } // Column - right setting column } // Row - Settings -- 2.22.0