diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index c21a843d076214130d4cca4f93ee45b216c11bf2..53f3454619eda40b09f0d92fbcabf08b78da1c17 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -445,7 +445,7 @@ void Joystick::run(void) } } - if (_outputEnabled && _calibrated) { + if (_activeVehicle->joystickEnabled() && !_calibrationMode && _calibrated) { int axis = _rgFunctionAxis[rollFunction]; float roll = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis], _deadband); @@ -798,18 +798,8 @@ void Joystick::setCalibrationMode(bool calibrating) else if (_pollingStartedForCalibration) { stopPolling(); } - if (calibrating){ - setOutputEnabled(false); //Disable the joystick output before calibrating - } - else if (!calibrating && _calibrated){ - setOutputEnabled(true); //Enable joystick output after calibration - } } -void Joystick::setOutputEnabled(bool enabled){ - _outputEnabled = enabled; - emit outputEnabledChanged(_outputEnabled); -} void Joystick::_buttonAction(const QString& action) { diff --git a/src/Joystick/Joystick.h b/src/Joystick/Joystick.h index 6394848add59fc7dace717e748465da419c0d2e7..d3469903f96e0c84a94237763e2a066e2d4e6cb3 100644 --- a/src/Joystick/Joystick.h +++ b/src/Joystick/Joystick.h @@ -61,7 +61,6 @@ public: Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(bool calibrated MEMBER _calibrated NOTIFY calibratedChanged) - Q_PROPERTY(bool outputEnabled MEMBER _outputEnabled WRITE setOutputEnabled NOTIFY outputEnabledChanged) Q_PROPERTY(int totalButtonCount READ totalButtonCount CONSTANT) Q_PROPERTY(int axisCount READ axisCount CONSTANT) @@ -129,11 +128,9 @@ public: /// Set the current calibration mode void setCalibrationMode(bool calibrating); - void setOutputEnabled(bool enabled); signals: void calibratedChanged(bool calibrated); - void outputEnabledChanged(bool enabled); // The raw signals are only meant for use by calibration void rawAxisValueChanged(int index, int value); @@ -202,7 +199,6 @@ protected: static int _transmitterMode; bool _calibrationMode; - bool _outputEnabled; int* _rgAxisValues; Calibration_t* _rgCalibration; diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index fbd986bfb7816f69b487e0ae6b83e921627a2e1e..98db6fd08732c4e06243f5824f2af6aab02c1386 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -1823,6 +1823,7 @@ void Vehicle::_loadSettings(void) // Joystick enabled is a global setting so first make sure there are any joysticks connected if (_toolbox->joystickManager()->joysticks().count()) { setJoystickEnabled(settings.value(_joystickEnabledSettingsKey, false).toBool()); + _startJoystick(true); } } @@ -1875,7 +1876,6 @@ bool Vehicle::joystickEnabled(void) void Vehicle::setJoystickEnabled(bool enabled) { _joystickEnabled = enabled; - _startJoystick(_joystickEnabled); _saveSettings(); emit joystickEnabledChanged(_joystickEnabled); } @@ -1885,9 +1885,7 @@ void Vehicle::_startJoystick(bool start) Joystick* joystick = _joystickManager->activeJoystick(); if (joystick) { if (start) { - if (_joystickEnabled) { - joystick->startPolling(this); - } + joystick->startPolling(this); } else { joystick->stopPolling(); } @@ -1903,6 +1901,7 @@ void Vehicle::setActive(bool active) { if (_active != active) { _active = active; + _startJoystick(false); emit activeChanged(_active); } } diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index d5112b14d2e4d964c6e369adbc455472eb4f49e3..ced3e8aae8141cefcbd083f8382ec8c5899b60d3 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -366,13 +366,14 @@ SetupPage { id: enabledCheckBox enabled: _activeJoystick ? _activeJoystick.calibrated : false text: _activeJoystick ? _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)") : "" - - onClicked: _activeJoystick.outputEnabled = checked + onClicked: _activeVehicle.joystickEnabled = checked + Component.onCompleted: checked = _activeVehicle.joystickEnabled Connections { - target: _activeJoystick - onOutputEnabledChanged: { - enabledCheckBox.checked=enabled + target: _activeVehicle + + onJoystickEnabledChanged: { + enabledCheckBox.checked = _activeVehicle.joystickEnabled } }