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 {
property bool _processTouchPoints: false property bool _processTouchPoints: false
property color _fgColor: QGroundControl.globalPalette.text property color _fgColor: QGroundControl.globalPalette.text
property color _bgColor: QGroundControl.globalPalette.window property color _bgColor: QGroundControl.globalPalette.window
property real _hatWidth: ScreenTools.defaultFontPixelHeight
property real _hatWidthHalf: _hatWidth / 2
property real stickPositionX: _centerXY property real stickPositionX: _centerXY
property real stickPositionY: yAxisReCenter ? _centerXY : height property real stickPositionY: yAxisReCenter ? _centerXY : height
@ -176,17 +179,14 @@ Item {
} }
Rectangle { Rectangle {
width: hatWidth width: _hatWidth
height: hatWidth height: _hatWidth
radius: hatWidthHalf radius: _hatWidthHalf
border.color: _fgColor border.color: _fgColor
border.width: 1 border.width: 1
color: Qt.rgba(_fgColor.r, _fgColor.g, _fgColor.b, 0.5) color: Qt.rgba(_fgColor.r, _fgColor.g, _fgColor.b, 0.5)
x: stickPositionX - hatWidthHalf x: stickPositionX - _hatWidthHalf
y: stickPositionY - hatWidthHalf y: stickPositionY - _hatWidthHalf
readonly property real hatWidth: ScreenTools.defaultFontPixelHeight
readonly property real hatWidthHalf: ScreenTools.defaultFontPixelHeight / 2
} }
Connections { Connections {
@ -205,11 +205,18 @@ Item {
} }
MultiPointTouchArea { MultiPointTouchArea {
anchors.fill: parent anchors.fill: parent
minimumTouchPoints: 1 anchors.bottomMargin: yAxisReCenter ? 0 : -_hatWidthHalf
maximumTouchPoints: 1 minimumTouchPoints: 1
touchPoints: [ TouchPoint { id: touchPoint } ] maximumTouchPoints: 1
onPressed: _joyRoot.thumbDown(touchPoints) touchPoints: [ TouchPoint { id: touchPoint } ]
onReleased: _joyRoot.reCenter() 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 @@
"shortDesc": "Auto-Center Throttle", "shortDesc": "Auto-Center Throttle",
"longDesc": "If enabled the throttle stick will snap back to center when released.", "longDesc": "If enabled the throttle stick will snap back to center when released.",
"type": "bool", "type": "bool",
"default": false "default": true
}, },
{ {
"name": "gstDebugLevel", "name": "gstDebugLevel",

Loading…
Cancel
Save