Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
f1b82fb9
Commit
f1b82fb9
authored
Jan 20, 2017
by
Don Gagne
Committed by
GitHub
Jan 20, 2017
Browse files
Merge pull request #4452 from NaterGator/sdlerr
SDL: warn with SDL error string when joystick feature detection fails
parents
bd11543d
3907cd09
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Joystick/JoystickManager.cc
View file @
f1b82fb9
...
...
@@ -53,7 +53,10 @@ void JoystickManager::setToolbox(QGCToolbox *toolbox)
_multiVehicleManager
=
_toolbox
->
multiVehicleManager
();
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
}
void
JoystickManager
::
discoverJoysticks
()
{
#ifdef __sdljoystick__
_name2JoystickMap
=
JoystickSDL
::
discover
(
_multiVehicleManager
);
#elif defined(__android__)
...
...
src/Joystick/JoystickManager.h
View file @
f1b82fb9
...
...
@@ -48,6 +48,9 @@ public:
// Override from QGCTool
virtual
void
setToolbox
(
QGCToolbox
*
toolbox
);
public
slots
:
void
discoverJoysticks
();
signals:
void
activeJoystickChanged
(
Joystick
*
joystick
);
void
activeJoystickNameChanged
(
const
QString
&
name
);
...
...
src/Joystick/JoystickSDL.cc
View file @
f1b82fb9
...
...
@@ -15,7 +15,7 @@ JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, in
QMap
<
QString
,
Joystick
*>
JoystickSDL
::
discover
(
MultiVehicleManager
*
_multiVehicleManager
)
{
static
QMap
<
QString
,
Joystick
*>
ret
;
if
(
SDL_InitSubSystem
(
SDL_INIT_GAMECONTROLLER
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
if
(
SDL_InitSubSystem
(
SDL_INIT_GAMECONTROLLER
|
SDL_INIT_JOYSTICK
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
qWarning
()
<<
"Couldn't initialize SimpleDirectMediaLayer:"
<<
SDL_GetError
();
return
ret
;
}
...
...
@@ -33,7 +33,7 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
int
axisCount
,
buttonCount
,
hatCount
;
bool
isGameController
;
SDL_Joystick
*
sdlJoystick
=
SDL_JoystickOpen
(
i
);
if
(
SDL_IsGameController
(
i
))
{
isGameController
=
true
;
axisCount
=
SDL_CONTROLLER_AXIS_MAX
;
...
...
@@ -41,13 +41,21 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
hatCount
=
0
;
}
else
{
isGameController
=
false
;
axisCount
=
SDL_JoystickNumAxes
(
sdlJoystick
);
buttonCount
=
SDL_JoystickNumButtons
(
sdlJoystick
);
hatCount
=
SDL_JoystickNumHats
(
sdlJoystick
);
if
(
SDL_Joystick
*
sdlJoystick
=
SDL_JoystickOpen
(
i
))
{
SDL_ClearError
();
axisCount
=
SDL_JoystickNumAxes
(
sdlJoystick
);
buttonCount
=
SDL_JoystickNumButtons
(
sdlJoystick
);
hatCount
=
SDL_JoystickNumHats
(
sdlJoystick
);
if
(
axisCount
<
0
||
buttonCount
<
0
||
hatCount
<
0
)
{
qCWarning
(
JoystickLog
)
<<
"
\t
libsdl error parsing joystick features:"
<<
SDL_GetError
();
}
SDL_JoystickClose
(
sdlJoystick
);
}
else
{
qCWarning
(
JoystickLog
)
<<
"
\t
libsdl failed opening joystick"
<<
qPrintable
(
name
)
<<
"error:"
<<
SDL_GetError
();
continue
;
}
}
SDL_JoystickClose
(
sdlJoystick
);
qCDebug
(
JoystickLog
)
<<
"
\t
"
<<
name
<<
"axes:"
<<
axisCount
<<
"buttons:"
<<
buttonCount
<<
"hats:"
<<
hatCount
<<
"isGC:"
<<
isGameController
;
ret
[
name
]
=
new
JoystickSDL
(
name
,
qMax
(
0
,
axisCount
),
qMax
(
0
,
buttonCount
),
qMax
(
0
,
hatCount
),
i
,
isGameController
,
_multiVehicleManager
);
}
else
{
...
...
src/QGCApplication.cc
View file @
f1b82fb9
...
...
@@ -429,6 +429,9 @@ bool QGCApplication::_initForNormalAppBoot(void)
// Load known link configurations
toolbox
()
->
linkManager
()
->
loadLinkConfigurationList
();
// Probe for joysticks - TODO: manage on a timer or use events to deal with hotplug
toolbox
()
->
joystickManager
()
->
discoverJoysticks
();
if
(
_settingsUpgraded
)
{
settings
.
clear
();
settings
.
setValue
(
_settingsVersionKey
,
QGC_SETTINGS_VERSION
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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