-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathInputSystem-TheGrandTour.html
524 lines (371 loc) · 10.4 KB
/
InputSystem-TheGrandTour.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<!DOCTYPE html>
<html>
<head>
<title>Input System: The Grand Tour</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.remark-slide-content h1 { font-size: 3em; }
.remark-slide-content h2 { font-size: 2em; }
.remark-slide-content h3 { font-size: 1.4em; }
/* Two-column layout */
.left-column {
color: #777;
width: 25%;
height: 92%;
float: left;
}
.left-column h2:last-of-type, .left-column h3:last-child {
color: #000;
}
.right-column {
width: 75%;
float: right;
padding-top: 1em;
}
.footnote {
position: absolute;
bottom: 3em;
font-size: 0.4em;
}
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Input System
## The Grand Tour
<br><br><br>
https://github.com/Unity-Technologies/InputSystem/Docs/Presentation/InputSystem-TheGrandTour.html<br><br>
https://www.youtube.com/playlist?list=PLXbAKDQVwzta4J2Sbmjio2rTD6uO-phbR
---
# Overview
.center[]
???
1. Mission
2. Background
3. The Buzzwords
4. The Concepts
5. The Architecture
6. The Debugger
7. The Code
8. The Problems
---
# 1. The Mission
<br><br>
.center[Transmit, with *low overhead*,<br>input device activity from *all platforms*<br>through a *single API* catering to<br>both *low-level and high-level usage*.]
---
# 2. Background
* `InputManager`
* 99% platform-dependent code
* Diverging APIs: touch, XR, consoles
* Non-extensible and largely inaccessible
* Push to user-land
* Package
---
# 3: The Buzzwords
* *Game-oriented*
* Frame-to-frame
* *Event-driven*
* All input delivered in timestamped packets
* *Device-agnostic*
* All devices represented the same way
* *Platform-agnostic*
* All platforms go through the same API
* *Automation-ready*
* Input can be fully driven from code
* *Cross-platform-consistent*
* Same device, same input
* *User-extensible*
* New devices and customizations
---
# 4: The Concepts
.center[]
---
# 4.1: Concept - Devices
.left-column[
### A. Devices
]
.right-column[
* Receive input
* Expose controls
* Execute commands ("IOCTL")
* Built from layouts
* Numeric ID
* Unique for application run
* Can be assigned "usages"
* `LeftHand`, `Player1`, `Horizontal`
* Can be added and removed by anyone
* Can be polled by anyone at any time
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Devices.html]
---
# 4.2: Concept - Controls
.left-column[
### A. Devices
### B. Controls
]
.right-column[
* Provide values
* Form hierarchies
* `Gamepad1/leftStick/x`
* Built from layouts
* Immutable internal name (`"buttonSouth"`)
* Mutable external name (`"é"`)
* Can have "usages" (`"Submit"`)
* Can be monitored for changes
* Think "data breakpoint"
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Controls.html]
---
# 4.3: Concept - Layouts
.left-column[
### A. Devices
### B. Controls
### C. Layouts
]
.right-column[
* Data that describes the setup of controls/devices
* Collection of control items that in turn may reference other layouts
* Three ways to build
1. Reflection
2. JSON
3. `InputControlLayout.Builder`
* Can be "precompiled"
* Can be added and modified on the fly
* Can be overridden in full or in part
* Are matched to devices by pattern matching on the device description
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Layouts.html]
---
# 4.4: Concept - State
.left-column[
### A. Devices
### B. Controls
### C. Layouts
### D. State
]
.right-column[
* Raw blob of unmanaged memory holding input state
* Memcpy'able, no heap references
* Multiple copies
* old&new, player&editor
* All devices share one big block of memory
* Each device and each control corresponds to a slice of memory
* State is updated by copying contents of events on top of it
* May be intercepted by device to deal with complications such as `Pointer.delta` and touchscreens
* Turned into processed values by `InputControl.ReadValue()`
]
---
# 4.5: Concept - Events
.left-column[
### A. Devices
### B. Controls
### C. Layouts
### D. State
### E. Events
]
.right-column[
* Anyone can feed `InputEvent`s
* ATM every event is associated with a device
* All events are raw blittable memory chunks
* Central buffer in native
* One main-thread-only buffer
* One threaded buffer for background threads (blocks when full)
* Buffer flushed on each input update
* In full except for `FixedUpdate`s for which we do timeslicing
* Various types
* State events (`StateEvent`, `DeltaStateEvent`)
* Disconnect event (`DeviceRemoveEvent`)
* Configuration change event (`DeviceConfigurationEvent`)
* Text input (`TextEvent`)
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Events.html]
---
# 4.6: Concept - Bindings
.left-column[
### A. Devices
### B. Controls
### C. Layouts
### D. State
### E. Events
### F. Bindings
]
.right-column[
* Establish __input__ channel from 1+ controls to an action
* Can be grouped into control schemes
* Controls are addressed using a "path language":
```
<XRController>{LeftHand}/trigger
```
* Can apply processor stack to incoming values
```
"invert,scale(factor=2)"
```
* Can apply "interactions"
```
"multitap(tapCount=3)"
```
* Can use "composites" to source several bindings into one
.center[]
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/ActionBindings.html]
---
# 4.7: Concept - Actions
.left-column[
### A. Devices
### B. Controls
### C. Layouts
### D. State
### E. Events
### F. Bindings
### G. Actions
]
.right-column[
* Logical input: "jump", "move", "look"
* Can be on their own or grouped into maps
* The latter can further be grouped into assets
* "Phased" interaction model
* `Started`
* `Performed`
* `Canceled`
* Three types
* Value
* Button (press/release)
* Pass-Through (input sink)
* Callback and polling APIs
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Actions.html]
---
# 4.8: Concept - Players
.left-column[
### A. Devices
### B. Controls
### C. Layouts
### D. State
### E. Events
### F. Bindings
### G. Actions
### H. Players
]
.right-column[
* Each player...
* ... is associated with 1+ devices
* ... may have an associated set of actions
* ... may have a current control scheme
* ... may be associated with a platform user account (consoles)
* Single-player: One player that can freely switch control schemes and devices
* Multiplayer: Multiple players each associated with a fixed set of devices
]
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/UserManagement.html]
---
# 5: The Architecture
* Low-level: Events and devices
* High-level: Actions and players
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Architecture.html]
---
# 5.1: The Architecture - Low-Level
.center[<img src="InputArchitectureLowLevel.png" style="max-width: 640px; max-height: 480px;"/>]
---
# 5.2: The Architecture - High-Level
.center[<img src="InputArchitectureHighLevel.png" style="max-width: 640px; max-height: 480px;"/>]
---
# 6: The Debugger
.footnote[https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Debugging.html]
.center[]
---
# 6.1: The Debugger - Device Descriptions
<img src="CopyDeviceDescription.png" style="max-width: 160; max-height: 120;"/>
<img src="DeviceDescription.png" style="max-width: 160; max-height: 120;"/>
<img src="PasteDeviceDescriptionAsDevice.png" style="max-width: 160; max-height: 120;"/>
---
# 6.2: The Debugger - Layouts
<img src="InputDebuggerLayouts.png" style="max-width: 160; max-height: 120;"/>
<img src="InputDebuggerLayouts2.png" style="max-width: 160; max-height: 120;"/>
---
# 7: The Code
.center[]
---
# 7.1: The Code - Native
.left-column[
### A. Modules/Input
]
.right-column[
.center[<img src="TheCode-Native.png" style="max-width: 640px; max-height: 480px;"/>]
]
---
# 7.2: The Code - Native
.left-column[
### A. Modules/Input
### B. PlatformDependent
]
.right-column[
* One backend for each platform we support
* Win32, Mac, Linux, UWP, Android, iOS, WebGL, etc.
* XR is orthogonal to this and feeds data in parallel from XRSDK subsystem
* Future: Unity/XR Remote
* Some platforms run UI on thread separate from app/Unity thread
* `QueueInputEvent()` may block and thus deadlock UI thread
* Use of separate, platform-specific input buffer
]
---
# 7.3: The Code - Managed
.left-column[
### A. Core
]
.right-column[
.center[<img src="TheCode-Core.png" style="max-width: 640px; max-height: 480px;"/>]
]
---
# 7.4: The Code - Managed
.left-column[
### A. Core
### B. Editor
]
.right-column[
.center[<img src="TheCode-Editor.png" style="max-width: 640px; max-height: 480px;"/>]
]
---
# 7.5: The Code - Managed
.left-column[
### A. Core
### B. Editor
### C. "Plugins"
]
.right-column[
* Integrations
* uGUI (`Plugins/UI`)
* Additions
* `MonoBehaviour` wrapper: `Plugins/PlayerInput`
* Touch polling: `Plugins/EnhancedTouch` (... wtf)
* On-screen controls: `Plugins/OnScreen`
* HID layout builder: `Plugins/HID`
* Platform/hardware-specific
]
---
# 8: The Problems
* Susceptible to event load
* System-wide buffer instead of per-device buffer
* Expensive `ReadValue()`
* Expensive layout system
---
# 9: Resources
* [Introducing the new Input System - Unite Copenhagen 2019](https://www.youtube.com/watch?v=hw3Gk5PoZ6A)
* [Custom Devices with Unity's Input System](https://www.youtube.com/watch?v=YNNVGGulscc)
* [DOTS Input Prototype](https://forum.unity.com/threads/dots-input-prototype-hackweek-2020.926939/)
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>
</html>