Skip to content

Commit 4b636c7

Browse files
committed
enduser-docs review
1 parent debc9e3 commit 4b636c7

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

Packages/com.unity.inputsystem/Documentation~/Architecture.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
22
uid: input-system-architecture
3-
description: Understand how the Input System's low-level and high-level layers turn platform input into actions that your application responds to.
43
---
54
# Input System architecture
65

76
Understand how the Input System's low-level and high-level layers turn platform input into actions that your application responds to.
87

98
The Input System has two layers. The low-level layer receives raw input from the platform-specific back end that ships with Unity, and stores that input as device state in unmanaged memory. The high-level layer interprets that state as controls, actions, and bindings that your application code responds to.
109

11-
This page describes the built-in back end that supplies the input, then the low-level system that stores it, then the high-level system that interprets it.
10+
The built-in back end supplies the input, the low-level system stores it, and the high-level system interprets it.
1211

1312
## The built-in back end
1413

15-
The foundation of the Input System is the built-in back-end code. This platform-specific code collects information about the available devices, and the input data from those devices. The code isn't part of the Input System package; it ships with Unity itself, and it has an implementation for each runtime platform that Unity supports.
14+
The foundation of the Input System is the built-in back-end code. This platform-specific code collects information about the available devices, and the input data from those devices. The code isn't part of the Input System package; it ships with Unity itself, and it has an implementation for each runtime platform that Unity supports.
1615

1716
The Input System interfaces with the built-in back end in two ways:
1817

@@ -33,7 +32,8 @@ The low-level system works as a layered pipeline. The following three diagrams e
3332
2. The `InputManager` class uses layouts to build devices.
3433
3. Each device writes its state into input state memory.
3534

36-
**Note**: `InputManager` is the Input System class that owns devices and drives updates. It's not the **Input Manager** window, which configures Unity's legacy input settings.
35+
> [!NOTE]
36+
> `InputManager` is the Input System class that owns devices and drives updates. It's not the **Input Manager** window, which configures Unity's legacy input settings.
3737
3838
The following table describes the color coding that all the diagrams on this page use:
3939

@@ -55,7 +55,7 @@ The built-in back ends push discovery and state events into the device discovery
5555

5656
```mermaid
5757
flowchart TB
58-
%% Diagram 1 of 3: platform back ends queue events
58+
%% Diagram 1: platform back ends queue events
5959
backends["Platform back ends
6060
Windows · macOS · Linux · UWP · iOS · Android
6161
· Switch · Xbox · PS4 · Web · XR"]
@@ -74,7 +74,7 @@ flowchart TB
7474
EQ -->|"Update (flushes event buffers)"| InputManager
7575
BEQ -->|"Flushed by the main thread"| EQ
7676
InputManager -->|"Queue event"| EQ
77-
InputManager -->|"Device command (IOCTL-style)"| backends
77+
InputManager -->|"Device command"| backends
7878
7979
InputManager -.-> out1>"→ Diagram 2: layouts build devices"]
8080
@@ -92,15 +92,15 @@ flowchart TB
9292

9393
Layouts derive from one another. Together with reusable control building blocks, they describe how to build devices and their controls. The `InputManager` class searches these layouts and creates the concrete devices.
9494

95-
For example:
95+
The following examples show how layouts and building blocks relate to one another:
9696

9797
- The `Mouse`, `Pen`, and `Touchscreen` layouts all derive from the `Pointer` layout.
98-
- The PS4 and HID variants of `DualShock` both derive from a shared `DualShock` layout, which itself derives from `Gamepad`.
98+
- The PS4 and human interface device (HID) variants of `DualShock` both derive from a shared `DualShock` layout, which itself derives from `Gamepad`.
9999
- Building blocks such as `Stick`, `Axis`, `Button`, and `Dpad` supply the individual controls that each device exposes.
100100

101101
```mermaid
102102
flowchart TB
103-
%% Diagram 2 of 3: layouts build devices
103+
%% Diagram 2: layouts build devices
104104
%% Bands stack top-to-bottom; each band is compact left-to-right.
105105
106106
in2>"→ from Diagram 1: the InputManager class"] -.-> InputManager
@@ -159,16 +159,16 @@ flowchart TB
159159

160160
Each built device exposes a tree of controls. When state events arrive, the Input System writes the device and control state into input state memory, where each device and control has its own chunk of unmanaged memory.
161161

162-
For example:
162+
The following examples show how devices expose controls:
163163

