Class InputState
Low-level APIs for working with input state memory.
Namespace: UnityEngine.InputSystem.LowLevel
Syntax
public static class InputState
Properties
currentTime
Declaration
public static double currentTime { get; }
Property Value
Type | Description |
---|---|
Double |
currentUpdateType
The type of update that was last run or is currently being run on the input state.
Declaration
public static InputUpdateType currentUpdateType { get; }
Property Value
Type | Description |
---|---|
InputUpdateType |
Remarks
This determines which set of buffers are currently active and thus determines which view code that queries input state will receive. For example, during editor updates, this will be Editor and the state buffers for the editor will be active.
updateCount
The number of times the current input state has been updated.
Declaration
public static uint updateCount { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Methods
AddChangeMonitor(InputControl, Action<InputControl, Double, InputEventPtr, Int64>, Int32, Action<InputControl, Double, Int64, Int32>)
Declaration
public static IInputStateChangeMonitor AddChangeMonitor(InputControl control, Action<InputControl, double, InputEventPtr, long> valueChangeCallback, int monitorIndex = -1, Action<InputControl, double, long, int> timerExpiredCallback = null)
Parameters
Type | Name | Description |
---|---|---|
InputControl | control | |
Action<InputControl, Double, InputEventPtr, Int64> | valueChangeCallback | |
Int32 | monitorIndex | |
Action<InputControl, Double, Int64, Int32> | timerExpiredCallback |
Returns
Type | Description |
---|---|
IInputStateChangeMonitor |
AddChangeMonitor(InputControl, IInputStateChangeMonitor, Int64)
Declaration
public static void AddChangeMonitor(InputControl control, IInputStateChangeMonitor monitor, long monitorIndex = -1L)
Parameters
Type | Name | Description |
---|---|---|
InputControl | control | |
IInputStateChangeMonitor | monitor | |
Int64 | monitorIndex |
AddChangeMonitorTimeout(InputControl, IInputStateChangeMonitor, Double, Int64, Int32)
Put a timeout on a previously registered state change monitor.
Declaration
public static void AddChangeMonitorTimeout(InputControl control, IInputStateChangeMonitor monitor, double time, long monitorIndex = -1L, int timerIndex = -1)
Parameters
Type | Name | Description |
---|---|---|
InputControl | control | |
IInputStateChangeMonitor | monitor | |
Double | time | |
Int64 | monitorIndex | |
Int32 | timerIndex |
Remarks
If by the given time
, no state change has been registered on the control monitored
by the given monitor
, NotifyTimerExpired(InputControl, Double, Int64, Int32)
will be called on monitor
. If a state change happens by the given time
,
the monitor is notified as usual and the timer is automatically removed.
Change(InputDevice, InputEventPtr, InputUpdateType)
Declaration
public static void Change(InputDevice device, InputEventPtr eventPtr, InputUpdateType updateType = InputUpdateType.None)
Parameters
Type | Name | Description |
---|---|---|
InputDevice | device | |
InputEventPtr | eventPtr | |
InputUpdateType | updateType |
Change<TState>(InputControl, TState, InputUpdateType, InputEventPtr)
Perform one update of input state.
Declaration
public static void Change<TState>(InputControl control, TState state, InputUpdateType updateType = InputUpdateType.None, InputEventPtr eventPtr = default(InputEventPtr))
where TState : struct
Parameters
Type | Name | Description |
---|---|---|
InputControl | control | |
TState | state | |
InputUpdateType | updateType | |
InputEventPtr | eventPtr |
Type Parameters
Name | Description |
---|---|
TState |
Remarks
Incorporates the given state and triggers all state change monitors as needed.
Note that input state changes performed with this method will not be visible on remotes as they will bypass event processing. It is effectively equivalent to directly writing into input state memory except that it also performs related tasks such as checking state change monitors, flipping buffers, or making the respective device current.
IsIntegerFormat(FourCC)
Declaration
public static bool IsIntegerFormat(this FourCC format)
Parameters
Type | Name | Description |
---|---|---|
FourCC | format |
Returns
Type | Description |
---|---|
Boolean |
RemoveChangeMonitor(InputControl, IInputStateChangeMonitor, Int64)
Declaration
public static void RemoveChangeMonitor(InputControl control, IInputStateChangeMonitor monitor, long monitorIndex = -1L)
Parameters
Type | Name | Description |
---|---|---|
InputControl | control | |
IInputStateChangeMonitor | monitor | |
Int64 | monitorIndex |
RemoveChangeMonitorTimeout(IInputStateChangeMonitor, Int64, Int32)
Declaration
public static void RemoveChangeMonitorTimeout(IInputStateChangeMonitor monitor, long monitorIndex = -1L, int timerIndex = -1)
Parameters
Type | Name | Description |
---|---|---|
IInputStateChangeMonitor | monitor | |
Int64 | monitorIndex | |
Int32 | timerIndex |
Events
onChange
Callback that is triggered when the state of an input device changes.
Declaration
public static event Action<InputDevice, InputEventPtr> onChange
Event Type
Type | Description |
---|---|
Action<InputDevice, InputEventPtr> |
Remarks
The first parameter is the device whose state was changed the second parameter is the event
that triggered the change in state. Note that the latter may be null
in case the
change was performed directly through Change(InputDevice, InputEventPtr, InputUpdateType) rather than through an event.