Game pad control reference

There are several default game pad analog input controls. These are defined in the structure Pad as follows:

Thumbsticks:
Pad.ThumbSticks.Left.X
Pad.ThumbSticks.Left.Y
Pad.ThumbSticks.Right.X
Pad.ThumbSticks.Right.Y


Triggers:
Pad.Triggers.Left
Pad.Triggers.Right


These can all be used by calling:
InputManager.AssignControl(PlayerIndex player, String name, Pad.Generator gen);


where gen is one of the delegates listed above.

To get a button press, use the button structure provided with Xna:
InputManager.AssignControl(PlayerIndex player, String name, Buttons button);
InputManager.AssignControl(PlayerIndex player, String name, Buttons high, Buttons low);


This structure includes the dpad, shoulder buttons, thumbstick buttons, and also entries that stand for analog inputs railed all the way, such as Buttons.LeftThumbstickDown.

The state of a particular game pad can be accessed by:
InputManager.GamePads[PlayerIndex player].State; 
InputManager.GamePads[PlayerIndex player].PreviousState;


Also, several helper methods are provided:
InputManager.GamePads[PlayerIndex player].JustPressed(Buttons button);
InputManager.GamePads[PlayerIndex player].JustReleased(Buttons button);
InputManager.GamePads[PlayerIndex player].IsButtonDown(Buttons button);
InputManager.GamePads[PlayerIndex player].IsButtonUp(Buttons button);


And a public bool:
InputManager.GamePads[PlayerIndex player].IsConnected;

Last edited Mar 23, 2009 at 3:04 AM by Shader, version 2

Comments

No comments yet.