Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[WIN32] replace SDL Joystick by DirectInput #972

merged 2 commits into from Jun 1, 2012


None yet
5 participants

wsoltys commented May 17, 2012

There're three reasons why this was done:

  1. the old and deprecated joystick interface used in SDL seems to have problems with newer joysticks like the x360. Also a native implementation with the old interface showed a lot of crashes.
  2. a further step to get rid of SDL
  3. see 2)

I dunno what to do with HAS_SDL_JOYSTICK. It also guards generic joystick code which I'll need with directinput as well. Currently I just left it in and only ifdef'ed the SDL_Joystick init out.

I also had to place the g_Joystick.Initialize() after the window creation as I need the window handle in order to set the cooperative level. Please review if this could cause problems somehow.


DDDamian commented May 17, 2012

+1 to DirectInput here - clearly it's the preferred interface


wsoltys commented May 17, 2012

btw I locally changed the WINJoystick files to unix style line endings but git found nothing to commit. I assume this needs to be handled afterwards by someone on Linux if needed.


elupus commented May 17, 2012

+1 for anything that rid us of SDL


jmarshallnz commented May 18, 2012

Nice - other than the fact that it could be squashed down to one commit (the fixups) it looks fine.

The HAS_SDL_JOYSTICK thing needs to be sorted at some point. eg ButtonTranslator probably doesn't need it at all - IIRC it uses only the #define's. That could happen later though?


wsoltys commented May 18, 2012

I reshuffled the includes and put them where they needed. Would be good if Linux/OSX could test it as well.

@jmarshallnz: I've replaced the statics as I don't think they're needed. Could you please review again and have a look if I don't have an error in reasoning here?

@CrystalP CrystalP commented on the diff May 18, 2012

+ }
+ for(std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_pJoysticks.begin(); it != m_pJoysticks.end(); ++it)
+ {
+ // Enumerate the joystick objects. The callback function enabled user
+ // interface elements for objects that are found, and sets the min/max
+ // values property for discovered axes.
+ if( FAILED( hr = pJoy->EnumObjects( EnumObjectsCallback, pJoy, DIDFT_ALL ) ) )
+ CLog::Log(LOGDEBUG, __FUNCTION__" : Failed to enumerate objects");
+ }
+ m_JoyId = -1;
+ // Set deadzone range
+ SetDeadzone(g_advancedSettings.m_controllerDeadzone);

CrystalP May 18, 2012


Is it possible to access the system deadzone/calibration settings through Direct Input? I think it would be better when the user doesn't explicitely want to override with an advanced setting.


wsoltys May 18, 2012


Yes its possible. I just wanted to keep it as simple as possible and kept it to mimic the old behavior. it can be changed later if someone wants it but I thought to not spend more time than needed on a feature which only a few may use ;)


jmarshallnz commented May 18, 2012

@wsoltys those look good, yeah. There's still two statics left in the GetAxis stuff.

@wsoltys wsoltys was assigned May 29, 2012

@wsoltys wsoltys added a commit that referenced this pull request Jun 1, 2012

@wsoltys wsoltys Merge pull request #972 from wsoltys/native_joystick
[WIN32] replaced SDL Joystick by DirectInput

@wsoltys wsoltys merged commit 7ce8254 into xbmc:master Jun 1, 2012

@tru tru added a commit to plexinc/plex-home-theater-public that referenced this pull request Jan 17, 2014

@tru tru Bah, fix Property("PlexPreplay") correctly.
Fixes #972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment