Add some extra logging to SDL Init and joystick handling, in an attempt

to debug joystick issues that some users are having.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2977 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-08-15 15:13:00 +00:00
parent e9a0bee314
commit 5a89990cc1
4 changed files with 20 additions and 11 deletions

View File

@ -36,12 +36,21 @@ void EventHandlerSDL2::initializeJoysticks()
{ {
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
// Initialize the joystick subsystem // Initialize the joystick subsystem
if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) && (SDL_NumJoysticks() > 0)) if(SDL_WasInit(SDL_INIT_JOYSTICK) != 0)
{ {
int numSticks = SDL_NumJoysticks(); if(SDL_NumJoysticks() > 0)
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);
myOSystem.logMessage("EventHandlerSDL2::initializeJoysticks() +sticks", 2);
}
else
myOSystem.logMessage("EventHandlerSDL2::initializeJoysticks() -sticks", 2);
} }
else
myOSystem.logMessage("EventHandlerSDL2::initializeJoysticks() failed!", 2);
#endif #endif
} }
@ -198,16 +207,16 @@ void EventHandlerSDL2::pollEvent()
handleSystemEvent(EVENT_WINDOW_FOCUS_LOST); handleSystemEvent(EVENT_WINDOW_FOCUS_LOST);
break; break;
} }
break; break; // SDL_WINDOWEVENT
} }
} }
} }
#ifdef JOYSTICK_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx) EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
: myStick(NULL) : myStick(NULL)
{ {
#ifdef JOYSTICK_SUPPORT
myStick = SDL_JoystickOpen(idx); myStick = SDL_JoystickOpen(idx);
if(myStick) if(myStick)
{ {
@ -215,13 +224,15 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
SDL_JoystickNumAxes(myStick), SDL_JoystickNumButtons(myStick), SDL_JoystickNumAxes(myStick), SDL_JoystickNumButtons(myStick),
SDL_JoystickNumHats(myStick), SDL_JoystickNumBalls(myStick)); SDL_JoystickNumHats(myStick), SDL_JoystickNumBalls(myStick));
} }
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerSDL2::JoystickSDL2::~JoystickSDL2() EventHandlerSDL2::JoystickSDL2::~JoystickSDL2()
{ {
#ifdef JOYSTICK_SUPPORT
if(myStick) if(myStick)
SDL_JoystickClose(myStick); SDL_JoystickClose(myStick);
myStick = NULL; myStick = NULL;
}
#endif #endif
}

View File

@ -68,7 +68,6 @@ class EventHandlerSDL2 : public EventHandler
private: private:
SDL_Event myEvent; SDL_Event myEvent;
#ifdef JOYSTICK_SUPPORT
// A thin wrapper around a basic StellaJoystick, holding the pointer to // A thin wrapper around a basic StellaJoystick, holding the pointer to
// the underlying SDL stick. // the underlying SDL stick.
class JoystickSDL2 : public StellaJoystick class JoystickSDL2 : public StellaJoystick
@ -80,7 +79,6 @@ class EventHandlerSDL2 : public EventHandler
private: private:
SDL_Joystick* myStick; SDL_Joystick* myStick;
}; };
#endif
}; };
#endif #endif

View File

@ -42,13 +42,14 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
myDblBufferedFlag(true) myDblBufferedFlag(true)
{ {
// Initialize SDL2 context // Initialize SDL2 context
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) < 0)
{ {
ostringstream buf; ostringstream buf;
buf << "ERROR: Couldn't initialize SDL: " << SDL_GetError() << endl; buf << "ERROR: Couldn't initialize SDL: " << SDL_GetError() << endl;
myOSystem.logMessage(buf.str(), 0); myOSystem.logMessage(buf.str(), 0);
return; return;
} }
myOSystem.logMessage("FrameBufferSDL2::FrameBufferSDL2 SDL_Init()", 2);
// We need a pixel format for palette value calculations // We need a pixel format for palette value calculations
// It's done this way (vs directly accessing a FBSurfaceSDL2 object) // It's done this way (vs directly accessing a FBSurfaceSDL2 object)

View File

@ -105,7 +105,6 @@ class MediaFactory
{ {
return new EventHandlerSDL2(osystem); return new EventHandlerSDL2(osystem);
} }
}; };
#endif #endif