Browse Source

Virtual joystick defaults to auto-center (#9201)

* Fix ability to click on hat when not recentered

* Default auto-center to on for safety
QGC4.4
Don Gagne 5 years ago committed by GitHub
parent
commit
f62900a40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      src/QmlControls/JoystickThumbPad.qml
  2. 2
      src/Settings/App.SettingsGroup.json

35
src/QmlControls/JoystickThumbPad.qml

@ -20,6 +20,9 @@ Item { @@ -20,6 +20,9 @@ Item {
property bool _processTouchPoints: false
property color _fgColor: QGroundControl.globalPalette.text
property color _bgColor: QGroundControl.globalPalette.window
property real _hatWidth: ScreenTools.defaultFontPixelHeight
property real _hatWidthHalf: _hatWidth / 2
property real stickPositionX: _centerXY
property real stickPositionY: yAxisReCenter ? _centerXY : height
@ -176,17 +179,14 @@ Item { @@ -176,17 +179,14 @@ Item {
}
Rectangle {
width: hatWidth
height: hatWidth
radius: hatWidthHalf
width: _hatWidth
height: _hatWidth
radius: _hatWidthHalf
border.color: _fgColor
border.width: 1
color: Qt.rgba(_fgColor.r, _fgColor.g, _fgColor.b, 0.5)
x: stickPositionX - hatWidthHalf
y: stickPositionY - hatWidthHalf
readonly property real hatWidth: ScreenTools.defaultFontPixelHeight
readonly property real hatWidthHalf: ScreenTools.defaultFontPixelHeight / 2
x: stickPositionX - _hatWidthHalf
y: stickPositionY - _hatWidthHalf
}
Connections {
@ -205,11 +205,18 @@ Item { @@ -205,11 +205,18 @@ Item {
}
MultiPointTouchArea {
anchors.fill: parent
minimumTouchPoints: 1
maximumTouchPoints: 1
touchPoints: [ TouchPoint { id: touchPoint } ]
onPressed: _joyRoot.thumbDown(touchPoints)
onReleased: _joyRoot.reCenter()
anchors.fill: parent
anchors.bottomMargin: yAxisReCenter ? 0 : -_hatWidthHalf
minimumTouchPoints: 1
maximumTouchPoints: 1
touchPoints: [ TouchPoint { id: touchPoint } ]
onPressed: _joyRoot.thumbDown(touchPoints)
onReleased: _joyRoot.reCenter()
Rectangle {
border.color: "red"
color: "transparent"
anchors.fill: parent
}
}
}

2
src/Settings/App.SettingsGroup.json

@ -119,7 +119,7 @@ @@ -119,7 +119,7 @@
"shortDesc": "Auto-Center Throttle",
"longDesc": "If enabled the throttle stick will snap back to center when released.",
"type": "bool",
"default": false
"default": true
},
{
"name": "gstDebugLevel",

Loading…
Cancel
Save