The Abandon Wars

Wednesday, March 31, 2010

Hey! It's an update. I've been off one of my fairly standard tangents(tm) and gone and written a general input library because I dislike every other input library I've ever used. You might have realised this by now, I've ranted about it enough.

The problem is that most windows (game related) input libraries are thin, pointless wrappers around DirectInput. Now DirectInput is pretty cool in many regards but it has 2 major failings. It only supports one keyboard and mouse and it doesn't support XBox 360 controllers properly. The lack of multiple mouse support has been a bug in DirectX in every Windows version after '95 - I'm not sure why it's never been fixed :(. The lack of XBox controller support is more insidious; Microsoft have deprecated support for DirectInput in favour of XInput. XInput is, unfortunately, a steaming pile of poo. It supports only the XBox controller; it's hard coded to 4 of them and it's also hard coded the inputs - there can be no support for any future game controllers without a new version and a recompile.

So XInput is technically deficient, looks like it was coded by a 3 year old, and doesn't support non-Microsoft certified devices. And there's my other big issue with it. It looks like a ploy by Microsoft to corner the hardware controller market; if developers stop supporting DirectInput then only XInput certified devices will work. Not cool but understandable from Microsoft's perspective - DirectInput doesn't generate revenue for them whereas I suspect XInput does at least enough to cover it's development.

I tried avoiding the DirectInput/XInput fiasco completely by using WinRaw and WinJoystick directly (they're lower level libraries but are curiously more usable) but that still didn't solve the XBox controller issue. I even tried querying the XBox Controller using it's mini-HID driver but still no joy. It's support is hidden behind even the HID driver and that is curious indeed. It means that someone has gone to an awful lot of effort to hide support for the XBox Controller from every input library other than XInput. It's not something that could have happened accidentally.

But that's enough ranting. What I've done is written a thick wrapper around all the different input libraries and consolidated their different types of output into one consistent event based stream. This means that pressing a button (or whatever) on any* joystick, keyboard, mouse etc... on the system is reported in the same way and the game built on top of the library doesn't need to know how the different input libraries function and interact (there's some nasty duplication and cross-talk between them).

Instead of having to write firing the primary weapon as If 'XBox Button A' or 'Joystick Button 0' or 'Keyboard Left Ctrl' or 'Mouse Button Left' then then Fire I just write a method called Fire and it will be activated by whatever button the players bound to it. This makes my life much, much simpler now although maybe not everyone is going to appreciate that I took five/six months to write this because if I'd hacked out the code for Star Control I'd have been done more than a year ago :).

And here's a picture of my desk. Lot's and lots of lovely input devices (there are more keyboards and mouses on the shelf under it. For testing I've added two 4 port usb hubs inside the case - the wires and dongles behind the chair - but was still unable to plug in everything.


*Wii-motes not included yet although I can read from them. Parallel- and game-port joystick also don't work and it's unlikely I'll ever bother. MIDI devices are also not included yet so you won't be able to play Star Control on your piano keyboard. You'll deal.

2 Comments:

  • I know this is a very late comment, but I just noticed a missing controller: Where is the steering wheel with pedals?! What if I want to steer Star Control around? ;-)

    Ciao and good luck :-)

    By Blogger Unknown, at 9:33 am  

  • Seriously, I want to get a Logitech G26 or similar and find out how it's reported. Also the G940 flight system. 'course someone may need to donate those. They're a bit expensive.

    By Blogger Andrew, at 5:06 pm  

Post a Comment

<< Home