Skip to content

Instantly share code, notes, and snippets.

@invisiblek
Created October 7, 2016 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invisiblek/6a0196dcf71643034d0e9ba3f36895ea to your computer and use it in GitHub Desktop.
Save invisiblek/6a0196dcf71643034d0e9ba3f36895ea to your computer and use it in GitHub Desktop.
diff --git a/xbmc/input/SDLJoystick.cpp b/xbmc/input/SDLJoystick.cpp
index b1e71e1..757effda 100644
--- a/xbmc/input/SDLJoystick.cpp
+++ b/xbmc/input/SDLJoystick.cpp
@@ -391,6 +391,7 @@ float CJoystick::SetDeadzone(float val)
bool CJoystick::ReleaseJoysticks()
{
+ int count = 0;
// close open joysticks
for (std::map<int, SDL_Joystick*>::const_iterator it = m_Joysticks.begin(); it != m_Joysticks.end(); ++it)
SDL_JoystickClose(it->second);
@@ -399,8 +400,14 @@ bool CJoystick::ReleaseJoysticks()
Reset();
// Restart SDL joystick subsystem
- SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
- if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0)
+ while (SDL_WasInit(SDL_INIT_JOYSTICK) != 0 && count < 10)
+ {
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
+ sleep(1);
+ count++;
+ }
+
+ if (count == 10)
{
CLog::Log(LOGERROR, "Stop joystick subsystem failed");
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment