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
8268ca2c
Commit
8268ca2c
authored
Jun 20, 2013
by
Bryant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The last selected joystick is now saved and re-selected on startup.
parent
9bda816e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
JoystickInput.cc
src/input/JoystickInput.cc
+21
-7
No files found.
src/input/JoystickInput.cc
View file @
8268ca2c
...
...
@@ -71,7 +71,9 @@ void JoystickInput::loadGeneralSettings()
// Deal with settings specific to the JoystickInput
settings
.
beginGroup
(
"JOYSTICK_INPUT"
);
isEnabled
=
settings
.
value
(
"ENABLED"
,
false
).
toBool
();
QString
joystickName
=
settings
.
value
(
"JOYSTICK"
,
""
).
toString
();
qDebug
()
<<
"JoystickInput: Loading enabled setting ("
<<
isEnabled
<<
")"
;
joystickName
=
settings
.
value
(
"JOYSTICK_NAME"
,
""
).
toString
();
qDebug
()
<<
"JoystickInput: Loading last joystick setting ("
<<
joystickName
<<
")"
;
settings
.
endGroup
();
}
...
...
@@ -342,21 +344,33 @@ void JoystickInput::init()
return
;
}
// Now that we've detected a joystick, load in the joystick-agnostic settings.
loadGeneralSettings
();
// Enumerate all found devices
qDebug
()
<<
QString
(
"%1 Input devices found:"
).
arg
(
numJoysticks
);
int
activeJoystick
=
0
;
for
(
int
i
=
0
;
i
<
numJoysticks
;
i
++
)
{
qDebug
()
<<
QString
(
"
\t
- %1"
).
arg
(
SDL_JoystickName
(
i
));
QString
name
=
SDL_JoystickName
(
i
);
qDebug
()
<<
QString
(
"
\t
- %1"
).
arg
(
name
);
// If we've matched this joystick to what was last opened, note it.
// Note: The way this is implemented the LAST joystick of a given name will be opened.
if
(
name
==
joystickName
)
{
activeJoystick
=
i
;
}
SDL_Joystick
*
x
=
SDL_JoystickOpen
(
i
);
qDebug
()
<<
QString
(
"Number of Axes: %1"
).
arg
(
QString
::
number
(
SDL_JoystickNumAxes
(
x
)));
qDebug
()
<<
QString
(
"Number of Buttons: %1"
).
arg
(
QString
::
number
(
SDL_JoystickNumButtons
(
x
)));
SDL_JoystickClose
(
x
);
}
// Now that we've detected a joystick, load in the joystick-agnostic settings.
loadGeneralSettings
();
// And attach to the first joystick found to start, which also loads in joystick-specific settings.
setActiveJoystick
(
0
);
// Set the active joystick based on name, if a joystick was found in the saved settings, otherwise
// default to the first one.
setActiveJoystick
(
activeJoystick
);
// Now make sure we know what the current UAS is and track changes to it.
setActiveUAS
(
UASManager
::
instance
()
->
getActiveUAS
());
...
...
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