Game Development Reference
In-Depth Information
Having played tons of console games, I already had a pretty good feel for a good
control scheme, but I ' d never had the chance to write one myself. The basics of the
gamepad interface code are really quite the same as a mouse, keyboard, or joystick,
but subtle differences between interface design and interpreting the device inputs
warrant some additional explanation. I
ll talk a little about dead zones, normalizing
input, input acceleration, and the design impact of one-stick versus two-stick control
schemes.
'
Dead Zones
A dead zone is any area of a control interface that has no input effect. This keeps
small errors in hand movement from adversely affecting game input. You know you
need a dead zone in a control when you watch players make mistakes because the
controls were too sensitive and interpreted their input in a way that they didn
'
t
expect.
A great example of this was on the Thief: Deadly Shadows camera control for the
Xbox gamepad. It used a two-stick control scheme like Halo or Splinter Cell, which
meant that the character moved with the left thumbstick and the camera moved with
the right thumbstick.
The first iteration of the camera movement code was pretty simple; the right thumb-
stick controlled the camera. Up/down movement caused the camera to pitch, and
left/right movement caused the camera to yaw. The speed of movement was coded
directly to how far the thumbstick was moved. But when I went to QA and watched
them play, I noticed something really strange happening. As the QA person would
spin the camera left or right, the camera would also pitch a few degrees up or
down. This happened every time in QA, but not with me as I tested the code.
I watched QA play more to try to figure out what was happening, and I realized that
when they were actually playing the game, they
d jam the left thumbstick left or right
to see if something was behind them, and it was a pretty fast movement. Once the
thumbstick hit the extreme position, it would stop, of course, but it would usually
also be in a slightly up or down angle as well as all the way left or right. In my
tests, I wasn
'
t jamming the controller, and thus I never had the slight up/down posi-
tion. Even though it was small, the up/down error in the thumbstick movement
always resulted in the camera pitching up/down, just as I wrote the code.
Figure 9.2 shows the movement area of a thumbstick controller on a gamepad. By
convention, gamepads, joysticks, and other two-axis controllers usually have raw out-
put ranges from [
'
1.0f, 1.0f], and the neutral position returns a raw output value of
(0.0f, 0.0f). Every now and then, you might find a control device returning odd
 
 
Search WWH ::




Custom Search