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
bffe803c
Commit
bffe803c
authored
Jan 24, 2017
by
Jacob Walser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add firmware-specific joystick TX mode settings
parent
0b2af266
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
13 deletions
+70
-13
ArduSubFirmwarePlugin.h
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h
+2
-0
FirmwarePlugin.cc
src/FirmwarePlugin/FirmwarePlugin.cc
+5
-0
FirmwarePlugin.h
src/FirmwarePlugin/FirmwarePlugin.h
+4
-0
Joystick.cc
src/Joystick/Joystick.cc
+51
-13
Joystick.h
src/Joystick/Joystick.h
+8
-0
No files found.
src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h
View file @
bffe803c
...
...
@@ -69,6 +69,8 @@ public:
// Overrides from FirmwarePlugin
int
manualControlReservedButtonCount
(
void
);
int
defaultJoystickTXMode
(
void
)
final
{
return
3
;
}
bool
supportsThrottleModeCenterZero
(
void
);
bool
supportsManualControl
(
void
);
...
...
src/FirmwarePlugin/FirmwarePlugin.cc
View file @
bffe803c
...
...
@@ -106,6 +106,11 @@ int FirmwarePlugin::manualControlReservedButtonCount(void)
return
-
1
;
}
int
FirmwarePlugin
::
defaultJoystickTXMode
(
void
)
{
return
2
;
}
bool
FirmwarePlugin
::
supportsThrottleModeCenterZero
(
void
)
{
// By default, this is supported
...
...
src/FirmwarePlugin/FirmwarePlugin.h
View file @
bffe803c
...
...
@@ -142,6 +142,10 @@ public:
/// @return -1: reserver all buttons, >0 number of buttons to reserve
virtual
int
manualControlReservedButtonCount
(
void
);
/// Default tx mode to apply to joystick axes
/// TX modes are as outlined here: http://www.rc-airplane-world.com/rc-transmitter-modes.html
virtual
int
defaultJoystickTXMode
(
void
);
/// Returns true if the vehicle and firmware supports the use of a throttle joystick that
/// is zero when centered. Typically not supported on vehicles that have bidirectional
/// throttle.
...
...
src/Joystick/Joystick.cc
View file @
bffe803c
...
...
@@ -18,14 +18,19 @@
QGC_LOGGING_CATEGORY
(
JoystickLog
,
"JoystickLog"
)
QGC_LOGGING_CATEGORY
(
JoystickValuesLog
,
"JoystickValuesLog"
)
const
char
*
Joystick
::
_settingsGroup
=
"Joysticks"
;
const
char
*
Joystick
::
_calibratedSettingsKey
=
"Calibrated1"
;
// Increment number to force recalibration
const
char
*
Joystick
::
_buttonActionSettingsKey
=
"ButtonActionName%1"
;
const
char
*
Joystick
::
_throttleModeSettingsKey
=
"ThrottleMode"
;
const
char
*
Joystick
::
_exponentialSettingsKey
=
"Exponential"
;
const
char
*
Joystick
::
_accumulatorSettingsKey
=
"Accumulator"
;
const
char
*
Joystick
::
_deadbandSettingsKey
=
"Deadband"
;
const
char
*
Joystick
::
_txModeSettingsKey
=
"TXMode"
;
const
char
*
Joystick
::
_settingsGroup
=
"Joysticks"
;
const
char
*
Joystick
::
_calibratedSettingsKey
=
"Calibrated1"
;
// Increment number to force recalibration
const
char
*
Joystick
::
_buttonActionSettingsKey
=
"ButtonActionName%1"
;
const
char
*
Joystick
::
_throttleModeSettingsKey
=
"ThrottleMode"
;
const
char
*
Joystick
::
_exponentialSettingsKey
=
"Exponential"
;
const
char
*
Joystick
::
_accumulatorSettingsKey
=
"Accumulator"
;
const
char
*
Joystick
::
_deadbandSettingsKey
=
"Deadband"
;
const
char
*
Joystick
::
_txModeSettingsKey
=
NULL
;
const
char
*
Joystick
::
_fixedWingTXModeSettingsKey
=
"TXMode_FixedWing"
;
const
char
*
Joystick
::
_multiRotorTXModeSettingsKey
=
"TXMode_MultiRotor"
;
const
char
*
Joystick
::
_roverTXModeSettingsKey
=
"TXMode_Rover"
;
const
char
*
Joystick
::
_vtolTXModeSettingsKey
=
"TXMode_VTOL"
;
const
char
*
Joystick
::
_submarineTXModeSettingsKey
=
"TXMode_Submarine"
;
const
char
*
Joystick
::
_rgFunctionSettingsKey
[
Joystick
::
maxFunction
]
=
{
"RollAxis"
,
...
...
@@ -70,6 +75,8 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
}
_loadSettings
();
connect
(
_multiVehicleManager
,
&
MultiVehicleManager
::
activeVehicleChanged
,
this
,
&
Joystick
::
_activeVehicleChanged
);
}
Joystick
::~
Joystick
()
...
...
@@ -96,9 +103,11 @@ void Joystick::_setDefaultCalibration(void) {
_rgCalibration
[
1
].
reversed
=
true
;
_rgCalibration
[
3
].
reversed
=
true
;
for
(
int
function
=
0
;
function
<
maxFunction
;
function
++
)
{
_rgFunctionAxis
[
function
]
=
function
;
}
// Default TX Mode 2 axis assignments for gamecontrollers
_rgFunctionAxis
[
rollFunction
]
=
2
;
_rgFunctionAxis
[
pitchFunction
]
=
3
;
_rgFunctionAxis
[
yawFunction
]
=
0
;
_rgFunctionAxis
[
throttleFunction
]
=
1
;
_exponential
=
false
;
_accumulator
=
false
;
...
...
@@ -109,13 +118,41 @@ void Joystick::_setDefaultCalibration(void) {
_saveSettings
();
}
void
Joystick
::
_activeVehicleChanged
(
Vehicle
*
activeVehicle
)
{
if
(
activeVehicle
)
{
if
(
activeVehicle
->
fixedWing
())
{
_txModeSettingsKey
=
_fixedWingTXModeSettingsKey
;
}
else
if
(
activeVehicle
->
multiRotor
())
{
_txModeSettingsKey
=
_multiRotorTXModeSettingsKey
;
}
else
if
(
activeVehicle
->
rover
())
{
_txModeSettingsKey
=
_roverTXModeSettingsKey
;
}
else
if
(
activeVehicle
->
vtol
())
{
_txModeSettingsKey
=
_vtolTXModeSettingsKey
;
}
else
if
(
activeVehicle
->
sub
())
{
_txModeSettingsKey
=
_submarineTXModeSettingsKey
;
}
else
{
_txModeSettingsKey
=
NULL
;
qWarning
()
<<
"No valid joystick TXmode settings key for selected vehicle"
;
return
;
}
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
int
mode
=
settings
.
value
(
_txModeSettingsKey
,
activeVehicle
->
firmwarePlugin
()
->
defaultJoystickTXMode
()).
toInt
();
setTXMode
(
mode
);
}
}
void
Joystick
::
_loadSettings
(
void
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
_transmitterMode
=
settings
.
value
(
_txModeSettingsKey
,
2
).
toInt
();
if
(
_txModeSettingsKey
)
_transmitterMode
=
settings
.
value
(
_txModeSettingsKey
,
2
).
toInt
();
settings
.
beginGroup
(
_name
);
...
...
@@ -195,7 +232,8 @@ void Joystick::_saveSettings(void)
// Transmitter mode is static
// Save the mode we are using
settings
.
setValue
(
_txModeSettingsKey
,
_transmitterMode
);
if
(
_txModeSettingsKey
)
settings
.
setValue
(
_txModeSettingsKey
,
_transmitterMode
);
settings
.
beginGroup
(
_name
);
...
...
src/Joystick/Joystick.h
View file @
bffe803c
...
...
@@ -221,6 +221,14 @@ private:
static
const
char
*
_accumulatorSettingsKey
;
static
const
char
*
_deadbandSettingsKey
;
static
const
char
*
_txModeSettingsKey
;
static
const
char
*
_fixedWingTXModeSettingsKey
;
static
const
char
*
_multiRotorTXModeSettingsKey
;
static
const
char
*
_roverTXModeSettingsKey
;
static
const
char
*
_vtolTXModeSettingsKey
;
static
const
char
*
_submarineTXModeSettingsKey
;
private
slots
:
void
_activeVehicleChanged
(
Vehicle
*
activeVehicle
);
};
#endif
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