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
// 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
}

View File

@ -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);