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
196153aa
Commit
196153aa
authored
Jun 30, 2016
by
Gus Grubba
Committed by
Don Gagne
Jun 30, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing a crash in the Joystick class. (#3701)
parent
e6efa19a
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
103 deletions
+100
-103
Joystick.cc
src/Joystick/Joystick.cc
+64
-67
Joystick.h
src/Joystick/Joystick.h
+36
-36
No files found.
src/Joystick/Joystick.cc
View file @
196153aa
This diff is collapsed.
Click to expand it.
src/Joystick/Joystick.h
View file @
196153aa
...
...
@@ -24,7 +24,7 @@ Q_DECLARE_LOGGING_CATEGORY(JoystickValuesLog)
class
Joystick
:
public
QThread
{
Q_OBJECT
public:
Joystick
(
const
QString
&
name
,
int
axisCount
,
int
buttonCount
,
int
hatCount
,
MultiVehicleManager
*
multiVehicleManager
);
...
...
@@ -36,7 +36,7 @@ public:
int
center
;
bool
reversed
;
}
Calibration_t
;
typedef
enum
{
rollFunction
,
pitchFunction
,
...
...
@@ -44,76 +44,76 @@ public:
throttleFunction
,
maxFunction
}
AxisFunction_t
;
typedef
enum
{
ThrottleModeCenterZero
,
ThrottleModeDownZero
,
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
(
QStringList
actions
READ
actions
CONSTANT
)
Q_PROPERTY
(
QVariantList
buttonActions
READ
buttonActions
NOTIFY
buttonActionsChanged
)
Q_INVOKABLE
void
setButtonAction
(
int
button
,
const
QString
&
action
);
Q_INVOKABLE
QString
getButtonAction
(
int
button
);
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
// Property accessors
int
axisCount
(
void
)
{
return
_axisCount
;
}
int
totalButtonCount
(
void
)
{
return
_totalButtonCount
;
}
/// Start the polling thread which will in turn emit joystick signals
void
startPolling
(
Vehicle
*
vehicle
);
void
stopPolling
(
void
);
void
setCalibration
(
int
axis
,
Calibration_t
&
calibration
);
Calibration_t
getCalibration
(
int
axis
);
void
setFunctionAxis
(
AxisFunction_t
function
,
int
axis
);
int
getFunctionAxis
(
AxisFunction_t
function
);
QStringList
actions
(
void
);
QVariantList
buttonActions
(
void
);
QString
name
(
void
)
{
return
_name
;
}
int
throttleMode
(
void
);
void
setThrottleMode
(
int
mode
);
typedef
enum
{
CalibrationModeOff
,
// Not calibrating
CalibrationModeMonitor
,
// Monitors are active, continue to send to vehicle if already polling
CalibrationModeCalibrating
,
// Calibrating, stop sending joystick to vehicle
}
CalibrationMode_t
;
/// Set the current calibration mode
void
startCalibrationMode
(
CalibrationMode_t
mode
);
/// Clear the current calibration mode
void
stopCalibrationMode
(
CalibrationMode_t
mode
);
signals:
void
calibratedChanged
(
bool
calibrated
);
// The raw signals are only meant for use by calibration
void
rawAxisValueChanged
(
int
index
,
int
value
);
void
rawButtonPressedChanged
(
int
index
,
int
pressed
);
void
buttonActionsChanged
(
QVariantList
actions
);
void
throttleModeChanged
(
int
mode
);
void
enabledChanged
(
bool
enabled
);
/// Signal containing new joystick information
/// @param roll Range is -1:1, negative meaning roll left, positive meaning roll right
/// @param pitch Range i -1:1, negative meaning pitch down, positive meaning pitch up
...
...
@@ -121,9 +121,9 @@ signals:
/// @param throttle Range is 0:1, 0 meaning no throttle, 1 meaning full throttle
/// @param mode See Vehicle::JoystickMode_t enum
void
manualControl
(
float
roll
,
float
pitch
,
float
yaw
,
float
throttle
,
quint16
buttons
,
int
joystickMmode
);
void
buttonActionTriggered
(
int
action
);
protected:
void
_saveSettings
(
void
);
void
_loadSettings
(
void
);
...
...
@@ -145,9 +145,9 @@ private:
virtual
void
run
(
void
);
protected:
bool
_exitThread
;
///< true: signal thread to exit
QString
_name
;
bool
_calibrated
;
int
_axisCount
;
...
...
@@ -155,24 +155,24 @@ protected:
int
_hatCount
;
int
_hatButtonCount
;
int
_totalButtonCount
;
CalibrationMode_t
_calibrationMode
;
int
*
_rgAxisValues
;
Calibration_t
*
_rgCalibration
;
int
_rgFunctionAxis
[
maxFunction
];
bool
*
_rgButtonValues
;
QString
*
_rgButtonActions
;
QString
List
_rgButtonActions
;
quint16
_lastButtonBits
;
ThrottleMode_t
_throttleMode
;
Vehicle
*
_activeVehicle
;
bool
_pollingStartedForCalibration
;
MultiVehicleManager
*
_multiVehicleManager
;
private:
static
const
char
*
_rgFunctionSettingsKey
[
maxFunction
];
...
...
@@ -181,5 +181,5 @@ private:
static
const
char
*
_buttonActionSettingsKey
;
static
const
char
*
_throttleModeSettingsKey
;
};
#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