@ -15,7 +15,7 @@ JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, in
@@ -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
@@ -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
@@ -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 {