InControl API Reference
PlayerAction Class Reference

This class represents a single action that may have multiple controls bound to it. A bound control is represented by a subclass of BindingSource. For example, DeviceBindingSource provides input from a control on any supported InputDevice. Similarly, KeyBindingSource provides input from one or more keypresses. An action may have any number of bindings. Actions have two groups of bindings defined: default bindings and regular bindings. Default bindings are the predefined default bindings, and the current bindings for the action can be reset to this group in a single operation. Regular bindings are those added by users, most likely at runtime in a settings menu or the like. There are no other distinctions between these groupings; they are purely for organizational convenience. More...

Inheritance diagram for PlayerAction:
OneAxisInputControl IInputControl

Public Member Functions

 PlayerAction (string name, PlayerActionSet owner)
 Construct an action belonging to a given action set. More...
 
void AddDefaultBinding (BindingSource binding)
 Adds a default binding for the action. This will also add it to the regular bindings. More...
 
void AddDefaultBinding (params Key[] keys)
 A convenience method for adding a KeyBindingSource to the default bindings. More...
 
void AddDefaultBinding (KeyCombo keyCombo)
 A convenience method for adding a KeyBindingSource to the default bindings. More...
 
void AddDefaultBinding (Mouse control)
 A convenience method for adding a MouseBindingSource to the default bindings. More...
 
void AddDefaultBinding (InputControlType control)
 A convenience method for adding a DeviceBindingSource to the default bindings. More...
 
bool AddBinding (BindingSource binding)
 Add a regular binding to the action. A binding cannot be added if it matches an existing binding on the action, or if it is already bound to another action. More...
 
bool InsertBindingAt (int index, BindingSource binding)
 Insert a regular binding to the action at the specified index. A binding cannot be inserted if it matches an existing binding on the action, or if it is already bound to another action. More...
 
bool ReplaceBinding (BindingSource findBinding, BindingSource withBinding)
 Add a regular binding to the action replacing an existing binding. A binding cannot be added if is already bound to another action. If the binding to replace is not present on this action, the binding will not be added. More...
 
bool HasBinding (BindingSource binding)
 Searches all the bindings on this action to see if any that match the provided binding object. More...
 
BindingSource FindBinding (BindingSource binding)
 Searches all the bindings on this action to see if any that match the provided binding object and, if found, returns it. More...
 
void RemoveBinding (BindingSource binding)
 Searches all the bindings on this action to see if any that match the provided binding object and, if found, removes it. NOTE: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection. More...
 
void RemoveBindingAt (int index)
 Removes the binding at the specified index from the action. Note: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection. More...
 
void ClearBindings ()
 Clears the bindings for this action. More...
 
void ResetBindings ()
 Resets the bindings to the default bindings. More...
 
void ListenForBinding ()
 Begin listening for a new user defined binding. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop. More...
 
void ListenForBindingReplacing (BindingSource binding)
 Begin listening for a new user defined binding, replacing an existing specified binding. If the binding to replace is not present on this action, the new binding will fail to be added. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop. More...
 
void StopListeningForBinding ()
 Stop listening for new user defined bindings. More...
 
- Public Member Functions inherited from OneAxisInputControl
bool UpdateWithState (bool state, ulong updateTick, float deltaTime)
 
bool UpdateWithValue (float value, ulong updateTick, float deltaTime)
 
void ClearInputState ()
 
void Commit ()
 
void CommitWithState (bool state, ulong updateTick, float deltaTime)
 
void CommitWithValue (float value, ulong updateTick, float deltaTime)
 

Public Attributes

BindingListenOptions ListenOptions = null
 Configures how this action listens for new bindings. When null (default) the owner's PlayerActionSet.ListenOptions will be used.

See also
ListenForBinding()
More...
 
BindingSourceType LastInputType = BindingSourceType.None
 The binding source type that last provided input to this action. More...
 
ulong LastInputTypeChangedTick
 Updated when LastInputType changes. More...
 
InputDeviceClass LastDeviceClass = InputDeviceClass.Unknown
 The InputDeviceClass of the binding source that last provided input to this action. More...
 
InputDeviceStyle LastDeviceStyle = InputDeviceStyle.Unknown
 The InputDeviceStyle of the binding source that last provided input to this action. More...
 
- Public Attributes inherited from OneAxisInputControl
float FirstRepeatDelay = 0.8f
 
float RepeatDelay = 0.1f
 
bool Raw
 

Properties

string Name [get]
 The unique identifier for this action within the context of its owning action set. More...
 
PlayerActionSet Owner [get]
 Gets the owning action set containing this action. More...
 
object UserData [get, set]
 This property can be used to store whatever arbitrary game data you want on this action. More...
 
