Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3a406dea
Unverified
Commit
3a406dea
authored
May 29, 2020
by
Don Gagne
Committed by
GitHub
May 29, 2020
Browse files
Merge pull request #8793 from DonLakeFlyer/CherryPickStableVirtualJoystick
Cherry pick virtual joystick fix from Stable
parents
ef9abaa0
7c2028ae
Changes
8
Hide whitespace changes
Inline
Side-by-side
ChangeLog.md
View file @
3a406dea
...
...
@@ -16,6 +16,8 @@ Note: This file only contains high level features or important fixes.
## 4.0.7 - Not yet released
*
Fix video page sizing
*
Virtual Joystick: Fix right stick centering. Fix/add support for rover/sub reverse throttle support.
*
Fix display of multiple ADSB vehicles
### 4.0.6 - Stable
...
...
src/FlightDisplay/FlyViewWidgetLayer.qml
View file @
3a406dea
...
...
@@ -91,18 +91,16 @@ Item {
z
:
QGroundControl
.
zOrderTopMost
+
1
width
:
parent
.
width
-
(
_pipOverlay
.
width
/
2
)
height
:
Math
.
min
(
parent
.
height
*
0.25
,
ScreenTools
.
defaultFontPixelWidth
*
16
)
visible
:
(
_virtualJoystick
?
_virtualJoystick
.
value
:
false
)
&&
!
(
_
activeVehicle
?
_
activeVehicle
.
highLatencyLink
:
false
)
visible
:
_virtualJoystick
Enabled
&&
!
QGroundControl
.
videoManager
.
fullScreen
&&
!
(
activeVehicle
?
activeVehicle
.
highLatencyLink
:
false
)
anchors.bottom
:
parent
.
bottom
anchors.bottomMargin
:
parentToolInsets
.
leftEdgeBottomInset
+
ScreenTools
.
defaultFontPixelHeight
*
2
anchors.horizontalCenter
:
parent
.
horizontalCenter
source
:
"
qrc:/qml/VirtualJoystick.qml
"
active
:
(
_virtualJoystick
?
_virtualJoystick
.
value
:
false
)
&&
!
(
_
activeVehicle
?
_
activeVehicle
.
highLatencyLink
:
false
)
active
:
_virtualJoystick
Enabled
&&
!
(
activeVehicle
?
activeVehicle
.
highLatencyLink
:
false
)
property
bool
centralizeThrottle
:
_virtualJoystickCentralized
?
_virtualJoystickCentralized
.
value
:
false
property
var
parentToolInsets
:
_totalToolInsets
property
bool
autoCenterThrottle
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystickAutoCenterThrottle
.
rawValue
property
Fact
_virtualJoystick
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystick
property
Fact
_virtualJoystickCentralized
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystickCentralized
property
bool
_virtualJoystickEnabled
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystick
.
rawValue
}
FlyViewToolStrip
{
...
...
src/FlightDisplay/VirtualJoystick.qml
View file @
3a406dea
...
...
@@ -17,7 +17,10 @@ import QGroundControl.Palette 1.0
import
QGroundControl
.
Vehicle
1.0
Item
{
//property bool centralizeThrottle - Must be passed in from loader
// The following properties must be passed in from the Loader
// property bool autoCenterThrottle - true: throttle will snap back to center when released
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
Timer
{
interval
:
40
// 25Hz, same as real joystick rate
...
...
@@ -25,7 +28,7 @@ Item {
repeat
:
true
onTriggered
:
{
if
(
activeVehicle
)
{
activeVehicle
.
virtualTabletJoystickValue
(
rightStick
.
xAxis
,
rightStick
.
yAxis
,
leftStick
.
xAxis
,
leftStick
.
yAxis
)
activeVehicle
.
virtualTabletJoystickValue
(
rightStick
.
xAxis
,
-
rightStick
.
yAxis
,
leftStick
.
xAxis
,
leftStick
.
yAxis
)
}
}
}
...
...
@@ -38,8 +41,8 @@ Item {
anchors.bottom
:
parent
.
bottom
width
:
parent
.
height
height
:
parent
.
height
yAxis
Throttle
:
true
yAxis
Throttl
eCenter
ed
:
centralize
Throttle
yAxis
PositiveRangeOnly
:
_activeVehicle
&&
!
_activeVehicle
.
rover
&&
!
_activeVehicle
.
sub
yAxis
R
eCenter
:
autoCenter
Throttle
}
JoystickThumbPad
{
...
...
src/QmlControls/JoystickThumbPad.qml
View file @
3a406dea
...
...
@@ -8,25 +8,28 @@ import QGroundControl.ScreenTools 1.0
Item
{
id
:
_joyRoot
property
real
xAxi
s
:
0
///< Value range [-1,1], negative values left stick, positive values right stick
property
real
y
Axis
:
0
///< Value range [-1,1], negative values
up
stick, positive values
down
stick
property
boo
l
yAxis
Throttle
:
false
///< true: yAxis used for throttle,
range [1,
0
], positive value
are
stick
up
property
bool
yAxis
ThrottleCentered
:
false
///<
false: center yAxis in throttle for reverser and forward
property
rea
l
xPositionDelta
:
0
///<
Amount to move the control on x axis
property
real
y
PositionDelta
:
0
///< Amount to move the control on
y
axis
property
boo
l
springYToCenter
:
true
///< true: Spring Y to center on release
property
alias
lightColor
s
:
mapPal
.
lightColors
///< true: use light colors from QGCMapPalette for drawing
property
real
x
Axis
:
0
///< Value range [-1,1], negative values
left
stick, positive values
right
stick
property
rea
l
yAxis
:
0
///< Value
range [
-
1,
1
],
negative values down stick,
positive value
s up
stick
property
bool
yAxis
PositiveRangeOnly
:
false
///<
true: value range [0,1], false: value range [-1,1]
property
boo
l
yAxisReCenter
:
true
///<
true: snaps back to center on release, false: stays at current position on release
property
real
x
PositionDelta
:
0
///< Amount to move the control on
x
axis
property
rea
l
yPositionDelta
:
0
///< Amount to move the control on y axis
property
real
_centerXY
:
width
/
2
property
bool
_processTouchPoints
:
false
property
real
stickPositionX
:
_centerXY
property
real
stickPositionY
:
yAxisThrottleCentered
?
_centerXY
:
height
property
color
_fgColor
:
QGroundControl
.
globalPalette
.
text
property
color
_bgColor
:
QGroundControl
.
globalPalette
.
window
property
real
stickPositionX
:
_centerXY
property
real
stickPositionY
:
yAxisReCenter
?
_centerXY
:
height
onWidthChanged
:
calculateXAxis
()
onStickPositionXChanged
:
calculateXAxis
()
onHeightChanged
:
calculateYAxis
()
onStickPositionYChanged
:
calculateYAxis
()
QGCMapPalette
{
id
:
mapPal
}
onWidthChanged
:
calculateXAxis
()
onStickPositionXChanged
:
calculateXAxis
()
onHeightChanged
:
calculateYAxis
()
onStickPositionYChanged
:
calculateYAxis
()
onYAxisPositiveRangeOnlyChanged
:
calculateYAxis
()
function
calculateXAxis
()
{
if
(
!
_joyRoot
.
visible
)
{
...
...
@@ -42,13 +45,13 @@ Item {
if
(
!
_joyRoot
.
visible
)
{
return
;
}
var
yAxisTemp
=
stickPositionY
/
height
yAxisTem
p
*
=
2
.0
yAxisTem
p
-
=
1.0
if
(
yAxis
Throttle
)
{
yAxisTem
p
=
((
yAxisTemp
*
-
1.0
)
/
2.0
)
+
0.5
var
fullRange
=
yAxisPositiveRangeOnly
?
1
:
2
var
pctU
p
=
1
.0
-
(
stickPositionY
/
height
)
var
rangeU
p
=
pctUp
*
fullRange
if
(
!
yAxis
PositiveRangeOnly
)
{
rangeU
p
-
=
1
}
yAxis
=
yAxisTem
p
yAxis
=
rangeU
p
}
function
reCenter
()
{
...
...
@@ -58,9 +61,9 @@ Item {
xPositionDelta
=
0
yPositionDelta
=
0
// Center sticks
//
Re-
Center sticks
as needed
stickPositionX
=
_centerXY
if
(
yAxis
Throttl
eCenter
ed
)
{
if
(
yAxis
R
eCenter
)
{
stickPositionY
=
_centerXY
}
}
...
...
@@ -68,7 +71,7 @@ Item {
function
thumbDown
(
touchPoints
)
{
// Position the control around the initial thumb position
xPositionDelta
=
touchPoints
[
0
].
x
-
_centerXY
if
(
yAxis
Throttle
)
{
if
(
yAxis
PositiveRangeOnly
)
{
yPositionDelta
=
touchPoints
[
0
].
y
-
stickPositionY
}
else
{
yPositionDelta
=
touchPoints
[
0
].
y
-
_centerXY
...
...
@@ -118,7 +121,7 @@ Item {
QGCColoredImage
{
color
:
_fgColor
visible
:
yAxis
Throttle
visible
:
yAxis
PositiveRangeOnly
height
:
ScreenTools
.
defaultFontPixelHeight
width
:
height
sourceSize.height
:
height
...
...
@@ -132,7 +135,7 @@ Item {
QGCColoredImage
{
color
:
_fgColor
visible
:
yAxis
Throttle
visible
:
yAxis
PositiveRangeOnly
height
:
ScreenTools
.
defaultFontPixelHeight
width
:
height
sourceSize.height
:
height
...
...
@@ -146,7 +149,7 @@ Item {
QGCColoredImage
{
color
:
_fgColor
visible
:
yAxis
Throttle
visible
:
yAxis
PositiveRangeOnly
height
:
ScreenTools
.
defaultFontPixelHeight
width
:
height
sourceSize.height
:
height
...
...
@@ -160,7 +163,7 @@ Item {
QGCColoredImage
{
color
:
_fgColor
visible
:
yAxis
Throttle
visible
:
yAxis
PositiveRangeOnly
height
:
ScreenTools
.
defaultFontPixelHeight
width
:
height
sourceSize.height
:
height
...
...
@@ -207,9 +210,6 @@ Item {
maximumTouchPoints
:
1
touchPoints
:
[
TouchPoint
{
id
:
touchPoint
}
]
onPressed
:
_joyRoot
.
thumbDown
(
touchPoints
)
onReleased
:
{
if
(
springYToCenter
)
_joyRoot
.
reCenter
()
}
onReleased
:
_joyRoot
.
reCenter
()
}
}
src/Settings/App.SettingsGroup.json
View file @
3a406dea
...
...
@@ -115,9 +115,9 @@
"defaultValue"
:
false
},
{
"name"
:
"virtualJoystick
Centralized
"
,
"shortDescription"
:
"
Set virtual joystick to be centralize throttle (spring-loaded).
"
,
"longDescription"
:
"If
this option is enabled the virtual joystick throttle stick will be centraliz
ed."
,
"name"
:
"virtualJoystick
AutoCenterThrottle
"
,
"shortDescription"
:
"
Auto-Center Throttle
"
,
"longDescription"
:
"If
enabled the throttle stick will snap back to center when releas
ed."
,
"type"
:
"bool"
,
"defaultValue"
:
false
},
...
...
src/Settings/AppSettings.cc
View file @
3a406dea
...
...
@@ -39,6 +39,15 @@ DECLARE_SETTINGGROUP(App, "")
qmlRegisterUncreatableType
<
AppSettings
>
(
"QGroundControl.SettingsManager"
,
1
,
0
,
"AppSettings"
,
"Reference only"
);
QGCPalette
::
setGlobalTheme
(
indoorPalette
()
->
rawValue
().
toBool
()
?
QGCPalette
::
Dark
:
QGCPalette
::
Light
);
// virtualJoystickCentralized -> virtualJoystickAutoCenterThrottle
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
QString
deprecatedVirtualJoystickCentralizedKey
(
"virtualJoystickCentralized"
);
if
(
settings
.
contains
(
deprecatedVirtualJoystickCentralizedKey
))
{
settings
.
setValue
(
virtualJoystickAutoCenterThrottleName
,
settings
.
value
(
deprecatedVirtualJoystickCentralizedKey
));
settings
.
remove
(
deprecatedVirtualJoystickCentralizedKey
);
}
// Instantiate savePath so we can check for override and setup default path if needed
SettingsFact
*
savePathFact
=
qobject_cast
<
SettingsFact
*>
(
savePath
());
...
...
@@ -85,7 +94,7 @@ DECLARE_SETTINGSFACT(AppSettings, telemetrySaveNotArmed)
DECLARE_SETTINGSFACT
(
AppSettings
,
audioMuted
)
DECLARE_SETTINGSFACT
(
AppSettings
,
checkInternet
)
DECLARE_SETTINGSFACT
(
AppSettings
,
virtualJoystick
)
DECLARE_SETTINGSFACT
(
AppSettings
,
virtualJoystick
Centralized
)
DECLARE_SETTINGSFACT
(
AppSettings
,
virtualJoystick
AutoCenterThrottle
)
DECLARE_SETTINGSFACT
(
AppSettings
,
appFontPointSize
)
DECLARE_SETTINGSFACT
(
AppSettings
,
showLargeCompass
)
DECLARE_SETTINGSFACT
(
AppSettings
,
savePath
)
...
...
src/Settings/AppSettings.h
View file @
3a406dea
...
...
@@ -39,7 +39,7 @@ public:
DEFINE_SETTINGFACT
(
audioMuted
)
DEFINE_SETTINGFACT
(
checkInternet
)
DEFINE_SETTINGFACT
(
virtualJoystick
)
DEFINE_SETTINGFACT
(
virtualJoystick
Centralized
)
DEFINE_SETTINGFACT
(
virtualJoystick
AutoCenterThrottle
)
DEFINE_SETTINGFACT
(
appFontPointSize
)
DEFINE_SETTINGFACT
(
indoorPalette
)
DEFINE_SETTINGFACT
(
showLargeCompass
)
...
...
src/ui/preferences/GeneralSettings.qml
View file @
3a406dea
...
...
@@ -30,11 +30,14 @@ Rectangle {
anchors.fill
:
parent
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
property
Fact
_percentRemainingAnnounce
:
QGroundControl
.
settingsManager
.
appSettings
.
batteryPercentRemainingAnnounce
property
Fact
_savePath
:
QGroundControl
.
settingsManager
.
appSettings
.
savePath
property
Fact
_appFontPointSize
:
QGroundControl
.
settingsManager
.
appSettings
.
appFontPointSize
property
Fact
_userBrandImageIndoor
:
QGroundControl
.
settingsManager
.
brandImageSettings
.
userBrandImageIndoor
property
Fact
_userBrandImageOutdoor
:
QGroundControl
.
settingsManager
.
brandImageSettings
.
userBrandImageOutdoor
property
Fact
_percentRemainingAnnounce
:
QGroundControl
.
settingsManager
.
appSettings
.
batteryPercentRemainingAnnounce
property
Fact
_savePath
:
QGroundControl
.
settingsManager
.
appSettings
.
savePath
property
Fact
_appFontPointSize
:
QGroundControl
.
settingsManager
.
appSettings
.
appFontPointSize
property
Fact
_userBrandImageIndoor
:
QGroundControl
.
settingsManager
.
brandImageSettings
.
userBrandImageIndoor
property
Fact
_userBrandImageOutdoor
:
QGroundControl
.
settingsManager
.
brandImageSettings
.
userBrandImageOutdoor
property
Fact
_virtualJoystick
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystick
property
Fact
_virtualJoystickAutoCenterThrottle
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystickAutoCenterThrottle
property
real
_labelWidth
:
ScreenTools
.
defaultFontPixelWidth
*
20
property
real
_comboFieldWidth
:
ScreenTools
.
defaultFontPixelWidth
*
30
property
real
_valueFieldWidth
:
ScreenTools
.
defaultFontPixelWidth
*
10
...
...
@@ -512,22 +515,23 @@ Rectangle {
property
Fact
_showLogReplayStatusBar
:
QGroundControl
.
settingsManager
.
flyViewSettings
.
showLogReplayStatusBar
}
FactCheckBox
{
text
:
qsTr
(
"
Virtual Joystick
"
)
visible
:
_virtualJoystick
.
visible
fact
:
_virtualJoystick
property
Fact
_virtualJoystick
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystick
}
RowLayout
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
FactCheckBox
{
text
:
qsTr
(
"
Auto-Center throttle
"
)
visible
:
_virtualJoystick
Centralized
.
visible
&&
activeVehicle
&&
(
activeVehicle
.
sub
||
activeVehicle
.
rover
)
fact
:
_virtualJoystick
Centralized
Layout.leftMargin
:
_margins
FactCheckBox
{
text
:
qsTr
(
"
Virtual Joystick
"
)
visible
:
_virtualJoystick
.
visible
fact
:
_virtualJoystick
}
property
Fact
_virtualJoystickCentralized
:
QGroundControl
.
settingsManager
.
appSettings
.
virtualJoystickCentralized
FactCheckBox
{
text
:
qsTr
(
"
Auto-Center Throttle
"
)
visible
:
_virtualJoystickAutoCenterThrottle
.
visible
enabled
:
_virtualJoystick
.
rawValue
fact
:
_virtualJoystickAutoCenterThrottle
}
}
FactCheckBox
{
text
:
qsTr
(
"
Use Vertical Instrument Panel
"
)
visible
:
_alternateInstrumentPanel
.
visible
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment