@origingame/engine 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/bin/og.mjs +25 -0
  2. package/dist/web/origin-engine.d.ts +1233 -0
  3. package/dist/web/origin-engine.js +8628 -0
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
  6. package/dist/web-publish/origin-engine-lanes.js +8509 -0
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +1176 -0
  9. package/dist/web-publish/origin-engine.js +8313 -0
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
  12. package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  13. package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
  14. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  15. package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
  16. package/dist/web-publish-2d/origin-engine.js +8313 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  18. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
  19. package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  20. package/knowledge/README.md +31 -0
  21. package/knowledge/knowledge.json +13 -0
  22. package/knowledge/looks/catalogue.json +1871 -0
  23. package/knowledge/package.json +33 -0
  24. package/knowledge/rules/platform.json +329 -0
  25. package/knowledge/scaffold/README.md +27 -0
  26. package/knowledge/scaffold/distribution.json +48 -0
  27. package/knowledge/scaffold/origin-engine.json +19 -0
  28. package/knowledge/scaffold/template/.origin/setup +14 -0
  29. package/knowledge/scaffold/template/LICENSES.md +23 -0
  30. package/knowledge/scaffold/template/README.md +37 -0
  31. package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
  32. package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
  33. package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
  34. package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
  35. package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
  36. package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
  37. package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
  38. package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
  39. package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
  40. package/knowledge/scaffold/template/gitattributes +22 -0
  41. package/knowledge/scaffold/template/package.json +18 -0
  42. package/knowledge/scaffold/template/project.ogt +25 -0
  43. package/knowledge/scaffold/template/src/main.ts +246 -0
  44. package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
  45. package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
  46. package/knowledge/scaffold/template/tsconfig.json +17 -0
  47. package/knowledge/scripts/lib.ts +203 -0
  48. package/knowledge/scripts/mount.ts +210 -0
  49. package/knowledge/scripts/pack.ts +24 -0
  50. package/knowledge/scripts/scaffold.ts +72 -0
  51. package/knowledge/scripts/validate.ts +749 -0
  52. package/knowledge/skills/og-ai/SKILL.md +386 -0
  53. package/knowledge/skills/og-audio/SKILL.md +191 -0
  54. package/knowledge/skills/og-build/SKILL.md +330 -0
  55. package/knowledge/skills/og-core/SKILL.md +285 -0
  56. package/knowledge/skills/og-feel/SKILL.md +385 -0
  57. package/knowledge/skills/og-game/SKILL.md +1479 -0
  58. package/knowledge/skills/og-i18n/SKILL.md +220 -0
  59. package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
  60. package/knowledge/skills/og-taste/SKILL.md +537 -0
  61. package/knowledge/skills/og-ui/SKILL.md +444 -0
  62. package/knowledge/wiki/ai.md +627 -0
  63. package/knowledge/wiki/anim.md +1187 -0
  64. package/knowledge/wiki/atmosphere.md +636 -0
  65. package/knowledge/wiki/audio.md +732 -0
  66. package/knowledge/wiki/camera.md +711 -0
  67. package/knowledge/wiki/commands.md +357 -0
  68. package/knowledge/wiki/game.md +220 -0
  69. package/knowledge/wiki/i18n.md +213 -0
  70. package/knowledge/wiki/index.md +1027 -0
  71. package/knowledge/wiki/input.md +1714 -0
  72. package/knowledge/wiki/load.md +1280 -0
  73. package/knowledge/wiki/math.md +166 -0
  74. package/knowledge/wiki/nav.md +1154 -0
  75. package/knowledge/wiki/physics.md +3142 -0
  76. package/knowledge/wiki/platform.md +857 -0
  77. package/knowledge/wiki/probe.md +1692 -0
  78. package/knowledge/wiki/reflect.md +285 -0
  79. package/knowledge/wiki/render.md +3511 -0
  80. package/knowledge/wiki/rng.md +393 -0
  81. package/knowledge/wiki/stream.md +376 -0
  82. package/knowledge/wiki/system.md +197 -0
  83. package/knowledge/wiki/systems.md +43 -0
  84. package/knowledge/wiki/terrain.md +727 -0
  85. package/knowledge/wiki/tilemap.md +422 -0
  86. package/knowledge/wiki/time.md +150 -0
  87. package/knowledge/wiki/transform.md +230 -0
  88. package/knowledge/wiki/tween.md +580 -0
  89. package/knowledge/wiki/ui.md +8000 -0
  90. package/knowledge/wiki/world.md +909 -0
  91. package/package.json +68 -4
  92. package/schema/api.schema.json +29675 -0
  93. package/shell/README.md +22 -0
  94. package/shell/brand/README.md +23 -0
  95. package/shell/brand/icon-192.png +0 -0
  96. package/shell/brand/icon-512.png +0 -0
  97. package/shell/brand/mark-on-paper.svg +6 -0
  98. package/shell/brand/origin-mark.svg +5 -0
  99. package/shell/brand/origin-motion.css +251 -0
  100. package/shell/brand/tokens.css +20 -0
  101. package/shell/brand.ts +132 -0
  102. package/shell/page.ts +715 -0
  103. package/shell/platform.ts +203 -0
  104. package/shell/player.ts +238 -0
  105. package/shell/shell.css +185 -0
  106. package/shell/sw.ts +177 -0
  107. package/shell/transport.ts +515 -0
  108. package/shell/wire.ts +369 -0
  109. package/src/e6.ts +69 -0
  110. package/src/env.d.ts +100 -0
  111. package/src/generated/abi.ts +980 -0
  112. package/src/index.ts +193 -0
  113. package/src/node/audio.ts +86 -0
  114. package/src/node/build.ts +109 -0
  115. package/src/node/device.ts +981 -0
  116. package/src/node/doctor.ts +60 -0
  117. package/src/node/index.ts +102 -0
  118. package/src/node/platform.ts +24 -0
  119. package/src/node/playtest-run.ts +249 -0
  120. package/src/node/png.ts +130 -0
  121. package/src/node/polish.ts +976 -0
  122. package/src/node/run.ts +373 -0
  123. package/src/node/web-build.ts +808 -0
  124. package/src/p2.ts +35 -0
  125. package/src/platform-local.ts +211 -0
  126. package/src/playtest.ts +131 -0
  127. package/src/runtime.ts +1509 -0
  128. package/src/systems/cameras.ts +247 -0
  129. package/src/ui-kit/bind.ts +141 -0
  130. package/src/ui-kit/huds.ts +303 -0
  131. package/src/ui-kit/index.ts +36 -0
  132. package/src/ui-kit/menus.ts +187 -0
  133. package/src/ui-kit/settings.ts +131 -0
  134. package/src/ui-kit/store.ts +222 -0
  135. package/src/ui-kit/story.ts +89 -0
  136. package/src/ui-kit/util.ts +106 -0
  137. package/src/web/a11y.ts +429 -0
  138. package/src/web/audio-worklet.ts +193 -0
  139. package/src/web/audio.ts +307 -0
  140. package/src/web/basis.ts +239 -0
  141. package/src/web/gamepad.ts +123 -0
  142. package/src/web/host.ts +166 -0
  143. package/src/web/input.ts +237 -0
  144. package/src/web/lanes.ts +21 -0
  145. package/src/web/play.ts +20 -0
  146. package/src/web/rpc-ring.ts +110 -0
  147. package/src/web/settle.ts +122 -0
  148. package/src/web/shell.ts +643 -0
  149. package/src/web/text-input.ts +248 -0
  150. package/src/web/worker.ts +1002 -0
  151. package/types/bindings.json +13654 -0
  152. package/types/index.d.ts +20090 -0
  153. package/vendor/basis/LICENSE +201 -0
  154. package/vendor/basis/NOTICE +15 -0
  155. package/vendor/basis/README.md +18 -0
  156. package/vendor/basis/basis_transcoder.js +19 -0
  157. package/vendor/basis/basis_transcoder.wasm +0 -0
  158. package/README.md +0 -3
