Workshop The Workshop is designed to help you
by allowing the joystick handle to be pushed and pulled vertically. A fourth axis can be the twisting of the joystick handle. The fifth and sixth axes apply to more advanced input devices, and are typically used for keeping track of moving the entire joystick in space, like an input glove. Because a traditional joystick has only two axes of motion, you can think of the joystick in much the same way as you think of the mouse. Although a mouse can be moved in any direction, its movement is limited to a single plane. In other words, you can always resolve mouse movement into an XY value. Joysticks are similar in this manner because you can identify their movement according to how far the handle is being pushed along each axis. If side to side movement is along the x axis and forward and back movement is along the y axis, a joystick can be tracked in a manner similar to the mouse by using an XY value. Also similar to the mouse are the buttons on a joystick. Just as mice are capable of supporting multiple buttons (typically three), joysticks are also capable of having several buttons. In fact, joysticks are much more flexible than mice in terms of how many buttons they can have; joysticks in Windows are allowed to have up to 32 buttons. I personally wouldn’t want to try and figure out how to use a joystick with that many buttons, but the option is there if someone wants to make a joystick for super humans. A more realistic number for joystick buttons is six, which is still a lot to keep track of for the average game player. Similar to mouse button presses and keyboard key presses, handling joystick button presses is relatively straightforward, as you learn a little later in the hour. Calibrating Joysticks Before getting into the details of how to handle joystick input from a programming perspective, it’s worth addressing an important issue related to joysticks: calibration. Calibration is the process of fine-tuning the settings for a joystick so that the handle is properly centered. Joystick calibration is kind of like having your car aligned; when a joystick isn’t properly calibrated, it has a tendency to pull to one side. Fortunately, joystick calibration is easy to perform, and is readily available from the Windows Control Panel. To access joystick settings, just follow these steps in Windows XP: 1. Click the Start button, and select Control Panel. 2. Click Printers and Other Hardware. 3. Click Game Controllers. 4. Select the joystick (game controller) to calibrate, and then click the Properties button. Even if you aren’t using Windows XP, you’ll still find some kind of joystick or controller icon in the Control Panel for calibrating and testing your game controllers. The specifics of calibrating your joystick might be a little different from the steps I’ve listed, but the general idea is the same. After following these steps, you’ll be presented with a window that is specific to your particular joystick. In my case, I’m using a Microsoft SideWinder game pad, so the window I see is shown in Figure 7.1. Figure 7.1. The Properties window for your joystick should provide a means of calibrating the joystick. To calibrate my joystick (game pad), I just click the Calibrate button. This starts the Device Calibration Wizard, which is shown in Figure 7.2. Figure 7.2. The Device Calibration Wizard provides a means of calibrating joysticks in Windows XP. Click the Next button to get started calibrating the joystick (see Figure 7.3). Figure 7.3. Calibrating a joystick first involves pressing a button on the joystick without touching the joystick handle (or control pad for game pads). The first step in calibrating a joystick is to leave the handle centered and press a button, as shown in Figure 7.3. In the case of a game pad, you simply don’t touch the control pad (D-Pad) and then press a button. You are then prompted to calibrate the axes of
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services