Class InputSystem
This is the central hub for the input system.
Inheritance
Namespace: UnityEngine.InputSystem
Syntax
public static class InputSystemProperties
devices
The list of currently connected devices.
Declaration
public static ReadOnlyArray<InputDevice> devices { get; }Property Value
| Type | Description | 
|---|---|
| ReadOnlyArray<InputDevice> | 
Remarks
Note that accessing this property does not allocate. It gives read-only access directly to the system's internal array of devices.
The value returned by this property should not be held on to. When the device setup in the system changes, any value previously returned by this property becomes invalid. Query the property directly whenever you need it.
disconnectedDevices
Devices that have been disconnected but are retained by the input system in case they are plugged back in.
Declaration
public static ReadOnlyArray<InputDevice> disconnectedDevices { get; }Property Value
| Type | Description | 
|---|---|
| ReadOnlyArray<InputDevice> | 
Remarks
During gameplay it is undesirable to have the system allocate and release managed memory as devices are unplugged and plugged back in as it would ultimately lead to GC spikes during gameplay. To avoid that, input devices that have been reported by the IInputRuntime and are removed through DeviceRemoveEvent are retained by the system and then reused if the device is plugged back in.
Note that the devices moved to disconnected status will still see a Removed notification and a Added notification when plugged back in.
To determine if a newly discovered device is one we have seen before, the system uses a simple approach of comparing InputDeviceDescription. Note that there can be errors and a device may be incorrectly classified as Reconnected when in fact it is a different device from before. The problem is that based on information made available by platforms, it can be inherently difficult to determine whether a device is indeed the very same one.
For example, it is often not possible to determine with 100% certainty whether an identical looking device to one we've previously seen on a different USB port is indeed the very same device. OSs will usually reattach a USB device to its previous instance if it is plugged into the same USB port but create a new instance of the same device is plugged into a different port.
For devices that do relay their serial the matching is reliable.
The list can be purged by calling 
Note that if you call RemoveDevice(InputDevice) explicitly, the given device is not retained by the input system and will not appear on this list.
Also note that devices on this list will be lost when domain reloads happen in the editor (i.e. on script recompilation and when entering play mode).
See Also
pollingFrequency
Frequency at which devices that need polling are being queried in the background.
Declaration
public static float pollingFrequency { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | 
Remarks
Input data is gathered from platform APIs either as events or polled periodically.
In the former case, where we get input as events, the platform is responsible for monitoring input devices and accumulating their state changes which the input runtime then periodically queries and sends off as InputEvent.
In the latter case, where input has to be explicitly polled from the system, the input runtime will periodically sample the state of input devices and send it off as input events. Wherever possible, this happens in the background at a fixed frequency. The pollingFrequency property controls the rate at which the sampling happens.
The unit is Hertz. A value of 120, for example, means that devices are sampled 120 times per second.
The default polling frequency is 60 Hz.
For devices that are polled, the frequency setting will directly translate to changes in the time patterns. At 60 Hz, for example, timestamps for a specific, polled device will be spaced at roughly 1/60th of a second apart.
Note that it depends on the platform which devices are polled (if any). On Win32, for example, only XInput gamepads are polled.
Also note that the polling frequency applies to all devices that are polled. It is not possible to set polling frequency on a per-device basis.
remoting
The local InputRemoting instance which can mirror local input to a remote input system or can make input in a remote system available locally.
Declaration
public static InputRemoting remoting { get; }Property Value
| Type | Description | 
|---|---|
| InputRemoting | 
Remarks
In the editor, this is always initialized. In players, this will be null if remoting is disabled (which it is by default in release players).
settings
Declaration
public static InputSettings settings { get; set; }Property Value
| Type | Description | 
|---|---|
| InputSettings | 
version
The current version of the input system package.
Declaration
public static Version version { get; }Property Value
| Type | Description | 
|---|---|
| System.Version | 
Methods
AddDevice(String, String, String)
Add a new device by instantiating the given device layout.
Declaration
public static InputDevice AddDevice(string layout, string name = null, string variants = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | layout | Name of the layout to instantiate. Must be a device layout. Note that layout names are case-insensitive. | 
| System.String | name | Name to assign to the device. If null, the layout name is used instead. Note that device names are made unique automatically by the system by appending numbers to them (e.g. "gamepad", "gamepad1", "gamepad2", etc.). | 
| System.String | variants | Semicolon-separated list of layout variants to use for the device. | 
Returns
| Type | Description | 
|---|---|
| InputDevice | The newly created input device. | 
Remarks
Note that adding a device to the system will allocate and also create garbage on the GC heap.
Examples
InputSystem.AddDevice("Gamepad");AddDevice(InputDevice)
Declaration
public static void AddDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
AddDevice(InputDeviceDescription)
Declaration
public static InputDevice AddDevice(InputDeviceDescription description)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDeviceDescription | description | 
Returns
| Type | Description | 
|---|---|
| InputDevice | 
AddDevice<TDevice>(String)
Declaration
public static TDevice AddDevice<TDevice>(string name = null)
    where TDevice : InputDeviceParameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Returns
| Type | Description | 
|---|---|
| TDevice | 
Type Parameters
| Name | Description | 
|---|---|
| TDevice | 
AddDeviceUsage(InputDevice, InternedString)
Declaration
public static void AddDeviceUsage(InputDevice device, InternedString usage)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| InternedString | usage | 
AddStateChangeMonitor(InputControl, Action<InputControl, Double, InputEventPtr, Int64>, Int32, Action<InputControl, Double, Int64, Int32>)
Declaration
public static IInputStateChangeMonitor AddStateChangeMonitor(InputControl control, Action<InputControl, double, InputEventPtr, long> valueChangeCallback, int monitorIndex = -1, Action<InputControl, double, long, int> timerExpiredCallback = null)Parameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| System.Action<InputControl, System.Double, InputEventPtr, System.Int64> | valueChangeCallback | |
| System.Int32 | monitorIndex | |
| System.Action<InputControl, System.Double, System.Int64, System.Int32> | timerExpiredCallback | 
Returns
| Type | Description | 
|---|---|
| IInputStateChangeMonitor | 
AddStateChangeMonitor(InputControl, IInputStateChangeMonitor, Int64)
Declaration
public static void AddStateChangeMonitor(InputControl control, IInputStateChangeMonitor monitor, long monitorIndex = -1L)Parameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| IInputStateChangeMonitor | monitor | |
| System.Int64 | monitorIndex | 
AddStateChangeMonitorTimeout(InputControl, IInputStateChangeMonitor, Double, Int64, Int32)
Put a timeout on a previously registered state change monitor.
Declaration
public static void AddStateChangeMonitorTimeout(InputControl control, IInputStateChangeMonitor monitor, double time, long monitorIndex = -1L, int timerIndex = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| IInputStateChangeMonitor | monitor | |
| System.Double | time | |
| System.Int64 | monitorIndex | |
| System.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.
DisableAllEnabledActions()
Disable all actions (and implicitly all action sets) that are currently enabled.
Declaration
public static void DisableAllEnabledActions()See Also
DisableDevice(InputDevice)
Declaration
public static void DisableDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
EnableDevice(InputDevice)
Declaration
public static void EnableDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
FindControls(String)
Find all controls that match the given InputControlPath.
Declaration
public static InputControlList<InputControl> FindControls(string path)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | 
Returns
| Type | Description | 
|---|---|
| InputControlList<InputControl> | 
Examples
// Find all gamepads (literally: that use the "Gamepad" layout).
InputSystem.FindControls("<Gamepad>");
// Find all sticks on all gamepads.
InputSystem.FindControls("<Gamepad>/*stick");
// Same but filter stick by type rather than by name.
InputSystem.FindControls<StickControl>("<Gamepad>/*");See Also
FindControls<TControl>(String)
Declaration
public static InputControlList<TControl> FindControls<TControl>(string path)
    where TControl : InputControlParameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | 
Returns
| Type | Description | 
|---|---|
| InputControlList<TControl> | 
Type Parameters
| Name | Description | 
|---|---|
| TControl | 
FindControls<TControl>(String, ref InputControlList<TControl>)
Declaration
public static int FindControls<TControl>(string path, ref InputControlList<TControl> controls)
    where TControl : InputControlParameters
| Type | Name | Description | 
|---|---|---|
| System.String | path | |
| InputControlList<TControl> | controls | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | 
Type Parameters
| Name | Description | 
|---|---|
| TControl | 
GetDevice(String)
Declaration
public static InputDevice GetDevice(string nameOrLayout)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | nameOrLayout | 
Returns
| Type | Description | 
|---|---|
| InputDevice | 
GetDevice<TDevice>()
Declaration
public static TDevice GetDevice<TDevice>()
    where TDevice : InputDeviceReturns
| Type | Description | 
|---|---|
| TDevice | 
Type Parameters
| Name | Description | 
|---|---|
| TDevice | 
GetDevice<TDevice>(String)
Declaration
public static TDevice GetDevice<TDevice>(string usage)
    where TDevice : InputDeviceParameters
| Type | Name | Description | 
|---|---|---|
| System.String | usage | 
Returns
| Type | Description | 
|---|---|
| TDevice | 
Type Parameters
| Name | Description | 
|---|---|
| TDevice | 
GetDevice<TDevice>(InternedString)
Declaration
public static TDevice GetDevice<TDevice>(InternedString usage)
    where TDevice : InputDeviceParameters
| Type | Name | Description | 
|---|---|---|
| InternedString | usage | 
Returns
| Type | Description | 
|---|---|
| TDevice | 
Type Parameters
| Name | Description | 
|---|---|
| TDevice | 
GetDeviceById(Int32)
Look up a device by its unique ID.
Declaration
public static InputDevice GetDeviceById(int deviceId)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | deviceId | Unique ID of device. Such as given by deviceId. | 
Returns
| Type | Description | 
|---|---|
| InputDevice | The device for the given ID or null if no device with the given ID exists (or no longer exists). | 
Remarks
Device IDs are not reused in a given session of the application (or Unity editor).
See Also
GetMetrics()
Declaration
public static InputMetrics GetMetrics()Returns
| Type | Description | 
|---|---|
| InputMetrics | 
GetUnsupportedDevices()
Return the list of devices that have been reported by the IInputRuntime but could not be matched to any known InputControlLayout.
Declaration
public static List<InputDeviceDescription> GetUnsupportedDevices()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<InputDeviceDescription> | A list of descriptions of devices that could not be recognized. | 
Remarks
If new layouts are added to the system or if additional InputDeviceMatcher are added to existing layouts, devices in this list may appear or disappear.
See Also
GetUnsupportedDevices(List<InputDeviceDescription>)
Declaration
public static int GetUnsupportedDevices(List<InputDeviceDescription> descriptions)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.List<InputDeviceDescription> | descriptions | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | 
ListEnabledActions()
Return a list of all the actions that are currently enabled in the system.
Declaration
public static List<InputAction> ListEnabledActions()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<InputAction> | A new list instance containing all currently enabled actions. | 
Remarks
To avoid allocations, use ListEnabledActions(List<InputAction>).
See Also
ListEnabledActions(List<InputAction>)
Add all actions that are currently enabled in the system to the given list.
Declaration
public static int ListEnabledActions(List<InputAction> actions)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.List<InputAction> | actions | List to add actions to. | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | The number of actions added to the list. | 
Remarks
If the capacity of the given list is large enough, this method will not allocate memory.
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
ListInteractions()
Declaration
public static IEnumerable<string> ListInteractions()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | 
ListLayouts()
Return a list with the names of all layouts that have been registered.
Declaration
public static List<string> ListLayouts()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.String> | A list of layout names. | 
See Also
ListLayouts(List<String>)
Add the names of all layouts that have been registered to the given list.
Declaration
public static int ListLayouts(List<string> list)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.List<System.String> | list | List to add the layout names to. | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | The number of names added to  | 
Remarks
If the capacity of the given list is large enough, this method will not allocate.
ListLayoutsBasedOn(String)
Declaration
public static List<string> ListLayoutsBasedOn(string baseLayout)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | baseLayout | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.String> | 
ListLayoutsBasedOn(String, List<String>)
Declaration
public static int ListLayoutsBasedOn(string baseLayout, List<string> list)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | baseLayout | |
| System.Collections.Generic.List<System.String> | list | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | 
ListProcessors()
Declaration
public static IEnumerable<string> ListProcessors()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | 
LoadLayout(String)
Try to load a layout instance.
Declaration
public static InputControlLayout LoadLayout(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of the layout to load. Note that layout names are case-insensitive. | 
Returns
| Type | Description | 
|---|---|
| InputControlLayout | The constructed layout instance or null if no layout of the given name could be found. | 
LoadLayout<TControl>()
Declaration
public static InputControlLayout LoadLayout<TControl>()
    where TControl : InputControlReturns
| Type | Description | 
|---|---|
| InputControlLayout | 
Type Parameters
| Name | Description | 
|---|---|
| TControl | 
PauseHaptics()
Pause haptic effect playback on all devices.
Declaration
public static void PauseHaptics()Remarks
Calls PauseHaptics() on all InputDevice that implement the interface.
Examples
// When going into the menu from gameplay, pause haptics.
gameplayControls.backAction.onPerformed +=
    ctx =>
    {
        gameplayControls.Disable();
        menuControls.Enable();
        InputSystem.PauseHaptics();
    };See Also
QueueConfigChangeEvent(InputDevice, Double)
Declaration
public static void QueueConfigChangeEvent(InputDevice device, double time = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| System.Double | time | 
QueueDeltaStateEvent<TDelta>(InputControl, TDelta, Double)
Declaration
public static void QueueDeltaStateEvent<TDelta>(InputControl control, TDelta delta, double time = -1)
    where TDelta : structParameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| TDelta | delta | |
| System.Double | time | 
Type Parameters
| Name | Description | 
|---|---|
| TDelta | 
QueueEvent(InputEventPtr)
Declaration
public static void QueueEvent(InputEventPtr eventPtr)Parameters
| Type | Name | Description | 
|---|---|---|
| InputEventPtr | eventPtr | 
QueueEvent<TEvent>(ref TEvent)
Declaration
public static void QueueEvent<TEvent>(ref TEvent inputEvent)
    where TEvent : struct, IInputEventTypeInfoParameters
| Type | Name | Description | 
|---|---|---|
| TEvent | inputEvent | 
Type Parameters
| Name | Description | 
|---|---|
| TEvent | 
QueueStateEvent<TState>(InputDevice, TState, Double)
Declaration
public static void QueueStateEvent<TState>(InputDevice device, TState state, double time = -1)
    where TState : struct, IInputStateTypeInfoParameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| TState | state | |
| System.Double | time | 
Type Parameters
| Name | Description | 
|---|---|
| TState | 
QueueTextEvent(InputDevice, Char, Double)
Queue a text input event on the given device.
Declaration
public static void QueueTextEvent(InputDevice device, char character, double time = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | Device to queue the event on. | 
| System.Char | character | Text character to input through the event. | 
| System.Double | time | Optional event time stamp. If not supplied, the current time will be used. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.InvalidOperationException | 
 | 
RegisterBindingComposite(Type, String)
Declaration
public static void RegisterBindingComposite(Type type, string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | |
| System.String | name | 
RegisterBindingComposite<T>(String)
Declaration
public static void RegisterBindingComposite<T>(string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Type Parameters
| Name | Description | 
|---|---|
| T | 
RegisterControlProcessor(Type, String)
Register an InputProcessor<TValue> with the system.
Declaration
public static void RegisterControlProcessor(Type type, string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | Type that implements InputProcessor<TValue>. | 
| System.String | name | Name to use for the processor. If null or empty, name will be taken from short name
of  | 
RegisterControlProcessor<T>(String)
Declaration
public static void RegisterControlProcessor<T>(string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Type Parameters
| Name | Description | 
|---|---|
| T | 
RegisterInteraction(Type, String)
Declaration
public static void RegisterInteraction(Type type, string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | |
| System.String | name | 
RegisterInteraction<T>(String)
Declaration
public static void RegisterInteraction<T>(string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Type Parameters
| Name | Description | 
|---|---|
| T | 
RegisterLayout(String, String, Nullable<InputDeviceMatcher>)
Register a layout in JSON format.
Declaration
public static void RegisterLayout(string json, string name = null, InputDeviceMatcher? matches = default(InputDeviceMatcher? ))Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | json | Layout in JSON format. | 
| System.String | name | Optional name of the layout. If null or empty, the name is taken from the "name" property of the JSON data. If it is supplied, it will override the "name" property if present. If neither is supplied, an System.ArgumentException is thrown. | 
| System.Nullable<InputDeviceMatcher> | matches | 
Remarks
Note that most errors in layouts will only be detected when instantiated (i.e. when a device or control is being created from a layout). The JSON data will, however, be parsed once on registration to check for a device description in the layout. JSON format errors will thus be detected during registration.
Examples
InputSystem.RegisterLayout(@"
   {
       ""name"" : ""MyDevice"",
       ""controls"" : [
           {
               ""name"" : ""myThing"",
               ""layout"" : ""MyControl"",
               ""usage"" : ""LeftStick""
           }
       ]
   }
);Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentException | No name has been supplied either through  | 
RegisterLayout(Type, String, Nullable<InputDeviceMatcher>)
Register a control layout based on a type.
Declaration
public static void RegisterLayout(Type type, string name = null, InputDeviceMatcher? matches = default(InputDeviceMatcher? ))Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | Type to derive a control layout from. Must be derived from InputControl. | 
| System.String | name | Name to use for the layout. If null or empty, the short name of the type will be used. | 
| System.Nullable<InputDeviceMatcher> | matches | Optional device description. If this is supplied, the layout will automatically be instantiated for newly discovered devices that match the description. | 
Remarks
When the layout is instantiated, the system will reflect on all public fields and properties of the type which have a value type derived from InputControl or which are annotated with InputControlAttribute.
RegisterLayout<T>(String, Nullable<InputDeviceMatcher>)
Register a type as a control layout.
Declaration
public static void RegisterLayout<T>(string name = null, InputDeviceMatcher? matches = default(InputDeviceMatcher? ))
    where T : InputControlParameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name to use for the layout. If null or empty, the short name of the type will be used. | 
| System.Nullable<InputDeviceMatcher> | matches | Optional device description. If this is supplied, the layout will automatically be instantiated for newly discovered devices that match the description. | 
Type Parameters
| Name | Description | 
|---|---|
| T | Type to derive a control layout from. | 
Remarks
When the layout is instantiated, the system will reflect on all public fields and properties of the type which have a value type derived from InputControl or which are annotated with InputControlAttribute.
RegisterLayoutBuilder(Expression<Func<InputControlLayout>>, String, String, Nullable<InputDeviceMatcher>)
Declaration
public static void RegisterLayoutBuilder(Expression<Func<InputControlLayout>> builderExpression, string name, string baseLayout = null, InputDeviceMatcher? matches = default(InputDeviceMatcher? ))Parameters
| Type | Name | Description | 
|---|---|---|
| Expression<System.Func<InputControlLayout>> | builderExpression | |
| System.String | name | |
| System.String | baseLayout | |
| System.Nullable<InputDeviceMatcher> | matches | 
RegisterLayoutMatcher(String, InputDeviceMatcher)
Declaration
public static void RegisterLayoutMatcher(string layoutName, InputDeviceMatcher matcher)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | layoutName | |
| InputDeviceMatcher | matcher | 
RegisterLayoutMatcher<TDevice>(InputDeviceMatcher)
Declaration
public static void RegisterLayoutMatcher<TDevice>(InputDeviceMatcher matcher)
    where TDevice : InputDeviceParameters
| Type | Name | Description | 
|---|---|---|
| InputDeviceMatcher | matcher | 
Type Parameters
| Name | Description | 
|---|---|
| TDevice | 
RegisterLayoutOverride(String, String)
Register a layout that applies overrides to one or more other layouts.
Declaration
public static void RegisterLayoutOverride(string json, string name = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | json | Layout in JSON format. | 
| System.String | name | Optional name of the layout. If null or empty, the name is taken from the "name" property of the JSON data. If it is supplied, it will override the "name" property if present. If neither is supplied, an System.ArgumentException is thrown. | 
Remarks
Layout overrides are layout pieces that are applied on top of existing layouts. This can be used to modify any layout in the system non-destructively. The process works the same as extending an existing layout except that instead of creating a new layout by merging the derived layout and the base layout, the overrides are merged directly into the base layout.
Layouts used as overrides look the same as normal layouts and have the same format. The only difference is that they are explicitly registered as overrides.
Note that unlike "normal" layouts, layout overrides have the ability to extend multiple base layouts.
RemoveDevice(InputDevice)
Declaration
public static void RemoveDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
RemoveDeviceUsage(InputDevice, InternedString)
Declaration
public static void RemoveDeviceUsage(InputDevice device, InternedString usage)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| InternedString | usage | 
RemoveDisconnectedDevices()
Purge all disconnected devices from disconnectedDevices.
Declaration
public static void RemoveDisconnectedDevices()Remarks
This will release all references held on to for these devices or any of their controls and will allow the devices to be reclaimed by the garbage collector.
See Also
RemoveLayout(String)
Remove an already registered layout from the system.
Declaration
public static void RemoveLayout(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of the layout to remove. Note that layout names are case-insensitive. | 
Remarks
Note that removing a layout also removes all devices that directly or indirectly use the layout.
This method can be used to remove both control or device layouts.
RemoveStateChangeMonitor(InputControl, IInputStateChangeMonitor, Int64)
Declaration
public static void RemoveStateChangeMonitor(InputControl control, IInputStateChangeMonitor monitor, long monitorIndex = -1L)Parameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| IInputStateChangeMonitor | monitor | |
| System.Int64 | monitorIndex | 
RemoveStateChangeMonitorTimeout(IInputStateChangeMonitor, Int64, Int32)
Declaration
public static void RemoveStateChangeMonitorTimeout(IInputStateChangeMonitor monitor, long monitorIndex = -1L, int timerIndex = -1)Parameters
| Type | Name | Description | 
|---|---|---|
| IInputStateChangeMonitor | monitor | |
| System.Int64 | monitorIndex | |
| System.Int32 | timerIndex | 
ResetHaptics()
Stop haptic effect playback on all devices.
Declaration
public static void ResetHaptics()Remarks
Will reset haptics effects on all devices to their default state.
Calls ResetHaptics() on all InputDevice that implement the interface.
ResumeHaptics()
Resume haptic effect playback on all devices.
Declaration
public static void ResumeHaptics()Remarks
Calls ResumeHaptics() on all InputDevice that implement the interface.
See Also
SetDeviceUsage(InputDevice, String)
Declaration
public static void SetDeviceUsage(InputDevice device, string usage)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| System.String | usage | 
SetDeviceUsage(InputDevice, InternedString)
Declaration
public static void SetDeviceUsage(InputDevice device, InternedString usage)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | |
| InternedString | usage | 
SetLayoutVariant(InputControl, String)
Declaration
public static void SetLayoutVariant(InputControl control, string variant)Parameters
| Type | Name | Description | 
|---|---|---|
| InputControl | control | |
| System.String | variant | 
TryFindMatchingLayout(InputDeviceDescription)
Try to match a description for an input device to a layout.
Declaration
public static string TryFindMatchingLayout(InputDeviceDescription deviceDescription)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDeviceDescription | deviceDescription | Description of an input device. | 
Returns
| Type | Description | 
|---|---|
| System.String | Name of the layout that has been matched to the given description or null if no matching layout was found. | 
Remarks
Layouts are matched by the InputDeviceDescription they were registered with (if any).
The fields in a layout's device description are considered regular expressions which are matched
against the values supplied in the given deviceDescription.
Examples
var layoutName = InputSystem.TryFindMatchingLayout(
    new InputDeviceDescription
    {
        product = "Xbox Wired Controller",
        manufacturer = "Microsoft"
    }
);TryGetBindingComposite(String)
Declaration
public static Type TryGetBindingComposite(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Returns
| Type | Description | 
|---|---|
| System.Type | 
TryGetInteraction(String)
Declaration
public static Type TryGetInteraction(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Returns
| Type | Description | 
|---|---|
| System.Type | 
TryGetProcessor(String)
Declaration
public static Type TryGetProcessor(string name)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | 
Returns
| Type | Description | 
|---|---|
| System.Type | 
TryResetDevice(InputDevice)
Declaration
public static bool TryResetDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
TrySyncDevice(InputDevice)
Declaration
public static bool TrySyncDevice(InputDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| InputDevice | device | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Update()
Declaration
public static void Update()Update(InputUpdateType)
Declaration
public static void Update(InputUpdateType updateType)Parameters
| Type | Name | Description | 
|---|---|---|
| InputUpdateType | updateType | 
Events
onActionChange
Event that is signalled when the state of enabled actions in the system changes or when actions are triggered.
Declaration
public static event Action<object, InputActionChange> onActionChangeEvent Type
| Type | Description | 
|---|---|
| System.Action<System.Object, InputActionChange> | 
Remarks
The object received by the callback is either an InputAction or an InputActionMap depending on whether the InputActionChange affects a single action or an entire action map.
Examples
InputSystem.onActionChange +=
    (obj, change) =>
    {
        if (change == InputActionChange.ActionPerformed)
        {
            var action = (InputAction)obj;
            var control = action.lastTriggerControl;
            ....
        }
    };onAfterUpdate
Event that is fired after the input system has completed an update and processed all pending events.
Declaration
public static event Action<InputUpdateType> onAfterUpdateEvent Type
| Type | Description | 
|---|---|
| System.Action<InputUpdateType> | 
See Also
onBeforeUpdate
Event that is fired before the input system updates.
Declaration
public static event Action<InputUpdateType> onBeforeUpdateEvent Type
| Type | Description | 
|---|---|
| System.Action<InputUpdateType> | 
Remarks
The input system updates in sync with player loop and editor updates. Input updates
are run right before the respective script update. For example, an input update for
Dynamic is run before MonoBehaviour.Update methods
are executed.
The update callback itself is triggered before the input system runs its own update and before it flushes out its event queue. This means that events queued from a callback will be fed right into the upcoming update.
See Also
onDeviceChange
Event that is signalled when the device setup in the system changes.
Declaration
public static event Action<InputDevice, InputDeviceChange> onDeviceChangeEvent Type
| Type | Description | 
|---|---|
| System.Action<InputDevice, InputDeviceChange> | 
Remarks
This can be used to detect when devices are added or removed as well as detecting when existing devices change their configuration.
Examples
InputSystem.onDeviceChange +=
    (device, change) =>
    {
        switch (change)
        {
            case InputDeviceChange.Added:
                Debug.Log("Device added: " + device);
                break;
            case InputDeviceChange.Removed:
                Debug.Log("Device removed: " + device);
                break;
            case InputDeviceChange.ConfigurationChanged:
                Debug.Log("Device configuration changed: " + device);
                break;
        }
    };onDeviceCommand
Event that is signalled when a InputDeviceCommand is sent to an InputDevice.
Declaration
public static event InputDeviceCommandDelegate onDeviceCommandEvent Type
| Type | Description | 
|---|---|
| InputDeviceCommandDelegate | 
Remarks
This can be used to intercept commands and optionally handle them without them reaching the IInputRuntime.
The first delegate in the list that returns a result other than null is considered
to have handled the command. If a command is handled by a delegate in the list, it will
not be sent on to the runtime.
See Also
onEvent
Declaration
public static event Action<InputEventPtr> onEventEvent Type
| Type | Description | 
|---|---|
| System.Action<InputEventPtr> | 
onEvents
Like onEvent but sends all events that have been received in an update as a single buffer rather than each event one by one.
Declaration
public static event Action<InputEventBuffer> onEventsEvent Type
| Type | Description | 
|---|---|
| System.Action<InputEventBuffer> | 
Remarks
The buffer can be modified by a callback receiver. The system will process whatever is left in the buffer after callbacks have been invoked.
onFindLayoutForDevice
Event that is signalled when the system is trying to match a layout to a device it has discovered.
Declaration
public static event InputDeviceFindControlLayoutDelegate onFindLayoutForDeviceEvent Type
| Type | Description | 
|---|---|
| InputDeviceFindControlLayoutDelegate | 
Remarks
This event allows customizing the layout discovery process and to generate
layouts on the fly, if need be. The system will invoke callbacks with the
name of the layout it has matched (or null if it couldn't find any
matching layout to the device based on the current layout setup. If all
the callbacks return null, that layout will be instantiated. If,
however, any of the callbacks returns a new name instead, the system will use that
layout instead.
To generate layouts on the fly, register them with the system in the callback and then return the name of the newly generated layout from the callback.
Note that this callback will also be invoked if the system could not match any
existing layout to the device. In that case, the matchedLayout argument
to the callback will be null.
Callbacks also receive a device ID and reference to the input runtime. For devices where more information has to be fetched from the runtime in order to generate a layout, this allows issuing DeviceCommand(Int32, InputDeviceCommand*) calls for the device. Note that for devices that are not coming from the runtime (i.e. devices created directly in script code), the device ID will be InvalidDeviceId.
Examples
InputSystem.onFindLayoutForDevice +=
    (deviceId, description, matchedLayout, runtime) =>
    {
        ////TODO: complete example
    };onLayoutChange
Event that is signalled when the layout setup in the system changes.
Declaration
public static event Action<string, InputControlLayoutChange> onLayoutChangeEvent Type
| Type | Description | 
|---|---|
| System.Action<System.String, InputControlLayoutChange> | 
onSettingsChange
Event that is triggered if any of the properties in settings changes or if settings is replaced entirely with a new InputSettings object.
Declaration
public static event Action onSettingsChangeEvent Type
| Type | Description | 
|---|---|
| System.Action |