Hey looky! It's an actual honest to goodness update**.
I've pretty much completed the input library that I alluded to in a previous post. It might not seem Star Control related (and in many ways it's not) however I have a pretty extreme dislike of 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.
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 certainly not something that could have happened accidentally.
*Rant ends and interesting stuff starts here...*
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
*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.
**I still need to post more about network play, the starmap and the AI opponents but I've already written to much in a single post. Expect more later.