Taking a Look at User Input Devices


Taking a Look at User Input Devices

Input devices are the physical hardware that allows a user to interact with a game. Input devices all perform the same function: converting information provided by the user into a form understandable by the computer. Input devices form the link between the user and your game. Even though you can't directly control the input device hardware, you can certainly control how it is interpreted in your game. As I mentioned earlier, there are three primary types of user input devices:

  • The keyboard

  • The mouse

  • Joysticks

graphics/book.gif

In case you're wondering, trackballs are functionally very similar to mice and are often treated just like mice from a software perspective. In fact, the Win32 API doesn't discern between trackballs and mice, so the mouse support in your games indirectly supports trackballs as well.


The next few sections get you acquainted with these devices and their relationship to game user input.

The Keyboard

The keyboard has been the computer input device of choice since its inception. Although mice, joysticks, flight sticks, and many other user input devices have brought extended input capabilities to the game player, none is as established as the keyboard. At the bare minimum, you can always count on a game player having a keyboard.

The keyboard is a surprisingly useful input device for a wide range of games. The sheer amount of keys alone gives the keyboard appeal for games that require a wide variety of user input. Even more useful in the keyboard is the natural feel of pressing keys for games requiring quick firing and movement. This usefulness is evident in the amount of arcade games that still use buttons, even when powerful digital joysticks are readily available. Keys (or buttons ) simply are easier to use in many games, including those with many input combinations.

When assessing the potential use of the keyboard in a game, try to think in terms of the most intuitive user interface possible. For example, any game involving the player moving an object around would benefit from using the arrow keys. A good example is the classic 3D shooter Doom, which makes creative use of a keyboard-specific feature that greatly enhances the playability of the game. The left and right arrow keys, when used alone, rotate the player left and right in the game world. However, when the Shift key is held down, the same left and right arrow keys cause the player to strafe , meaning that the player moves sideways without changing direction. This seemingly small enhancement to the keyboard controls goes a long way when playing the game.

When you're deciding on specific keys to use for keyboard controls in your game, consider the potential limitations on players using other platforms or hardware configurations. For example, I primarily use a Windows XP PC equipped with a Microsoft Natural keyboard. If you aren't familiar with these keyboards, they are split down the middle for ergonomic reasons. If you don't use one of these keyboards, it might not occur to you that key combinations near the center of the keyboard will be separated a few inches for people like me. So, remember that if you use the G and H keys (or other middle keys) in your game, and it plays well for you, it might not work out so well for players with different keyboards.

The most common keys used in games are the arrow keys. If you're writing an action game, you might also have keys for firing and selecting between weapons. When you're deciding on the keys to use, keep in mind things like the creative usage of the Shift key in Doom. If you can limit the number of primary game control keys by making use of a secondary key such as Shift, you've made the game controls that much easier to use.

The Mouse

Although the keyboard is firmly in place as the most necessary of user input devices, the graphical nature of modern computers establishes the mouse, or a similar pointing device, as a standard input device as well. The mouse, however, doesn't share the wide range of input applications to games that the keyboard has. This stems from its primary usage as a point-and-click device; if you haven't noticed, a lot of games don't follow the point-and-click paradigm.

In regard to gaming, the usefulness of the mouse is dependent totally on the type of game and, therefore, the type of user interaction dictated by the game. However, as quickly as some people write off the mouse as being a useless interface in some games, others praise the fine control it provides. Again, a good example is Doom. Personally, I think the keyboard is much more responsive than the mouse, and the keyboard enables me to get around faster and with more control. But I have friends who feel lost playing the game without a mouse.

Clearly, this is a situation in which the game designers saw a way to provide support for both the keyboard and mouse. With the exception of the most extreme cases, this should be your goal as well. Different game players like different things, and the safest solution is to hedge your bets and support all input devices whenever possible. By following this simple rule, you can develop games that can be appreciated and enjoyed by a broader group of game players.

Joysticks

Although not quite as standard as keyboards and mice, joysticks nonetheless represent a very common component of modern computer systems. Joysticks are in many ways a throwback to video games of old ”many of which relied heavily on joysticks for controlling characters , spaceships, and other game objects. Joysticks come in both digital and analog form, although the difference between the two isn't terribly important from a programming perspective. The primary thing to consider when assessing the role of joysticks in games is whether it makes sense to play the game with a joystick. In other words, does the movement in the game lend itself to being carried out with a vertical stick (or flat game pad), as opposed to using keyboard keys or a mouse? Of course, it's not a bad idea to support multiple input devices ”in which case you might opt to include joystick support just to be flexible.

graphics/book.gif

Most game pads count as joysticks because they provide a similar functionality in terms of providing a multidirectional control for movement, as well as several buttons. From a programming perspective, Windows doesn't distinguish between joysticks and game pads, which is a good thing for you.


It's worth mentioning that some games out there seem to be expressly designed for being played with joysticks. For one, the extremely popular game Halo on the XBox console system uses a unique feature that would be difficult to replicate with a keyboard or mouse. Halo allows you to press the joystick inward to activate a rifle scope on your gun. So, if you see some bad guys off in the distance, you can push in on the joystick to zoom with the scope and pick them off one by one. The scope/zoom feature in Halo is an excellent example of an ingenious game feature made possible by a specific type of input device. Of course, the XBox controller had to include a joystick with the push feature in order for Halo to work, so Microsoft deserves some credit on the hardware side of things.



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net