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