Class VirtualButton
Describes a virtual button (a key from a keyboard, a mouse button, an axis of a joystick...etc.).
public abstract class VirtualButton : IVirtualButton
- Inheritance
-
VirtualButton
- Implements
- Derived
Constructors
VirtualButton(string, VirtualButtonType, int, bool)
Initializes a new instance of the VirtualButton class.
protected VirtualButton(string shortName, VirtualButtonType type, int id, bool isPositiveAndNegative = false)
Parameters
shortName
stringThe name.
type
VirtualButtonTypeThe type.
id
intThe id.
isPositiveAndNegative
boolif set to
true
[is positive and negative].
Fields
Id
Unique Id for a particular button Type.
public readonly int Id
Field Value
Index
protected readonly int Index
Field Value
IsPositiveAndNegative
A boolean indicating whether this button supports positive and negative value.
public readonly bool IsPositiveAndNegative
Field Value
ShortName
The short name of this button.
public readonly string ShortName
Field Value
Type
Type of this button.
public readonly VirtualButtonType Type
Field Value
Properties
Name
The full name of this button.
public string Name { get; }
Property Value
Registered
Gets all registered VirtualButton.
public static IReadOnlyCollection<VirtualButton> Registered { get; }
Property Value
- IReadOnlyCollection<VirtualButton>
The registered virtual buttons.
Methods
BuildButtonName()
protected virtual string BuildButtonName()
Returns
Find(int)
Finds a virtual button by the specified id.
public static VirtualButton Find(int id)
Parameters
id
intThe id.
Returns
- VirtualButton
An instance of VirtualButton or null if no match.
Find(string)
Finds a virtual button by the specified name.
public static VirtualButton Find(string name)
Parameters
name
stringThe name.
Returns
- VirtualButton
An instance of VirtualButton or null if no match.
GetValue(InputManager)
Gets the value associated with this virtual button from an input manager.
public abstract float GetValue(InputManager manager)
Parameters
manager
InputManagerThe manager.
Returns
- float
System.Single.
IsDown(InputManager)
Indicate if the button is currently down
public abstract bool IsDown(InputManager manager)
Parameters
manager
InputManagerThe input manager
Returns
IsPressed(InputManager)
Indicate if the button has been pressed since the last frame
public abstract bool IsPressed(InputManager manager)
Parameters
manager
InputManagerThe input manager
Returns
IsReleased(InputManager)
Indicate if the button has been released since the last frame
public abstract bool IsReleased(InputManager manager)
Parameters
manager
InputManagerThe input manager
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Operators
operator +(IVirtualButton, VirtualButton)
Implements the + operator to combine to VirtualButton.
public static IVirtualButton operator +(IVirtualButton left, VirtualButton right)
Parameters
left
IVirtualButtonThe left virtual button.
right
VirtualButtonThe right virtual button.
Returns
- IVirtualButton
A set containting the two virtual buttons.