C# Class TraceRacer.InputState

Helper for reading input from keyboard, gamepad, and touch input. This class tracks both the current and previous state of the input devices, and implements query methods for high level input actions such as "move up through the menu" or "pause the game".
Datei anzeigen Open project: alexcoco/trace_racer Class Usage Examples

Public Properties

Property Type Description
CurrentGamePadStates Microsoft.Xna.Framework.Input.GamePadState[]
CurrentKeyboardStates Microsoft.Xna.Framework.Input.KeyboardState[]
GamePadWasConnected bool[]
Gestures List
LastGamePadStates Microsoft.Xna.Framework.Input.GamePadState[]
LastKeyboardStates Microsoft.Xna.Framework.Input.KeyboardState[]
TouchState TouchCollection

Public Methods

Method Description
InputState ( ) : System.Collections.Generic

Constructs a new input state.

IsButtonPressed ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a button was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.

IsKeyPressed ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a key was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.

IsNewButtonPress ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a button was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.

IsNewKeyPress ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a key was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.

Update ( ) : void

Reads the latest state user input.

Method Details

InputState() public method

Constructs a new input state.
public InputState ( ) : System.Collections.Generic
return System.Collections.Generic

IsButtonPressed() public method

Helper for checking if a button was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.
public IsButtonPressed ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
button Buttons
controllingPlayer PlayerIndex
playerIndex PlayerIndex
return bool

IsKeyPressed() public method

Helper for checking if a key was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.
public IsKeyPressed ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
key Keys
controllingPlayer PlayerIndex
playerIndex PlayerIndex
return bool

IsNewButtonPress() public method

Helper for checking if a button was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.
public IsNewButtonPress ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
button Buttons
controllingPlayer PlayerIndex
playerIndex PlayerIndex
return bool

IsNewKeyPress() public method

Helper for checking if a key was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.
public IsNewKeyPress ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
key Keys
controllingPlayer PlayerIndex
playerIndex PlayerIndex
return bool

Update() public method

Reads the latest state user input.
public Update ( ) : void
return void

Property Details

CurrentGamePadStates public_oe property

public GamePadState[],Microsoft.Xna.Framework.Input CurrentGamePadStates
return Microsoft.Xna.Framework.Input.GamePadState[]

CurrentKeyboardStates public_oe property

public KeyboardState[],Microsoft.Xna.Framework.Input CurrentKeyboardStates
return Microsoft.Xna.Framework.Input.KeyboardState[]

GamePadWasConnected public_oe property

public bool[] GamePadWasConnected
return bool[]

Gestures public_oe property

public List Gestures
return List

LastGamePadStates public_oe property

public GamePadState[],Microsoft.Xna.Framework.Input LastGamePadStates
return Microsoft.Xna.Framework.Input.GamePadState[]

LastKeyboardStates public_oe property

public KeyboardState[],Microsoft.Xna.Framework.Input LastKeyboardStates
return Microsoft.Xna.Framework.Input.KeyboardState[]

TouchState public_oe property

public TouchCollection TouchState
return TouchCollection