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
0b2af266
Commit
0b2af266
authored
Jan 24, 2017
by
Jacob Walser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup gamecontrollers with default calibration
parent
f8a07f3c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
10 deletions
+55
-10
Joystick.cc
src/Joystick/Joystick.cc
+31
-1
Joystick.h
src/Joystick/Joystick.h
+18
-8
JoystickSDL.cc
src/Joystick/JoystickSDL.cc
+1
-0
JoystickSDL.h
src/Joystick/JoystickSDL.h
+4
-1
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+1
-0
No files found.
src/Joystick/Joystick.cc
View file @
0b2af266
...
@@ -79,6 +79,36 @@ Joystick::~Joystick()
...
@@ -79,6 +79,36 @@ Joystick::~Joystick()
delete
_rgButtonValues
;
delete
_rgButtonValues
;
}
}
void
Joystick
::
_setDefaultCalibration
(
void
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
settings
.
beginGroup
(
_name
);
_calibrated
=
settings
.
value
(
_calibratedSettingsKey
,
false
).
toBool
();
// Only set default calibrations if we do not have a calibration for this gamecontroller
if
(
_calibrated
)
return
;
for
(
int
axis
=
0
;
axis
<
_axisCount
;
axis
++
)
{
Joystick
::
Calibration_t
calibration
;
_rgCalibration
[
axis
]
=
calibration
;
}
_rgCalibration
[
1
].
reversed
=
true
;
_rgCalibration
[
3
].
reversed
=
true
;
for
(
int
function
=
0
;
function
<
maxFunction
;
function
++
)
{
_rgFunctionAxis
[
function
]
=
function
;
}
_exponential
=
false
;
_accumulator
=
false
;
_deadband
=
false
;
_throttleMode
=
ThrottleModeCenterZero
;
_calibrated
=
true
;
_saveSettings
();
}
void
Joystick
::
_loadSettings
(
void
)
void
Joystick
::
_loadSettings
(
void
)
{
{
QSettings
settings
;
QSettings
settings
;
...
@@ -102,7 +132,7 @@ void Joystick::_loadSettings(void)
...
@@ -102,7 +132,7 @@ void Joystick::_loadSettings(void)
_throttleMode
=
(
ThrottleMode_t
)
settings
.
value
(
_throttleModeSettingsKey
,
ThrottleModeCenterZero
).
toInt
(
&
convertOk
);
_throttleMode
=
(
ThrottleMode_t
)
settings
.
value
(
_throttleModeSettingsKey
,
ThrottleModeCenterZero
).
toInt
(
&
convertOk
);
badSettings
|=
!
convertOk
;
badSettings
|=
!
convertOk
;
qCDebug
(
JoystickLog
)
<<
"_loadSettings calibrated:t
hrottlemode:exponential:deadband:badsettings"
<<
_calibrated
<<
_throttleMode
<<
_exponential
<<
_deadband
<<
badSettings
;
qCDebug
(
JoystickLog
)
<<
"_loadSettings calibrated:t
xmode:throttlemode:exponential:deadband:badsettings"
<<
_calibrated
<<
_transmitterMode
<<
_throttleMode
<<
_exponential
<<
_deadband
<<
badSettings
;
QString
minTpl
(
"Axis%1Min"
);
QString
minTpl
(
"Axis%1Min"
);
QString
maxTpl
(
"Axis%1Max"
);
QString
maxTpl
(
"Axis%1Max"
);
...
...
src/Joystick/Joystick.h
View file @
0b2af266
...
@@ -30,12 +30,18 @@ public:
...
@@ -30,12 +30,18 @@ public:
~
Joystick
();
~
Joystick
();
typedef
struct
{
typedef
struct
Calibration_t
{
int
min
;
int
min
;
int
max
;
int
max
;
int
center
;
int
center
;
int
deadband
;
int
deadband
;
bool
reversed
;
bool
reversed
;
Calibration_t
()
:
min
(
-
32767
)
,
max
(
32767
)
,
center
(
0
)
,
deadband
(
0
)
,
reversed
(
false
)
{}
}
Calibration_t
;
}
Calibration_t
;
typedef
enum
{
typedef
enum
{
...
@@ -68,7 +74,8 @@ public:
...
@@ -68,7 +74,8 @@ public:
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
Q_PROPERTY
(
bool
exponential
READ
exponential
WRITE
setExponential
NOTIFY
exponentialChanged
)
Q_PROPERTY
(
bool
exponential
READ
exponential
WRITE
setExponential
NOTIFY
exponentialChanged
)
Q_PROPERTY
(
bool
accumulator
READ
accumulator
WRITE
setAccumulator
NOTIFY
accumulatorChanged
)
Q_PROPERTY
(
bool
accumulator
READ
accumulator
WRITE
setAccumulator
NOTIFY
accumulatorChanged
)
Q_PROPERTY
(
bool
requiresCalibration
READ
requiresCalibration
CONSTANT
)
// Property accessors
// Property accessors
int
axisCount
(
void
)
{
return
_axisCount
;
}
int
axisCount
(
void
)
{
return
_axisCount
;
}
...
@@ -89,6 +96,8 @@ public:
...
@@ -89,6 +96,8 @@ public:
QString
name
(
void
)
{
return
_name
;
}
QString
name
(
void
)
{
return
_name
;
}
virtual
bool
requiresCalibration
(
void
)
{
return
true
;
}
int
throttleMode
(
void
);
int
throttleMode
(
void
);
void
setThrottleMode
(
int
mode
);
void
setThrottleMode
(
int
mode
);
...
@@ -144,12 +153,13 @@ signals:
...
@@ -144,12 +153,13 @@ signals:
void
buttonActionTriggered
(
int
action
);
void
buttonActionTriggered
(
int
action
);
protected:
protected:
void
_saveSettings
(
void
);
void
_setDefaultCalibration
(
void
);
void
_loadSettings
(
void
);
void
_saveSettings
(
void
);
float
_adjustRange
(
int
value
,
Calibration_t
calibration
,
bool
withDeadbands
);
void
_loadSettings
(
void
);
void
_buttonAction
(
const
QString
&
action
);
float
_adjustRange
(
int
value
,
Calibration_t
calibration
,
bool
withDeadbands
);
bool
_validAxis
(
int
axis
);
void
_buttonAction
(
const
QString
&
action
);
bool
_validButton
(
int
button
);
bool
_validAxis
(
int
axis
);
bool
_validButton
(
int
button
);
private:
private:
virtual
bool
_open
()
=
0
;
virtual
bool
_open
()
=
0
;
...
...
src/Joystick/JoystickSDL.cc
View file @
0b2af266
...
@@ -10,6 +10,7 @@ JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, in
...
@@ -10,6 +10,7 @@ JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, in
,
_isGameController
(
isGameController
)
,
_isGameController
(
isGameController
)
,
_index
(
index
)
,
_index
(
index
)
{
{
if
(
_isGameController
)
_setDefaultCalibration
();
}
}
QMap
<
QString
,
Joystick
*>
JoystickSDL
::
discover
(
MultiVehicleManager
*
_multiVehicleManager
)
{
QMap
<
QString
,
Joystick
*>
JoystickSDL
::
discover
(
MultiVehicleManager
*
_multiVehicleManager
)
{
...
...
src/Joystick/JoystickSDL.h
View file @
0b2af266
...
@@ -12,7 +12,10 @@ class JoystickSDL : public Joystick
...
@@ -12,7 +12,10 @@ class JoystickSDL : public Joystick
public:
public:
JoystickSDL
(
const
QString
&
name
,
int
axisCount
,
int
buttonCount
,
int
hatCount
,
int
index
,
bool
isGameController
,
MultiVehicleManager
*
multiVehicleManager
);
JoystickSDL
(
const
QString
&
name
,
int
axisCount
,
int
buttonCount
,
int
hatCount
,
int
index
,
bool
isGameController
,
MultiVehicleManager
*
multiVehicleManager
);
static
QMap
<
QString
,
Joystick
*>
discover
(
MultiVehicleManager
*
_multiVehicleManager
);
static
QMap
<
QString
,
Joystick
*>
discover
(
MultiVehicleManager
*
_multiVehicleManager
);
// This can be uncommented to hide the calibration buttons for gamecontrollers in the future
// bool requiresCalibration(void) final { return !_isGameController; }
private:
private:
static
void
_loadGameControllerMappings
();
static
void
_loadGameControllerMappings
();
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
0b2af266
...
@@ -302,6 +302,7 @@ SetupPage {
...
@@ -302,6 +302,7 @@ SetupPage {
// Command Buttons
// Command Buttons
Row
{
Row
{
spacing
:
10
spacing
:
10
visible
:
_activeJoystick
.
requiresCalibration
QGCButton
{
QGCButton
{
id
:
skipButton
id
:
skipButton
...
...
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