--- uid: input-system-controls --- # Controls An input control represents a source of values. These values can be of any structured or primitive type. The only requirement is that the type is [blittable](https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types). > [!NOTE] > Controls are for input only. Output and configuration items on input devices are not represented as controls. ## Identification Each control is identified by its [name](xref:UnityEngine.InputSystem.InputControl.name). Optionally, it can also have a different [display name](xref:UnityEngine.InputSystem.InputControl.displayName). For example, the right-hand face button closest to the touchpad on a PlayStation DualShock 4 controller has the control name "buttonWest" and the display name "Square". Additionally, a control might have one or more aliases which provide alternative names for the control. You can access the aliases for a specific control through its [`aliases`](xref:UnityEngine.InputSystem.InputControl.aliases) property. Finally, a control might also have a short display name which can be accessed through the [`shortDisplayName`](xref:UnityEngine.InputSystem.InputControl.shortDisplayName) property. For example, the short display name for the left mouse button is "LMB". ## Control hierarchies Controls can form hierarchies. The root of a control hierarchy is always a [device](xref:input-system-devices). The setup of hierarchies is exclusively controlled through [layouts](xref:input-system-layouts). You can access the parent of a control using its [`parent`](xref:UnityEngine.InputSystem.InputControl.parent) property, and its children using [`children`](xref:UnityEngine.InputSystem.InputControl.children). To access the flattened hierarchy of all controls on a device, use [`allControls`](xref:UnityEngine.InputSystem.InputDevice.allControls). ## Control types All controls are based on the [`InputControl`](xref:UnityEngine.InputSystem.InputControl) base class. Most concrete implementations are based on [InputControl](xref:UnityEngine.InputSystem.InputControl`1). The Input System provides the following types of controls out of the box: |Control Type|Description|Example| |------------|-----------|-------| |[`AxisControl`](xref:UnityEngine.InputSystem.Controls.AxisControl)|A 1D floating-point axis.|[`Gamepad.leftStick.x`](xref:UnityEngine.InputSystem.Controls.Vector2Control.x)| |[`ButtonControl`](xref:UnityEngine.InputSystem.Controls.ButtonControl)|A button expressed as a floating-point value. Whether the button can have a value other than 0 or 1 depends on the underlying representation. For example, gamepad trigger buttons can have values other than 0 and 1, but gamepad face buttons generally can't.|[`Mouse.leftButton`](xref:UnityEngine.InputSystem.Mouse.leftButton)| |[`KeyControl`](xref:UnityEngine.InputSystem.Controls.KeyControl)|A specialized button that represents a key on a [`Keyboard`](xref:UnityEngine.InputSystem.Keyboard). Keys have an associated [`keyCode`](xref:UnityEngine.InputSystem.Controls.KeyControl.keyCode) and, unlike other types of controls, change their display name in accordance to the currently active system-wide keyboard layout. See the [Keyboard](xref:input-system-keyboard) documentation for details.|[`Keyboard.aKey`](xref:UnityEngine.InputSystem.Keyboard.aKey)| |[`Vector2Control`](xref:UnityEngine.InputSystem.Controls.Vector2Control)|A 2D floating-point vector.|[`Pointer.position`](xref:UnityEngine.InputSystem.Pointer.position)| |[`Vector3Control`](xref:UnityEngine.InputSystem.Controls.Vector3Control)|A 3D floating-point vector.|[`Accelerometer.acceleration`](xref:UnityEngine.InputSystem.Accelerometer.acceleration)| |[`QuaternionControl`](xref:UnityEngine.InputSystem.Controls.QuaternionControl)|A 3D rotation.|[`AttitudeSensor.attitude`](xref:UnityEngine.InputSystem.AttitudeSensor.attitude)| |[`IntegerControl`](xref:UnityEngine.InputSystem.Controls.IntegerControl)|An integer value.|[`Touchscreen.primaryTouch.touchId`](xref:UnityEngine.InputSystem.Controls.TouchControl.touchId)| |[`StickControl`](xref:UnityEngine.InputSystem.Controls.StickControl)|A 2D stick control like the thumbsticks on gamepads or the stick control of a joystick.|[`Gamepad.rightStick`](xref:UnityEngine.InputSystem.Gamepad.rightStick)| |[`DpadControl`](xref:UnityEngine.InputSystem.Controls.DpadControl)|A 4-way button control like the D-pad on gamepads or hatswitches on joysticks.|[`Gamepad.dpad`](xref:UnityEngine.InputSystem.Gamepad.dpad)| |[`TouchControl`](xref:UnityEngine.InputSystem.Controls.TouchControl)|A control that represents all the properties of a touch on a [touch screen](xref:input-system-touch).|[`Touchscreen.primaryTouch`](xref:UnityEngine.InputSystem.Touchscreen.primaryTouch)| You can browse the set of all registered control layouts in the [input debugger](xref:input-system-debugging#debugging-layouts). ## Control usages A control can have one or more associated usages. A usage is a string that denotes the control's intended use. An example of a control usage is `Submit`, which labels a control that is commonly used to confirm a selection in the UI. On a gamepad, this usage is commonly found on the `buttonSouth` control. You can access a control's usages using the [`InputControl.usages`](xref:UnityEngine.InputSystem.InputControl.usages) property. Usages can be arbitrary strings. However, a certain set of usages is very commonly used and comes predefined in the API in the [`CommonUsages`](xref:UnityEngine.InputSystem.CommonUsages) static class. ## Control paths The Input System can look up controls using textual paths. [Bindings](xref:input-system-action-bindings) on Input Actions rely on this feature to identify the control(s) they read input from. For example, `/leftStick/x` means "X control on left stick of gamepad". However, you can also use them for lookup directly on controls and devices, or to let the Input System search for controls among all devices using [`InputSystem.FindControls`](xref:UnityEngine.InputSystem.InputSystem.FindControls(System.String)): ```CSharp var gamepad = Gamepad.all[0]; var leftStickX = gamepad["leftStick/x"]; var submitButton = gamepad["{Submit}"]; var allSubmitButtons = InputSystem.FindControls("*/{Submit}"); ``` Control paths resemble file system paths: they contain components separated by a forward slash (`/`): component/component... Each component itself contains a set of [fields](#component-fields) with its own syntax. Each field is individually optional, provided that at least one of the fields is present as either a name or a wildcard: ```structured text {usageName}#(displayName)controlName ``` You can access the literal path of a given control via its [`InputControl.path`](xref:UnityEngine.InputSystem.InputControl.path) property. If you need to, you can manually parse a control path into its components using the [`InputControlPath.Parse(path)`](xref:UnityEngine.InputSystem.InputControlPath.Parse(System.String)) API: ```CSharp var parsed = InputControlPath.Parse("{LeftHand}/trigger").ToArray(); Debug.Log(parsed.Length); // Prints 2. Debug.Log(parsed[0].layout); // Prints "XRController". Debug.Log(parsed[0].name); // Prints an empty string. Debug.Log(parsed[0].usages.First()); // Prints "LeftHand". Debug.Log(parsed[1].layout); // Prints null. Debug.Log(parsed[1].name); // Prints "trigger". ``` ### Component fields All fields are case-insensitive. The following table explains the use of each field: |Field|Description|Related links| |-----|-----|------------------| |`layoutName`|The name of the layout that the control must be based on. The actual layout of the control may be the same or a layout *based* on the given layout. For example, ``.|The [Layouts](xref:input-system-layouts) user manual topic

