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 width: parent.width
19 spacing: 0
20
21 VehicleSummaryRow {
22 labelText: qsTr("Status")
23 valueText: {
24 if (!_activeJoystick) return qsTr("No joystick detected")
25 if (_activeJoystick.axisCount === 0) return qsTr("Buttons only")
26 if (!_activeJoystick.requiresCalibration) return qsTr("Ready")
27 return _activeJoystick.settings.calibrated.rawValue ? qsTr("Calibrated") : qsTr("Needs calibration")
28 }
29 }
30
31 VehicleSummaryRow {
32 visible: _activeJoystick
33 labelText: qsTr("Type")
34 valueText: {
35 if (!_activeJoystick) return ""
36 if (_activeJoystick.isGamepad) {
37 return _activeJoystick.gamepadType || qsTr("Gamepad")
38 }
39 return qsTr("Joystick")
40 }
41 }
42
43 VehicleSummaryRow {
44 visible: _activeJoystick && _activeJoystick.connectionType
45 labelText: qsTr("Connection")
46 valueText: _activeJoystick ? _activeJoystick.connectionType : ""
47 }
48
49 VehicleSummaryRow {
50 visible: _activeJoystick
51 labelText: qsTr("Inputs")
52 valueText: {
53 if (!_activeJoystick) return ""
54 var parts = []
55 if (_activeJoystick.axisCount > 0) parts.push(qsTr("%1 axes").arg(_activeJoystick.axisCount))
56 if (_activeJoystick.buttonCount > 0) parts.push(qsTr("%1 buttons").arg(_activeJoystick.buttonCount))
57 if (_activeJoystick.ballCount > 0) parts.push(qsTr("%1 balls").arg(_activeJoystick.ballCount))
58 if (_activeJoystick.touchpadCount() > 0) parts.push(qsTr("%1 touchpads").arg(_activeJoystick.touchpadCount()))
59 return parts.join(", ")
60 }
61 }
62
63 VehicleSummaryRow {
64 visible: _activeJoystick && _activeJoystick.batteryPercent >= 0
65 labelText: qsTr("Battery")
66 valueText: {
67 if (!_activeJoystick || _activeJoystick.batteryPercent < 0) return ""
68 var text = qsTr("%1%").arg(_activeJoystick.batteryPercent)
69 if (_activeJoystick.powerState) text += " (" + _activeJoystick.powerState + ")"
70 return text
71 }
72 valueColor: _activeJoystick && _activeJoystick.batteryPercent < 20 ? "red" : ""
73 }
74
75 VehicleSummaryRow {
76 visible: _activeJoystick && (_activeJoystick.hasRumble || _activeJoystick.hasLED || _activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
77 labelText: qsTr("Features")
78 valueText: {
79 if (!_activeJoystick) return ""
80 var features = []
81 if (_activeJoystick.hasRumble) features.push(qsTr("Rumble"))
82 if (_activeJoystick.hasRumbleTriggers) features.push(qsTr("Triggers"))
83 if (_activeJoystick.hasLED) features.push(qsTr("LED"))
84 if (_activeJoystick.hasGyroscope()) features.push(qsTr("Gyro"))
85 if (_activeJoystick.hasAccelerometer()) features.push(qsTr("Accel"))
86 return features.join(", ")
87 }
88 }
89
90 VehicleSummaryRow {
91 visible: _activeJoystick && _activeJoystick.vendorId > 0
92 labelText: qsTr("Device ID")
93 valueText: _activeJoystick ? "0x%1:0x%2".arg(_activeJoystick.vendorId.toString(16).toUpperCase().padStart(4, '0')).arg(_activeJoystick.productId.toString(16).toUpperCase().padStart(4, '0')) : ""
94 }
95
96 VehicleSummaryRow {
97 visible: _activeJoystick && _activeJoystick.playerIndex >= 0
98 labelText: qsTr("Player")
99 valueText: _activeJoystick ? (_activeJoystick.playerIndex + 1).toString() : ""
100 }
101
102 VehicleSummaryRow {
103 visible: _activeJoystick && _activeJoystick.isVirtual
104 labelText: qsTr("Virtual")
105 valueText: qsTr("Yes")
106 }
107 }
108}