There are a couple of videos going around on Youtube where a standard USB gamepad is being used to control a CNC milling machine. This seemed a really neat idea, so I decided to give it a bash with my own setup, which is a Sherline mill plus LinuxCNC.
The gamepad itself is a knockoff of the Sony Dualshock. These are widely available on EBay for around £10-£12. Some are bluetooth, but I went for a USB wired version. Never having used one before, I didn't quite realise how they worked, but it turns out they are recognized as a standard input device by the OS and don't need any drivers.
I'm using LinuxCNC v2.5 on Ubuntu 10.04 Lucid Lynx, installed using the LiveCD from the LinuxCNC website at http://linuxcnc.org/. It is possible to actually go into the LinuxCNC configuration and add the gamepad directly, so LinuxCNC itself recognises it, but I barely understand LinuxCNC enough, so I went down the route of using a mapping program to map gamepad presses to keyboard presses, since all the LinuxCNC functions can be controlled with keyboard shortcuts. As a result, what follows could be used wherever you want to control a program using a gamepad.
The mapping software I'm using is called QJoyPad - the website is http://qjoypad.sourceforge.net/ (there are others, I'll mention them at the end). You can either try downloading the source code and compiling it from QJoyPad's own site (I had no luck with this, but my Linux skills are pretty basic), or you can download a Debian binary from http://archive.getdeb.net/getdeb/ubuntu/pool/games/q/qjoypad/. I used the latter option, and had no trouble installing. I have mirrored the Debian packages here - i386 version, amd64 version. Just download the package, double-click it, and the package installer will open and install it. Once installed, the program is available under Applications -> Accessories -> QJoyPad.
The prorgram is capable of mapping all of the buttons and axes to corresponding keyboard or mouse events. The quick set feature lets you press a button on the gamepad, then the corresponding key on the keyboard, making setup easy. Just have QJoyPad running, then start up LinuxCNC (or whatever program you want to control), and you're away. The last photo shows the various keyboard shotcuts for LinuxCNC and the open QJoyPad config dialog.
Here is a list of other similar mapping software for both Windows and Linux:
While we're at it, if you need a good utility for calibrating a gamepad (e.g. you find it's too responsive in a game), try DXTweak2 from http://www.wingmanteam.com/latest_software/gadgets.htm.