Game Development Reference
In-Depth Information
return _state == _expectedState;
}
This is just a simple example of checking the state of the key against the state
provided by InputManager , and then adjusting the state accordingly so we can
get a Boolean value indicating if the state matches the expected state set using
SetData .
To handle the GamePad we need to define an enumeration that outlines the avail-
able buttons.
typedef enum
{
None = 0,
DPad_Up = XINPUT_GAMEPAD_DPAD_UP,
DPad_Down = XINPUT_GAMEPAD_DPAD_DOWN,
DPad_Left = XINPUT_GAMEPAD_DPAD_LEFT,
DPad_Right = XINPUT_GAMEPAD_DPAD_RIGHT,
Start = XINPUT_GAMEPAD_START,
Back = XINPUT_GAMEPAD_BACK,
LeftThumbStick = XINPUT_GAMEPAD_LEFT_THUMB,
RightThumbStick = XINPUT_GAMEPAD_RIGHT_THUMB,
LeftShoulder = XINPUT_GAMEPAD_LEFT_SHOULDER,
RightShoulder = XINPUT_GAMEPAD_RIGHT_SHOULDER,
A = XINPUT_GAMEPAD_A,
B = XINPUT_GAMEPAD_B,
X = XINPUT_GAMEPAD_X,
Y = XINPUT_GAMEPAD_Y
} GamepadButtons;
We can then use this in a fashion similar to KeyTrigger by replacing VirtualKey
with GamepadButtons inside our new GamepadButtonTrigger class.
class GamepadButtonTrigger :
public Trigger
{
Search WWH ::




Custom Search