Joystick Support in PrBoom 2.5.0
Posted by postfuturist on 2009-04-25 13:08:22

PrBoom is a fairly conservative port of the original Doom source code for modern computers. It is very stable, incorporates a lot of improvements and additions to the Doom engine from other ports. It has one shortcoming, however. The joystick support is awful. You can only use the first four buttons on your joystick in a fixed configuration and one pair of axes for walking forward and backward and turning. This makes playing the game with a joystick not a compelling experience.
I recently picked up a Logitech Dual Action USB game controller. It's a fantastic controller, especially for the sub $20 range. It is in a standard modern console configuration with a D-Pad, two analog sticks, and 12 buttons (4 face buttons, 4 trigger buttons, "start" and "select" style buttons, and two buttons activated by depressing the analog sticks). The joystick is perfect for using with console emulators. I am somewhat more of a console gamer than a traditional PC gamer. I enjoy the modern game controller layout quite a bit. I actually enjoy playing first person shooters, like Doom, as much with a good controller as I do with the keyboard/mouse combination.
I decided to do something about the poor joystick / game controller support in PrBoom. Instead of 4 buttons with fixed functions, I changed the code to treat the buttons (as many as you want) as key presses and so can be configured for any function. I also changed the analog stick controls to be in a more modern console style where the left stick is for moving (backward and forward and side to side) while the right stick is for turning. It took a couple hours to get into the source code, figure out what's going on and implement the changes. At first I tried using Code::Blocks as the IDE, but that proved to be an unsatisfactory experience, so I switched over to Netbeans 6.7 M3. Netbeans has fantastic autocomplete support for code written in C. It's basically flawless.
I have a few more changes I'd like to make. I would like to add some configuration for the behavior of the various joystick axes so people can set up the controls however they like. Also, I would like the option of using the various axes like buttons, too. This would allow, for example, using the various directions on the D-Pad for different functions. PrBoom is missing the ability to assign a key/button to cycle through the available weapons. This is not a problem on the keyboard, as there are so many keys, but it is not ideal for a game controller, even one with 12 buttons. The sensitivity of the analog control for movement that I added is linear which turns out to be not ideal for fine-grained aiming and careful movement.
Once I've brought the game controller integration of PrBoom into the 21st century, I will try to get my changes merged upstream with PrBoom.


blog comments powered by Disqus