Xinput / DirectInput xbox360 controller support

Roderick Colenbrander thunderbird2k at
Thu Jun 17 21:21:36 CDT 2010

On Thu, Jun 17, 2010 at 7:03 PM, Vitaliy Margolen
<wine-devel at> wrote:
> On 06/16/2010 12:59 PM, Roderick Colenbrander wrote:
>> 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
> IMHO directly accessing joysticks via evdev would be the best way. DInput is
> a mess you don't want to deal with it (both in and out). And as you noted it
> doesn't implement everything you need for xinput.
> Using Xorg for joystick enumeration seems to be like a good idea, except it
> won't really help you much. You'll still have to find which evdev you have
> to talk to, get all the joystick parameters, settings, etc. You won't get
> all that info from xorg.
> Vitaliy.

It looks like on Windows xinput also directly access the USB device
(the hardware buffer directly maps onto the xinput datatypes). In the
far away future once we have WMI it might make sense to use that in
both xinput and dinput to enumerate devices (I wouldn't be surprised
if dinput used that internally these days and perhaps dxdiag and other
dlls use it as well).

As I mentioned the xinput API is really basic but for my liking it is
slightly too basic. What I don't like is that there is no function to
open the device (it is all about XInputGetState and also about
XInputSetKeyStroke which is needed for force feedback). Right now I'm
opening/closing the file descriptor each call and I don't like that.
You also can't keep them open because xinput allows hotplugging :( Not
sure if this is going to be an issue though.

If we really wanted we might be able to layer xinput on top of dinput
(we would need a private property for the force feedback part) but I
think it would cause all sorts of issues and the APIs don't match well
at all. Some people attempted to do this already to support non-xbox
joysticks in xinput but it has issues (I think they have issues with


More information about the wine-devel mailing list