@ -8,25 +8,28 @@ import QGroundControl.ScreenTools 1.0
@@ -8,25 +8,28 @@ import QGroundControl.ScreenTools 1.0
Item {
id: _joyRoot
property real xAxis: 0 / / / < V a l u e r a n g e [ - 1 , 1 ] , n e g a t i v e v a l u e s l e f t s t i c k , p o s i t i v e v a l u e s r i g h t s t i c k
property real yAxis: 0 / / / < V a l u e r a n g e [ - 1 , 1 ] , n e g a t i v e v a l u e s u p s t i c k , p o s i t i v e v a l u e s d o w n s t i c k
property bool yAxisThrottle: false / / / < t r u e : y A x i s u s e d f o r t h r o t t l e , r a n g e [ 1 , 0 ] , p o s i t i v e v a l u e a r e s t i c k u p
property bool yAxisThrottleCentered: false / / / < f a l s e : c e n t e r y A x i s i n t h r o t t l e f o r r e v e r s e r a n d f o r w a r d
property real xPositionDelta: 0 / / / < A m o u n t t o m o v e t h e c o n t r o l o n x a x i s
property real yPositionDelta: 0 / / / < A m o u n t t o m o v e t h e c o n t r o l o n y a x i s
property bool springYToCenter: true / / / < t r u e : S p r i n g Y t o c e n t e r o n r e l e a s e
property alias lightColors: mapPal . lightColors / / / < t r u e : u s e l i g h t c o l o r s f r o m Q G C M a p P a l e t t e f o r d r a w i n g
property real xAxis: 0 / / / < V a l u e r a n g e [ - 1 , 1 ] , n e g a t i v e v a l u e s l e f t s t i c k , p o s i t i v e v a l u e s r i g h t s t i c k
property real yAxis: 0 / / / < V a l u e r a n g e [ - 1 , 1 ] , n e g a t i v e v a l u e s d o w n s t i c k , p o s i t i v e v a l u e s u p s t i c k
property bool yAxisPositiveRangeOnly: false / / / < t r u e : v a l u e r a n g e [ 0 , 1 ] , f a l s e : v a l u e r a n g e [ - 1 , 1 ]
property bool yAxisReCenter: true / / / < t r u e : s n a p s b a c k t o c e n t e r o n r e l e a s e , f a l s e : s t a y s a t c u r r e n t p o s i t i o n o n r e l e a s e
property real xPositionDelta: 0 / / / < A m o u n t t o m o v e t h e c o n t r o l o n x a x i s
property real yPositionDelta: 0 / / / < A m o u n t t o m o v e t h e c o n t r o l o n y a x i s
property real _centerXY : width / 2
property bool _processTouchPoints : false
property real stickPositionX: _centerXY
property real stickPositionY: yAxisThrottleCentered ? _centerXY : height
property color _fgColor : QGroundControl . globalPalette . text
property color _bgColor : QGroundControl . globalPalette . window
property real stickPositionX: _centerXY
property real stickPositionY: yAxisReCenter ? _centerXY : height
onWidthChanged: calculateXAxis ( )
onStickPositionXChanged: calculateXAxis ( )
onHeightChanged: calculateYAxis ( )
onStickPositionYChanged: calculateYAxis ( )
QGCMapPalette { id: mapPal }
onWidthChanged: calculateXAxis ( )
onStickPositionXChanged: calculateXAxis ( )
onHeightChanged: calculateYAxis ( )
onStickPositionYChanged: calculateYAxis ( )
onYAxisPositiveRangeOnlyChanged: calculateYAxis ( )
function calculateXAxis ( ) {
if ( ! _joyRoot . visible ) {
@ -42,13 +45,13 @@ Item {
@@ -42,13 +45,13 @@ Item {
if ( ! _joyRoot . visible ) {
return ;
}
var yAxisTemp = stickPositionY / height
yAxisTemp *= 2.0
yAxisTemp -= 1.0
if ( yAxisThrottle ) {
yAxisTemp = ( ( yAxisTemp * - 1.0 ) / 2.0 ) + 0.5
var fullRange = yAxisPositiveRangeOnly ? 1 : 2
var pctUp = 1.0 - ( stickPositionY / height )
var rangeUp = pctUp * fullRange
if ( ! yAxisPositiveRangeOnly ) {
rangeUp -= 1
}
yAxis = yAxisTem p
yAxis = rangeU p
}
function reCenter ( ) {
@ -58,9 +61,9 @@ Item {
@@ -58,9 +61,9 @@ Item {
xPositionDelta = 0
yPositionDelta = 0
/ / C e n t e r s t i c k s
/ / R e - C e n t e r s t i c k s a s n e e d e d
stickPositionX = _centerXY
if ( yAxisThrottleCentered ) {
if ( yAxisReCenter ) {
stickPositionY = _centerXY
}
}
@ -68,7 +71,7 @@ Item {
@@ -68,7 +71,7 @@ Item {
function thumbDown ( touchPoints ) {
/ / P o s i t i o n t h e c o n t r o l a r o u n d t h e i n i t i a l t h u m b p o s i t i o n
xPositionDelta = touchPoints [ 0 ] . x - _centerXY
if ( yAxisThrottle ) {
if ( yAxisPositiveRangeOnly ) {
yPositionDelta = touchPoints [ 0 ] . y - stickPositionY
} else {
yPositionDelta = touchPoints [ 0 ] . y - _centerXY
@ -118,7 +121,7 @@ Item {
@@ -118,7 +121,7 @@ Item {
QGCColoredImage {
color: _fgColor
visible: yAxisThrottle
visible: yAxisPositiveRangeOnly
height: ScreenTools . defaultFontPixelHeight
width: height
sourceSize.height: height
@ -132,7 +135,7 @@ Item {
@@ -132,7 +135,7 @@ Item {
QGCColoredImage {
color: _fgColor
visible: yAxisThrottle
visible: yAxisPositiveRangeOnly
height: ScreenTools . defaultFontPixelHeight
width: height
sourceSize.height: height
@ -146,7 +149,7 @@ Item {
@@ -146,7 +149,7 @@ Item {
QGCColoredImage {
color: _fgColor
visible: yAxisThrottle
visible: yAxisPositiveRangeOnly
height: ScreenTools . defaultFontPixelHeight
width: height
sourceSize.height: height
@ -160,7 +163,7 @@ Item {
@@ -160,7 +163,7 @@ Item {
QGCColoredImage {
color: _fgColor
visible: yAxisThrottle
visible: yAxisPositiveRangeOnly
height: ScreenTools . defaultFontPixelHeight
width: height
sourceSize.height: height
@ -207,9 +210,6 @@ Item {
@@ -207,9 +210,6 @@ Item {
maximumTouchPoints: 1
touchPoints: [ TouchPoint { id: touchPoint } ]
onPressed: _joyRoot . thumbDown ( touchPoints )
onReleased: {
if ( springYToCenter )
_joyRoot . reCenter ( )
}
onReleased: _joyRoot . reCenter ( )
}
}