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
4690a091
Commit
4690a091
authored
Jul 19, 2017
by
Jacob Walser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Joystick: give duplicate joystick names distinct keys
parent
667c1e12
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
JoystickSDL.cc
src/Joystick/JoystickSDL.cc
+11
-1
No files found.
src/Joystick/JoystickSDL.cc
View file @
4690a091
...
...
@@ -36,7 +36,6 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
for
(
int
i
=
0
;
i
<
SDL_NumJoysticks
();
i
++
)
{
QString
name
=
SDL_JoystickNameForIndex
(
i
);
// TODO use GUID instead of name in case of two joysticks with same name
if
(
!
ret
.
contains
(
name
))
{
int
axisCount
,
buttonCount
,
hatCount
;
bool
isGameController
;
...
...
@@ -65,6 +64,17 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
}
qCDebug
(
JoystickLog
)
<<
"
\t
"
<<
name
<<
"axes:"
<<
axisCount
<<
"buttons:"
<<
buttonCount
<<
"hats:"
<<
hatCount
<<
"isGC:"
<<
isGameController
;
// Check for joysticks with duplicate names and differentiate the keys when neccessary.
// This is required when using an Xbox 360 wireless receiver that always identifies as
// 4 individual joysticks, regardless of how many joysticks are actually connected to the
// receiver. Using GUID does not help, all of these devices present the same GUID.
QString
originalName
=
name
;
uint8_t
duplicateIdx
=
1
;
while
(
newRet
[
name
])
{
name
=
QString
(
"%1 %2"
).
arg
(
originalName
).
arg
(
duplicateIdx
++
);
}
newRet
[
name
]
=
new
JoystickSDL
(
name
,
qMax
(
0
,
axisCount
),
qMax
(
0
,
buttonCount
),
qMax
(
0
,
hatCount
),
i
,
isGameController
,
_multiVehicleManager
);
}
else
{
newRet
[
name
]
=
ret
[
name
];
...
...
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