@@ -0,0 +1,1714 @@
1
+ <!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
2
+
3
+ # The `input` module
4
+
5
+ Input as the game sees it: the Input resource for polling, events for edges.
6
+
7
+ The shell collects pointer, keyboard and wheel input on the main thread; the probe and the command channel inject through the same path.
8
+
9
+ Several pointers at once (multi-touch) are og.Pointers; the first four gamepads, in the W3C standard mapping, are og.Gamepad. Both are world state, as og.Input is, so they replay.
10
+
11
+ - **TypeScript**: functions are none at module level (its members live on the types below); components, resources and events are tokens on `og`.
12
+ - **Publish builds**: kept (members may override).
13
+ - **Skill**: `og-game`, which teaches the module (how much of it to use, and how to prove it).
14
+ - **Index**: [every module and name](index.md).
15
+
16
+ ```ogt
17
+ module input {
18
+ # declarations follow, each quoted below
19
+ ```
20
+
21
+ <sub>`api.ogt` line 716</sub>
22
+
23
+ ## Contents
24
+
25
+ | Name | Kind | Summary |
26
+ |---|---|---|
27
+ | [`MAX_POINTERS`](#const-MAX_POINTERS) | constant | The most pointers og.Pointers tracks at once: ids 0 (the primary pointer) to 4. |
28
+ | [`MAX_GAMEPADS`](#const-MAX_GAMEPADS) | constant | The most gamepads og.Gamepad reads: pads 0 to 3. |
29
+ | [`GamepadButton`](#type-GamepadButton) | enum | A gamepad button in the W3C standard mapping, in its index order (a is button 0). |
30
+ | [`GamepadAxis`](#type-GamepadAxis) | enum | An analog input of a gamepad. |
31
+ | [`KeyAction`](#type-KeyAction) | enum | What an injected key event does. |
32
+ | [`PointerAction`](#type-PointerAction) | enum | What an injected pointer event does. |
33
+ | [`PointerButton`](#type-PointerButton) | enum | A physical pointer button; `none` is a hover move. |
34
+ | [`Modifiers`](#type-Modifiers) | struct | Modifier keys held during a key event. |
35
+ | [`KeyInput`](#type-KeyInput) | struct | A key event. `key` names the physical key as KeyboardEvent.code does: ArrowRight, Space, KeyA. |
36
+ | [`PointerInput`](#type-PointerInput) | struct | A pointer event at a point in CSS pixels of the play surface. |
37
+ | [`GamepadInput`](#type-GamepadInput) | struct | A gamepad's whole state (an engine extension of protocol 5): the shell sends one whenever a pad changes, and a playtest can send its own. |
38
+ | [`WheelInput`](#type-WheelInput) | struct | A wheel or trackpad scroll at a point. |
39
+ | [`TextEntry`](#type-TextEntry) | struct | Typed or composed text (an engine extension of protocol 5): what the page's `beforeinput` inserted (a key's character, a paste, an input method's commit), or with `composing` an input method's composition so far. Raises TextInput events; the UI's focused text field takes them. |
40
+ | [`A11yActionKind`](#type-A11yActionKind) | enum | What an assistive technology asks of a UI control. |
41
+ | [`A11yRequest`](#type-A11yRequest) | struct | A screen reader's request on a UI control (an engine extension of protocol 5): the web shell's mirror of og.ui.a11y() sends it when a reader focuses, activates or adjusts a mirrored node. Raises an A11yAction event; the UI acts on it at the start of the next frame, against the last frame's controls (a path naming no focusable control of the topmost dialog is ignored; increment and decrement also take a stepper's spinbutton, whose buttons are the focusable controls). |
42
+ | [`InjectedInput`](#type-InjectedInput) | union | One input event in the game's own vocabulary, as the probe's input() and playtest scripts carry it. |
43
+ | [`og.Input`](#record-Input) | resource | The input state at the start of this tick (og-input's og.Input, version 2). Edges (pressed, released) last exactly one tick; read the state through the methods. |
44
+ | [`og.Pointers`](#record-Pointers) | resource | Every pointer on the play surface at once, at the start of this tick (og-input's og.Pointers): a touch stick and a touch button can be held together. Pointer 0 is og.Input's pointer; ids 1 to 4 are further touches, in the order they landed (the lowest free id). |
45
+ | [`og.Gamepad`](#record-Gamepad) | resource | The first four gamepads in the W3C standard mapping, at the start of this tick (og-input's og.Gamepad). On the web the shell polls the pads each display frame and sends their state through the input ring, so a pad is world state and replays; it also maps pads to keys for games that only read keys. |
46
+ | [`og.KeyDown`](#record-KeyDown) | event | A key went down (a down for a held key is a repeat and sets no edge). Input events are sent between ticks and read by the next tick's systems. |
47
+ | [`og.TextInput`](#record-TextInput) | event | Text typed or composed (an engine extension): the shell sends it from the page's `beforeinput` and composition events, the probe's `type:`, `compose:` and `commit:` from scripts. A text longer than 255 bytes arrives as several events in order. Key events still arrive for the keys; a text field types from these once a world has had one. |
48
+ | [`og.KeyUp`](#record-KeyUp) | event | A key went up. |
49
+ | [`og.PointerDown`](#record-PointerDown) | event | A pointer button went down (or a touch landed). |
50
+ | [`og.PointerUp`](#record-PointerUp) | event | A pointer button went up (or a touch lifted). |
51
+ | [`og.PointerMove`](#record-PointerMove) | event | A pointer moved. |
52
+ | [`og.Wheel`](#record-Wheel) | event | A wheel or trackpad scroll. |
53
+ | [`og.A11yAction`](#record-A11yAction) | event | A screen reader's request on a UI control (an engine extension): the web shell sends it from its mirror of og.ui.a11y(); the UI takes it at the start of the next frame. A path longer than 255 bytes is refused. |
54
+
55
+ ## Components, resources and events
56
+
57
+ <a id="record-Input"></a>
58
+
59
+ ### `og.Input` (resource)
60
+
61
+ The input state at the start of this tick (og-input's og.Input, version 2). Edges (pressed, released) last exactly one tick; read the state through the methods.
62
+
63
+ Key sets are 128 bits over og-input's KEY_CODES (KeyboardEvent.code names): code i is bit i % 32 of word i / 32. Button masks: left 1, middle 2, right 4.
64
+
65
+ Token `og.Input`, registered under the schema name `og.Input`; its value type is `Input`.
66
+
67
+ | Field | Type | Default | Range | Unit | Notes | Doc |
68
+ |---|---|---|---|---|---|---|
69
+ | `pointer` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | The pointer position. |
70
+ | `pointerInside` | `boolean` | `false` | — | — | read only | Whether a pointer event has placed the pointer over the play surface. |
71
+ | `wheel` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Scroll accumulated during this tick. |
72
+ | `buttons` | `number` | `0` | — | — | read only | Held pointer buttons, as a mask. |
73
+ | `buttonsPressed` | `number` | `0` | — | — | read only | Buttons that went down this tick. |
74
+ | `buttonsReleased` | `number` | `0` | — | — | read only | Buttons that went up this tick. |
75
+ | `buttonsReleaseNext` | `number` | `0` | — | — | read only | Buttons a click releases at the end of the next tick. |
76
+ | `keys0` | `number` | `0` | — | — | read only | Held keys, word 0: codes 0 to 31 of KEY_CODES. |
77
+ | `keys1` | `number` | `0` | — | — | read only | Held keys, word 1: codes 32 to 63 of KEY_CODES. |
78
+ | `keys2` | `number` | `0` | — | — | read only | Held keys, word 2: codes 64 to 95 of KEY_CODES. |
79
+ | `keys3` | `number` | `0` | — | — | read only | Held keys, word 3: codes 96 to 127 of KEY_CODES. |
80
+ | `pressed0` | `number` | `0` | — | — | read only | Keys that went down this tick, word 0: codes 0 to 31 of KEY_CODES. |
81
+ | `pressed1` | `number` | `0` | — | — | read only | Keys that went down this tick, word 1: codes 32 to 63 of KEY_CODES. |
82
+ | `pressed2` | `number` | `0` | — | — | read only | Keys that went down this tick, word 2: codes 64 to 95 of KEY_CODES. |
83
+ | `pressed3` | `number` | `0` | — | — | read only | Keys that went down this tick, word 3: codes 96 to 127 of KEY_CODES. |
84
+ | `released0` | `number` | `0` | — | — | read only | Keys that went up this tick, word 0: codes 0 to 31 of KEY_CODES. |
85
+ | `released1` | `number` | `0` | — | — | read only | Keys that went up this tick, word 1: codes 32 to 63 of KEY_CODES. |
86
+ | `released2` | `number` | `0` | — | — | read only | Keys that went up this tick, word 2: codes 64 to 95 of KEY_CODES. |
87
+ | `released3` | `number` | `0` | — | — | read only | Keys that went up this tick, word 3: codes 96 to 127 of KEY_CODES. |
88
+ | `releaseNext0` | `number` | `0` | — | — | read only | Keys a press releases at the end of the next tick, word 0: codes 0 to 31 of KEY_CODES. |
89
+ | `releaseNext1` | `number` | `0` | — | — | read only | Keys a press releases at the end of the next tick, word 1: codes 32 to 63 of KEY_CODES. |
90
+ | `releaseNext2` | `number` | `0` | — | — | read only | Keys a press releases at the end of the next tick, word 2: codes 64 to 95 of KEY_CODES. |
91
+ | `releaseNext3` | `number` | `0` | — | — | read only | Keys a press releases at the end of the next tick, word 3: codes 96 to 127 of KEY_CODES. |
92
+
93
+ ```ogt
94
+ resource Input {
95
+ doc "The input state at the start of this tick (og-input's og.Input, version 2). Edges (pressed, released) last exactly one tick; read the state through the methods."
96
+ doc "Key sets are 128 bits over og-input's KEY_CODES (KeyboardEvent.code names): code i is bit i % 32 of word i / 32. Button masks: left 1, middle 2, right 4."
97
+ field pointer Vector2 "The pointer position." {
98
+ readonly true
99
+ unit cssPx
100
+ }
101
+ field pointerInside bool "Whether a pointer event has placed the pointer over the play surface." {
102
+ readonly true
103
+ }
104
+ field wheel Vector2 "Scroll accumulated during this tick." {
105
+ readonly true
106
+ unit cssPx
107
+ }
108
+ field buttons u32 "Held pointer buttons, as a mask." {
109
+ readonly true
110
+ }
111
+ field buttonsPressed u32 "Buttons that went down this tick." {
112
+ readonly true
113
+ }
114
+ field buttonsReleased u32 "Buttons that went up this tick." {
115
+ readonly true
116
+ }
117
+ field buttonsReleaseNext u32 "Buttons a click releases at the end of the next tick." {
118
+ readonly true
119
+ }
120
+ field keys0 u32 "Held keys, word 0: codes 0 to 31 of KEY_CODES." {
121
+ readonly true
122
+ }
123
+ field keys1 u32 "Held keys, word 1: codes 32 to 63 of KEY_CODES." {
124
+ readonly true
125
+ }
126
+ field keys2 u32 "Held keys, word 2: codes 64 to 95 of KEY_CODES." {
127
+ readonly true
128
+ }
129
+ field keys3 u32 "Held keys, word 3: codes 96 to 127 of KEY_CODES." {
130
+ readonly true
131
+ }
132
+ field pressed0 u32 "Keys that went down this tick, word 0: codes 0 to 31 of KEY_CODES." {
133
+ readonly true
134
+ }
135
+ field pressed1 u32 "Keys that went down this tick, word 1: codes 32 to 63 of KEY_CODES." {
136
+ readonly true
137
+ }
138
+ field pressed2 u32 "Keys that went down this tick, word 2: codes 64 to 95 of KEY_CODES." {
139
+ readonly true
140
+ }
141
+ field pressed3 u32 "Keys that went down this tick, word 3: codes 96 to 127 of KEY_CODES." {
142
+ readonly true
143
+ }
144
+ field released0 u32 "Keys that went up this tick, word 0: codes 0 to 31 of KEY_CODES." {
145
+ readonly true
146
+ }
147
+ field released1 u32 "Keys that went up this tick, word 1: codes 32 to 63 of KEY_CODES." {
148
+ readonly true
149
+ }
150
+ field released2 u32 "Keys that went up this tick, word 2: codes 64 to 95 of KEY_CODES." {
151
+ readonly true
152
+ }
153
+ field released3 u32 "Keys that went up this tick, word 3: codes 96 to 127 of KEY_CODES." {
154
+ readonly true
155
+ }
156
+ field releaseNext0 u32 "Keys a press releases at the end of the next tick, word 0: codes 0 to 31 of KEY_CODES." {
157
+ readonly true
158
+ }
159
+ field releaseNext1 u32 "Keys a press releases at the end of the next tick, word 1: codes 32 to 63 of KEY_CODES." {
160
+ readonly true
161
+ }
162
+ field releaseNext2 u32 "Keys a press releases at the end of the next tick, word 2: codes 64 to 95 of KEY_CODES." {
163
+ readonly true
164
+ }
165
+ field releaseNext3 u32 "Keys a press releases at the end of the next tick, word 3: codes 96 to 127 of KEY_CODES." {
166
+ readonly true
167
+ }
168
+ fn down {
169
+ doc "Whether a key is held."
170
+ param key String "A KeyboardEvent.code name, such as KeyW or Space."
171
+ returns bool
172
+ }
173
+ fn pressed {
174
+ doc "Whether a key went down this tick."
175
+ param key String "A KeyboardEvent.code name."
176
+ returns bool
177
+ }
178
+ fn released {
179
+ doc "Whether a key went up this tick."
180
+ param key String "A KeyboardEvent.code name."
181
+ returns bool
182
+ }
183
+ fn axis {
184
+ doc "-1, 0 or 1 from two keys, such as `axis(\"KeyA\", \"KeyD\")`."
185
+ param negative String "The key for -1."
186
+ param positive String "The key for +1."
187
+ returns f32
188
+ }
189
+ fn axis2 {
190
+ doc "A 2D axis from four keys, such as `axis2(\"KeyA\", \"KeyD\", \"KeyS\", \"KeyW\")`: each component -1, 0 or 1."
191
+ param left String "The key for x = -1."
192
+ param right String "The key for x = +1."
193
+ param down String "The key for y = -1."
194
+ param up String "The key for y = +1."
195
+ returns Vector2
196
+ }
197
+ fn buttonDown {
198
+ doc "Whether a pointer button is held."
199
+ param button PointerButton "The button."
200
+ returns bool
201
+ }
202
+ fn buttonPressed {
203
+ doc "Whether a pointer button went down this tick."
204
+ param button PointerButton "The button."
205
+ returns bool
206
+ }
207
+ fn buttonReleased {
208
+ doc "Whether a pointer button went up this tick."
209
+ param button PointerButton "The button."
210
+ returns bool
211
+ }
212
+ }
213
+ ```
214
+
215
+ <sub>`api.ogt` line 891</sub>
216
+
217
+ <a id="member-Input-down"></a>
218
+
219
+ #### `Input.down`
220
+
221
+ Whether a key is held.
222
+
223
+ ```ts
224
+ Input.down(key: string): boolean
225
+ ```
226
+
227
+ | Parameter | Type | Optional | Doc |
228
+ |---|---|---|---|
229
+ | `key` | `string` | no | A KeyboardEvent.code name, such as KeyW or Space. |
230
+
231
+ **Returns** `boolean`.
232
+
233
+ Binding symbol `og_input_down` · publish builds: kept
234
+
235
+ ```ogt
236
+ fn down {
237
+ doc "Whether a key is held."
238
+ param key String "A KeyboardEvent.code name, such as KeyW or Space."
239
+ returns bool
240
+ }
241
+ ```
242
+
243
+ <sub>`api.ogt` line 965</sub>
244
+
245
+ <a id="member-Input-pressed"></a>
246
+
247
+ #### `Input.pressed`
248
+
249
+ Whether a key went down this tick.
250
+
251
+ ```ts
252
+ Input.pressed(key: string): boolean
253
+ ```
254
+
255
+ | Parameter | Type | Optional | Doc |
256
+ |---|---|---|---|
257
+ | `key` | `string` | no | A KeyboardEvent.code name. |
258
+
259
+ **Returns** `boolean`.
260
+
261
+ Binding symbol `og_input_pressed` · publish builds: kept
262
+
263
+ ```ogt
264
+ fn pressed {
265
+ doc "Whether a key went down this tick."
266
+ param key String "A KeyboardEvent.code name."
267
+ returns bool
268
+ }
269
+ ```
270
+
271
+ <sub>`api.ogt` line 970</sub>
272
+
273
+ <a id="member-Input-released"></a>
274
+
275
+ #### `Input.released`
276
+
277
+ Whether a key went up this tick.
278
+
279
+ ```ts
280
+ Input.released(key: string): boolean
281
+ ```
282
+
283
+ | Parameter | Type | Optional | Doc |
284
+ |---|---|---|---|
285
+ | `key` | `string` | no | A KeyboardEvent.code name. |
286
+
287
+ **Returns** `boolean`.
288
+
289
+ Binding symbol `og_input_released` · publish builds: kept
290
+
291
+ ```ogt
292
+ fn released {
293
+ doc "Whether a key went up this tick."
294
+ param key String "A KeyboardEvent.code name."
295
+ returns bool
296
+ }
297
+ ```
298
+
299
+ <sub>`api.ogt` line 975</sub>
300
+
301
+ <a id="member-Input-axis"></a>
302
+
303
+ #### `Input.axis`
304
+
305
+ -1, 0 or 1 from two keys, such as `axis("KeyA", "KeyD")`.
306
+
307
+ ```ts
308
+ Input.axis(negative: string, positive: string): number
309
+ ```
310
+
311
+ | Parameter | Type | Optional | Doc |
312
+ |---|---|---|---|
313
+ | `negative` | `string` | no | The key for -1. |
314
+ | `positive` | `string` | no | The key for +1. |
315
+
316
+ **Returns** `number`.
317
+
318
+ Binding symbol `og_input_axis` · publish builds: kept
319
+
320
+ ```ogt
321
+ fn axis {
322
+ doc "-1, 0 or 1 from two keys, such as `axis(\"KeyA\", \"KeyD\")`."
323
+ param negative String "The key for -1."
324
+ param positive String "The key for +1."
325
+ returns f32
326
+ }
327
+ ```
328
+
329
+ <sub>`api.ogt` line 980</sub>
330
+
331
+ <a id="member-Input-axis2"></a>
332
+
333
+ #### `Input.axis2`
334
+
335
+ A 2D axis from four keys, such as `axis2("KeyA", "KeyD", "KeyS", "KeyW")`: each component -1, 0 or 1.
336
+
337
+ ```ts
338
+ Input.axis2(left: string, right: string, down: string, up: string): Vector2
339
+ ```
340
+
341
+ | Parameter | Type | Optional | Doc |
342
+ |---|---|---|---|
343
+ | `left` | `string` | no | The key for x = -1. |
344
+ | `right` | `string` | no | The key for x = +1. |
345
+ | `down` | `string` | no | The key for y = -1. |
346
+ | `up` | `string` | no | The key for y = +1. |
347
+
348
+ **Returns** `Vector2`.
349
+
350
+ Binding symbol `og_input_axis2` · publish builds: kept
351
+
352
+ ```ogt
353
+ fn axis2 {
354
+ doc "A 2D axis from four keys, such as `axis2(\"KeyA\", \"KeyD\", \"KeyS\", \"KeyW\")`: each component -1, 0 or 1."
355
+ param left String "The key for x = -1."
356
+ param right String "The key for x = +1."
357
+ param down String "The key for y = -1."
358
+ param up String "The key for y = +1."
359
+ returns Vector2
360
+ }
361
+ ```
362
+
363
+ <sub>`api.ogt` line 986</sub>
364
+
365
+ <a id="member-Input-buttonDown"></a>
366
+
367
+ #### `Input.buttonDown`
368
+
369
+ Whether a pointer button is held.
370
+
371
+ ```ts
372
+ Input.buttonDown(button: PointerButton): boolean
373
+ ```
374
+
375
+ | Parameter | Type | Optional | Doc |
376
+ |---|---|---|---|
377
+ | `button` | `PointerButton` | no | The button. |
378
+
379
+ **Returns** `boolean`.
380
+
381
+ Binding symbol `og_input_button_down` · publish builds: kept
382
+
383
+ ```ogt
384
+ fn buttonDown {
385
+ doc "Whether a pointer button is held."
386
+ param button PointerButton "The button."
387
+ returns bool
388
+ }
389
+ ```
390
+
391
+ <sub>`api.ogt` line 994</sub>
392
+
393
+ <a id="member-Input-buttonPressed"></a>
394
+
395
+ #### `Input.buttonPressed`
396
+
397
+ Whether a pointer button went down this tick.
398
+
399
+ ```ts
400
+ Input.buttonPressed(button: PointerButton): boolean
401
+ ```
402
+
403
+ | Parameter | Type | Optional | Doc |
404
+ |---|---|---|---|
405
+ | `button` | `PointerButton` | no | The button. |
406
+
407
+ **Returns** `boolean`.
408
+
409
+ Binding symbol `og_input_button_pressed` · publish builds: kept
410
+
411
+ ```ogt
412
+ fn buttonPressed {
413
+ doc "Whether a pointer button went down this tick."
414
+ param button PointerButton "The button."
415
+ returns bool
416
+ }
417
+ ```
418
+
419
+ <sub>`api.ogt` line 999</sub>
420
+
421
+ <a id="member-Input-buttonReleased"></a>
422
+
423
+ #### `Input.buttonReleased`
424
+
425
+ Whether a pointer button went up this tick.
426
+
427
+ ```ts
428
+ Input.buttonReleased(button: PointerButton): boolean
429
+ ```
430
+
431
+ | Parameter | Type | Optional | Doc |
432
+ |---|---|---|---|
433
+ | `button` | `PointerButton` | no | The button. |
434
+
435
+ **Returns** `boolean`.
436
+
437
+ Binding symbol `og_input_button_released` · publish builds: kept
438
+
439
+ ```ogt
440
+ fn buttonReleased {
441
+ doc "Whether a pointer button went up this tick."
442
+ param button PointerButton "The button."
443
+ returns bool
444
+ }
445
+ ```
446
+
447
+ <sub>`api.ogt` line 1004</sub>
448
+
449
+ <a id="record-Pointers"></a>
450
+
451
+ ### `og.Pointers` (resource)
452
+
453
+ Every pointer on the play surface at once, at the start of this tick (og-input's og.Pointers): a touch stick and a touch button can be held together. Pointer 0 is og.Input's pointer; ids 1 to 4 are further touches, in the order they landed (the lowest free id).
454
+
455
+ Edges last exactly one tick, as og.Input's do. Masks are bit `id`; read them through the methods.
456
+
457
+ Token `og.Pointers`, registered under the schema name `og.Pointers`; its value type is `Pointers`.
458
+
459
+ | Field | Type | Default | Range | Unit | Notes | Doc |
460
+ |---|---|---|---|---|---|---|
461
+ | `heldMask` | `number` | `0` | — | — | read only | Pointers held down, as a mask. |
462
+ | `pressedMask` | `number` | `0` | — | — | read only | Pointers that went down this tick. |
463
+ | `releasedMask` | `number` | `0` | — | — | read only | Pointers that went up this tick. |
464
+ | `releaseNextMask` | `number` | `0` | — | — | read only | Pointers a click releases at the end of the next tick. |
465
+ | `position0` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 0 is. |
466
+ | `position1` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 1 is. |
467
+ | `position2` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 2 is. |
468
+ | `position3` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 3 is. |
469
+ | `position4` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 4 is. |
470
+ | `start0` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 0 went down. |
471
+ | `start1` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 1 went down. |
472
+ | `start2` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 2 went down. |
473
+ | `start3` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 3 went down. |
474
+ | `start4` | `Vector2` | `{ x: 0, y: 0 }` | — | `cssPx` | read only | Where pointer 4 went down. |
475
+
476
+ ```ogt
477
+ resource Pointers {
478
+ doc "Every pointer on the play surface at once, at the start of this tick (og-input's og.Pointers): a touch stick and a touch button can be held together. Pointer 0 is og.Input's pointer; ids 1 to 4 are further touches, in the order they landed (the lowest free id)."
479
+ doc "Edges last exactly one tick, as og.Input's do. Masks are bit `id`; read them through the methods."
480
+ field heldMask u32 "Pointers held down, as a mask." {
481
+ readonly true
482
+ }
483
+ field pressedMask u32 "Pointers that went down this tick." {
484
+ readonly true
485
+ }
486
+ field releasedMask u32 "Pointers that went up this tick." {
487
+ readonly true
488
+ }
489
+ field releaseNextMask u32 "Pointers a click releases at the end of the next tick." {
490
+ readonly true
491
+ }
492
+ field position0 Vector2 "Where pointer 0 is." {
493
+ readonly true
494
+ unit cssPx
495
+ }
496
+ field position1 Vector2 "Where pointer 1 is." {
497
+ readonly true
498
+ unit cssPx
499
+ }
500
+ field position2 Vector2 "Where pointer 2 is." {
501
+ readonly true
502
+ unit cssPx
503
+ }
504
+ field position3 Vector2 "Where pointer 3 is." {
505
+ readonly true
506
+ unit cssPx
507
+ }
508
+ field position4 Vector2 "Where pointer 4 is." {
509
+ readonly true
510
+ unit cssPx
511
+ }
512
+ field start0 Vector2 "Where pointer 0 went down." {
513
+ readonly true
514
+ unit cssPx
515
+ }
516
+ field start1 Vector2 "Where pointer 1 went down." {
517
+ readonly true
518
+ unit cssPx
519
+ }
520
+ field start2 Vector2 "Where pointer 2 went down." {
521
+ readonly true
522
+ unit cssPx
523
+ }
524
+ field start3 Vector2 "Where pointer 3 went down." {
525
+ readonly true
526
+ unit cssPx
527
+ }
528
+ field start4 Vector2 "Where pointer 4 went down." {
529
+ readonly true
530
+ unit cssPx
531
+ }
532
+ fn down {
533
+ doc "Whether a pointer is held."
534
+ param id u32 "The pointer, 0 to 4."
535
+ returns bool
536
+ }
537
+ fn pressed {
538
+ doc "Whether a pointer went down this tick."
539
+ param id u32 "The pointer, 0 to 4."
540
+ returns bool
541
+ }
542
+ fn released {
543
+ doc "Whether a pointer went up this tick."
544
+ param id u32 "The pointer, 0 to 4."
545
+ returns bool
546
+ }
547
+ fn position {
548
+ doc "Where a pointer is, in CSS pixels."
549
+ param id u32 "The pointer, 0 to 4."
550
+ returns Vector2
551
+ }
552
+ fn start {
553
+ doc "Where a pointer went down, in CSS pixels: a touch control claims the pointers that started on it."
554
+ param id u32 "The pointer, 0 to 4."
555
+ returns Vector2
556
+ }
557
+ fn count {
558
+ doc "How many pointers are held."
559
+ returns u32
560
+ }
561
+ }
562
+ ```
563
+
564
+ <sub>`api.ogt` line 1011</sub>
565
+
566
+ <a id="member-Pointers-down"></a>
567
+
568
+ #### `Pointers.down`
569
+
570
+ Whether a pointer is held.
571
+
572
+ ```ts
573
+ Pointers.down(id: number): boolean
574
+ ```
575
+
576
+ | Parameter | Type | Optional | Doc |
577
+ |---|---|---|---|
578
+ | `id` | `number` | no | The pointer, 0 to 4. |
579
+
580
+ **Returns** `boolean`.
581
+
582
+ Binding symbol `og_pointers_down` · publish builds: kept
583
+
584
+ ```ogt
585
+ fn down {
586
+ doc "Whether a pointer is held."
587
+ param id u32 "The pointer, 0 to 4."
588
+ returns bool
589
+ }
590
+ ```
591
+
592
+ <sub>`api.ogt` line 1066</sub>
593
+
594
+ <a id="member-Pointers-pressed"></a>
595
+
596
+ #### `Pointers.pressed`
597
+
598
+ Whether a pointer went down this tick.
599
+
600
+ ```ts
601
+ Pointers.pressed(id: number): boolean
602
+ ```
603
+
604
+ | Parameter | Type | Optional | Doc |
605
+ |---|---|---|---|
606
+ | `id` | `number` | no | The pointer, 0 to 4. |
607
+
608
+ **Returns** `boolean`.
609
+
610
+ Binding symbol `og_pointers_pressed` · publish builds: kept
611
+
612
+ ```ogt
613
+ fn pressed {
614
+ doc "Whether a pointer went down this tick."
615
+ param id u32 "The pointer, 0 to 4."
616
+ returns bool
617
+ }
618
+ ```
619
+
620
+ <sub>`api.ogt` line 1071</sub>
621
+
622
+ <a id="member-Pointers-released"></a>
623
+
624
+ #### `Pointers.released`
625
+
626
+ Whether a pointer went up this tick.
627
+
628
+ ```ts
629
+ Pointers.released(id: number): boolean
630
+ ```
631
+
632
+ | Parameter | Type | Optional | Doc |
633
+ |---|---|---|---|
634
+ | `id` | `number` | no | The pointer, 0 to 4. |
635
+
636
+ **Returns** `boolean`.
637
+
638
+ Binding symbol `og_pointers_released` · publish builds: kept
639
+
640
+ ```ogt
641
+ fn released {
642
+ doc "Whether a pointer went up this tick."
643
+ param id u32 "The pointer, 0 to 4."
644
+ returns bool
645
+ }
646
+ ```
647
+
648
+ <sub>`api.ogt` line 1076</sub>
649
+
650
+ <a id="member-Pointers-position"></a>
651
+
652
+ #### `Pointers.position`
653
+
654
+ Where a pointer is, in CSS pixels.
655
+
656
+ ```ts
657
+ Pointers.position(id: number): Vector2
658
+ ```
659
+
660
+ | Parameter | Type | Optional | Doc |
661
+ |---|---|---|---|
662
+ | `id` | `number` | no | The pointer, 0 to 4. |
663
+
664
+ **Returns** `Vector2`.
665
+
666
+ Binding symbol `og_pointers_position` · publish builds: kept
667
+
668
+ ```ogt
669
+ fn position {
670
+ doc "Where a pointer is, in CSS pixels."
671
+ param id u32 "The pointer, 0 to 4."
672
+ returns Vector2
673
+ }
674
+ ```
675
+
676
+ <sub>`api.ogt` line 1081</sub>
677
+
678
+ <a id="member-Pointers-start"></a>
679
+
680
+ #### `Pointers.start`
681
+
682
+ Where a pointer went down, in CSS pixels: a touch control claims the pointers that started on it.
683
+
684
+ ```ts
685
+ Pointers.start(id: number): Vector2
686
+ ```
687
+
688
+ | Parameter | Type | Optional | Doc |
689
+ |---|---|---|---|
690
+ | `id` | `number` | no | The pointer, 0 to 4. |
691
+
692
+ **Returns** `Vector2`.
693
+
694
+ Binding symbol `og_pointers_start` · publish builds: kept
695
+
696
+ ```ogt
697
+ fn start {
698
+ doc "Where a pointer went down, in CSS pixels: a touch control claims the pointers that started on it."
699
+ param id u32 "The pointer, 0 to 4."
700
+ returns Vector2
701
+ }
702
+ ```
703
+
704
+ <sub>`api.ogt` line 1086</sub>
705
+
706
+ <a id="member-Pointers-count"></a>
707
+
708
+ #### `Pointers.count`
709
+
710
+ How many pointers are held.
711
+
712
+ ```ts
713
+ Pointers.count(): number
714
+ ```
715
+
716
+ **Returns** `number`.
717
+
718
+ Binding symbol `og_pointers_count` · publish builds: kept
719
+
720
+ ```ogt
721
+ fn count {
722
+ doc "How many pointers are held."
723
+ returns u32
724
+ }
725
+ ```
726
+
727
+ <sub>`api.ogt` line 1091</sub>
728
+
729
+ <a id="record-Gamepad"></a>
730
+
731
+ ### `og.Gamepad` (resource)
732
+
733
+ The first four gamepads in the W3C standard mapping, at the start of this tick (og-input's og.Gamepad). On the web the shell polls the pads each display frame and sends their state through the input ring, so a pad is world state and replays; it also maps pads to keys for games that only read keys.
734
+
735
+ Button masks are bit `GamepadButton` index per pad; edges last exactly one tick, and a press and a release between two ticks leave both edges set. Read them through the methods.
736
+
737
+ Token `og.Gamepad`, registered under the schema name `og.Gamepad`; its value type is `Gamepad`.
738
+
739
+ | Field | Type | Default | Range | Unit | Notes | Doc |
740
+ |---|---|---|---|---|---|---|
741
+ | `connectedMask` | `number` | `0` | — | — | read only | Connected pads: bit `pad`. |
742
+ | `buttons0` | `number` | `0` | — | — | read only | Held buttons of pad 0. |
743
+ | `buttons1` | `number` | `0` | — | — | read only | Held buttons of pad 1. |
744
+ | `buttons2` | `number` | `0` | — | — | read only | Held buttons of pad 2. |
745
+ | `buttons3` | `number` | `0` | — | — | read only | Held buttons of pad 3. |
746
+ | `pressed0` | `number` | `0` | — | — | read only | Buttons of pad 0 that went down this tick. |
747
+ | `pressed1` | `number` | `0` | — | — | read only | Buttons of pad 1 that went down this tick. |
748
+ | `pressed2` | `number` | `0` | — | — | read only | Buttons of pad 2 that went down this tick. |
749
+ | `pressed3` | `number` | `0` | — | — | read only | Buttons of pad 3 that went down this tick. |
750
+ | `released0` | `number` | `0` | — | — | read only | Buttons of pad 0 that went up this tick. |
751
+ | `released1` | `number` | `0` | — | — | read only | Buttons of pad 1 that went up this tick. |
752
+ | `released2` | `number` | `0` | — | — | read only | Buttons of pad 2 that went up this tick. |
753
+ | `released3` | `number` | `0` | — | — | read only | Buttons of pad 3 that went up this tick. |
754
+ | `leftStick0` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left stick of pad 0, -1 to 1, y down. |
755
+ | `leftStick1` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left stick of pad 1, -1 to 1, y down. |
756
+ | `leftStick2` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left stick of pad 2, -1 to 1, y down. |
757
+ | `leftStick3` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left stick of pad 3, -1 to 1, y down. |
758
+ | `rightStick0` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The right stick of pad 0, -1 to 1, y down. |
759
+ | `rightStick1` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The right stick of pad 1, -1 to 1, y down. |
760
+ | `rightStick2` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The right stick of pad 2, -1 to 1, y down. |
761
+ | `rightStick3` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The right stick of pad 3, -1 to 1, y down. |
762
+ | `triggers0` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left (x) and right (y) triggers of pad 0, 0 to 1. |
763
+ | `triggers1` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left (x) and right (y) triggers of pad 1, 0 to 1. |
764
+ | `triggers2` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left (x) and right (y) triggers of pad 2, 0 to 1. |
765
+ | `triggers3` | `Vector2` | `{ x: 0, y: 0 }` | — | — | read only | The left (x) and right (y) triggers of pad 3, 0 to 1. |
766
+
767
+ ```ogt
768
+ resource Gamepad {
769
+ doc "The first four gamepads in the W3C standard mapping, at the start of this tick (og-input's og.Gamepad). On the web the shell polls the pads each display frame and sends their state through the input ring, so a pad is world state and replays; it also maps pads to keys for games that only read keys."
770
+ doc "Button masks are bit `GamepadButton` index per pad; edges last exactly one tick, and a press and a release between two ticks leave both edges set. Read them through the methods."
771
+ field connectedMask u32 "Connected pads: bit `pad`." {
772
+ readonly true
773
+ }
774
+ field buttons0 u32 "Held buttons of pad 0." {
775
+ readonly true
776
+ }
777
+ field buttons1 u32 "Held buttons of pad 1." {
778
+ readonly true
779
+ }
780
+ field buttons2 u32 "Held buttons of pad 2." {
781
+ readonly true
782
+ }
783
+ field buttons3 u32 "Held buttons of pad 3." {
784
+ readonly true
785
+ }
786
+ field pressed0 u32 "Buttons of pad 0 that went down this tick." {
787
+ readonly true
788
+ }
789
+ field pressed1 u32 "Buttons of pad 1 that went down this tick." {
790
+ readonly true
791
+ }
792
+ field pressed2 u32 "Buttons of pad 2 that went down this tick." {
793
+ readonly true
794
+ }
795
+ field pressed3 u32 "Buttons of pad 3 that went down this tick." {
796
+ readonly true
797
+ }
798
+ field released0 u32 "Buttons of pad 0 that went up this tick." {
799
+ readonly true
800
+ }
801
+ field released1 u32 "Buttons of pad 1 that went up this tick." {
802
+ readonly true
803
+ }
804
+ field released2 u32 "Buttons of pad 2 that went up this tick." {
805
+ readonly true
806
+ }
807
+ field released3 u32 "Buttons of pad 3 that went up this tick." {
808
+ readonly true
809
+ }
810
+ field leftStick0 Vector2 "The left stick of pad 0, -1 to 1, y down." {
811
+ readonly true
812
+ }
813
+ field leftStick1 Vector2 "The left stick of pad 1, -1 to 1, y down." {
814
+ readonly true
815
+ }
816
+ field leftStick2 Vector2 "The left stick of pad 2, -1 to 1, y down." {
817
+ readonly true
818
+ }
819
+ field leftStick3 Vector2 "The left stick of pad 3, -1 to 1, y down." {
820
+ readonly true
821
+ }
822
+ field rightStick0 Vector2 "The right stick of pad 0, -1 to 1, y down." {
823
+ readonly true
824
+ }
825
+ field rightStick1 Vector2 "The right stick of pad 1, -1 to 1, y down." {
826
+ readonly true
827
+ }
828
+ field rightStick2 Vector2 "The right stick of pad 2, -1 to 1, y down." {
829
+ readonly true
830
+ }
831
+ field rightStick3 Vector2 "The right stick of pad 3, -1 to 1, y down." {
832
+ readonly true
833
+ }
834
+ field triggers0 Vector2 "The left (x) and right (y) triggers of pad 0, 0 to 1." {
835
+ readonly true
836
+ }
837
+ field triggers1 Vector2 "The left (x) and right (y) triggers of pad 1, 0 to 1." {
838
+ readonly true
839
+ }
840
+ field triggers2 Vector2 "The left (x) and right (y) triggers of pad 2, 0 to 1." {
841
+ readonly true
842
+ }
843
+ field triggers3 Vector2 "The left (x) and right (y) triggers of pad 3, 0 to 1." {
844
+ readonly true
845
+ }
846
+ fn connected {
847
+ doc "Whether a pad is connected."
848
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
849
+ optional true
850
+ }
851
+ returns bool
852
+ }
853
+ fn down {
854
+ doc "Whether a button is held."
855
+ param button GamepadButton "The button."
856
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
857
+ optional true
858
+ }
859
+ returns bool
860
+ }
861
+ fn pressed {
862
+ doc "Whether a button went down this tick."
863
+ param button GamepadButton "The button."
864
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
865
+ optional true
866
+ }
867
+ returns bool
868
+ }
869
+ fn released {
870
+ doc "Whether a button went up this tick."
871
+ param button GamepadButton "The button."
872
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
873
+ optional true
874
+ }
875
+ returns bool
876
+ }
877
+ fn axis {
878
+ doc "An analog input: a stick's x or y (-1 to 1, y down) or a trigger (0 to 1). Dead zones are the game's."
879
+ param axis GamepadAxis "Which input."
880
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
881
+ optional true
882
+ }
883
+ returns f32
884
+ }
885
+ }
886
+ ```
887
+
888
+ <sub>`api.ogt` line 1097</sub>
889
+
890
+ <a id="member-Gamepad-connected"></a>
891
+
892
+ #### `Gamepad.connected`
893
+
894
+ Whether a pad is connected.
895
+
896
+ ```ts
897
+ Gamepad.connected(pad?: number): boolean
898
+ ```
899
+
900
+ | Parameter | Type | Optional | Doc |
901
+ |---|---|---|---|
902
+ | `pad` | `number` | yes | The pad, 0 to 3; omitted is 0. |
903
+
904
+ **Returns** `boolean`.
905
+
906
+ Binding symbol `og_gamepad_connected` · publish builds: kept
907
+
908
+ ```ogt
909
+ fn connected {
910
+ doc "Whether a pad is connected."
911
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
912
+ optional true
913
+ }
914
+ returns bool
915
+ }
916
+ ```
917
+
918
+ <sub>`api.ogt` line 1175</sub>
919
+
920
+ <a id="member-Gamepad-down"></a>
921
+
922
+ #### `Gamepad.down`
923
+
924
+ Whether a button is held.
925
+
926
+ ```ts
927
+ Gamepad.down(button: GamepadButton, pad?: number): boolean
928
+ ```
929
+
930
+ | Parameter | Type | Optional | Doc |
931
+ |---|---|---|---|
932
+ | `button` | `GamepadButton` | no | The button. |
933
+ | `pad` | `number` | yes | The pad, 0 to 3; omitted is 0. |
934
+
935
+ **Returns** `boolean`.
936
+
937
+ Binding symbol `og_gamepad_down` · publish builds: kept
938
+
939
+ ```ogt
940
+ fn down {
941
+ doc "Whether a button is held."
942
+ param button GamepadButton "The button."
943
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
944
+ optional true
945
+ }
946
+ returns bool
947
+ }
948
+ ```
949
+
950
+ <sub>`api.ogt` line 1182</sub>
951
+
952
+ <a id="member-Gamepad-pressed"></a>
953
+
954
+ #### `Gamepad.pressed`
955
+
956
+ Whether a button went down this tick.
957
+
958
+ ```ts
959
+ Gamepad.pressed(button: GamepadButton, pad?: number): boolean
960
+ ```
961
+
962
+ | Parameter | Type | Optional | Doc |
963
+ |---|---|---|---|
964
+ | `button` | `GamepadButton` | no | The button. |
965
+ | `pad` | `number` | yes | The pad, 0 to 3; omitted is 0. |
966
+
967
+ **Returns** `boolean`.
968
+
969
+ Binding symbol `og_gamepad_pressed` · publish builds: kept
970
+
971
+ ```ogt
972
+ fn pressed {
973
+ doc "Whether a button went down this tick."
974
+ param button GamepadButton "The button."
975
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
976
+ optional true
977
+ }
978
+ returns bool
979
+ }
980
+ ```
981
+
982
+ <sub>`api.ogt` line 1190</sub>
983
+
984
+ <a id="member-Gamepad-released"></a>
985
+
986
+ #### `Gamepad.released`
987
+
988
+ Whether a button went up this tick.
989
+
990
+ ```ts
991
+ Gamepad.released(button: GamepadButton, pad?: number): boolean
992
+ ```
993
+
994
+ | Parameter | Type | Optional | Doc |
995
+ |---|---|---|---|
996
+ | `button` | `GamepadButton` | no | The button. |
997
+ | `pad` | `number` | yes | The pad, 0 to 3; omitted is 0. |
998
+
999
+ **Returns** `boolean`.
1000
+
1001
+ Binding symbol `og_gamepad_released` · publish builds: kept
1002
+
1003
+ ```ogt
1004
+ fn released {
1005
+ doc "Whether a button went up this tick."
1006
+ param button GamepadButton "The button."
1007
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
1008
+ optional true
1009
+ }
1010
+ returns bool
1011
+ }
1012
+ ```
1013
+
1014
+ <sub>`api.ogt` line 1198</sub>
1015
+
1016
+ <a id="member-Gamepad-axis"></a>
1017
+
1018
+ #### `Gamepad.axis`
1019
+
1020
+ An analog input: a stick's x or y (-1 to 1, y down) or a trigger (0 to 1). Dead zones are the game's.
1021
+
1022
+ ```ts
1023
+ Gamepad.axis(axis: GamepadAxis, pad?: number): number
1024
+ ```
1025
+
1026
+ | Parameter | Type | Optional | Doc |
1027
+ |---|---|---|---|
1028
+ | `axis` | `GamepadAxis` | no | Which input. |
1029
+ | `pad` | `number` | yes | The pad, 0 to 3; omitted is 0. |
1030
+
1031
+ **Returns** `number`.
1032
+
1033
+ Binding symbol `og_gamepad_axis` · publish builds: kept
1034
+
1035
+ ```ogt
1036
+ fn axis {
1037
+ doc "An analog input: a stick's x or y (-1 to 1, y down) or a trigger (0 to 1). Dead zones are the game's."
1038
+ param axis GamepadAxis "Which input."
1039
+ param pad u32 "The pad, 0 to 3; omitted is 0." {
1040
+ optional true
1041
+ }
1042
+ returns f32
1043
+ }
1044
+ ```
1045
+
1046
+ <sub>`api.ogt` line 1206</sub>
1047
+
1048
+ <a id="record-KeyDown"></a>
1049
+
1050
+ ### `og.KeyDown` (event)
1051
+
1052
+ A key went down (a down for a held key is a repeat and sets no edge). Input events are sent between ticks and read by the next tick's systems.
1053
+
1054
+ Token `og.KeyDown`, registered under the schema name `og.KeyDown`; its value type is `KeyDown`.
1055
+
1056
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1057
+ |---|---|---|---|---|---|---|
1058
+ | `key` | `string` | `""` | — | — | — | The physical key code. |
1059
+ | `repeat` | `boolean` | `false` | — | — | — | Whether this is an auto-repeat. |
1060
+ | `at` | `number` | `0` | -1 … 1 | — | — | When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it. |
1061
+
1062
+ ```ogt
1063
+ event KeyDown {
1064
+ doc "A key went down (a down for a held key is a repeat and sets no edge). Input events are sent between ticks and read by the next tick's systems."
1065
+ field key String "The physical key code."
1066
+ field repeat bool "Whether this is an auto-repeat."
1067
+ field at f32 "When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it." {
1068
+ min -1
1069
+ max 1
1070
+ }
1071
+ }
1072
+ ```
1073
+
1074
+ <sub>`api.ogt` line 1216</sub>
1075
+
1076
+ <a id="record-TextInput"></a>
1077
+
1078
+ ### `og.TextInput` (event)
1079
+
1080
+ Text typed or composed (an engine extension): the shell sends it from the page's `beforeinput` and composition events, the probe's `type:`, `compose:` and `commit:` from scripts. A text longer than 255 bytes arrives as several events in order. Key events still arrive for the keys; a text field types from these once a world has had one.
1081
+
1082
+ Token `og.TextInput`, registered under the schema name `og.TextInput`; its value type is `TextInput`.
1083
+
1084
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1085
+ |---|---|---|---|---|---|---|
1086
+ | `text` | `string` | `""` | — | — | — | The text (whole characters). |
1087
+ | `composing` | `boolean` | `false` | — | — | — | An input method's composition so far, not committed: it replaces the composition before it (empty ends it). False: committed text to insert. |
1088
+ | `more` | `boolean` | `false` | — | — | — | Continues the composition of the event before it (a composition longer than one event). |
1089
+
1090
+ ```ogt
1091
+ event TextInput {
1092
+ doc "Text typed or composed (an engine extension): the shell sends it from the page's `beforeinput` and composition events, the probe's `type:`, `compose:` and `commit:` from scripts. A text longer than 255 bytes arrives as several events in order. Key events still arrive for the keys; a text field types from these once a world has had one."
1093
+ field text String "The text (whole characters)."
1094
+ field composing bool "An input method's composition so far, not committed: it replaces the composition before it (empty ends it). False: committed text to insert."
1095
+ field more bool "Continues the composition of the event before it (a composition longer than one event)."
1096
+ }
1097
+ ```
1098
+
1099
+ <sub>`api.ogt` line 1226</sub>
1100
+
1101
+ <a id="record-KeyUp"></a>
1102
+
1103
+ ### `og.KeyUp` (event)
1104
+
1105
+ A key went up.
1106
+
1107
+ Token `og.KeyUp`, registered under the schema name `og.KeyUp`; its value type is `KeyUp`.
1108
+
1109
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1110
+ |---|---|---|---|---|---|---|
1111
+ | `key` | `string` | `""` | — | — | — | The physical key code. |
1112
+ | `at` | `number` | `0` | -1 … 1 | — | — | When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it. |
1113
+
1114
+ ```ogt
1115
+ event KeyUp {
1116
+ doc "A key went up."
1117
+ field key String "The physical key code."
1118
+ field at f32 "When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it." {
1119
+ min -1
1120
+ max 1
1121
+ }
1122
+ }
1123
+ ```
1124
+
1125
+ <sub>`api.ogt` line 1233</sub>
1126
+
1127
+ <a id="record-PointerDown"></a>
1128
+
1129
+ ### `og.PointerDown` (event)
1130
+
1131
+ A pointer button went down (or a touch landed).
1132
+
1133
+ Token `og.PointerDown`, registered under the schema name `og.PointerDown`; its value type is `PointerDown`.
1134
+
1135
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1136
+ |---|---|---|---|---|---|---|
1137
+ | `x` | `number` | `0` | — | — | — | Horizontal position in CSS pixels. |
1138
+ | `y` | `number` | `0` | — | — | — | Vertical position in CSS pixels. |
1139
+ | `button` | `PointerButton` | `"none"` | — | — | — | The button. |
1140
+ | `id` | `number` | `0` | — | — | — | Which pointer: 0 the primary one, 1 to 4 further touches (og.Pointers). |
1141
+ | `at` | `number` | `0` | -1 … 1 | — | — | When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it. |
1142
+
1143
+ ```ogt
1144
+ event PointerDown {
1145
+ doc "A pointer button went down (or a touch landed)."
1146
+ field x f32 "Horizontal position in CSS pixels."
1147
+ field y f32 "Vertical position in CSS pixels."
1148
+ field button PointerButton "The button."
1149
+ field id u32 "Which pointer: 0 the primary one, 1 to 4 further touches (og.Pointers)."
1150
+ field at f32 "When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it." {
1151
+ min -1
1152
+ max 1
1153
+ }
1154
+ }
1155
+ ```
1156
+
1157
+ <sub>`api.ogt` line 1242</sub>
1158
+
1159
+ <a id="record-PointerUp"></a>
1160
+
1161
+ ### `og.PointerUp` (event)
1162
+
1163
+ A pointer button went up (or a touch lifted).
1164
+
1165
+ Token `og.PointerUp`, registered under the schema name `og.PointerUp`; its value type is `PointerUp`.
1166
+
1167
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1168
+ |---|---|---|---|---|---|---|
1169
+ | `x` | `number` | `0` | — | — | — | Horizontal position in CSS pixels. |
1170
+ | `y` | `number` | `0` | — | — | — | Vertical position in CSS pixels. |
1171
+ | `button` | `PointerButton` | `"none"` | — | — | — | The button. |
1172
+ | `id` | `number` | `0` | — | — | — | Which pointer: 0 the primary one, 1 to 4 further touches. |
1173
+ | `at` | `number` | `0` | -1 … 1 | — | — | When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it. |
1174
+
1175
+ ```ogt
1176
+ event PointerUp {
1177
+ doc "A pointer button went up (or a touch lifted)."
1178
+ field x f32 "Horizontal position in CSS pixels."
1179
+ field y f32 "Vertical position in CSS pixels."
1180
+ field button PointerButton "The button."
1181
+ field id u32 "Which pointer: 0 the primary one, 1 to 4 further touches."
1182
+ field at f32 "When it happened, in ticks from the start of the tick that reads it, -1 to 1 (0 when the host gave no time): its world time is `time.elapsed + at * time.dt`. The shell stamps it from the browser event's timeStamp, the command channel from the step's time; it is part of the event, so a replay carries it." {
1183
+ min -1
1184
+ max 1
1185
+ }
1186
+ }
1187
+ ```
1188
+
1189
+ <sub>`api.ogt` line 1254</sub>
1190
+
1191
+ <a id="record-PointerMove"></a>
1192
+
1193
+ ### `og.PointerMove` (event)
1194
+
1195
+ A pointer moved.
1196
+
1197
+ Token `og.PointerMove`, registered under the schema name `og.PointerMove`; its value type is `PointerMove`.
1198
+
1199
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1200
+ |---|---|---|---|---|---|---|
1201
+ | `x` | `number` | `0` | — | — | — | Horizontal position in CSS pixels. |
1202
+ | `y` | `number` | `0` | — | — | — | Vertical position in CSS pixels. |
1203
+ | `id` | `number` | `0` | — | — | — | Which pointer: 0 the primary one, 1 to 4 further touches. |
1204
+
1205
+ ```ogt
1206
+ event PointerMove {
1207
+ doc "A pointer moved."
1208
+ field x f32 "Horizontal position in CSS pixels."
1209
+ field y f32 "Vertical position in CSS pixels."
1210
+ field id u32 "Which pointer: 0 the primary one, 1 to 4 further touches."
1211
+ }
1212
+ ```
1213
+
1214
+ <sub>`api.ogt` line 1266</sub>
1215
+
1216
+ <a id="record-Wheel"></a>
1217
+
1218
+ ### `og.Wheel` (event)
1219
+
1220
+ A wheel or trackpad scroll.
1221
+
1222
+ Token `og.Wheel`, registered under the schema name `og.Wheel`; its value type is `Wheel`.
1223
+
1224
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1225
+ |---|---|---|---|---|---|---|
1226
+ | `deltaX` | `number` | `0` | — | — | — | Horizontal scroll in CSS pixels. |
1227
+ | `deltaY` | `number` | `0` | — | — | — | Vertical scroll in CSS pixels. |
1228
+
1229
+ ```ogt
1230
+ event Wheel {
1231
+ doc "A wheel or trackpad scroll."
1232
+ field deltaX f32 "Horizontal scroll in CSS pixels."
1233
+ field deltaY f32 "Vertical scroll in CSS pixels."
1234
+ }
1235
+ ```
1236
+
1237
+ <sub>`api.ogt` line 1273</sub>
1238
+
1239
+ <a id="record-A11yAction"></a>
1240
+
1241
+ ### `og.A11yAction` (event)
1242
+
1243
+ A screen reader's request on a UI control (an engine extension): the web shell sends it from its mirror of og.ui.a11y(); the UI takes it at the start of the next frame. A path longer than 255 bytes is refused.
1244
+
1245
+ Token `og.A11yAction`, registered under the schema name `og.A11yAction`; its value type is `A11yAction`.
1246
+
1247
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1248
+ |---|---|---|---|---|---|---|
1249
+ | `action` | `A11yActionKind` | `"focus"` | — | — | — | What is asked. |
1250
+ | `path` | `string` | `""` | — | — | — | The control's path, as og.ui.a11y() names it. |
1251
+
1252
+ ```ogt
1253
+ event A11yAction {
1254
+ doc "A screen reader's request on a UI control (an engine extension): the web shell sends it from its mirror of og.ui.a11y(); the UI takes it at the start of the next frame. A path longer than 255 bytes is refused."
1255
+ field action A11yActionKind "What is asked."
1256
+ field path String "The control's path, as og.ui.a11y() names it."
1257
+ }
1258
+ ```
1259
+
1260
+ <sub>`api.ogt` line 1279</sub>
1261
+
1262
+ ## Types
1263
+
1264
+ <a id="type-GamepadButton"></a>
1265
+
1266
+ ### `GamepadButton` (enum)
1267
+
1268
+ A gamepad button in the W3C standard mapping, in its index order (a is button 0).
1269
+
1270
+ A string: one of the variants below. The zero value is `"a"`.
1271
+
1272
+ | Variant | Doc |
1273
+ |---|---|
1274
+ | `"a"` | The bottom face button (A, Cross). |
1275
+ | `"b"` | The right face button (B, Circle). |
1276
+ | `"x"` | The left face button (X, Square). |
1277
+ | `"y"` | The top face button (Y, Triangle). |
1278
+ | `"leftBumper"` | The left shoulder button. |
1279
+ | `"rightBumper"` | The right shoulder button. |
1280
+ | `"leftTrigger"` | The left trigger, as a button (its analog value is the leftTrigger axis). |
1281
+ | `"rightTrigger"` | The right trigger, as a button. |
1282
+ | `"back"` | Back, Select or View. |
1283
+ | `"start"` | Start, Options or Menu. |
1284
+ | `"leftStick"` | The left stick pressed in. |
1285
+ | `"rightStick"` | The right stick pressed in. |
1286
+ | `"up"` | The d-pad's up. |
1287
+ | `"down"` | The d-pad's down. |
1288
+ | `"left"` | The d-pad's left. |
1289
+ | `"right"` | The d-pad's right. |
1290
+ | `"home"` | The home or guide button. |
1291
+
1292
+ ```ogt
1293
+ enum GamepadButton {
1294
+ doc "A gamepad button in the W3C standard mapping, in its index order (a is button 0)."
1295
+ variant a "The bottom face button (A, Cross)."
1296
+ variant b "The right face button (B, Circle)."
1297
+ variant x "The left face button (X, Square)."
1298
+ variant y "The top face button (Y, Triangle)."
1299
+ variant leftBumper "The left shoulder button."
1300
+ variant rightBumper "The right shoulder button."
1301
+ variant leftTrigger "The left trigger, as a button (its analog value is the leftTrigger axis)."
1302
+ variant rightTrigger "The right trigger, as a button."
1303
+ variant back "Back, Select or View."
1304
+ variant start "Start, Options or Menu."
1305
+ variant leftStick "The left stick pressed in."
1306
+ variant rightStick "The right stick pressed in."
1307
+ variant up "The d-pad's up."
1308
+ variant down "The d-pad's down."
1309
+ variant left "The d-pad's left."
1310
+ variant right "The d-pad's right."
1311
+ variant home "The home or guide button."
1312
+ }
1313
+ ```
1314
+
1315
+ <sub>`api.ogt` line 725</sub>
1316
+
1317
+ <a id="type-GamepadAxis"></a>
1318
+
1319
+ ### `GamepadAxis` (enum)
1320
+
1321
+ An analog input of a gamepad.
1322
+
1323
+ A string: one of the variants below. The zero value is `"leftX"`.
1324
+
1325
+ | Variant | Doc |
1326
+ |---|---|
1327
+ | `"leftX"` | The left stick's x, -1 (left) to 1 (right). |
1328
+ | `"leftY"` | The left stick's y, -1 (up) to 1 (down), as the Gamepad API reports it. |
1329
+ | `"rightX"` | The right stick's x. |
1330
+ | `"rightY"` | The right stick's y, down positive. |
1331
+ | `"leftTrigger"` | The left trigger, 0 to 1. |
1332
+ | `"rightTrigger"` | The right trigger, 0 to 1. |
1333
+
1334
+ ```ogt
1335
+ enum GamepadAxis {
1336
+ doc "An analog input of a gamepad."
1337
+ variant leftX "The left stick's x, -1 (left) to 1 (right)."
1338
+ variant leftY "The left stick's y, -1 (up) to 1 (down), as the Gamepad API reports it."
1339
+ variant rightX "The right stick's x."
1340
+ variant rightY "The right stick's y, down positive."
1341
+ variant leftTrigger "The left trigger, 0 to 1."
1342
+ variant rightTrigger "The right trigger, 0 to 1."
1343
+ }
1344
+ ```
1345
+
1346
+ <sub>`api.ogt` line 746</sub>
1347
+
1348
+ <a id="type-KeyAction"></a>
1349
+
1350
+ ### `KeyAction` (enum)
1351
+
1352
+ What an injected key event does.
1353
+
1354
+ A string: one of the variants below. The zero value is `"press"`.
1355
+
1356
+ | Variant | Doc |
1357
+ |---|---|
1358
+ | `"press"` | Down, then up on the next tick. |
1359
+ | `"down"` | Held down until an up. |
1360
+ | `"up"` | Released. |
1361
+
1362
+ ```ogt
1363
+ enum KeyAction {
1364
+ doc "What an injected key event does."
1365
+ variant press "Down, then up on the next tick."
1366
+ variant down "Held down until an up."
1367
+ variant up "Released."
1368
+ }
1369
+ ```
1370
+
1371
+ <sub>`api.ogt` line 756</sub>
1372
+
1373
+ <a id="type-PointerAction"></a>
1374
+
1375
+ ### `PointerAction` (enum)
1376
+
1377
+ What an injected pointer event does.
1378
+
1379
+ A string: one of the variants below. The zero value is `"click"`.
1380
+
1381
+ | Variant | Doc |
1382
+ |---|---|
1383
+ | `"click"` | Down, then up on the next tick, at the point. |
1384
+ | `"move"` | A move to the point. |
1385
+ | `"down"` | A press at the point. |
1386
+ | `"up"` | A release at the point. |
1387
+
1388
+ ```ogt
1389
+ enum PointerAction {
1390
+ doc "What an injected pointer event does."
1391
+ variant click "Down, then up on the next tick, at the point."
1392
+ variant move "A move to the point."
1393
+ variant down "A press at the point."
1394
+ variant up "A release at the point."
1395
+ }
1396
+ ```
1397
+
1398
+ <sub>`api.ogt` line 763</sub>
1399
+
1400
+ <a id="type-PointerButton"></a>
1401
+
1402
+ ### `PointerButton` (enum)
1403
+
1404
+ A physical pointer button; `none` is a hover move.
1405
+
1406
+ A string: one of the variants below. The zero value is `"none"`.
1407
+
1408
+ | Variant | Doc |
1409
+ |---|---|
1410
+ | `"none"` | No button. |
1411
+ | `"left"` | The primary button, or a touch. |
1412
+ | `"middle"` | The middle button. |
1413
+ | `"right"` | The secondary button. |
1414
+
1415
+ ```ogt
1416
+ enum PointerButton {
1417
+ doc "A physical pointer button; `none` is a hover move."
1418
+ variant none "No button."
1419
+ variant left "The primary button, or a touch."
1420
+ variant middle "The middle button."
1421
+ variant right "The secondary button."
1422
+ }
1423
+ ```
1424
+
1425
+ <sub>`api.ogt` line 771</sub>
1426
+
1427
+ <a id="type-Modifiers"></a>
1428
+
1429
+ ### `Modifiers` (struct)
1430
+
1431
+ Modifier keys held during a key event.
1432
+
1433
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1434
+ |---|---|---|---|---|---|---|
1435
+ | `alt` | `boolean` | `false` | — | — | — | Alt or Option. |
1436
+ | `control` | `boolean` | `false` | — | — | — | Control. |
1437
+ | `platform` | `boolean` | `false` | — | — | — | Command on macOS, the Windows key on Windows. |
1438
+ | `shift` | `boolean` | `false` | — | — | — | Shift. |
1439
+
1440
+ ```ogt
1441
+ struct Modifiers {
1442
+ doc "Modifier keys held during a key event."
1443
+ field alt bool "Alt or Option."
1444
+ field control bool "Control."
1445
+ field platform bool "Command on macOS, the Windows key on Windows."
1446
+ field shift bool "Shift."
1447
+ }
1448
+ ```
1449
+
1450
+ <sub>`api.ogt` line 779</sub>
1451
+
1452
+ <a id="type-KeyInput"></a>
1453
+
1454
+ ### `KeyInput` (struct)
1455
+
1456
+ A key event. `key` names the physical key as KeyboardEvent.code does: ArrowRight, Space, KeyA.
1457
+
1458
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1459
+ |---|---|---|---|---|---|---|
1460
+ | `key` | `string` | `""` | — | — | — | The physical key code. |
1461
+ | `action` | `KeyAction` | `"press"` | — | — | — | Press, down or up. |
1462
+ | `modifiers` | `Modifiers` | `{ alt: false, control: false, platform: false, shift: false }` | — | — | optional | Held modifiers; omitted means none. |
1463
+ | `at` | `number` | `0` | -1 … 1 | — | optional | When it happened, in ticks from the start of the tick that reads it (-1 to 1; omitted is 0): the KeyDown, KeyUp, PointerDown or PointerUp it raises carry it. An engine extension of protocol 5. |
1464
+
1465
+ ```ogt
1466
+ struct KeyInput {
1467
+ doc "A key event. `key` names the physical key as KeyboardEvent.code does: ArrowRight, Space, KeyA."
1468
+ field key String "The physical key code."
1469
+ field action KeyAction "Press, down or up."
1470
+ field modifiers Modifiers "Held modifiers; omitted means none." {
1471
+ optional true
1472
+ }
1473
+ field at f32 "When it happened, in ticks from the start of the tick that reads it (-1 to 1; omitted is 0): the KeyDown, KeyUp, PointerDown or PointerUp it raises carry it. An engine extension of protocol 5." {
1474
+ min -1
1475
+ max 1
1476
+ optional true
1477
+ }
1478
+ }
1479
+ ```
1480
+
1481
+ <sub>`api.ogt` line 787</sub>
1482
+
1483
+ <a id="type-PointerInput"></a>
1484
+
1485
+ ### `PointerInput` (struct)
1486
+
1487
+ A pointer event at a point in CSS pixels of the play surface.
1488
+
1489
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1490
+ |---|---|---|---|---|---|---|
1491
+ | `action` | `PointerAction` | `"click"` | — | — | — | Click, move, down or up. |
1492
+ | `x` | `number` | `0` | — | `cssPx` | — | Horizontal position. |
1493
+ | `y` | `number` | `0` | — | `cssPx` | — | Vertical position. |
1494
+ | `button` | `PointerButton` | `"none"` | — | — | — | The button; `none` for a hover move. |
1495
+ | `id` | `number` | `0` | ≤ 4 | — | optional | Which pointer: 0 the primary one (the mouse, the first touch; what protocol 5 means), 1 to 4 further touches held at the same time (an engine extension). Omitted is 0. |
1496
+ | `at` | `number` | `0` | -1 … 1 | — | optional | When it happened, in ticks from the start of the tick that reads it (-1 to 1; omitted is 0): the KeyDown, KeyUp, PointerDown or PointerUp it raises carry it. An engine extension of protocol 5. |
1497
+
1498
+ ```ogt
1499
+ struct PointerInput {
1500
+ doc "A pointer event at a point in CSS pixels of the play surface."
1501
+ field action PointerAction "Click, move, down or up."
1502
+ field x f32 "Horizontal position." {
1503
+ unit cssPx
1504
+ }
1505
+ field y f32 "Vertical position." {
1506
+ unit cssPx
1507
+ }
1508
+ field button PointerButton "The button; `none` for a hover move."
1509
+ field id u32 "Which pointer: 0 the primary one (the mouse, the first touch; what protocol 5 means), 1 to 4 further touches held at the same time (an engine extension). Omitted is 0." {
1510
+ max 4
1511
+ optional true
1512
+ }
1513
+ field at f32 "When it happened, in ticks from the start of the tick that reads it (-1 to 1; omitted is 0): the KeyDown, KeyUp, PointerDown or PointerUp it raises carry it. An engine extension of protocol 5." {
1514
+ min -1
1515
+ max 1
1516
+ optional true
1517
+ }
1518
+ }
1519
+ ```
1520
+
1521
+ <sub>`api.ogt` line 801</sub>
1522
+
1523
+ <a id="type-GamepadInput"></a>
1524
+
1525
+ ### `GamepadInput` (struct)
1526
+
1527
+ A gamepad's whole state (an engine extension of protocol 5): the shell sends one whenever a pad changes, and a playtest can send its own.
1528
+
1529
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1530
+ |---|---|---|---|---|---|---|
1531
+ | `pad` | `number` | `0` | ≤ 3 | — | optional | Which pad, 0 to 3; omitted is 0. |
1532
+ | `connected` | `boolean` | `false` | — | — | optional | Whether the pad is connected (omitted is true); a disconnected pad holds nothing. |
1533
+ | `buttons` | `readonly GamepadButton[]` | `[]` | — | — | optional | The buttons held (omitted is none). |
1534
+ | `axes` | `readonly number[]` | `[]` | — | — | optional | Left stick x, y, right stick x, y; each -1 to 1, y down. Missing values are 0. |
1535
+ | `triggers` | `readonly number[]` | `[]` | — | — | optional | The left and right analog triggers, 0 to 1. Missing values are 0. |
1536
+
1537
+ ```ogt
1538
+ struct GamepadInput {
1539
+ doc "A gamepad's whole state (an engine extension of protocol 5): the shell sends one whenever a pad changes, and a playtest can send its own."
1540
+ field pad u32 "Which pad, 0 to 3; omitted is 0." {
1541
+ max 3
1542
+ optional true
1543
+ }
1544
+ field connected bool "Whether the pad is connected (omitted is true); a disconnected pad holds nothing." {
1545
+ optional true
1546
+ }
1547
+ field buttons List.GamepadButton "The buttons held (omitted is none)." {
1548
+ optional true
1549
+ }
1550
+ field axes List.f32 "Left stick x, y, right stick x, y; each -1 to 1, y down. Missing values are 0." {
1551
+ optional true
1552
+ }
1553
+ field triggers List.f32 "The left and right analog triggers, 0 to 1. Missing values are 0." {
1554
+ optional true
1555
+ }
1556
+ }
1557
+ ```
1558
+
1559
+ <sub>`api.ogt` line 822</sub>
1560
+
1561
+ <a id="type-WheelInput"></a>
1562
+
1563
+ ### `WheelInput` (struct)
1564
+
1565
+ A wheel or trackpad scroll at a point.
1566
+
1567
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1568
+ |---|---|---|---|---|---|---|
1569
+ | `x` | `number` | `0` | — | `cssPx` | — | Horizontal position. |
1570
+ | `y` | `number` | `0` | — | `cssPx` | — | Vertical position. |
1571
+ | `deltaX` | `number` | `0` | — | `cssPx` | — | Horizontal scroll amount. |
1572
+ | `deltaY` | `number` | `0` | — | `cssPx` | — | Vertical scroll amount. |
1573
+
1574
+ ```ogt
1575
+ struct WheelInput {
1576
+ doc "A wheel or trackpad scroll at a point."
1577
+ field x f32 "Horizontal position." {
1578
+ unit cssPx
1579
+ }
1580
+ field y f32 "Vertical position." {
1581
+ unit cssPx
1582
+ }
1583
+ field deltaX f32 "Horizontal scroll amount." {
1584
+ unit cssPx
1585
+ }
1586
+ field deltaY f32 "Vertical scroll amount." {
1587
+ unit cssPx
1588
+ }
1589
+ }
1590
+ ```
1591
+
1592
+ <sub>`api.ogt` line 842</sub>
1593
+
1594
+ <a id="type-TextEntry"></a>
1595
+
1596
+ ### `TextEntry` (struct)
1597
+
1598
+ Typed or composed text (an engine extension of protocol 5): what the page's `beforeinput` inserted (a key's character, a paste, an input method's commit), or with `composing` an input method's composition so far. Raises TextInput events; the UI's focused text field takes them.
1599
+
1600
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1601
+ |---|---|---|---|---|---|---|
1602
+ | `text` | `string` | `""` | — | — | — | The text. |
1603
+ | `composing` | `boolean` | `false` | — | — | optional | An input method's composition, not yet committed: it replaces the composition before it, and empty ends it. Omitted is false: committed text. |
1604
+
1605
+ ```ogt
1606
+ struct TextEntry {
1607
+ doc "Typed or composed text (an engine extension of protocol 5): what the page's `beforeinput` inserted (a key's character, a paste, an input method's commit), or with `composing` an input method's composition so far. Raises TextInput events; the UI's focused text field takes them."
1608
+ field text String "The text."
1609
+ field composing bool "An input method's composition, not yet committed: it replaces the composition before it, and empty ends it. Omitted is false: committed text." {
1610
+ optional true
1611
+ }
1612
+ }
1613
+ ```
1614
+
1615
+ <sub>`api.ogt` line 858</sub>
1616
+
1617
+ <a id="type-A11yActionKind"></a>
1618
+
1619
+ ### `A11yActionKind` (enum)
1620
+
1621
+ What an assistive technology asks of a UI control.
1622
+
1623
+ A string: one of the variants below. The zero value is `"focus"`.
1624
+
1625
+ | Variant | Doc |
1626
+ |---|---|
1627
+ | `"focus"` | Move the UI's focus to it (with the focus ring). |
1628
+ | `"activate"` | Press it, as Enter on it would (a text control takes the focus). |
1629
+ | `"increment"` | Step an adjustable control (a slider, a stepper) up. |
1630
+ | `"decrement"` | Step an adjustable control down. |
1631
+
1632
+ ```ogt
1633
+ enum A11yActionKind {
1634
+ doc "What an assistive technology asks of a UI control."
1635
+ variant focus "Move the UI's focus to it (with the focus ring)."
1636
+ variant activate "Press it, as Enter on it would (a text control takes the focus)."
1637
+ variant increment "Step an adjustable control (a slider, a stepper) up."
1638
+ variant decrement "Step an adjustable control down."
1639
+ }
1640
+ ```
1641
+
1642
+ <sub>`api.ogt` line 866</sub>
1643
+
1644
+ <a id="type-A11yRequest"></a>
1645
+
1646
+ ### `A11yRequest` (struct)
1647
+
1648
+ A screen reader's request on a UI control (an engine extension of protocol 5): the web shell's mirror of og.ui.a11y() sends it when a reader focuses, activates or adjusts a mirrored node. Raises an A11yAction event; the UI acts on it at the start of the next frame, against the last frame's controls (a path naming no focusable control of the topmost dialog is ignored; increment and decrement also take a stepper's spinbutton, whose buttons are the focusable controls).
1649
+
1650
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1651
+ |---|---|---|---|---|---|---|
1652
+ | `action` | `A11yActionKind` | `"focus"` | — | — | — | What is asked. |
1653
+ | `path` | `string` | `""` | — | — | — | The control's path, as og.ui.a11y() names it. |
1654
+
1655
+ ```ogt
1656
+ struct A11yRequest {
1657
+ doc "A screen reader's request on a UI control (an engine extension of protocol 5): the web shell's mirror of og.ui.a11y() sends it when a reader focuses, activates or adjusts a mirrored node. Raises an A11yAction event; the UI acts on it at the start of the next frame, against the last frame's controls (a path naming no focusable control of the topmost dialog is ignored; increment and decrement also take a stepper's spinbutton, whose buttons are the focusable controls)."
1658
+ field action A11yActionKind "What is asked."
1659
+ field path String "The control's path, as og.ui.a11y() names it."
1660
+ }
1661
+ ```
1662
+
1663
+ <sub>`api.ogt` line 874</sub>
1664
+
1665
+ <a id="type-InjectedInput"></a>
1666
+
1667
+ ### `InjectedInput` (union)
1668
+
1669
+ One input event in the game's own vocabulary, as the probe's input() and playtest scripts carry it.
1670
+
1671
+ Tagged by `kind`.
1672
+
1673
+ | Case | Payload | Doc |
1674
+ |---|---|---|
1675
+ | `kind: "key"` | [`KeyInput`](#type-KeyInput) | A key event. |
1676
+ | `kind: "pointer"` | [`PointerInput`](#type-PointerInput) | A pointer event. |
1677
+ | `kind: "wheel"` | [`WheelInput`](#type-WheelInput) | A wheel event. |
1678
+ | `kind: "gamepad"` | [`GamepadInput`](#type-GamepadInput) | A gamepad's state. |
1679
+ | `kind: "text"` | [`TextEntry`](#type-TextEntry) | Typed or composed text. |
1680
+ | `kind: "a11y"` | [`A11yRequest`](#type-A11yRequest) | A screen reader's request on a UI control. |
1681
+
1682
+ ```ogt
1683
+ union InjectedInput {
1684
+ doc "One input event in the game's own vocabulary, as the probe's input() and playtest scripts carry it."
1685
+ tag kind
1686
+ case key KeyInput "A key event."
1687
+ case pointer PointerInput "A pointer event."
1688
+ case wheel WheelInput "A wheel event."
1689
+ case gamepad GamepadInput "A gamepad's state."
1690
+ case text TextEntry "Typed or composed text."
1691
+ case a11y A11yRequest "A screen reader's request on a UI control."
1692
+ }
1693
+ ```
1694
+
1695
+ <sub>`api.ogt` line 880</sub>
1696
+
1697
+ ## Constants
1698
+
1699
+ | Constant | Type | Value | Doc |
1700
+ |---|---|---|---|
1701
+ | <a id="const-MAX_POINTERS"></a>`MAX_POINTERS` | `number` | `5` | The most pointers og.Pointers tracks at once: ids 0 (the primary pointer) to 4. |
1702
+ | <a id="const-MAX_GAMEPADS"></a>`MAX_GAMEPADS` | `number` | `4` | The most gamepads og.Gamepad reads: pads 0 to 3. |
1703
+
1704
+ ```ogt
1705
+ const MAX_POINTERS u32 5 "The most pointers og.Pointers tracks at once: ids 0 (the primary pointer) to 4."
1706
+ ```
1707
+
1708
+ <sub>`api.ogt` line 722</sub>
1709
+
1710
+ ```ogt
1711
+ const MAX_GAMEPADS u32 4 "The most gamepads og.Gamepad reads: pads 0 to 3."
1712
+ ```
1713
+
1714
+ <sub>`api.ogt` line 723</sub>