The [InputControlLayout](xref:UnityEngine.InputSystem.Layouts.InputControlLayout) class| |`usageName`|Works differently for controls and devices:
  • When used on a device (the first component of a path), it requires the device to have the given usage. For example, `{LeftHand}/trigger`.
  • For looking up a control, the usage field is currently restricted to the path component immediately following the device (the second component in the path). It finds the control on the device that has the given usage. The control can be anywhere in the control hierarchy of the device. For example, `/{Submit}`.
|The [Device usages](xref:input-system-devices#device-usages) user manual topic

The [Control usages](#control-usages) topic on this page<

The [InputControl.usages](xref:UnityEngine.InputSystem.Layouts.InputControlLayout) property| |`displayName`|Requires the control at the current level to have the given display name. The display name may contain whitespace and symbols. For example:
  • `/#(a)` matches the key that generates the "a" character, if any, according to the current keyboard layout.
  • `/#(Cross)` matches the button named "Cross" on the Gamepad.
|The [Identification](#identification) topic on this page

The [InputControl.displayName](xref:UnityEngine.InputSystem.InputControl.displayName) property| |`controlName`|Requires the control at the current level to have the given name. Takes both "proper" names such as `MyGamepad/buttonSouth`, and aliases such as `MyGamepad/South` into account.

This field can also be a wildcard (`*`) to match any name. For example, `*/{PrimaryAction}` matches any `PrimaryAction` usage on devices with any name.|The [Identification](#identification) topic on this page

The [InputControl.name](xref:UnityEngine.InputSystem.InputControl.name) property for "proper" names

The [InputControl.aliases](xref:UnityEngine.InputSystem.InputControl.aliases) property for aliases| Here are several examples of control paths: ```csharp // Matches all gamepads (also gamepads *based* on the Gamepad layout): "" // Matches the "Submit" control on all devices: "*/" // Matches the key that prints the "a" character on the current keyboard layout: "/#(a)" // Matches the X axis of the left stick on a gamepad. "/leftStick/x" // Matches the orientation control of the right-hand XR controller: "/orientation" // Matches all buttons on a gamepad. "/