Game Development Reference
In-Depth Information
Figure 23-2. Pressure-sensitive button
By measuring this increase in current, the controller knows how far down the button
is being pressed. In State D in Figure 23-2 , the button is at its limit of travel and the
dome has deflected to its maximum contact area. The difference between this maximum
and the minimum required to detect contact determines the absolute lowest and highest
pressure the button is able to differentiate. For instance, let us assume that if the button
were depressed completely, the current would register at I max . If the button were not
pressed at all, of course, the current would be 0. If we call the current I ( t ) for any time,
t , we see that the ratio I ( t )/ I max gives a nondimensional quantity for how far down the
button is pressed. During this operation, the hardware converts the analog voltage to a
digital representation suitable for input to a program. For the Sony example, this value
is calculated by the hardware and passed as part of the data stream from the controller
with hex values between 0x00 to 0xFF, or in other words, integers 0 to 255 in decimal.
This means that each button's travel is divided into 255 parts that your program can
register.
While 255 individual increments are beyond the human ability to control fingertip
pressure, different ranges of pressure have practical uses in games. For example, you
could program your button to raise a weapon with a half-press (0 to 127), bring the
weapon to the shoulder with more pressure (127 to 250), and to fire when totally de‐
pressed (250 to 255). Of course, those values would have to be tuned for the desired