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
41b2fd7e
Commit
41b2fd7e
authored
Jul 25, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
2aa69014
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
232 additions
and
121 deletions
+232
-121
Joystick.cc
src/Joystick/Joystick.cc
+171
-101
Joystick.h
src/Joystick/Joystick.h
+44
-17
JoystickConfigButtons.qml
src/VehicleSetup/JoystickConfigButtons.qml
+17
-3
No files found.
src/Joystick/Joystick.cc
View file @
41b2fd7e
This diff is collapsed.
Click to expand it.
src/Joystick/Joystick.h
View file @
41b2fd7e
...
...
@@ -21,10 +21,33 @@
Q_DECLARE_LOGGING_CATEGORY
(
JoystickLog
)
Q_DECLARE_LOGGING_CATEGORY
(
JoystickValuesLog
)
//-- Action assigned to button
class
AssignedButtonAction
:
public
QObject
{
Q_OBJECT
public:
QString
action
;
QTime
buttonTime
;
bool
repeat
=
false
;
int
frequency
=
1
;
};
//-- Assignable Button Action
class
ButtonAction
:
public
QObject
{
Q_OBJECT
public:
ButtonAction
(
QObject
*
parent
,
QString
action_
,
bool
canRepeat_
=
false
);
Q_PROPERTY
(
QString
action
READ
action
CONSTANT
)
Q_PROPERTY
(
bool
canRepeat
READ
canRepeat
CONSTANT
)
QString
action
()
{
return
_action
;
}
bool
repeat
()
{
return
_repeat
;
}
private:
QString
_action
;
bool
_repeat
=
false
;
};
class
Joystick
:
public
QThread
{
Q_OBJECT
public:
Joystick
(
const
QString
&
name
,
int
axisCount
,
int
buttonCount
,
int
hatCount
,
MultiVehicleManager
*
multiVehicleManager
);
...
...
@@ -60,13 +83,13 @@ public:
ThrottleModeMax
}
ThrottleMode_t
;
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
Q_PROPERTY
(
bool
calibrated
MEMBER
_calibrated
NOTIFY
calibratedChanged
)
Q_PROPERTY
(
int
totalButtonCount
READ
totalButtonCount
CONSTANT
)
Q_PROPERTY
(
int
axisCount
READ
axisCount
CONSTANT
)
Q_PROPERTY
(
bool
requiresCalibration
READ
requiresCalibration
CONSTANT
)
Q_PROPERTY
(
Q
StringList
actions
READ
actions
CONSTANT
)
Q_PROPERTY
(
Q
VariantList
buttonActions
READ
buttonActions
NOTIFY
buttonAction
sChanged
)
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
Q_PROPERTY
(
bool
calibrated
MEMBER
_calibrated
NOTIFY
calibratedChanged
)
Q_PROPERTY
(
int
totalButtonCount
READ
totalButtonCount
CONSTANT
)
Q_PROPERTY
(
int
axisCount
READ
axisCount
CONSTANT
)
Q_PROPERTY
(
bool
requiresCalibration
READ
requiresCalibration
CONSTANT
)
Q_PROPERTY
(
Q
List
<
ButtonAction
*>
actions
READ
actions
CONSTANT
)
Q_PROPERTY
(
Q
StringList
actionTitles
READ
actionTitles
NOTIFY
actionTitle
sChanged
)
Q_PROPERTY
(
bool
gimbalEnabled
READ
gimbalEnabled
WRITE
setGimbalEnabled
NOTIFY
gimbalEnabledChanged
)
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
...
...
@@ -85,8 +108,8 @@ public:
int
totalButtonCount
()
{
return
_totalButtonCount
;
}
int
axisCount
()
{
return
_axisCount
;
}
bool
gimbalEnabled
()
{
return
_gimbalEnabled
;
}
Q
StringList
actions
();
Q
VariantList
buttonActions
();
Q
List
<
ButtonAction
*>
actions
();
Q
StringList
actionTitles
();
void
setGimbalEnabled
(
bool
set
);
...
...
@@ -143,7 +166,7 @@ signals:
void
rawAxisValueChanged
(
int
index
,
int
value
);
void
rawButtonPressedChanged
(
int
index
,
int
pressed
);
void
buttonActionsChanged
(
QVariant
List
actions
);
void
actionTitlesChanged
(
QString
List
actions
);
void
throttleModeChanged
(
int
mode
);
...
...
@@ -166,7 +189,7 @@ signals:
void
manualControl
(
float
roll
,
float
pitch
,
float
yaw
,
float
throttle
,
quint16
buttons
,
int
joystickMmode
);
void
manualControlGimbal
(
float
gimbalPitch
,
float
gimbalYaw
);
void
buttonActionTriggered
(
int
action
);
void
buttonActionTriggered
(
int
action
);
void
gimbalEnabledChanged
();
void
frequencyChanged
();
...
...
@@ -192,6 +215,8 @@ protected:
void
_buttonAction
(
const
QString
&
action
);
bool
_validAxis
(
int
axis
);
bool
_validButton
(
int
button
);
void
_handleAxis
();
void
_handleButtons
();
private:
virtual
bool
_open
()
=
0
;
...
...
@@ -244,19 +269,21 @@ protected:
int
_totalButtonCount
;
static
int
_transmitterMode
;
int
_rgFunctionAxis
[
maxFunction
]
=
{};
QTime
_axisTime
;
Q
StringList
_rgButtonA
ctions
;
MultiVehicleManager
*
_multiVehicleManager
=
nullptr
;
Q
List
<
ButtonAction
*>
_a
ctions
;
QList
<
AssignedButtonAction
*>
_buttonActionArray
;
MultiVehicleManager
*
_multiVehicleManager
=
nullptr
;
private:
static
const
char
*
_rgFunctionSettingsKey
[
maxFunction
];
static
const
char
*
_settingsGroup
;
static
const
char
*
_calibratedSettingsKey
;
static
const
char
*
_buttonActionSettingsKey
;
static
const
char
*
_buttonActionNameKey
;
static
const
char
*
_buttonActionRepeatKey
;
static
const
char
*
_buttonActionFrequencyKey
;
static
const
char
*
_throttleModeSettingsKey
;
static
const
char
*
_exponentialSettingsKey
;
static
const
char
*
_accumulatorSettingsKey
;
...
...
src/VehicleSetup/JoystickConfigButtons.qml
View file @
41b2fd7e
...
...
@@ -48,7 +48,7 @@ Item {
property
bool
pressed
QGCCheckBox
{
anchors.verticalCenter
:
parent
.
verticalCenter
checked
:
_activeJoystick
?
_activeJoystick
.
buttonAction
s
[
modelData
]
!==
""
:
false
checked
:
_activeJoystick
?
_activeJoystick
.
actionTitle
s
[
modelData
]
!==
""
:
false
onClicked
:
_activeJoystick
.
setButtonAction
(
modelData
,
checked
?
buttonActionCombo
.
textAt
(
buttonActionCombo
.
currentIndex
)
:
""
)
}
Rectangle
{
...
...
@@ -69,9 +69,23 @@ Item {
QGCComboBox
{
id
:
buttonActionCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
26
model
:
_activeJoystick
?
_activeJoystick
.
actions
:
0
model
:
_activeJoystick
?
_activeJoystick
.
actions
:
[]
onActivated
:
_activeJoystick
.
setButtonAction
(
modelData
,
textAt
(
index
))
Component.onCompleted
:
currentIndex
=
find
(
_activeJoystick
.
buttonActions
[
modelData
])
Component.onCompleted
:
currentIndex
=
find
(
_activeJoystick
.
actionTitles
[
modelData
])
}
QGCCheckBox
{
id
:
repeatCheck
text
:
qsTr
(
"
Repeat
"
)
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCComboBox
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
10
model
:
[
"
1Hz
"
,
"
2Hz
"
,
"
5Hz
"
,
"
10Hz
"
]
enabled
:
repeatCheck
.
checked
}
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