Sunday, July 27, 2008

The return of Joystick support!

One of the nicest things about DirectInput is that it uses largely the same code for all devices. This means that once you have the basic code done for one device, it's utterly trivial to add in the extra you need for another. One day, MHQuake may support steering wheels, Wii-style controllers, and so on, all with about 20 extra lines of code each.

Anyway, one of the first things I removed from MHQuake was Joystick support. Today I added it back in a DirectInput stylee. It took literally 10 minutes to do. I've decided not to get too fancy with this, so I'm only using the basic Joystick device, but as that supports up to 32 buttons it should be sufficient (the DIJOYSTATE2 struct supports up to 128 buttons, but unfortunately the basic Quake Input subsystem won't be happy with that!)

I don't have a Joystick to test it on however, so this should be considered as very experimental code. Once I find a nice cheap and cheerful USB device, I'll finish things off and add in the cvars. Oh yeah, and because DirectInput is a standardised interface, I can make these archive cvars too! Who knows, I might even add force feedback!

0 comments: