Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
eb23e67e
Commit
eb23e67e
authored
Apr 15, 2020
by
DoinLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
1c4e2252
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
59 deletions
+89
-59
Joystick.cc
src/Joystick/Joystick.cc
+23
-3
JoystickConfigButtons.qml
src/VehicleSetup/JoystickConfigButtons.qml
+66
-56
No files found.
src/Joystick/Joystick.cc
View file @
eb23e67e
...
@@ -515,12 +515,32 @@ void Joystick::_handleButtons()
...
@@ -515,12 +515,32 @@ void Joystick::_handleButtons()
QString
buttonAction
=
_buttonActionArray
[
buttonIndex
]
->
action
;
QString
buttonAction
=
_buttonActionArray
[
buttonIndex
]
->
action
;
if
(
buttonAction
.
isEmpty
()
||
buttonAction
==
_buttonActionNone
)
if
(
buttonAction
.
isEmpty
()
||
buttonAction
==
_buttonActionNone
)
continue
;
continue
;
//-- Process single button
if
(
!
_buttonActionArray
[
buttonIndex
]
->
repeat
)
{
if
(
!
_buttonActionArray
[
buttonIndex
]
->
repeat
)
{
//-- This button just went down
//-- This button just went down
if
(
_rgButtonValues
[
buttonIndex
]
==
BUTTON_DOWN
)
{
if
(
_rgButtonValues
[
buttonIndex
]
==
BUTTON_DOWN
)
{
qCDebug
(
JoystickLog
)
<<
"Single button triggered"
<<
buttonIndex
<<
buttonAction
;
// Check for a multi-button action
_executeButtonAction
(
buttonAction
,
true
);
QList
<
int
>
rgButtons
=
{
buttonIndex
};
bool
executeButtonAction
=
true
;
for
(
int
multiIndex
=
0
;
multiIndex
<
_totalButtonCount
;
multiIndex
++
)
{
if
(
multiIndex
!=
buttonIndex
)
{
if
(
_buttonActionArray
[
multiIndex
]
&&
_buttonActionArray
[
multiIndex
]
->
action
==
buttonAction
)
{
// We found a multi-button action
if
(
_rgButtonValues
[
multiIndex
]
==
BUTTON_DOWN
||
_rgButtonValues
[
multiIndex
]
==
BUTTON_REPEAT
)
{
// So far so good
rgButtons
.
append
(
multiIndex
);
continue
;
}
else
{
// We are missing a press we need
executeButtonAction
=
false
;
break
;
}
}
}
}
if
(
executeButtonAction
)
{
qCDebug
(
JoystickLog
)
<<
"Action triggered"
<<
rgButtons
<<
buttonAction
;
_executeButtonAction
(
buttonAction
,
true
);
}
}
}
}
else
{
}
else
{
//-- Process repeat buttons
//-- Process repeat buttons
...
...
src/VehicleSetup/JoystickConfigButtons.qml
View file @
eb23e67e
...
@@ -22,7 +22,7 @@ import QGroundControl.FactControls 1.0
...
@@ -22,7 +22,7 @@ import QGroundControl.FactControls 1.0
Item
{
Item
{
width
:
availableWidth
width
:
availableWidth
height
:
(
activeVehicle
.
supportsJSButton
?
buttonCol
.
height
:
buttonFlow
.
height
)
+
(
ScreenTools
.
defaultFontPixelHeight
*
2
)
height
:
(
activeVehicle
.
supportsJSButton
?
buttonCol
.
height
:
flowColumn
.
height
)
+
(
ScreenTools
.
defaultFontPixelHeight
*
2
)
Connections
{
Connections
{
target
:
_activeJoystick
target
:
_activeJoystick
onRawButtonPressedChanged
:
{
onRawButtonPressedChanged
:
{
...
@@ -34,66 +34,76 @@ Item {
...
@@ -34,66 +34,76 @@ Item {
}
}
}
}
}
}
Flow
{
ColumnLayout
{
id
:
buttonFlow
id
:
flowColumn
width
:
parent
.
width
y
:
ScreenTools
.
defaultFontPixelHeight
/
2
spacing
:
ScreenTools
.
defaultFontPixelWidth
width
:
parent
.
width
visible
:
!
activeVehicle
.
supportsJSButton
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
anchors.centerIn
:
parent
QGCLabel
{
Repeater
{
Layout.preferredWidth
:
parent
.
width
id
:
buttonActionRepeater
wrapMode
:
Text
.
WordWrap
model
:
_activeJoystick
?
Math
.
min
(
_activeJoystick
.
totalButtonCount
,
_maxButtons
)
:
[]
text
:
qsTr
(
"
Assigning the same action to multiple buttons requires the press of all those buttons for the action to be taken. This is useful to prevent accidental button presses for critical actions like Arm or Emergency Stop.
"
)
Row
{
}
spacing
:
ScreenTools
.
defaultFontPixelWidth
Flow
{
property
bool
pressed
id
:
buttonFlow
property
var
currentAssignableAction
:
_activeJoystick
?
_activeJoystick
.
assignableActions
.
get
(
buttonActionCombo
.
currentIndex
)
:
null
Layout.preferredWidth
:
parent
.
width
Rectangle
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
anchors.verticalCenter
:
parent
.
verticalCenter
visible
:
!
activeVehicle
.
supportsJSButton
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
Repeater
{
height
:
width
id
:
buttonActionRepeater
border.width
:
1
model
:
_activeJoystick
?
Math
.
min
(
_activeJoystick
.
totalButtonCount
,
_maxButtons
)
:
[]
border.color
:
qgcPal
.
text
Row
{
color
:
pressed
?
qgcPal
.
buttonHighlight
:
qgcPal
.
button
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
property
bool
pressed
anchors.fill
:
parent
property
var
currentAssignableAction
:
_activeJoystick
?
_activeJoystick
.
assignableActions
.
get
(
buttonActionCombo
.
currentIndex
)
:
null
color
:
pressed
?
qgcPal
.
buttonHighlightText
:
qgcPal
.
buttonText
Rectangle
{
horizontalAlignment
:
Text
.
AlignHCenter
anchors.verticalCenter
:
parent
.
verticalCenter
verticalAlignment
:
Text
.
AlignVCenter
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
text
:
modelData
height
:
width
}
border.width
:
1
}
border.color
:
qgcPal
.
text
QGCComboBox
{
color
:
pressed
?
qgcPal
.
buttonHighlight
:
qgcPal
.
button
id
:
buttonActionCombo
QGCLabel
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
26
anchors.fill
:
parent
model
:
_activeJoystick
?
_activeJoystick
.
assignableActionTitles
:
[]
color
:
pressed
?
qgcPal
.
buttonHighlightText
:
qgcPal
.
buttonText
onActivated
:
{
horizontalAlignment
:
Text
.
AlignHCenter
_activeJoystick
.
setButtonAction
(
modelData
,
textAt
(
index
))
verticalAlignment
:
Text
.
AlignVCenter
}
text
:
modelData
Component.onCompleted
:
{
if
(
_activeJoystick
)
{
var
i
=
find
(
_activeJoystick
.
buttonActions
[
modelData
])
if
(
i
<
0
)
i
=
0
currentIndex
=
i
}
}
}
}
}
QGCComboBox
{
QGCCheckBox
{
id
:
buttonActionCombo
id
:
repeatCheck
width
:
ScreenTools
.
defaultFontPixelWidth
*
26
text
:
qsTr
(
"
Repeat
"
)
model
:
_activeJoystick
?
_activeJoystick
.
assignableActionTitles
:
[]
enabled
:
currentAssignableAction
&&
_activeJoystick
.
calibrated
&&
currentAssignableAction
.
canRepeat
onActivated
:
{
onClicked
:
{
_activeJoystick
.
setButtonAction
(
modelData
,
textAt
(
index
))
_activeJoystick
.
setButtonRepeat
(
modelData
,
checked
)
}
Component.onCompleted
:
{
if
(
_activeJoystick
)
{
var
i
=
find
(
_activeJoystick
.
buttonActions
[
modelData
])
if
(
i
<
0
)
i
=
0
currentIndex
=
i
}
}
}
}
Component.onCompleted
:
{
QGCCheckBox
{
if
(
_activeJoystick
)
{
id
:
repeatCheck
checked
=
_activeJoystick
.
getButtonRepeat
(
modelData
)
text
:
qsTr
(
"
Repeat
"
)
enabled
:
currentAssignableAction
&&
_activeJoystick
.
calibrated
&&
currentAssignableAction
.
canRepeat
onClicked
:
{
_activeJoystick
.
setButtonRepeat
(
modelData
,
checked
)
}
Component.onCompleted
:
{
if
(
_activeJoystick
)
{
checked
=
_activeJoystick
.
getButtonRepeat
(
modelData
)
}
}
}
anchors
.
verticalCenter
:
parent
.
verticalCenter
}
Item
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
2
height
:
1
}
}
anchors
.
verticalCenter
:
parent
.
verticalCenter
}
Item
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
2
height
:
1
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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