Xinput / DirectInput xbox360 controller support

Roderick Colenbrander thunderbird2k at gmail.com
Wed Jun 16 13:59:26 CDT 2010


Hi all,

I'm interested in adding Xbox 360 controller support to Wine. For
people who don't know how this works and what's so special I will
first give a small introduction.

The Xbox 360 controller is a normal USB device which you can use from
'xinput*.dll' (typically xinput1_3.dll is used). The xinput API is
very easy (and it is the same what is used on the Xbox360) and in
total it exports a handful of functions. Basically there is a call to
query the capabilities, a call to poll which button was pressed and a
call to 'set the controller to a certain state' (rumble stuff) and a
few other not so important calls. The dll can ONLY be used for xbox
360 compatible controllers and other controllers should use dinput.

In Wine we have a stubbed xinput implementation. Last year Michael
Gruber submitted a number of patches which added implementations for
most calls but the code wasn't added. I tested his XInput code on
current Wine and it actually works well in DirectX SDK examples
including force feedback! After he submitted the code there was a
short discussion on wine-devel but then it stopped. Michael his xinput
code directly interfaces with the Linux input event interface. It was
asked whether XInput can't be layered on top of DirectInput but that's
not possible since DirectInput doesn't expose all the needed
functionality (it doesn't support the Xbox360 force feedback). The
other way around is also not possible because XInput is only for Xbox
360 controllers/joysticks while DirectInput also supports keyboard and
mouse.

I'm wondering how to proceed with XInput. My main issue is the
'joystick access part'. Would it be fine to directly access the
controller from Xinput (so we would need multiple hardware backends
later on). Code size won't be a problem though since XInput doesn't
support much functionality at all (the current mostly working version
is less than 500 lines of code; half of that is for the Linux
backend). One small issue is though that DirectInput and XInput might
have to cooperate since typically games use DirectInput to enumerate
all joysticks, see for instance
http://msdn.microsoft.com/en-us/library/ee417014%28VS.85%29.aspx

Roderick



More information about the wine-devel mailing list