Game Development Reference
In-Depth Information
and the
RightThumbX
and
RightThumbY
properties for the right stick. Note that
the range for joystick axis values in XInput is always
-32,768
to
32,767
.
You also may have noticed that we didn't add properties to the user input class to
provide access to our joystick objects. They would be just as simple as the prop-
erties we added in this chapter, so they've simply been omitted from the chapter
to save space. They are, however, included in the downloadable code for this
chapter. Also included are a bunch of joystick handling methods for XInput devices,
including
XI_LeftStickPosition()
,
XI_RightStickPosition()
,
XI_LeftTrigger()
, and
XI_RightTrigger()
, among others.
XI
is of course
short for XInput. Note that for the left and right triggers, their values are in the range
of
0
to
255
depending on how much you press the trigger in. Also, in XInput the D-
Pad is treated as regular buttons, so you will find button flags for all of its directions
in the
GamepadButtonFlags
enumeration. This is also true for the thumbstick but-
tons.
Explore the various properties of the XInput
Controller
object to learn more
about what you can do. Remember that we stored our
Controller
object in the
m_Controller1
member variable. Experiment with this code and see what you can
discover.
Note that the downloadable code for this chapter also includes some additional test
code for the keyboard and mouse input inside our
Update()
method in the
User-
Input
class. This code is very similar to the joystick test code that was shown in this
chapter for both DirectInput and XInput.