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
f086840f
Commit
f086840f
authored
Jun 16, 2013
by
Bryant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove range limiting for joystick axes in preparation for moving that code into UASInterface.h.
parent
f820eefc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1 addition
and
59 deletions
+1
-59
JoystickInput.cc
src/input/JoystickInput.cc
+1
-16
JoystickInput.h
src/input/JoystickInput.h
+0
-7
JoystickAxis.cc
src/ui/JoystickAxis.cc
+0
-23
JoystickAxis.h
src/ui/JoystickAxis.h
+0
-4
JoystickAxis.ui
src/ui/JoystickAxis.ui
+0
-7
JoystickWidget.cc
src/ui/JoystickWidget.cc
+0
-2
No files found.
src/input/JoystickInput.cc
View file @
f086840f
...
...
@@ -198,12 +198,7 @@ void JoystickInput::run()
axisValue
=
(
axisValue
-
calibrationPositive
[
i
])
/
(
calibrationNegative
[
i
]
-
calibrationPositive
[
i
]);
}
axisValue
=
1.0
f
-
axisValue
;
// If the joystick isn't limited to [0:1.0], map it into [-1.0:1.0].
if
(
!
joystickAxesRangeLimited
[
i
])
{
axisValue
=
axisValue
*
2.0
f
-
1.0
f
;
}
axisValue
=
axisValue
*
2.0
f
-
1.0
f
;
// Bound rounding errors
if
(
axisValue
>
1.0
f
)
axisValue
=
1.0
f
;
...
...
@@ -281,7 +276,6 @@ void JoystickInput::setActiveJoystick(int id)
// Update cached joystick values
joystickAxes
.
clear
();
joystickAxesInverted
.
clear
();
joystickAxesRangeLimited
.
clear
();
for
(
int
i
=
0
;
i
<
joystickNumAxes
;
i
++
)
{
int
axisValue
=
SDL_JoystickGetAxis
(
joystick
,
i
);
...
...
@@ -289,7 +283,6 @@ void JoystickInput::setActiveJoystick(int id)
emit
axisValueChanged
(
i
,
axisValue
);
joystickAxesInverted
.
append
(
false
);
joystickAxesRangeLimited
.
append
(
false
);
}
joystickButtons
=
0
;
for
(
int
i
=
0
;
i
<
joystickNumButtons
;
i
++
)
...
...
@@ -355,14 +348,6 @@ void JoystickInput::setAxisInversion(int axis, bool inverted)
}
}
void
JoystickInput
::
setAxisRangeLimit
(
int
axis
,
bool
rangeLimited
)
{
if
(
axis
<
joystickAxesRangeLimited
.
size
())
{
joystickAxesRangeLimited
[
axis
]
=
rangeLimited
;
}
}
float
JoystickInput
::
getCurrentValueForAxis
(
int
axis
)
{
if
(
axis
<
joystickAxes
.
size
())
...
...
src/input/JoystickInput.h
View file @
f086840f
...
...
@@ -158,7 +158,6 @@ protected:
QList
<
float
>
joystickAxes
;
///< The values of every axes during the last sample.
QList
<
bool
>
joystickAxesInverted
;
///< Whether each axis should be used inverted from what was reported.
QList
<
bool
>
joystickAxesRangeLimited
;
///< Whether each axis should be scaled into [0:1.0] instead of [-1.0:1.0].
quint16
joystickButtons
;
///< The state of every button. Bitfield supporting 16 buttons with 1s indicating that the button is down.
int
xHat
,
yHat
;
///< The horizontal/vertical hat directions. Values are -1, 0, 1, with (-1,-1) indicating bottom-left.
...
...
@@ -233,12 +232,6 @@ public slots:
* @param inverted True indicates inverted from normal. Varies by controller.
*/
void
setAxisInversion
(
int
axis
,
bool
inverted
);
/**
* @brief Specifies whether an axis should have its range limited to only positive values.
* @param axis The index of the axis to limit
* @param rangeLimited True if the axis should be limited, false otherwise.
*/
void
setAxisRangeLimit
(
int
axis
,
bool
rangeLimited
);
};
#endif // _JOYSTICKINPUT_H_
src/ui/JoystickAxis.cc
View file @
f086840f
...
...
@@ -9,11 +9,9 @@ JoystickAxis::JoystickAxis(int id, QWidget *parent) :
ui
(
new
Ui
::
JoystickAxis
)
{
ui
->
setupUi
(
this
);
ui
->
limitRangeCheckBox
->
hide
();
// Hide the range checkbox by default. It's only activated by switching to the Throttle axis option.
ui
->
label
->
setText
(
QString
::
number
(
id
));
connect
(
ui
->
comboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
mappingComboBoxChanged
(
int
)));
connect
(
ui
->
invertedCheckBox
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
inversionCheckBoxChanged
(
bool
)));
connect
(
ui
->
limitRangeCheckBox
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
limitRangeCheckBoxChanged
(
bool
)));
}
JoystickAxis
::~
JoystickAxis
()
...
...
@@ -28,14 +26,6 @@ void JoystickAxis::setValue(float value)
void
JoystickAxis
::
mappingComboBoxChanged
(
int
newMapping
)
{
if
(
newMapping
==
JoystickInput
::
JOYSTICK_INPUT_MAPPING_THROTTLE
)
{
ui
->
limitRangeCheckBox
->
show
();
}
else
{
ui
->
limitRangeCheckBox
->
hide
();
}
emit
mappingChanged
(
id
,
(
JoystickInput
::
JOYSTICK_INPUT_MAPPING
)
newMapping
);
}
...
...
@@ -43,16 +33,3 @@ void JoystickAxis::inversionCheckBoxChanged(bool inverted)
{
emit
inversionChanged
(
id
,
inverted
);
}
void
JoystickAxis
::
limitRangeCheckBoxChanged
(
bool
limited
)
{
if
(
limited
)
{
ui
->
progressBar
->
setRange
(
0
,
100
);
}
else
{
ui
->
progressBar
->
setRange
(
-
100
,
100
);
}
emit
rangeLimitChanged
(
id
,
limited
);
}
src/ui/JoystickAxis.h
View file @
f086840f
...
...
@@ -21,8 +21,6 @@ signals:
void
mappingChanged
(
int
id
,
JoystickInput
::
JOYSTICK_INPUT_MAPPING
newMapping
);
/** @brief Signal a change in this axis' inversion status */
void
inversionChanged
(
int
id
,
bool
);
/** @brief Signal a change in this axis' range limit */
void
rangeLimitChanged
(
int
id
,
bool
);
public
slots
:
/** @brief Update the displayed value of the included progressbar.
...
...
@@ -39,8 +37,6 @@ private slots:
void
mappingComboBoxChanged
(
int
newMapping
);
/** @brief Emit signal when the inversion checkbox is changed. */
void
inversionCheckBoxChanged
(
bool
inverted
);
/** @brief Emit signal when the limit range checkbox is changed. */
void
limitRangeCheckBoxChanged
(
bool
limited
);
};
#endif // JOYSTICKAXIS_H
src/ui/JoystickAxis.ui
View file @
f086840f
...
...
@@ -86,13 +86,6 @@
</item>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"limitRangeCheckBox"
>
<property
name=
"text"
>
<string>
Limit range
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QProgressBar"
name=
"progressBar"
>
<property
name=
"enabled"
>
...
...
src/ui/JoystickWidget.cc
View file @
f086840f
...
...
@@ -125,7 +125,6 @@ void JoystickWidget::updateUIForJoystick(int id)
for
(
int
i
=
0
;
i
<
newButtons
;
i
++
)
{
JoystickButton
*
button
=
new
JoystickButton
(
i
,
m_ui
->
buttonBox
);
// And make sure we insert BEFORE the vertical spacer.
m_ui
->
buttonLayout
->
addWidget
(
button
);
buttons
.
append
(
button
);
}
...
...
@@ -145,7 +144,6 @@ void JoystickWidget::updateUIForJoystick(int id)
axis
->
setValue
(
joystick
->
getCurrentValueForAxis
(
i
));
connect
(
axis
,
SIGNAL
(
mappingChanged
(
int
,
JoystickInput
::
JOYSTICK_INPUT_MAPPING
)),
this
->
joystick
,
SLOT
(
setAxisMapping
(
int
,
JoystickInput
::
JOYSTICK_INPUT_MAPPING
)));
connect
(
axis
,
SIGNAL
(
inversionChanged
(
int
,
bool
)),
this
->
joystick
,
SLOT
(
setAxisInversion
(
int
,
bool
)));
connect
(
axis
,
SIGNAL
(
rangeLimitChanged
(
int
,
bool
)),
this
->
joystick
,
SLOT
(
setAxisRangeLimit
(
int
,
bool
)));
m_ui
->
axesLayout
->
addWidget
(
axis
);
axes
.
append
(
axis
);
}
...
...
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