Table of Contents

Class Input

Namespace
MonoEight.Core.UserInput
Assembly
MonoEight.Template.dll

A static manger that polls keyboard, gamepad, and mouse states to provide unified access.

public static class Input
Inheritance
Input
Inherited Members

Properties

ControllerDeadZone

Gets or sets the threshold of detecting analog stick movement. Threshold is between 0.0 and 1.0. Default is 0.1.

public static float ControllerDeadZone { get; set; }

Property Value

float

HorizontalAxis

Gets the horizontal input axis based on the inputs of A/D, left/right arrows, DPad, and left stick.

public static int HorizontalAxis { get; }

Property Value

int

-1 for left and 1 for right.

InputAxis

Gets the combined HorizontalAxis and VerticalAxis in a Microsoft.Xna.Framework.Point.

public static Point InputAxis { get; }

Property Value

Point

Mouse

Gets the mouse handler instance for accessing the cursor positon and clicks.

public static MouseHandler Mouse { get; }

Property Value

MouseHandler

VerticalAxis

Gets the vertical input axis based on the inputs of W/S, up/down arrows, DPad, and left stick.

public static int VerticalAxis { get; }

Property Value

int

-1 for up and 1 for down.

Methods

Action(string)

Retrieves the InputAction object associated with the given name.

public static InputAction Action(string name)

Parameters

name string

Returns

InputAction

Add(string, Keys[], Buttons[])

Registers a new named input action binding specific keys and buttons to a single name.

public static void Add(string name, Keys[] keys, Buttons[] buttons)

Parameters

name string

The unique name for the action.

keys Keys[]

The keyboard keys that trigger this action.

buttons Buttons[]

The gamepad buttons that trigger this action.

Exceptions

Exception

Thrown if an action with the same name already exists.

IsButtonDown(Buttons)

Checks if the given gamepad button is currently held down.

public static bool IsButtonDown(Buttons button)

Parameters

button Buttons

The gamepad button to check.

Returns

bool

IsButtonPressed(Buttons)

Checks if the given gamepad button was pressed this frame.

public static bool IsButtonPressed(Buttons button)

Parameters

button Buttons

Returns

bool

IsButtonReleased(Buttons)

Checks if the given gamepad button was released this frame.

public static bool IsButtonReleased(Buttons button)

Parameters

button Buttons

Returns

bool

IsDown(string)

Checks if the named action is currently held down.

public static bool IsDown(string name)

Parameters

name string

The name of the action to check.

Returns

bool

Exceptions

Exception

Thrown if the action name does not exist.

IsKeyDown(Keys)

Checks if the given key is currently held down.

public static bool IsKeyDown(Keys key)

Parameters

key Keys

The keyboard key to check.

Returns

bool

true if the key is down, otherwise, false.

IsKeyPressed(Keys)

Checks if the given key was pressed this frame.

public static bool IsKeyPressed(Keys key)

Parameters

key Keys

Returns

bool

Remarks

Returns true only on the single frame the key transitions from Up to Down.

IsKeyReleased(Keys)

Checks if the given key was released this frame.

public static bool IsKeyReleased(Keys key)

Parameters

key Keys

Returns

bool

Remarks

Returns true only on the single frame the key transitions from Down to Up.

IsPressed(string)

Checks if the named action was pressed this frame.

public static bool IsPressed(string name)

Parameters

name string

The name of the action to check.

Returns

bool

Exceptions

Exception

Thrown if the action name does not exist.

IsReleased(string)

Checks if the named action was released this frame.

public static bool IsReleased(string name)

Parameters

name string

The name of the action to check.

Returns

bool

Exceptions

Exception

Thrown if the action name does not exist.

Update(Rectangle)

Updates the current and previous input states.

public static void Update(Rectangle displayRect)

Parameters

displayRect Rectangle

The current display rectangle.