Fixed joystick messages, to properly indicate when no joysticks are present.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2866 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-03-07 18:19:09 +00:00
parent 90fbea8286
commit 81347af093
2 changed files with 11 additions and 9 deletions

View File

@ -37,15 +37,12 @@ void EventHandlerSDL2::initializeJoysticks()
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// Initialize the joystick subsystem // 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); int numSticks = SDL_NumJoysticks();
return; 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 #endif
} }

View File

@ -130,8 +130,13 @@ void EventHandler::initialize()
ostringstream buf; ostringstream buf;
buf << "Joystick devices found:" << endl; buf << "Joystick devices found:" << endl;
for(uInt32 i = 0; i < myJoysticks.size(); ++i) if(myJoysticks.size() == 0)
buf << " " << i << ": " << myJoysticks[i]->about() << endl << endl; 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); myOSystem->logMessage(buf.str(), 1);
#else #else
myOSystem->logMessage("Joystick support disabled.", 1); myOSystem->logMessage("Joystick support disabled.", 1);