mirror of https://github.com/stella-emu/stella.git
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:
parent
e9a0bee314
commit
5a89990cc1
|
@ -36,12 +36,21 @@ void EventHandlerSDL2::initializeJoysticks()
|
|||
{
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
// 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();
|
||||
for(int i = 0; i < numSticks; ++i)
|
||||
addJoystick(new JoystickSDL2(i), i);
|
||||
if(SDL_NumJoysticks() > 0)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -198,16 +207,16 @@ void EventHandlerSDL2::pollEvent()
|
|||
handleSystemEvent(EVENT_WINDOW_FOCUS_LOST);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break; // SDL_WINDOWEVENT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
|
||||
: myStick(NULL)
|
||||
{
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
myStick = SDL_JoystickOpen(idx);
|
||||
if(myStick)
|
||||
{
|
||||
|
@ -215,13 +224,15 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
|
|||
SDL_JoystickNumAxes(myStick), SDL_JoystickNumButtons(myStick),
|
||||
SDL_JoystickNumHats(myStick), SDL_JoystickNumBalls(myStick));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventHandlerSDL2::JoystickSDL2::~JoystickSDL2()
|
||||
{
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
if(myStick)
|
||||
SDL_JoystickClose(myStick);
|
||||
myStick = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ class EventHandlerSDL2 : public EventHandler
|
|||
private:
|
||||
SDL_Event myEvent;
|
||||
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
// A thin wrapper around a basic StellaJoystick, holding the pointer to
|
||||
// the underlying SDL stick.
|
||||
class JoystickSDL2 : public StellaJoystick
|
||||
|
@ -80,7 +79,6 @@ class EventHandlerSDL2 : public EventHandler
|
|||
private:
|
||||
SDL_Joystick* myStick;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,13 +42,14 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
|
|||
myDblBufferedFlag(true)
|
||||
{
|
||||
// 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;
|
||||
buf << "ERROR: Couldn't initialize SDL: " << SDL_GetError() << endl;
|
||||
myOSystem.logMessage(buf.str(), 0);
|
||||
return;
|
||||
}
|
||||
myOSystem.logMessage("FrameBufferSDL2::FrameBufferSDL2 SDL_Init()", 2);
|
||||
|
||||
// We need a pixel format for palette value calculations
|
||||
// It's done this way (vs directly accessing a FBSurfaceSDL2 object)
|
||||
|
|
|
@ -105,7 +105,6 @@ class MediaFactory
|
|||
{
|
||||
return new EventHandlerSDL2(osystem);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue