Struct GenericInput
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
MouseButtonThe 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
ButtonsThe 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
KeysThe 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
EnumThe 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
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
AllKeys
All GenericInput values created from all values of the Microsoft.Xna.Framework.Input.Keys enum.
public static readonly GenericInput[] AllKeys
Field Value
AllMouseButtons
All GenericInput values created from all values of the MouseButton enum.
public static readonly GenericInput[] AllMouseButtons
Field Value
Type
The GenericInput.InputType of this generic input's current value.
[DataMember]
public readonly GenericInput.InputType Type
Field Value
Properties
Button
Returns this generic input's Microsoft.Xna.Framework.Input.Buttons.
public Buttons Button { get; }
Property Value
- Buttons
Exceptions
Key
Returns this generic input's Microsoft.Xna.Framework.Input.Keys.
public Keys Key { get; }
Property Value
- Keys
Exceptions
MouseButton
Returns this generic input's MouseButton.
public MouseButton MouseButton { get; }
Property Value
Exceptions
Methods
Equals(GenericInput)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(GenericInput other)
Parameters
other
GenericInputAn 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
objectThe 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
GenericInputThe left input
right
GenericInputThe 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
GenericInputThe input to convert
Returns
- MouseButton
The resulting button
Exceptions
implicit operator Buttons(GenericInput)
Converts a generic input to a Microsoft.Xna.Framework.Input.Buttons.
public static implicit operator Buttons(GenericInput input)
Parameters
input
GenericInputThe input to convert
Returns
- Buttons
The resulting buttons
Exceptions
implicit operator Keys(GenericInput)
Converts a generic input to a Microsoft.Xna.Framework.Input.Keys.
public static implicit operator Keys(GenericInput input)
Parameters
input
GenericInputThe input to convert
Returns
- Keys
The resulting keys
Exceptions
implicit operator GenericInput(MouseButton)
Converts a MouseButton to a generic input.
public static implicit operator GenericInput(MouseButton button)
Parameters
button
MouseButtonThe 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
ButtonsThe 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
KeysThe 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
GenericInputThe left input
right
GenericInputThe right input
Returns
- bool
Whether the two generic inputs are not equal