QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
JoystickComponentSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Item {
9 implicitWidth: mainLayout.implicitWidth
10 implicitHeight: mainLayout.implicitHeight
11 width: parent.width // grows when Loader is wider than implicitWidth
12
13 readonly property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
14 readonly property var _activeJoystick: joystickManager.activeJoystick
15
16 ColumnLayout {
17 id: mainLayout
18 spacing: 0
19
20 VehicleSummaryRow {
21 labelText: qsTr("Status")
22 valueText: {
23 if (!_activeJoystick) return qsTr("No joystick detected")
24 if (_activeJoystick.axisCount === 0) return qsTr("Buttons only")
25 if (!_activeJoystick.requiresCalibration) return qsTr("Ready")
26 return _activeJoystick.settings.calibrated.rawValue ? qsTr("Calibrated") : qsTr("Needs calibration")
27 }
28 }
29
30 VehicleSummaryRow {
31 visible: _activeJoystick
32 labelText: qsTr("Type")
33 valueText: {
34 if (!_activeJoystick) return ""
35 if (_activeJoystick.isGamepad) {
36 return _activeJoystick.gamepadType || qsTr("Gamepad")
37 }
38 return qsTr("Joystick")
39 }
40 }
41
42 VehicleSummaryRow {
43 visible: _activeJoystick && _activeJoystick.connectionType
44 labelText: qsTr("Connection")
45 valueText: _activeJoystick ? _activeJoystick.connectionType : ""
46 }
47
48 VehicleSummaryRow {
49 visible: _activeJoystick
50 labelText: qsTr("Inputs")
51 valueText: {
52 if (!_activeJoystick) return ""
53 var parts = []
54 if (_activeJoystick.axisCount > 0) parts.push(qsTr("%1 axes").arg(_activeJoystick.axisCount))
55 if (_activeJoystick.buttonCount > 0) parts.push(qsTr("%1 buttons").arg(_activeJoystick.buttonCount))
56 if (_activeJoystick.ballCount > 0) parts.push(qsTr("%1 balls").arg(_activeJoystick.ballCount))
57 if (_activeJoystick.touchpadCount() > 0) parts.push(qsTr("%1 touchpads").arg(_activeJoystick.touchpadCount()))
58 return parts.join(", ")
59 }
60 }
61
62 VehicleSummaryRow {
63 visible: _activeJoystick && _activeJoystick.batteryPercent >= 0
64 labelText: qsTr("Battery")
65 valueText: {
66 if (!_activeJoystick || _activeJoystick.batteryPercent < 0) return ""
67 var text = qsTr("%1%").arg(_activeJoystick.batteryPercent)
68 if (_activeJoystick.powerState) text += " (" + _activeJoystick.powerState + ")"
69 return text
70 }
71 valueColor: _activeJoystick && _activeJoystick.batteryPercent < 20 ? "red" : ""
72 }
73
74 VehicleSummaryRow {
75 visible: _activeJoystick && (_activeJoystick.hasRumble || _activeJoystick.hasLED || _activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
76 labelText: qsTr("Features")
77 valueText: {
78 if (!_activeJoystick) return ""
79 var features = []
80 if (_activeJoystick.hasRumble) features.push(qsTr("Rumble"))
81 if (_activeJoystick.hasRumbleTriggers) features.push(qsTr("Triggers"))
82 if (_activeJoystick.hasLED) features.push(qsTr("LED"))
83 if (_activeJoystick.hasGyroscope()) features.push(qsTr("Gyro"))
84 if (_activeJoystick.hasAccelerometer()) features.push(qsTr("Accel"))
85 return features.join(", ")
86 }
87 }
88
89 VehicleSummaryRow {
90 visible: _activeJoystick && _activeJoystick.vendorId > 0
91 labelText: qsTr("Device ID")
92 valueText: _activeJoystick ? "0x%1:0x%2".arg(_activeJoystick.vendorId.toString(16).toUpperCase().padStart(4, '0')).arg(_activeJoystick.productId.toString(16).toUpperCase().padStart(4, '0')) : ""
93 }
94
95 VehicleSummaryRow {
96 visible: _activeJoystick && _activeJoystick.playerIndex >= 0
97 labelText: qsTr("Player")
98 valueText: _activeJoystick ? (_activeJoystick.playerIndex + 1).toString() : ""
99 }
100
101 VehicleSummaryRow {
102 visible: _activeJoystick && _activeJoystick.isVirtual
103 labelText: qsTr("Virtual")
104 valueText: qsTr("Yes")
105 }
106 }
107}