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
merged 2 commits into from Jun 1, 2012

Conversation

Projects
None yet
5 participants
Member

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.

Contributor

DDDamian commented May 17, 2012

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

Member

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.

Member

elupus commented May 17, 2012

+1 for anything that rid us of SDL

Member

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?

Member

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

xbmc/input/windows/WINJoystick.cpp
+ }
+
+ for(std::vector<LPDIRECTINPUTDEVICE8>::iterator it = m_pJoysticks.begin(); it != m_pJoysticks.end(); ++it)
+ {
+ LPDIRECTINPUTDEVICE8 pJoy = (*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

CrystalP May 18, 2012

Contributor

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

wsoltys May 18, 2012

Member

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

Member

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
7ce8254

@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
6545c94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment