5import QGroundControl.Controls
10 width: joystickIcon.width * 1.1
11 anchors.top: parent.top
12 anchors.bottom: parent.bottom
14 property bool showIndicator: _activeJoystick
15 property var _activeJoystick: joystickManager.activeJoystick
16 property bool _joystickEnabled: globals.activeVehicle && joystickManager.activeJoystickEnabledForActiveVehicle
18 QGCPalette { id: qgcPal }
26 contentComponent: SettingsGroupLayout {
27 heading: _activeJoystick ? _activeJoystick.name : qsTr("Joystick")
31 columnSpacing: ScreenTools.defaultFontPixelWidth * 2
33 QGCLabel { text: qsTr("Enabled:") }
36 if (!globals.activeVehicle)
37 return qsTr("No Vehicle")
38 return _joystickEnabled ? qsTr("Yes") : qsTr("No")
41 if (!globals.activeVehicle)
42 return qgcPal.buttonText
43 return _joystickEnabled ? qgcPal.buttonText : "orange"
47 QGCLabel { text: qsTr("Type:") }
49 text: _activeJoystick ? (_activeJoystick.isGamepad ? _activeJoystick.gamepadType || qsTr("Gamepad") : qsTr("Joystick")) : ""
53 text: qsTr("Connection:")
54 visible: _activeJoystick && _activeJoystick.connectionType && _activeJoystick.connectionType !== "Unknown" && _activeJoystick.connectionType !== "Invalid"
57 text: _activeJoystick ? _activeJoystick.connectionType : ""
58 visible: _activeJoystick && _activeJoystick.connectionType && _activeJoystick.connectionType !== "Unknown" && _activeJoystick.connectionType !== "Invalid"
61 QGCLabel { text: qsTr("Inputs:") }
64 if (!_activeJoystick) return ""
65 var parts = [qsTr("%1 axes").arg(_activeJoystick.axisCount), qsTr("%1 buttons").arg(_activeJoystick.buttonCount)]
66 if (_activeJoystick.ballCount > 0) parts.push(qsTr("%1 balls").arg(_activeJoystick.ballCount))
67 if (_activeJoystick.touchpadCount() > 0) parts.push(qsTr("%1 touchpads").arg(_activeJoystick.touchpadCount()))
68 return parts.join(", ")
73 text: qsTr("Battery:")
74 visible: _activeJoystick && _activeJoystick.batteryPercent >= 0
78 if (!_activeJoystick || _activeJoystick.batteryPercent < 0) return ""
79 var batteryText = qsTr("%1%").arg(_activeJoystick.batteryPercent)
80 if (_activeJoystick.powerState) batteryText += " (" + _activeJoystick.powerState + ")"
83 color: _activeJoystick && _activeJoystick.batteryPercent < 20 ? "red" : qgcPal.buttonText
84 visible: _activeJoystick && _activeJoystick.batteryPercent >= 0
88 text: qsTr("Features:")
89 visible: _activeJoystick && (_activeJoystick.hasRumble || _activeJoystick.hasLED || _activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
92 property var features: {
94 if (_activeJoystick) {
95 if (_activeJoystick.hasRumble) list.push(qsTr("Rumble"))
96 if (_activeJoystick.hasRumbleTriggers) list.push(qsTr("Trigger Rumble"))
97 if (_activeJoystick.hasLED) list.push(qsTr("LED"))
98 if (_activeJoystick.hasGyroscope()) list.push(qsTr("Gyro"))
99 if (_activeJoystick.hasAccelerometer()) list.push(qsTr("Accel"))
101 return list.join(", ")
104 visible: _activeJoystick && (_activeJoystick.hasRumble || _activeJoystick.hasLED || _activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
108 text: qsTr("Player:")
109 visible: _activeJoystick && _activeJoystick.playerIndex >= 0
112 text: _activeJoystick ? (_activeJoystick.playerIndex + 1).toString() : ""
113 visible: _activeJoystick && _activeJoystick.playerIndex >= 0
118 expandedComponent: SettingsGroupLayout {
119 heading: qsTr("Device Details")
123 columnSpacing: ScreenTools.defaultFontPixelWidth * 2
126 text: qsTr("Device Type:")
127 visible: _activeJoystick && _activeJoystick.deviceType
130 text: _activeJoystick ? _activeJoystick.deviceType : ""
131 visible: _activeJoystick && _activeJoystick.deviceType
135 text: qsTr("Vendor/Product:")
136 visible: _activeJoystick && _activeJoystick.vendorId > 0
139 text: _activeJoystick ? "0x%1 / 0x%2".arg(_activeJoystick.vendorId.toString(16).toUpperCase().padStart(4, '0')).arg(_activeJoystick.productId.toString(16).toUpperCase().padStart(4, '0')) : ""
140 visible: _activeJoystick && _activeJoystick.vendorId > 0
144 text: qsTr("Serial:")
145 visible: _activeJoystick && _activeJoystick.serial
148 text: _activeJoystick ? _activeJoystick.serial : ""
149 visible: _activeJoystick && _activeJoystick.serial
153 text: qsTr("Firmware:")
154 visible: _activeJoystick && _activeJoystick.firmwareVersion > 0
157 text: _activeJoystick ? _activeJoystick.firmwareVersion.toString() : ""
158 visible: _activeJoystick && _activeJoystick.firmwareVersion > 0
163 visible: _activeJoystick && _activeJoystick.path
166 text: _activeJoystick ? _activeJoystick.path : ""
167 visible: _activeJoystick && _activeJoystick.path
168 elide: Text.ElideMiddle
169 Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 20
174 visible: _activeJoystick && _activeJoystick.guid
177 text: _activeJoystick ? _activeJoystick.guid : ""
178 visible: _activeJoystick && _activeJoystick.guid
179 font.family: "monospace"
180 font.pixelSize: ScreenTools.smallFontPointSize
181 elide: Text.ElideMiddle
182 Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 20
186 text: qsTr("Virtual:")
187 visible: _activeJoystick && _activeJoystick.isVirtual
191 visible: _activeJoystick && _activeJoystick.isVirtual
195 text: qsTr("LED Types:")
196 visible: _activeJoystick && (_activeJoystick.hasMonoLED() || _activeJoystick.hasRGBLED() || _activeJoystick.hasPlayerLED())
199 property var ledTypes: {
201 if (_activeJoystick) {
202 if (_activeJoystick.hasMonoLED()) list.push(qsTr("Mono"))
203 if (_activeJoystick.hasRGBLED()) list.push(qsTr("RGB"))
204 if (_activeJoystick.hasPlayerLED()) list.push(qsTr("Player"))
206 return list.join(", ")
209 visible: _activeJoystick && (_activeJoystick.hasMonoLED() || _activeJoystick.hasRGBLED() || _activeJoystick.hasPlayerLED())
213 text: qsTr("Haptic:")
214 visible: _activeJoystick && _activeJoystick.hasHaptic()
217 text: _activeJoystick && _activeJoystick.hasHaptic() ? qsTr("%1 effects").arg(_activeJoystick.hapticEffectsCount()) : ""
218 visible: _activeJoystick && _activeJoystick.hasHaptic()
222 text: qsTr("Motion Sensors:")
223 visible: _activeJoystick && (_activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
226 property var sensors: {
228 if (_activeJoystick) {
229 if (_activeJoystick.hasGyroscope()) {
230 var gyroRate = _activeJoystick.gyroscopeDataRate()
231 list.push(gyroRate > 0 ? qsTr("Gyro (%1 Hz)").arg(gyroRate.toFixed(0)) : qsTr("Gyro"))
233 if (_activeJoystick.hasAccelerometer()) {
234 var accelRate = _activeJoystick.accelerometerDataRate()
235 list.push(accelRate > 0 ? qsTr("Accel (%1 Hz)").arg(accelRate.toFixed(0)) : qsTr("Accel"))
238 return list.join(", ")
241 visible: _activeJoystick && (_activeJoystick.hasGyroscope() || _activeJoystick.hasAccelerometer())
251 anchors.top: parent.top
252 anchors.bottom: parent.bottom
253 sourceSize.height: height
254 source: "/qmlimages/Joystick.png"
255 fillMode: Image.PreserveAspectFit
257 if (!globals.activeVehicle) {
258 return qgcPal.buttonText
260 if (_joystickEnabled) {
261 return qgcPal.buttonText
268 fillItem: joystickIcon
269 onClicked: mainWindow.showIndicatorDrawer(joystickInfoPage, control)