You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The diagram below reads top-to-bottom as a layered pipeline: the native **platform backends** at the bottom feed the **InputManager**, which uses **layouts** to build **devices** whose state is stored in **Input State Memory** at the top.
19
+
20
+
```mermaid
21
+
flowchart TB
22
+
%% ---------- Input State Memory (top) ----------
23
+
StateMemory["Input State Memory
24
+
(unmanaged raw memory — each device and control
25
+
gets a chunk that stores its current state)"]
26
+
27
+
%% ---------- Devices (built from layouts) ----------
28
+
Gamepad_D["Gamepad (device)"] --> leftStick
29
+
leftStick --> x & y & up & down & left & right
30
+
Keyboard_D["Keyboard (device)"] --> a & b & c & d
31
+
leftStick -->|"state written to"| StateMemory
32
+
Keyboard_D -->|"state written to"| StateMemory
33
+
34
+
%% ---------- Layouts (describe how to build controls and devices) ----------
35
+
Mouse -->|derives| Pointer
36
+
Pen -->|derives| Pointer
37
+
Touchscreen -->|derives| Pointer
38
+
DS_PS4["DualShock (PS4)"] --> DualShock
39
+
DS_HID["DualShock (HID)"] --> DualShock
40
+
DualShock --> Gamepad_L["Gamepad (layout)"]
41
+
Keyboard_L["Keyboard (layout)"]
42
+
Stick(("Stick"))
43
+
Axis(("Axis"))
44
+
Button(("Button"))
45
+
Dpad(("Dpad"))
46
+
47
+
%% Layout building blocks build the individual device controls
class Mouse,Pen,Touchscreen,Pointer,DS_PS4,DS_HID,DualShock,Gamepad_L,Keyboard_L,Stick,Axis,Button,Dpad layout;
83
+
class Gamepad_D,leftStick,x,y,up,down,left,right,Keyboard_D,a,b,c,d device;
84
+
class DDQ,EQ,BEQ,Backends runtime;
85
+
class StateMemory mem;
86
+
class InputManager manager;
87
+
```
19
88
20
89
The low-level Input System code processes and interprets the memory from the event stream that the native backend provides, and dispatches individual events.
21
90
@@ -25,7 +94,86 @@ The low-level system code also contains structs which describe the data layout o
The high-level system is easiest to understand in two parts: how input flows through the system at **runtime**, and how Actions are **authored as assets**. Both are shown below for a single player; each additional player gets its own `InputActionState` and a cloned `InputActionAsset` with its own device list and binding mask.
98
+
99
+
**Runtime data flow** — a Device control's state is written into Input State memory, a State Change Monitor notices the change, the `InputActionState` is updated, and the resulting Action fires a callback on the `PlayerInput` component in the scene:
100
+
101
+
```mermaid
102
+
flowchart LR
103
+
%% ---------- Devices ----------
104
+
Keyboard["Keyboard"] --> space["space"]
105
+
106
+
%% ---------- Input State (unmanaged raw memory) ----------
**Asset structure** — an `InputActionAsset` contains Maps, Actions, and Bindings. At runtime these populate the arrays inside the `InputActionState` shown above (`m_State`):
144
+
145
+
```mermaid
146
+
flowchart LR
147
+
%% ---------- Asset hierarchy ----------
148
+
Asset["InputActionAsset: MyGame.inputactions
149
+
devices = [ Keyboard ]
150
+
bindingMask = { groups: KeyboardMouse }"]
151
+
Map["InputActionMap: gameplay"]
152
+
Act["InputAction (m_Actions[])
153
+
gameplay/jump"]
154
+
Bind_a["InputBinding (m_Bindings[])
155
+
path: <Keyboard>/space
156
+
action: jump — groups: KeyboardMouse"]
157
+
Bind_b["InputBinding (m_Bindings[])
158
+
path: <Gamepad>/buttonSouth
159
+
action: jump — groups: Gamepad"]
160
+
Asset --> Map
161
+
Map --> Act
162
+
Map --> Bind_a & Bind_b
163
+
164
+
%% ---------- Populates the runtime action state ----------
The high-level Input System code interprets the data in a Device's state buffers by using [layouts](layouts.md), which describe the data layout of a Device and its Controls in memory. The Input System creates layouts from either the pre-defined structs of commonly known Devices supplied by the low level system, or dynamically at runtime, as in the case of [generic HIDs](hid-specification.md).
0 commit comments