C# Class GameStateManagement.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".
Show file Open project: GarethIW/LDEngine Class Usage Examples

Public Properties

Property Type Description
CurrentKeyboardState Microsoft.Xna.Framework.Input.KeyboardState
CurrentMouseState Microsoft.Xna.Framework.Input.MouseState
LastKeyboardState KeyboardState
LastMouseState MouseState

Public Methods

Method Description
InputState ( ) : System.Collections.Generic

Constructs a new input state.

IsMenuCancel ( ) : bool

Checks for a "menu cancel" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When the action is detected, the output playerIndex reports which player pressed it.

IsMenuDown ( ) : bool

Checks for a "menu down" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.

IsMenuLeft ( ) : bool
IsMenuRight ( ) : bool

Checks for a "menu down" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.

IsMenuSelect ( ) : bool

Checks for a "menu select" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When the action is detected, the output playerIndex reports which player pressed it.

IsMenuUp ( ) : bool

Checks for a "menu up" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.

IsNewKeyPress ( Keys key ) : 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.

IsPauseGame ( ) : bool

Checks for a "pause the game" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.

Update ( ) : void

Reads the latest state of the keyboard and gamepad.

Method Details

InputState() public method

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

IsMenuCancel() public method

Checks for a "menu cancel" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When the action is detected, the output playerIndex reports which player pressed it.
public IsMenuCancel ( ) : bool
return bool

IsMenuDown() public method

Checks for a "menu down" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.
public IsMenuDown ( ) : bool
return bool

IsMenuLeft() public method

public IsMenuLeft ( ) : bool
return bool

IsMenuRight() public method

Checks for a "menu down" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.
public IsMenuRight ( ) : bool
return bool

IsMenuSelect() public method

Checks for a "menu select" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When the action is detected, the output playerIndex reports which player pressed it.
public IsMenuSelect ( ) : bool
return bool

IsMenuUp() public method

Checks for a "menu up" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.
public IsMenuUp ( ) : bool
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 ) : bool
key Keys
return bool

IsPauseGame() public method

Checks for a "pause the game" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.
public IsPauseGame ( ) : bool
return bool

Update() public method

Reads the latest state of the keyboard and gamepad.
public Update ( ) : void
return void

Property Details

CurrentKeyboardState public property

public KeyboardState,Microsoft.Xna.Framework.Input CurrentKeyboardState
return Microsoft.Xna.Framework.Input.KeyboardState

CurrentMouseState public property

public MouseState,Microsoft.Xna.Framework.Input CurrentMouseState
return Microsoft.Xna.Framework.Input.MouseState

LastKeyboardState public property

public KeyboardState LastKeyboardState
return KeyboardState

LastMouseState public property

public MouseState LastMouseState
return MouseState