bool IsListeningForBinding [get]
 Gets a value indicating whether this action is listening for new user defined bindings. More...
 
ReadOnlyCollection< BindingSourceBindings [get]
 Gets the valid (in context of the current device) bindings for this action as a readonly collection. What this means is, if your current active controller is an Xbox One controller and you have InputControlType.Options bound, it will not be included. This is generally the bindings you should display unless you are doing something custom. More...
 
ReadOnlyCollection< BindingSourceUnfilteredBindings [get]
 Gets ALL bindings for this action (including ones that don't make sense for the current device) as a readonly collection. Use of this collection is not recommended unless you really need unfettered access to all the bindings on an action. More...
 
InputDevice?? ActiveDevice [get]
 Gets the currently active device (controller) if present, otherwise returns a null device which does nothing. The currently active device is defined as the last device that provided input to this action. When LastInputType is not a device (controller), this will return the null device. More...
 
new float LowerDeadZone [get, set]
 
new float UpperDeadZone [get, set]
 
- Properties inherited from OneAxisInputControl
ulong UpdateTick [get, protected set]
 
bool State [get]
 
bool LastState [get]
 
float? Value [get]
 
float? LastValue [get]
 
float? RawValue [get]
 
bool HasChanged [get]
 
bool IsPressed [get]
 
bool WasPressed [get]
 
bool WasReleased [get]
 
bool WasRepeated [get]
 
float Sensitivity [get, set]
 
float LowerDeadZone [get, set]
 
float UpperDeadZone [get, set]
 
float StateThreshold [get, set]
 
bool IsNullControl [get]
 
bool Enabled [get, set]
 
bool EnabledInHierarchy [get]
 
- Properties inherited from IInputControl
bool HasChanged [get]
 
bool IsPressed [get]
 
bool WasPressed [get]
 
bool WasReleased [get]
 

Events

Action< BindingSourceType > OnLastInputTypeChanged
 This event is triggered when the binding source type that last provided input to this action changes. More...
 
Action OnBindingsChanged
 This event is triggered if bindings on an action are added or removed. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from OneAxisInputControl
static implicit operator bool (OneAxisInputControl instance)
 
static implicit operator float (OneAxisInputControl instance)
 
- Protected Attributes inherited from OneAxisInputControl
bool isNullControl = false
 
bool ownerEnabled = true
 

Detailed Description

This class represents a single action that may have multiple controls bound to it. A bound control is represented by a subclass of BindingSource. For example, DeviceBindingSource provides input from a control on any supported InputDevice. Similarly, KeyBindingSource provides input from one or more keypresses. An action may have any number of bindings. Actions have two groups of bindings defined: default bindings and regular bindings. Default bindings are the predefined default bindings, and the current bindings for the action can be reset to this group in a single operation. Regular bindings are those added by users, most likely at runtime in a settings menu or the like. There are no other distinctions between these groupings; they are purely for organizational convenience.

Constructor & Destructor Documentation

◆ PlayerAction()

PlayerAction ( string  name,
PlayerActionSet  owner 
)

Construct an action belonging to a given action set.

Parameters
nameA unique identifier for this action within the context of its owning action set.
ownerThe action set to contain (own) this action.

Member Function Documentation

◆ AddBinding()

bool AddBinding ( BindingSource  binding)

Add a regular binding to the action. A binding cannot be added if it matches an existing binding on the action, or if it is already bound to another action.

Returns
true, if binding was added, false otherwise.
Parameters
bindingThe BindingSource to add.

◆ AddDefaultBinding() [1/5]

void AddDefaultBinding ( BindingSource  binding)

Adds a default binding for the action. This will also add it to the regular bindings.

Parameters
bindingThe BindingSource to add.

◆ AddDefaultBinding() [2/5]

void AddDefaultBinding ( InputControlType  control)

A convenience method for adding a DeviceBindingSource to the default bindings.

Parameters
controlThe InputControlType to add.

◆ AddDefaultBinding() [3/5]

void AddDefaultBinding ( KeyCombo  keyCombo)

A convenience method for adding a KeyBindingSource to the default bindings.

Parameters
keyComboA KeyCombo for the binding source.

◆ AddDefaultBinding() [4/5]

void AddDefaultBinding ( Mouse  control)

A convenience method for adding a MouseBindingSource to the default bindings.

Parameters
controlThe Mouse control to add.

◆ AddDefaultBinding() [5/5]

void AddDefaultBinding ( params Key[]  keys)

A convenience method for adding a KeyBindingSource to the default bindings.

Parameters
keysA list of one or more keys making up a KeyCombo for the binding source.

◆ ClearBindings()

void ClearBindings ( )

Clears the bindings for this action.

◆ FindBinding()

BindingSource FindBinding ( BindingSource  binding)

Searches all the bindings on this action to see if any that match the provided binding object and, if found, returns it.

Parameters
bindingThe BindingSource template to search for.

◆ HasBinding()

bool HasBinding ( BindingSource  binding)

Searches all the bindings on this action to see if any that match the provided binding object.

Returns
true, if a matching binding is found on this action, false otherwise.
Parameters
bindingThe BindingSource template to search for.

◆ InsertBindingAt()

bool InsertBindingAt ( int  index,
BindingSource  binding 
)

Insert a regular binding to the action at the specified index. A binding cannot be inserted if it matches an existing binding on the action, or if it is already bound to another action.

Returns
true, if binding was inserted, false otherwise.
Parameters
indexThe index at which to insert.
bindingThe BindingSource to insert.

◆ ListenForBinding()

void ListenForBinding ( )

Begin listening for a new user defined binding. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop.

◆ ListenForBindingReplacing()

void ListenForBindingReplacing ( BindingSource  binding)

Begin listening for a new user defined binding, replacing an existing specified binding. If the binding to replace is not present on this action, the new binding will fail to be added. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop.

◆ RemoveBinding()

void RemoveBinding ( BindingSource  binding)

Searches all the bindings on this action to see if any that match the provided binding object and, if found, removes it. NOTE: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection.

Parameters
bindingThe BindingSource template to search for.

◆ RemoveBindingAt()

void RemoveBindingAt ( int  index)

Removes the binding at the specified index from the action. Note: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection.

Parameters
indexThe index of the BindingSource in the Bindings collection to remove.

◆ ReplaceBinding()

bool ReplaceBinding ( BindingSource  findBinding,
BindingSource  withBinding 
)

Add a regular binding to the action replacing an existing binding. A binding cannot be added if is already bound to another action. If the binding to replace is not present on this action, the binding will not be added.

Returns
true, if binding was added, false otherwise.
Parameters
findBindingThe BindingSource to replace.
withBindingThe BindingSource to replace it with.

◆ ResetBindings()

void ResetBindings ( )

Resets the bindings to the default bindings.

◆ StopListeningForBinding()

void StopListeningForBinding ( )

Stop listening for new user defined bindings.

Member Data Documentation

◆ LastDeviceClass

InputDeviceClass LastDeviceClass = InputDeviceClass.Unknown

The InputDeviceClass of the binding source that last provided input to this action.

◆ LastDeviceStyle

InputDeviceStyle LastDeviceStyle = InputDeviceStyle.Unknown

The InputDeviceStyle of the binding source that last provided input to this action.

◆ LastInputType

BindingSourceType LastInputType = BindingSourceType.None

The binding source type that last provided input to this action.

◆ LastInputTypeChangedTick

ulong LastInputTypeChangedTick

Updated when LastInputType changes.

◆ ListenOptions

BindingListenOptions ListenOptions = null

Configures how this action listens for new bindings. When null (default) the owner's PlayerActionSet.ListenOptions will be used.

See also
ListenForBinding()

Property Documentation

◆ ActiveDevice

InputDevice?? ActiveDevice
get

Gets the currently active device (controller) if present, otherwise returns a null device which does nothing. The currently active device is defined as the last device that provided input to this action. When LastInputType is not a device (controller), this will return the null device.

◆ Bindings

ReadOnlyCollection<BindingSource> Bindings
get

Gets the valid (in context of the current device) bindings for this action as a readonly collection. What this means is, if your current active controller is an Xbox One controller and you have InputControlType.Options bound, it will not be included. This is generally the bindings you should display unless you are doing something custom.

◆ IsListeningForBinding

bool IsListeningForBinding
get

Gets a value indicating whether this action is listening for new user defined bindings.

◆ Name

string Name
get

The unique identifier for this action within the context of its owning action set.

◆ Owner

PlayerActionSet Owner
get

Gets the owning action set containing this action.

◆ UnfilteredBindings

ReadOnlyCollection<BindingSource> UnfilteredBindings
get

Gets ALL bindings for this action (including ones that don't make sense for the current device) as a readonly collection. Use of this collection is not recommended unless you really need unfettered access to all the bindings on an action.

◆ UserData

object UserData
getset

This property can be used to store whatever arbitrary game data you want on this action.

Event Documentation

◆ OnBindingsChanged

Action OnBindingsChanged

This event is triggered if bindings on an action are added or removed.

◆ OnLastInputTypeChanged

Action<BindingSourceType> OnLastInputTypeChanged

This event is triggered when the binding source type that last provided input to this action changes.


The documentation for this class was generated from the following file: