Playing PC games with a keyboard and mouse can sometimes feel like playing tennis in a tuxedo - entirely possible but not quite right. Wouldn't it be so much cooler to pull out that game pad, joystick, or steering wheel, plug it in, and play games the way that nature intended?
It's not that difficult, as the next two chapters will show. I'll start by giving some background on JInput, an open-source API for game controller discovery and polled input.
I'll explain how to program with JInput by describing three small applications that display information about the input devices attached to your PC. I'll also develop a GamePadController class which offers a simplified interface to my game pad. GamePadController is utilized in two examples: a Swing application called GamePadViewer in this chapter (shown on the right), and a revised version of Arms3D (the articulated arms example from chapter 4) in the next chapter.
Arms3D illustrates how a game pad can enhance the user's playing experience, replacing a confusing mix of keys with more intuitive buttons and sticks. The game pad also allows multiple inputs to be processed at once, so that different parts of the grabber's arms can rotate and move at the same time.