Skip to content

Commit 03f6509

Browse files
committed
chore(Docs): add diagrams to documentation
1 parent 7a54be8 commit 03f6509

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

docs/index.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,51 @@ InputPlumber is an open source input routing and control daemon for Linux. It ca
1717
be used to combine any number of input devices (like gamepads, mice, and keyboards)
1818
and translate their input to a variety of virtual device formats.
1919

20-
### Features
20+
## Features
2121

2222
* [x] Combine multiple input devices
2323
* [x] Emulate mouse, keyboard, and gamepad inputs
2424
* [x] Intercept and route input over DBus for overlay interface control
2525
* [x] Input mapping profiles to translate source input into the desired target input
2626
* [ ] Route input over the network
2727

28+
## How it works
2829

30+
InputPlumber is designed around the concept of a **Composite Device**, which
31+
is a logical collection of one or more **_source devices_** that InputPlumber
32+
reads input events from, then translates and routes those events to one or more
33+
**_target devices_**.
34+
35+
```mermaid
36+
graph LR
37+
A["Xbox Gamepad (event0)"] --> C{Composite Device};
38+
B["Keyboard (event1)"] --> C{Composite Device};
39+
C --> D["DualSense Gamepad"];
40+
C --> F["Mouse"];
41+
C --> G["Keyboard"];
42+
```
43+
44+
### Input Event Flow
45+
46+
When InputPlumber reads an event from a **source device**, it first identifies any
47+
input events that may need to be interpreted differently using a **Capability Map**,
48+
which is a YAML configuration file that tells InputPlumber how it should interpret
49+
events from a source device. After the event is interpreted, it is sent to the
50+
**Composite Device**.
51+
52+
Once the **Composite Device** receives the input event from the **source device**,
53+
the event is translated according to any **Profile** that might be loaded on
54+
the **Composite Device**. A **Profile** allows translating one kind of input
55+
(like a gamepad joystick) into another kind of input (like mouse motion).
56+
57+
Finally, once the event is translated according to the **Profile**, it is routed
58+
to any **target device(s)** that support the input event.
59+
60+
```mermaid
61+
sequenceDiagram
62+
autonumber
63+
Source Device->>Source Device: Interpret event with Capability Map
64+
Source Device->>Composite Device: Input Event
65+
Composite Device->>Composite Device: Translate event with Profile
66+
Composite Device->>Target Device: Route to target device
67+
```

docs/usage.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ any other supported input event. Input profiles are defined as YAML configuratio
1717
files that can be loaded on-demand for any device that InputPlumber manages. The
1818
format of an input profile config is defined by the [Device Profile Schema](https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/device_profile_v1.json) to make it easier to create profiles.
1919

20+
```mermaid
21+
sequenceDiagram
22+
autonumber
23+
Composite Device->>Profile: Input Event
24+
Profile->>Composite Device: Translated Event
25+
Composite Device->>Target Device: Route to target device
26+
```
27+
2028
Typically input profiles should be generated using an external tool, but you
2129
can manually create your own profiles using any text editor. If you use an editor
2230
that supports the [YAML Language Server](https://github.com/redhat-developer/yaml-language-server)
@@ -63,6 +71,15 @@ to stop input from reaching other running applications (like a game),
6371
allowing the overlay to process inputs without those inputs leaking into other
6472
running apps.
6573

74+
```mermaid
75+
sequenceDiagram
76+
autonumber
77+
Composite Device->>Composite Device: Intercept Mode ALL
78+
Composite Device->>Target Device: Input Event
79+
Target Device-->Game: Input Blocked
80+
Target Device->>Overlay App: DBus Event
81+
```
82+
6683
You can set the intercept mode by setting the `InterceptMode` property on the
6784
input device you want to intercept input from. The intercept mode can be one
6885
of three values:
@@ -101,7 +118,18 @@ busctl call org.shadowblip.InputPlumber \
101118
One feature of InputPlumber is the ability to combine multiple input devices
102119
together into a single logical input device called a "Composite Device". This is
103120
often required for many handheld gaming PCs that have built-in gamepads with
104-
special non-standard buttons that show up as multiple independent input devices.
121+
special non-standard buttons that show up as multiple independent input devices,
122+
like a gamepad and a keyboard.
123+
124+
```mermaid
125+
graph LR
126+
A["Xbox Gamepad (event0)"] --> C{Composite Device};
127+
B["Keyboard (event1)"] --> C{Composite Device};
128+
C --> D["DualSense Gamepad"];
129+
C --> F["Mouse"];
130+
C --> G["Keyboard"];
131+
```
132+
105133

106134
Composite devices are defined as YAML configuration files that follow the
107135
[Composite Device Schema](https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json)
@@ -110,6 +138,15 @@ looks at all the input devices on the system and checks to see if they match a
110138
composite device configuration. If they do, the input devices are combined into
111139
a single logical composite device.
112140

141+
```mermaid
142+
graph LR
143+
A["Device Added"] --> B["InputPlumber"];
144+
B --> C["Read Config"];
145+
C --> D{"Device matches config?"};
146+
D -->|No| C;
147+
D -->|Yes| F["Create Composite Device"];
148+
```
149+
113150
A composite device configuration looks like this:
114151

115152
```yaml

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ markdown_extensions:
3737
pygments_lang_class: true
3838
- pymdownx.tasklist:
3939
custom_checkbox: true
40+
- pymdownx.superfences:
41+
custom_fences:
42+
- name: mermaid
43+
class: mermaid
44+
format: !!python/name:pymdownx.superfences.fence_code_format
4045
- pymdownx.inlinehilite
4146
- pymdownx.snippets
4247
- pymdownx.superfences

0 commit comments

Comments
 (0)