164164
- A `Gamepad` device exposes a `leftStick` control that resolves to the `x`, `y`, `up`, `down`, `left`, and `right` controls.
165-
- A `Keyboard` device exposes one control for each key.
165+
- A `Keyboard` device exposes one control for each key.
166166

167167
Both devices write into the same input state memory.
168168

169169
```mermaid
170170
flowchart TB
171-
%% Diagram 3 of 3: devices store their state in memory
171+
%% Diagram 3: devices store their state in memory
172172
%% Outer flow is top-to-bottom; subgraphs run left-to-right so controls stay readable.
173173
in3>"→ from Diagram 2: the built devices"] -.-> GP & KB
174174
@@ -215,13 +215,13 @@ The high-level system also lets you do the following:
215215

216216
Two diagrams describe the high-level system:
217217

218-
1. How input flows through the system at runtime.
219-
1. How you author actions as assets.
218+
1. The first diagram shows how input flows through the system at runtime.
219+
1. The second diagram shows how you author actions as assets.
220220

221-
Both diagrams show a single player. Each additional player has:
221+
Both diagrams show a single player. For each additional player, the Input System creates the following objects:
222222

223-
- Its own `InputActionState` object.
224-
- A cloned `InputActionAsset` object with its own device list and binding mask.
223+
- An `InputActionState` object for that player.
224+
- A cloned [`InputActionAsset`](xref:UnityEngine.InputSystem.InputActionAsset) object with its own device list and binding mask.
225225

226226
### Diagram 4: Runtime input flow
227227

@@ -230,18 +230,19 @@ At runtime, input reaches your scene through four steps:
230230
1. The Input System writes a device's control state into input state memory.
231231
2. A state change monitor notices the change.
232232
3. The Input System updates the `InputActionState` object.
233-
4. The resulting action fires a callback on the `PlayerInput` component in the scene.
233+
4. The resulting action fires a callback on the [`PlayerInput`](xref:UnityEngine.InputSystem.PlayerInput) component in the scene.
234234

235235
The following diagram traces those steps for a single control, the space key on a keyboard:
236236

237-
1. The keyboard's space control stores its value as one bit of `KeyboardState`.
238-
1. A `StateEvent` object carrying that state feeds `InputManager.OnUpdate()`, which calls `NotifyControlStateChanged()` on the `InputActionState` object.
239-
That object holds three arrays: `triggerStates[]`, `bindingStates[]`, and `controls[]`.
237+
1. The keyboard's space control stores its value as one bit of `KeyboardState`.
238+
1. A [`StateEvent`](xref:UnityEngine.InputSystem.LowLevel.StateEvent) object carrying that state feeds `InputManager.OnUpdate()`, which calls `NotifyControlStateChanged()` on the `InputActionState` object.
239+
That object holds three arrays: `triggerStates[]`, `bindingStates[]`, and `controls[]`.
240240
1. State change monitors update the binding and control arrays.
241-
1. The trigger array notifies `InputUser`, which calls `OnActionTriggered()` on the `PlayerInput` component.
241+
1. The trigger array notifies [`InputUser`](xref:UnityEngine.InputSystem.Users.InputUser), which calls `OnActionTriggered()` on the `PlayerInput` component.
242242

243243
```mermaid
244244
flowchart TB
245+
%% Diagram 4: runtime input flow
245246
%% ---------- Devices ----------
246247
Keyboard["Keyboard"] --> space["space"]
247248
@@ -288,15 +289,16 @@ An `InputActionAsset` object contains action maps, actions, and bindings. At run
288289

289290
The following diagram shows an asset named `MyGame.inputactions` that lists `Keyboard` as its device and masks bindings to the `KeyboardMouse` group:
290291

291-
1. The asset contains a `gameplay` action map, which contains a `jump` action and two bindings for that action:
292+
1. The asset contains a `gameplay` action map, which contains a `jump` action and two bindings for that action:
292293
- `<Keyboard>/space` in the `KeyboardMouse` group.
293-
- `<Gamepad>/buttonSouth` in the `Gamepad` group.
294+
- `<Gamepad>/buttonSouth` in the `Gamepad` group.
294295
1. The action populates `triggerStates[]`.
295296
1. The bindings populate `bindingStates[]`.
296297
1. The binding states resolve to `controls[]`.
297298

298299
```mermaid
299300
flowchart TB
301+
%% Diagram 5: action asset structure
300302
%% ---------- Asset hierarchy ----------
301303
Asset["InputActionAsset: MyGame.inputactions
302304
devices = [ Keyboard ]

0 commit comments

Comments
 (0)