From 7c595499448f5d8cb32fe7a733fffcaa5c2eed03 Mon Sep 17 00:00:00 2001 From: DoinLakeFlyer Date: Mon, 25 May 2020 08:40:22 -0700 Subject: [PATCH] Cherry pick joystick fixes from stable and fixup merge --- src/Joystick/Joystick.cc | 2 +- src/VehicleSetup/JoystickConfigButtons.qml | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index e3e5e8c9f..cd7aab9e1 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -280,7 +280,7 @@ void Joystick::_loadSettings() for (int button = 0; button < _totalButtonCount; button++) { QString a = settings.value(QString(_buttonActionNameKey).arg(button), QString()).toString(); - if(!a.isEmpty() && _findAssignableButtonAction(a) >= 0 && a != _buttonActionNone) { + if(!a.isEmpty() && a != _buttonActionNone) { if(_buttonActionArray[button]) { _buttonActionArray[button]->deleteLater(); } diff --git a/src/VehicleSetup/JoystickConfigButtons.qml b/src/VehicleSetup/JoystickConfigButtons.qml index 9dc274c23..10d6ad7aa 100644 --- a/src/VehicleSetup/JoystickConfigButtons.qml +++ b/src/VehicleSetup/JoystickConfigButtons.qml @@ -75,16 +75,18 @@ Item { id: buttonActionCombo width: ScreenTools.defaultFontPixelWidth * 26 model: _activeJoystick ? _activeJoystick.assignableActionTitles : [] - onActivated: { - _activeJoystick.setButtonAction(modelData, textAt(index)) - } - Component.onCompleted: { + + function _findCurrentButtonAction() { if(_activeJoystick) { var i = find(_activeJoystick.buttonActions[modelData]) if(i < 0) i = 0 currentIndex = i } } + + Component.onCompleted: _findCurrentButtonAction() + onModelChanged: _findCurrentButtonAction() + onActivated: _activeJoystick.setButtonAction(modelData, textAt(index)) } QGCCheckBox { id: repeatCheck -- 2.22.0