@vnejs/docs 0.2.66 → 0.2.68
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.
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# 0.2.68
|
|
2
|
+
|
|
3
|
+
- `plugins/controls/gamepad` — joypad.js is gone. The plugin polls `navigator.getGamepads()` every frame, including a pad already connected at launch. API: `GAMEPAD.BUTTON_PRESS`, `GAMEPAD.BUTTON_RELEASE`, `GAMEPAD.AXIS`, `GAMEPAD.CONNECT`, `GAMEPAD.DISCONNECT`. One pad still sets `CONTROLS.DEVICE_SET` at once.
|
|
4
|
+
- `compatibility/controls.gamepad/controls.cursor` — stick input comes from `GAMEPAD.AXIS`. Left stick is `CURSOR.SHIFT`, right stick is `CURSOR.SCROLL`.
|
package/changelog/README.md
CHANGED
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@ None.
|
|
|
40
40
|
| `controls` | Handles EMIT, PUSH, POP; sets `shared.isControlsLocked` while an async EMIT handler runs. |
|
|
41
41
|
| `controls.device` | Holds `currentDevice`; on `DEVICE_SET` emits `DEVICE_CHANGED` only when the type really changes. |
|
|
42
42
|
|
|
43
|
-
Sources of `DEVICE_SET`: keyboard (keydown) → keyboard; `controls.gamepad.device` (
|
|
43
|
+
Sources of `DEVICE_SET`: keyboard (keydown) → keyboard; `controls.gamepad.device` (`GAMEPAD.CONNECT` for one pad, `GAMEPAD.BUTTON_PRESS`, `GAMEPAD.AXIS`) → xbox|playstation by `gamepad.id`; cursor (`mousemove`) → keyboard.
|
|
44
44
|
|
|
45
45
|
## Related plugins
|
|
46
46
|
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Package: `@vnejs/plugins.controls.gamepad` · namespace: `GAMEPAD`
|
|
4
4
|
|
|
5
|
-
Gamepad → abstract control events
|
|
5
|
+
Gamepad → abstract control events. The plugin polls `navigator.getGamepads()` every frame.
|
|
6
6
|
|
|
7
7
|
## Events
|
|
8
8
|
|
|
9
9
|
Handler payloads and results are typed through module augmentation of the contract (`VneEventPayloadMap` / `VneEventResultMap`). The types live in `@vnejs/contracts.controls.gamepad`.
|
|
10
10
|
|
|
11
|
-
| Key
|
|
12
|
-
|
|
|
13
|
-
| `EMIT`
|
|
11
|
+
| Key | String | Meaning |
|
|
12
|
+
| ---------------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
|
13
|
+
| `EMIT` | `vne:gamepad:emit` | Proxy a press to `CONTROLS.EMIT` (`{ keys }`) with lock `inProcess`. |
|
|
14
|
+
| `BUTTON_PRESS` | `vne:gamepad:button_press` | Rising edge of a logical button (`{ buttonName, gamepad? }`). |
|
|
15
|
+
| `BUTTON_RELEASE` | `vne:gamepad:button_release` | Falling edge of a logical button (`{ buttonName, gamepad? }`). |
|
|
16
|
+
| `AXIS` | `vne:gamepad:axis` | Stick or trigger axis while `abs(value) > 0.1` (`{ axis, value, gamepad? }`), every frame. |
|
|
17
|
+
| `CONNECT` | `vne:gamepad:connect` | A gamepad index appeared in `navigator.getGamepads()`. Payload is empty. |
|
|
18
|
+
| `DISCONNECT` | `vne:gamepad:disconnect` | A gamepad index left `navigator.getGamepads()`. Payload is empty. |
|
|
14
19
|
|
|
15
20
|
## Constants
|
|
16
21
|
|
|
@@ -26,9 +31,9 @@ None.
|
|
|
26
31
|
|
|
27
32
|
## Button mapping (W3C / Xbox standard)
|
|
28
33
|
|
|
29
|
-
After
|
|
34
|
+
After the poll yields logical name `button_N`, `controls.gamepad.buttons` emits `GAMEPAD.EMIT`, and `controls.gamepad` proxies keys to `CONTROLS.EMIT`:
|
|
30
35
|
|
|
31
|
-
|
|
|
36
|
+
| Logical name | Physical (standard) | Abstract control |
|
|
32
37
|
| ---------------- | ------------------- | ------------------------------------------ |
|
|
33
38
|
| `button_0` | A / Cross (bottom) | `ACCEPT` |
|
|
34
39
|
| `button_1` | B / Circle (right) | `BACK` |
|
|
@@ -44,13 +49,17 @@ After joypad yields logical name `button_N`, button and trigger modules emit `GA
|
|
|
44
49
|
|
|
45
50
|
## Profiles and active pad
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
On Steam Deck you often see two pads at once (raw HID + Steam Input Xbox virtual); you cannot pick the quiet virtual pad ahead of time.
|
|
48
53
|
|
|
49
54
|
So the plugin:
|
|
50
55
|
|
|
51
56
|
1. If there is one pad — use its profile at once.
|
|
52
57
|
2. If there are several pads — wait for the **first real press** and lock to the `gamepad.index` that sent it (not ghost Steam Input).
|
|
53
|
-
3. Then ignore events from other indexes
|
|
58
|
+
3. Then ignore button events from other indexes. The locked pad uses its profile. Other pads stay on identity.
|
|
59
|
+
|
|
60
|
+
`controls.gamepad.poll` reads `navigator.getGamepads()` on init and on every animation frame. A pad that was already connected at launch is in that list, so it does not depend on the browser `gamepadconnected` event.
|
|
61
|
+
|
|
62
|
+
`controls.gamepad.device` reads the same list on init and on `CONNECT`. One pad sets `CONTROLS.DEVICE_SET` at once (`DEVICES.XBOX` or `DEVICES.PLAYSTATION` by `gamepad.id`). Several pads still wait for the first real press or stick.
|
|
54
63
|
|
|
55
64
|
Profile priority: `steam-deck` → `playstation` → `nintendo` → `firefox` → `standard`.
|
|
56
65
|
|
|
@@ -62,7 +71,7 @@ Raw button dump for debugging — separate view plugin [gamepad.debug](../views/
|
|
|
62
71
|
| `steam-deck` | preferred without standard + Deck/Steam id (`28de` / `valve` / …) or `?steamDeck=1` | raw HID Deck → W3C |
|
|
63
72
|
| `playstation` | `mapping !== "standard"` and PS id | raw Square-first → W3C |
|
|
64
73
|
| `nintendo` | Nintendo/Switch id, including with `standard` | A/B and X/Y for Nintendo confirm |
|
|
65
|
-
| `firefox` | Firefox UA and no device profile matched |
|
|
74
|
+
| `firefox` | Firefox UA and no device profile matched | Firefox button indexes |
|
|
66
75
|
|
|
67
76
|
Electron with `STEAM_DECK=1` adds `?steamDeck=1`.
|
|
68
77
|
|
|
@@ -78,9 +87,10 @@ All mappings — object `CUSTOM_BUTTON_MAPPING` in `plugins/controls/gamepad/src
|
|
|
78
87
|
|
|
79
88
|
| Module | Role |
|
|
80
89
|
| -------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
81
|
-
| `controls.gamepad` | `
|
|
82
|
-
| `controls.gamepad.
|
|
83
|
-
| `controls.gamepad.
|
|
90
|
+
| `controls.gamepad` | `CONNECT` / `DISCONNECT` → sync profile. Proxy `GAMEPAD.EMIT`. |
|
|
91
|
+
| `controls.gamepad.poll` | Poll `navigator.getGamepads()` every frame. Emit button, axis, connect, and disconnect events. |
|
|
92
|
+
| `controls.gamepad.buttons` | `BUTTON_PRESS` / `BUTTON_RELEASE` → `GAMEPAD.EMIT`; lock active pad. |
|
|
93
|
+
| `controls.gamepad.device` | One pad, `CONNECT`, `BUTTON_PRESS`, or `AXIS` → `CONTROLS.DEVICE_SET` (xbox or playstation). Several pads wait. |
|
|
84
94
|
|
|
85
95
|
## Related plugins
|
|
86
96
|
|
|
@@ -77,7 +77,7 @@ None.
|
|
|
77
77
|
| `choose.skip` | Handles `SKIP` via `getBlockSkipShift`. |
|
|
78
78
|
| `choose.logs` | Log `EMIT` / `OPTION` / `SKIP` / `SHOW` / `HIDE`. |
|
|
79
79
|
| `choose.replace` | Registry for `OPTION_REPLACE_REG` handlers; extends `@vnejs/module.replace`. |
|
|
80
|
-
| `choose.option.text` | Registry for `OPTION_TEXT_REG` handlers; extends `@vnejs/module.replace`. `EMIT` resolves each option through `OPTION_TEXT`.
|
|
80
|
+
| `choose.option.text` | Registry for `OPTION_TEXT_REG` handlers; extends `@vnejs/module.replace`. `EMIT` resolves each option through `OPTION_TEXT`. |
|
|
81
81
|
| `choose.exec` | Registry for EXEC_REG / EXEC_GET handlers. |
|
|
82
82
|
| `choose.scenario` | Register `% choose`: collect option lines via `getBlockOptions`, emit `EMIT`. |
|
|
83
83
|
| `choose.scenario.option` | Register `% choose.option`: skip unchosen branches. |
|