Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/Vehicle/VehicleSetup/JoystickConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import QGroundControl

import QGroundControl.Controls



import QGroundControl.FactControls

Item {
Expand Down Expand Up @@ -152,6 +150,20 @@ Item {
width: axisGrid.width + (ScreenTools.defaultFontPixelWidth * 2)
height: axisGrid.height + (ScreenTools.defaultFontPixelHeight * 2)
visible: !_buttonsOnly

function joyToAxis(v, reversed) {
v = Math.max(-1, Math.min(1, v))
if (reversed) v = -v
return v * 32768.0
}

function joyToThrottleAxis(v, reversed) {
v = (2 * v - 1)
v = Math.max(-1, Math.min(1, v))
if (reversed) v = -v
return v * 32768.0
}

GridLayout {
id: axisGrid
columns: 2
Expand Down Expand Up @@ -210,12 +222,12 @@ Item {
}

Connections {
target: _activeJoystick
target: _activeJoystick
onAxisValues: (roll, pitch, yaw, throttle) => {
rollAxis.axisValue = roll * 32768.0
pitchAxis.axisValue = pitch * 32768.0
yawAxis.axisValue = yaw * 32768.0
throttleAxis.axisValue = _activeJoystick.negativeThrust ? throttle * -32768.0 : (-2 * throttle + 1) * 32768.0
rollAxis.axisValue = axisRect.joyToAxis(roll, controller.rollAxisReversed)
pitchAxis.axisValue = axisRect.joyToAxis(pitch, controller.pitchAxisReversed)
yawAxis.axisValue = axisRect.joyToAxis(yaw, controller.yawAxisReversed)
throttleAxis.axisValue = axisRect.joyToThrottleAxis(throttle, controller.throttleAxisReversed)
}
}
}
Expand Down Expand Up @@ -262,6 +274,4 @@ Item {
}
}
}
}


}
Loading