Game Development Reference
In-Depth Information
m_MouseStateCurrent = new MouseState();
m_MouseStateLast = new MouseState();
m_Joy1StateCurrent = new JoystickState();
m_Joy1StateLast = new JoystickState();
m_Controller1StateCurrent = new Gamepad();
m_Controller1StateLast = new Gamepad();
}
Now, we must add the following code to the end of the Update() method in our user
input class:
m_Controller1StateLast =
m_Controller1StateCurrent;
m_Controller1StateCurrent =
m_Controller1.GetState().Gamepad;"
if (XI_IsButtonPressed(GamepadButtonFlags.A))
System.Diagnostics.Debug.WriteLine("XINPUT:
THE A BUTTON IS PRESSED!!");
if (XI_IsButtonPressed(GamepadButtonFlags.B))
System.Diagnostics.Debug.WriteLine("XINPUT:
THE B BUTTON IS PRESSED!!");
if (XI_IsButtonPressed(GamepadButtonFlags.X))
System.Diagnostics.Debug.WriteLine("XINPUT:
THE X BUTTON IS PRESSED!!");
if (XI_IsButtonPressed(GamepadButtonFlags.Y))
System.Diagnostics.Debug.WriteLine("XINPUT:
THE Y BUTTON IS PRESSED!!");
This code is very similar to our DirectInput joystick test code. It copies the state
data from the previous frame into the m_Controller1StateLast member vari-
able, and then gets the current controller state and stores it in the
m_Controller1StateCurrent variable.
The if statements are just like the ones we used to test our DirectInput joystick
code. The first one checks if the A button is pressed. If so, it prints a debug message
Search WWH ::




Custom Search