Browse Source

Merge pull request #7216 from Williangalvani/fixDeadband

Change joystick deadband adjustment to dragging horizontally
QGC4.4
Don Gagne 6 years ago committed by GitHub
parent
commit
aa2b46e6b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/VehicleSetup/JoystickConfig.qml

18
src/VehicleSetup/JoystickConfig.qml

@ -849,20 +849,24 @@ SetupPage {
MouseArea { MouseArea {
id: deadbandMouseArea id: deadbandMouseArea
anchors.fill: parent.item anchors.fill: parent.item
enabled: controller.deadbandToggle enabled: controller.deadbandToggle
preventStealing: true
property real startY property real startX
property real direction
onPressed: { onPressed: {
startY = mouseY startX = mouseX
direction = startX > width/2 ? 1 : -1
parent.item.deadbandColor = "#3C6315" parent.item.deadbandColor = "#3C6315"
} }
onPositionChanged: { onPositionChanged: {
var newValue = parent.item.deadbandValue + (startY - mouseY)*15 var mouseToDeadband = 32768/(width/2) // Factor to have deadband follow the mouse movement
var newValue = parent.item.deadbandValue + direction*(mouseX - startX)*mouseToDeadband
if ((newValue > 0) && (newValue <32768)){parent.item.deadbandValue=newValue;} if ((newValue > 0) && (newValue <32768)){parent.item.deadbandValue=newValue;}
startY = mouseY startX = mouseX
} }
onReleased: { onReleased: {
controller.setDeadbandValue(modelData,parent.item.deadbandValue) controller.setDeadbandValue(modelData,parent.item.deadbandValue)

Loading…
Cancel
Save