Commit e89d23b9 authored by Patrick José Pereira's avatar Patrick José Pereira

JoystickThumbPad: Fix invalid axis value calculation

When the item is not visible, the width and height are not valid,
resulting in wrong output values
Signed-off-by: 's avatarPatrick José Pereira <patrickelectric@gmail.com>
parent 3c9a246f
......@@ -22,14 +22,27 @@ Item {
QGCMapPalette { id: mapPal }
onStickPositionXChanged: {
onWidthChanged: calculateXAxis()
onStickPositionXChanged: calculateXAxis()
onHeightChanged: calculateYAxis()
onStickPositionYChanged: calculateYAxis()
function calculateXAxis()
{
if(!visible()) {
return;
}
var xAxisTemp = stickPositionX / width
xAxisTemp *= 2.0
xAxisTemp -= 1.0
xAxis = xAxisTemp
}
onStickPositionYChanged: {
function calculateYAxis()
{
if(!visible()) {
return;
}
var yAxisTemp = stickPositionY / height
yAxisTemp *= 2.0
yAxisTemp -= 1.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment