Skip to content

Commit 09df47c

Browse files
committed
Continuing to work on the text
1 parent 8625709 commit 09df47c

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ uid: input-system-architecture
33
---
44
# Architecture
55

6-
The Input System has a layered architecture that consists of a low-level layer and a high-level layer.
6+
The Input System architecture has two layers: low-level high-level. It interacts with the built-in back end in the Unity Editor.
77

8-
# Native backend
8+
## The built-in back end
99

10-
The foundation of the Input System is the native backend code. This is platform-specific code that collects information about available devices and input data from devices. This code isn't part of the Input System package; it's included with Unity itself. It has implementations for each runtime platform supported by Unity. This is why some platform-specific input bugs can only be fixed by an update to Unity, rather than a new version of the Input System package.
10+
The foundation of the Input System is the built-in back end code. This is platform-specific code that collects information about available devices and input data from devices. This code isn't part of the Input System package; it's included with Unity itself. It has implementations for each runtime platform supported by Unity. This is why some platform-specific input bugs can only be fixed by an update to Unity, rather than a new version of the Input System package.
1111

12-
The Input System interfaces with the native backend using [events](input-events.md) that the native backend sends. These events notify the system of the creation and removal of [Input Devices](devices.md) and any updates to the Device states. For efficiency and to avoid creating garbage, the native backend reports these events as a simple buffer of raw, unmanaged memory containing a stream of events.
12+
The Input System interfaces with the built-in back end in one of two ways:
1313

14-
The Input System can also send data back to the native backend in the form of [commands](device-commands.md) sent to devices, which are also buffers of memory that the native backend interprets. These commands can have different meanings for different device types and platforms.
14+
- With [events](input-events.md) that the built-in back end sends. These events notify the system of the creation and removal of [Input devices](devices.md) and any updates to the device states. For efficiency, the built-in back end reports these events as a simple buffer of raw, unmanaged memory containing a stream of events.
15+
- Sending data back to the built-in back end in the form of [commands](device-commands.md) sent to devices, which are also buffers of memory that the built-in back end interprets. These commands can have different meanings for different device types and platforms.
1516

16-
# Input System (low-level)
17+
## Low-level diagram
1718

1819
The diagram of the low-level Input System reads top-to-bottom as a layered pipeline:
1920

20-
1. The native platform backends at the bottom feed the InputManager.
21+
1. The built-in platform back ends feed the InputManager.
2122
1. The InputManager uses layouts to build devices.
22-
1. The device's state is stored in Input State Memory at the top.
23+
1. The device's state is stored in Input State Memory.
2324

2425
```mermaid
2526
flowchart TB
@@ -68,14 +69,14 @@ flowchart TB
6869
EQ["Event Queue"]
6970
BEQ["Background Event Queue
7071
(async; flushes into the foreground queue)"]
71-
Backends["Platform Backends
72+
back ends["Platform back ends
7273
Windows · macOS · Linux · UWP · iOS · Android
7374
· Switch · Xbox · PS4 · WebGL · XR"]
74-
Backends --> DDQ & EQ & BEQ
75+
back ends --> DDQ & EQ & BEQ
7576
DDQ -->|"Device Discovered"| InputManager
7677
EQ -->|"Update (flushes event buffers)"| InputManager
7778
InputManager -->|"Queue Event"| EQ
78-
InputManager -->|"Device Command (IOCTL-style)"| Backends
79+
InputManager -->|"Device Command (IOCTL-style)"| back ends
7980
8081
%% ---------- Grouping by color ----------
8182
classDef layout fill:#e6f0ff,stroke:#4a78c0,color:#000;
@@ -85,7 +86,7 @@ flowchart TB
8586
classDef manager fill:#ffffff,stroke:#e0403f,stroke-width:2px,color:#000;
8687
class Mouse,Pen,Touchscreen,Pointer,DS_PS4,DS_HID,DualShock,Gamepad_L,Keyboard_L,Stick,Axis,Button,Dpad layout;
8788
class Gamepad_D,leftStick,x,y,up,down,left,right,Keyboard_D,a,b,c,d device;
88-
class DDQ,EQ,BEQ,Backends runtime;
89+
class DDQ,EQ,BEQ,back ends runtime;
8990
class StateMemory mem;
9091
class InputManager manager;
9192
```
@@ -96,7 +97,7 @@ When the Input System discovers a device in the event stream, it creates a devic
9697

9798
The low-level system code also contains structs that describe the data layout of commonly known devices.
9899

99-
# Input System (high-level)
100+
## High-level diagram
100101

101102
The high-level system is easiest to understand in two parts:
102103

@@ -124,7 +125,7 @@ flowchart LR
124125
125126
%% ---------- Runtime ----------
126127
StateEvent["StateEvent (KeyboardState)
127-
NativeInputSystem.onUpdate"] -->|feeds| OnUpdate["InputManager.OnUpdate()"]
128+
built-inInputSystem.onUpdate"] -->|feeds| OnUpdate["InputManager.OnUpdate()"]
128129
129130
%% ---------- Action state ----------
130131
AState(["InputActionState
@@ -192,8 +193,11 @@ flowchart LR
192193
class trig,bind,ctrl,State astate;
193194
```
194195

195-
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).
196+
The high-level Input System code uses [layouts](layouts.md) to interpret the data in a device's state buffers. The layouts describe a device's data and its controls in memory. The Input System creates layouts from either the predefined structs of commonly known devices supplied by the low-level system, or dynamically at runtime, for example, for [generic HIDs](hid-specification.md).
196197

197-
Based on the information in the layouts, the Input System then creates [Control](controls.md) representations for each of the Device's controls, which let you read the state of each individual Control in a Device.
198+
Based on the information in the layouts, the Input System creates representations for each of the device's [controls](controls.md). You can now read the state of each of the device's controls individually.
198199

199-
As part of the high-level system, you can also build another abstraction layer to map Input Controls to your application mechanics. Use [Actions](actions.md) to [bind](bindings.md) one or more Controls to an input in your application. The Input System then monitors these Controls for state changes, and notifies your game logic using [callbacks](set-callbacks-on-actions.md). You can also specify more complex behaviors for your Actions using [Processors](processors.md) (which perform processing on the input data before sending it to you) and [Interactions](Interactions.md) (which let you specify patterns of input on a Control to listen to, such as multi-taps).
200+
As part of the high-level system, you can also:
201+
202+
- Build another abstraction layer to map controls to your application mechanics: Use [actions](actions.md) to [bind](bindings.md) one or more controls to an input in your application. The Input System then monitors these controls for state changes, and notifies your game logic using [callbacks](set-callbacks-on-actions.md).
203+
- Specify more complex behaviors for your actions using [processors](processors.md), which perform processing on the input data before sending it to you, and [interactions](Interactions.md), which let you specify patterns of input on a control to listen to, such as multi-taps.

0 commit comments

Comments
 (0)