Table of Contents

Struct GenericInput

Namespace
MLEM.Input
Assembly
MLEM.dll

A generic input represents any kind of input key. This includes Microsoft.Xna.Framework.Input.Keys for keyboard keys, MouseButton for mouse buttons and Microsoft.Xna.Framework.Input.Buttons for gamepad buttons. For creating and extracting inputs from a generic input, the implicit operators and Type can additionally be used. Note that this type is serializable using DataContractAttribute.

[DataContract]
public readonly struct GenericInput : IEquatable<GenericInput>
Implements
Inherited Members
Extension Methods

Constructors

GenericInput(MouseButton)

Creates a new generic input from the given MouseButton.

public GenericInput(MouseButton button)

Parameters

button MouseButton

The button to convert.

GenericInput(Buttons)

Creates a new generic input from the given gamepad Microsoft.Xna.Framework.Input.Buttons.

public GenericInput(Buttons button)

Parameters

button Buttons

The button to convert.

GenericInput(Keys)

Creates a new generic input from the given keyboard Microsoft.Xna.Framework.Input.Keys.

public GenericInput(Keys key)

Parameters

key Keys

The key to convert.

GenericInput(Enum)

Creates a new generic input from the given Enum value. If the value is a MouseButton, Microsoft.Xna.Framework.Input.Keys or Microsoft.Xna.Framework.Input.Buttons, the appropriate Type and value will be set. Otherwise, the Type will be set to None.

public GenericInput(Enum value)

Parameters

value Enum

The value to convert.

Fields

AllButtons

All GenericInput values created from all values of the Microsoft.Xna.Framework.Input.Buttons enum.

public static readonly GenericInput[] AllButtons

Field Value

GenericInput[]

AllInputs

All GenericInput values created from all values of the Microsoft.Xna.Framework.Input.Keys, MouseButton and Microsoft.Xna.Framework.Input.Buttons enums. This collection represents all possible valid, non-default GenericInput values.

public static readonly GenericInput[] AllInputs

Field Value

GenericInput[]

AllKeys

All GenericInput values created from all values of the Microsoft.Xna.Framework.Input.Keys enum.

public static readonly GenericInput[] AllKeys

Field Value

GenericInput[]

AllMouseButtons

All GenericInput values created from all values of the MouseButton enum.

public static readonly GenericInput[] AllMouseButtons

Field Value

GenericInput[]

Type

The GenericInput.InputType of this generic input's current value.

[DataMember]
public readonly GenericInput.InputType Type

Field Value

GenericInput.InputType

Properties

Button

Returns this generic input's Microsoft.Xna.Framework.Input.Buttons.

public Buttons Button { get; }

Property Value

Buttons

Exceptions

InvalidOperationException

If this generic input's Type is not Gamepad or None.

Key

Returns this generic input's Microsoft.Xna.Framework.Input.Keys.

public Keys Key { get; }

Property Value

Keys

Exceptions

InvalidOperationException

If this generic input's Type is not Keyboard or None.

MouseButton

Returns this generic input's MouseButton.

public MouseButton MouseButton { get; }

Property Value

MouseButton

Exceptions

InvalidOperationException

If this generic input's Type is not Mouse.

Methods

Equals(GenericInput)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(GenericInput other)

Parameters

other GenericInput

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns this generic input, converted to a string.

public override string ToString()

Returns

string

This generic input, converted to a string.

Operators

operator ==(GenericInput, GenericInput)

Compares the two generic input instances for equality using Equals(GenericInput)

public static bool operator ==(GenericInput left, GenericInput right)

Parameters

left GenericInput

The left input

right GenericInput

The right input

Returns

bool

Whether the two generic inputs are equal

implicit operator MouseButton(GenericInput)

Converts a generic input to a MouseButton.

public static implicit operator MouseButton(GenericInput input)

Parameters

input GenericInput

The input to convert

Returns

MouseButton

The resulting button

Exceptions

InvalidOperationException

If the given generic input's Type is not Mouse

implicit operator Buttons(GenericInput)

Converts a generic input to a Microsoft.Xna.Framework.Input.Buttons.

public static implicit operator Buttons(GenericInput input)

Parameters

input GenericInput

The input to convert

Returns

Buttons

The resulting buttons

Exceptions

InvalidOperationException

If the given generic input's Type is not Gamepad

implicit operator Keys(GenericInput)

Converts a generic input to a Microsoft.Xna.Framework.Input.Keys.

public static implicit operator Keys(GenericInput input)

Parameters

input GenericInput

The input to convert

Returns

Keys

The resulting keys

Exceptions

InvalidOperationException

If the given generic input's Type is not Keyboard or None

implicit operator GenericInput(MouseButton)

Converts a MouseButton to a generic input.

public static implicit operator GenericInput(MouseButton button)

Parameters

button MouseButton

The button to convert

Returns

GenericInput

The resulting generic input

implicit operator GenericInput(Buttons)

Converts a Microsoft.Xna.Framework.Input.Buttons to a generic input.

public static implicit operator GenericInput(Buttons button)

Parameters

button Buttons

The buttons to convert

Returns

GenericInput

The resulting generic input

implicit operator GenericInput(Keys)

Converts a Microsoft.Xna.Framework.Input.Keys to a generic input.

public static implicit operator GenericInput(Keys key)

Parameters

key Keys

The keys to convert

Returns

GenericInput

The resulting generic input

operator !=(GenericInput, GenericInput)

Compares the two generic input instances for inequality using Equals(GenericInput)

public static bool operator !=(GenericInput left, GenericInput right)

Parameters

left GenericInput

The left input

right GenericInput

The right input

Returns

bool

Whether the two generic inputs are not equal