Game Engine Architecture

(Ben Green) #1

350 8. Human Interface Devices (HID)


translate into smooth, pleasing, intuitive behaviors in-game. In addition, most
engines introduce at least one additional level of indirection between the HID
and the game in order to abstract HID inputs in various ways. For example, a
butt on-mapping table might be used to translate raw butt on inputs into logi-
cal game actions, so that human players can re-assign the butt ons’ functions
as they see fi t. In this section, we’ll outline the typical requirements of a game
engine HID system and then explore each one in some depth.

8.5.1. Typical Requirements
A game engine’s HID system usually provides some or all of the following
features:
z dead zones,
z analog signal fi ltering,
z event detection (e.g., butt on up, butt on down),
z detection of butt on sequences and multibutt on combinations (known as
chords),
z gesture detection,
z management of multiple HIDs for multiple players,
z multiplatform HID support,
z controller input re-mapping,
z context-sensitive inputs,
z the ability to temporarily disable certain inputs.

8.5.2. Dead Zone
A joystick, thumb stick, shoulder trigger, or any other analog axis produces
input values that range between a predefi ned minimum and maximum value,
which we’ll call Imin and Imax. When the control is not being touched, we would
expect it to produce a steady and clear “undisturbed” value, which we’ll call
I 0. The undisturbed value is usually numerically equal to zero, and it either
lies half-way between Imin and Imax for a centered, two-way control like a joy-
stick axis, or it coincides with Imin for a one-way control like a trigger.
Unfortunately, because HIDs are analog devices by nature, the voltage pro-
duced by the device is noisy, and the actual inputs we observe may fl uctuate
slightly around I 0. The most common solution to this problem is to introduce a
small dead zone around I 0. The dead zone might be defi ned as [I 0 – δ , I 0 + δ] for
a joy stick, or [I 0 , I 0 + δ] for a trigger. Any input values that are within the dead
zone are simply clamped to I 0. The dead zone must be wide enough to account
Free download pdf