From 41a994128311ce92d0cdbfe7726493adbe4b3227 Mon Sep 17 00:00:00 2001 From: nanthony21 Date: Thu, 25 Jan 2018 00:22:09 -0600 Subject: [PATCH] Made deadband adjustable by click and drag. --- src/VehicleSetup/JoystickConfig.qml | 21 ++++++++++++++++++++ src/VehicleSetup/JoystickConfigController.cc | 9 +++++++++ src/VehicleSetup/JoystickConfigController.h | 1 + 3 files changed, 31 insertions(+) diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index ba35a3bdc..adf391f22 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -796,7 +796,28 @@ SetupPage { property real defaultTextWidth: ScreenTools.defaultFontPixelWidth property bool mapped: true readonly property bool reversed: false + + + MouseArea { + id: deadbandMouseArea + anchors.fill: parent.item + + property real startY + + onPressed: { + startY = mouseY + } + onPositionChanged: { + var newValue = parent.item.deadbandValue + (startY - mouseY)*15 + if ((newValue > 0) && (newValue <32768)){parent.item.deadbandValue=newValue;} + startY = mouseY + } + onReleased: { + controller.setDeadbandValue(modelData,parent.item.deadbandValue) + } + } } + } } } // Column - Axis Monitor diff --git a/src/VehicleSetup/JoystickConfigController.cc b/src/VehicleSetup/JoystickConfigController.cc index 6168ce338..67a3ffa1e 100644 --- a/src/VehicleSetup/JoystickConfigController.cc +++ b/src/VehicleSetup/JoystickConfigController.cc @@ -71,6 +71,15 @@ void JoystickConfigController::start(void) _stopCalibration(); } +void JoystickConfigController::setDeadbandValue(int axis, int value) +{ + _axisDeadbandChanged(axis,value); + Joystick* joystick = _joystickManager->activeJoystick(); + Joystick::Calibration_t calibration = joystick->getCalibration(axis); + calibration.deadband = value; + joystick->setCalibration(axis,calibration); +} + JoystickConfigController::~JoystickConfigController() { if(_activeJoystick) { diff --git a/src/VehicleSetup/JoystickConfigController.h b/src/VehicleSetup/JoystickConfigController.h index d0e1faf23..19d826d8c 100644 --- a/src/VehicleSetup/JoystickConfigController.h +++ b/src/VehicleSetup/JoystickConfigController.h @@ -67,6 +67,7 @@ public: Q_INVOKABLE void skipButtonClicked(void); Q_INVOKABLE void nextButtonClicked(void); Q_INVOKABLE void start(void); + Q_INVOKABLE void setDeadbandValue(int axis, int value); bool rollAxisMapped(void); bool pitchAxisMapped(void); -- 2.22.0