diff --git a/src/FlightDisplay/FlyViewWidgetLayer.qml b/src/FlightDisplay/FlyViewWidgetLayer.qml index 55f8341dc3c..fe0f51466bd 100644 --- a/src/FlightDisplay/FlyViewWidgetLayer.qml +++ b/src/FlightDisplay/FlyViewWidgetLayer.qml @@ -128,6 +128,7 @@ Item { property real bottomEdgeLeftInset: parent.height-y property bool autoCenterThrottle: QGroundControl.settingsManager.appSettings.virtualJoystickAutoCenterThrottle.rawValue + property bool leftHandedMode: QGroundControl.settingsManager.appSettings.virtualJoystickLeftHandedMode.rawValue property bool _virtualJoystickEnabled: QGroundControl.settingsManager.appSettings.virtualJoystick.rawValue property real bottomEdgeRightInset: parent.height-y property var _pipViewMargin: _pipView.visible ? parentToolInsets.bottomEdgeLeftInset + ScreenTools.defaultFontPixelHeight * 2 : diff --git a/src/FlightDisplay/VirtualJoystick.qml b/src/FlightDisplay/VirtualJoystick.qml index 1008cbb01fa..6077500c854 100644 --- a/src/FlightDisplay/VirtualJoystick.qml +++ b/src/FlightDisplay/VirtualJoystick.qml @@ -19,6 +19,7 @@ import QGroundControl.Vehicle Item { // The following properties must be passed in from the Loader // property bool autoCenterThrottle - true: throttle will snap back to center when released + // property bool leftHandedMode - true: virtual joystick layout will be reversed id: virtualJoysticks @@ -35,7 +36,7 @@ Item { repeat: true onTriggered: { if (_activeVehicle && _initialConnectComplete) { - _activeVehicle.virtualTabletJoystickValue(rightStick.xAxis, rightStick.yAxis, leftStick.xAxis, leftStick.yAxis) + leftHandedMode ? _activeVehicle.virtualTabletJoystickValue(leftStick.xAxis, leftStick.yAxis, rightStick.xAxis, rightStick.yAxis) : _activeVehicle.virtualTabletJoystickValue(rightStick.xAxis, rightStick.yAxis, leftStick.xAxis, leftStick.yAxis) } leftYAxisValue = leftStick.yAxis // We keep Y axis value from the throttle stick for using it while there is a resize } @@ -74,7 +75,7 @@ Item { anchors.bottom: parent.bottom width: parent.height height: parent.height - yAxisPositiveRangeOnly: _activeVehicle && !_activeVehicle.rover + yAxisPositiveRangeOnly: _activeVehicle && !_activeVehicle.rover && !leftHandedMode yAxisReCenter: autoCenterThrottle } @@ -86,6 +87,7 @@ Item { anchors.bottom: parent.bottom width: parent.height height: parent.height + yAxisPositiveRangeOnly: _activeVehicle && !_activeVehicle.rover && leftHandedMode yAxisReCenter: true } } diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 3f1b3412584..eff495fb689 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -114,6 +114,13 @@ "type": "bool", "default": true }, +{ + "name": "virtualJoystickLeftHandedMode", + "shortDesc": "Left Handed Mode", + "longDesc": "If this option is enabled the virtual joystick layout will be reversed", + "type": "bool", + "default": false +}, { "name": "gstDebugLevel", "shortDesc": "Video streaming debug", diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index e66432e1f68..0b28e6000ab 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -153,6 +153,7 @@ DECLARE_SETTINGSFACT(AppSettings, telemetrySaveNotArmed) DECLARE_SETTINGSFACT(AppSettings, audioMuted) DECLARE_SETTINGSFACT(AppSettings, virtualJoystick) DECLARE_SETTINGSFACT(AppSettings, virtualJoystickAutoCenterThrottle) +DECLARE_SETTINGSFACT(AppSettings, virtualJoystickLeftHandedMode) DECLARE_SETTINGSFACT(AppSettings, appFontPointSize) DECLARE_SETTINGSFACT(AppSettings, savePath) DECLARE_SETTINGSFACT(AppSettings, androidSaveToSDCard) diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index c6a10f9693f..1735f7c48bb 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -37,6 +37,7 @@ class AppSettings : public SettingsGroup DEFINE_SETTINGFACT(audioMuted) DEFINE_SETTINGFACT(virtualJoystick) DEFINE_SETTINGFACT(virtualJoystickAutoCenterThrottle) + DEFINE_SETTINGFACT(virtualJoystickLeftHandedMode) DEFINE_SETTINGFACT(appFontPointSize) DEFINE_SETTINGFACT(indoorPalette) DEFINE_SETTINGFACT(savePath) diff --git a/src/UI/preferences/FlyViewSettings.qml b/src/UI/preferences/FlyViewSettings.qml index 560982c0188..e7021e7c241 100644 --- a/src/UI/preferences/FlyViewSettings.qml +++ b/src/UI/preferences/FlyViewSettings.qml @@ -28,6 +28,7 @@ SettingsPage { property var _customMavlinkActionsSettings: _settingsManager.customMavlinkActionsSettings property Fact _virtualJoystick: _settingsManager.appSettings.virtualJoystick property Fact _virtualJoystickAutoCenterThrottle: _settingsManager.appSettings.virtualJoystickAutoCenterThrottle + property Fact _virtualJoystickLeftHandedMode: _settingsManager.appSettings.virtualJoystickLeftHandedMode property Fact _showAdditionalIndicatorsCompass: _flyViewSettings.showAdditionalIndicatorsCompass property Fact _lockNoseUpCompass: _flyViewSettings.lockNoseUpCompass property Fact _guidedMinimumAltitude: _flyViewSettings.guidedMinimumAltitude @@ -164,7 +165,7 @@ SettingsPage { SettingsGroupLayout { Layout.fillWidth: true heading: qsTr("Virtual Joystick") - visible: _virtualJoystick.visible || _virtualJoystickAutoCenterThrottle.visible + visible: _virtualJoystick.visible || _virtualJoystickAutoCenterThrottle.visible || _virtualJoystickLeftHandedMode.visible FactCheckBoxSlider { Layout.fillWidth: true @@ -180,6 +181,14 @@ SettingsPage { enabled: _virtualJoystick.rawValue fact: _virtualJoystickAutoCenterThrottle } + + FactCheckBoxSlider { + Layout.fillWidth: true + text: qsTr("Left-Handed Mode (swap sticks)") + visible: _virtualJoystickLeftHandedMode.visible + enabled: _virtualJoystick.rawValue + fact: _virtualJoystickLeftHandedMode + } } SettingsGroupLayout {