diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 355af746a..f5911a162 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -37,15 +37,12 @@ void EventHandlerSDL2::initializeJoysticks() { #ifdef JOYSTICK_SUPPORT // Initialize the joystick subsystem - if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) || (SDL_NumJoysticks() <= 0)) + if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) && (SDL_NumJoysticks() > 0)) { - myOSystem->logMessage("No joysticks present.", 1); - return; + int numSticks = SDL_NumJoysticks(); + for(int i = 0; i < numSticks; ++i) + addJoystick(new JoystickSDL2(i), i); } - - int numSticks = SDL_NumJoysticks(); - for(int i = 0; i < numSticks; ++i) - addJoystick(new JoystickSDL2(i), i); #endif } diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 2ab9974fb..290af5045 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -130,8 +130,13 @@ void EventHandler::initialize() ostringstream buf; buf << "Joystick devices found:" << endl; - for(uInt32 i = 0; i < myJoysticks.size(); ++i) - buf << " " << i << ": " << myJoysticks[i]->about() << endl << endl; + if(myJoysticks.size() == 0) + buf << "No joysticks present." << endl; + else + { + for(uInt32 i = 0; i < myJoysticks.size(); ++i) + buf << " " << i << ": " << myJoysticks[i]->about() << endl; + } myOSystem->logMessage(buf.str(), 1); #else myOSystem->logMessage("Joystick support disabled.", 1);