@codexo/exojs 0.7.12 → 0.7.13
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.
- package/CHANGELOG.md +334 -0
- package/dist/esm/core/Application.d.ts +3 -1
- package/dist/esm/core/Application.js +7 -6
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +30 -0
- package/dist/esm/core/Scene.js +56 -0
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.js +2 -2
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/debug/DebugOverlay.js +2 -2
- package/dist/esm/debug/DebugOverlay.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.js +1 -1
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.js +18 -19
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +164 -62
- package/dist/esm/input/Gamepad.js +290 -134
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadAxis.d.ts +120 -0
- package/dist/esm/input/GamepadAxis.js +106 -0
- package/dist/esm/input/GamepadAxis.js.map +1 -0
- package/dist/esm/input/GamepadButton.d.ts +110 -0
- package/dist/esm/input/GamepadButton.js +99 -0
- package/dist/esm/input/GamepadButton.js.map +1 -0
- package/dist/esm/input/GamepadDefinitions.js +4 -0
- package/dist/esm/input/GamepadDefinitions.js.map +1 -1
- package/dist/esm/input/GamepadMapping.d.ts +28 -24
- package/dist/esm/input/GamepadMapping.js +33 -16
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.d.ts +10 -8
- package/dist/esm/input/GamepadPromptLayouts.js +21 -20
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +6 -3
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js +55 -46
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/InputBinding.d.ts +74 -0
- package/dist/esm/input/InputBinding.js +100 -0
- package/dist/esm/input/InputBinding.js.map +1 -0
- package/dist/esm/input/InputManager.d.ts +79 -33
- package/dist/esm/input/InputManager.js +229 -104
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +1 -1
- package/dist/esm/input/InteractionManager.js +13 -13
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +14 -9
- package/dist/esm/input/JoyConLeftGamepadMapping.js +39 -9
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.d.ts +14 -9
- package/dist/esm/input/JoyConRightGamepadMapping.js +35 -9
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +84 -71
- package/dist/esm/input/Pointer.js +71 -71
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
- package/dist/esm/input/index.d.ts +7 -4
- package/dist/esm/input/types.d.ts +0 -76
- package/dist/esm/input/types.js +1 -80
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/resources/CacheFirstStrategy.d.ts +7 -4
- package/dist/esm/resources/CacheFirstStrategy.js +11 -8
- package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
- package/dist/esm/resources/CacheStrategy.d.ts +14 -6
- package/dist/esm/resources/Loader.d.ts +8 -3
- package/dist/esm/resources/Loader.js +19 -37
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/NetworkOnlyStrategy.d.ts +3 -0
- package/dist/esm/resources/NetworkOnlyStrategy.js +8 -3
- package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.d.ts +2 -2
- package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +2 -2
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +3 -3
- package/dist/esm/resources/factories/VttFactory.js +83 -6
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/exo.esm.js +1390 -795
- package/dist/exo.esm.js.map +1 -1
- package/package.json +2 -1
- package/dist/esm/input/GamepadChannels.d.ts +0 -47
- package/dist/esm/input/GamepadChannels.js +0 -53
- package/dist/esm/input/GamepadChannels.js.map +0 -1
- package/dist/esm/input/GamepadControl.d.ts +0 -33
- package/dist/esm/input/GamepadControl.js +0 -42
- package/dist/esm/input/GamepadControl.js.map +0 -1
- package/dist/esm/input/Input.d.ts +0 -52
- package/dist/esm/input/Input.js +0 -90
- package/dist/esm/input/Input.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GamepadButton } from './GamepadButton.js';
|
|
2
2
|
import { GamepadMappingFamily } from './GamepadMapping.js';
|
|
3
3
|
|
|
4
4
|
const basePositions = new Map([
|
|
@@ -21,22 +21,22 @@ const basePositions = new Map([
|
|
|
21
21
|
['RightStick', [0.62, 0.66]],
|
|
22
22
|
]);
|
|
23
23
|
const channelMap = new Map([
|
|
24
|
-
['ButtonNorth',
|
|
25
|
-
['ButtonWest',
|
|
26
|
-
['ButtonEast',
|
|
27
|
-
['ButtonSouth',
|
|
28
|
-
['LeftShoulder',
|
|
29
|
-
['RightShoulder',
|
|
30
|
-
['LeftTrigger',
|
|
31
|
-
['RightTrigger',
|
|
32
|
-
['Select',
|
|
33
|
-
['Start',
|
|
34
|
-
['LeftStick',
|
|
35
|
-
['RightStick',
|
|
36
|
-
['DPadUp',
|
|
37
|
-
['DPadDown',
|
|
38
|
-
['DPadLeft',
|
|
39
|
-
['DPadRight',
|
|
24
|
+
['ButtonNorth', GamepadButton.North],
|
|
25
|
+
['ButtonWest', GamepadButton.West],
|
|
26
|
+
['ButtonEast', GamepadButton.East],
|
|
27
|
+
['ButtonSouth', GamepadButton.South],
|
|
28
|
+
['LeftShoulder', GamepadButton.LeftShoulder],
|
|
29
|
+
['RightShoulder', GamepadButton.RightShoulder],
|
|
30
|
+
['LeftTrigger', GamepadButton.LeftTrigger],
|
|
31
|
+
['RightTrigger', GamepadButton.RightTrigger],
|
|
32
|
+
['Select', GamepadButton.Select],
|
|
33
|
+
['Start', GamepadButton.Start],
|
|
34
|
+
['LeftStick', GamepadButton.LeftStick],
|
|
35
|
+
['RightStick', GamepadButton.RightStick],
|
|
36
|
+
['DPadUp', GamepadButton.DPadUp],
|
|
37
|
+
['DPadDown', GamepadButton.DPadDown],
|
|
38
|
+
['DPadLeft', GamepadButton.DPadLeft],
|
|
39
|
+
['DPadRight', GamepadButton.DPadRight],
|
|
40
40
|
]);
|
|
41
41
|
const genericLabels = new Map([
|
|
42
42
|
['ButtonNorth', 'North'],
|
|
@@ -103,6 +103,7 @@ const promptLabelsByFamily = new Map([
|
|
|
103
103
|
[GamepadMappingFamily.JoyConRight, switchLabels],
|
|
104
104
|
[GamepadMappingFamily.GameCube, genericLabels],
|
|
105
105
|
[GamepadMappingFamily.SteamController, genericLabels],
|
|
106
|
+
[GamepadMappingFamily.SteamDeck, genericLabels],
|
|
106
107
|
[GamepadMappingFamily.ArcadeStick, genericLabels],
|
|
107
108
|
]);
|
|
108
109
|
/**
|
|
@@ -111,7 +112,7 @@ const promptLabelsByFamily = new Map([
|
|
|
111
112
|
* Provides the canonical set of prompt controls, their normalised [x, y] positions
|
|
112
113
|
* on a generic controller silhouette, device-family label strings (e.g. "A" for
|
|
113
114
|
* Xbox, "Cross" for PlayStation, "B" for Switch), and the mapping from prompt
|
|
114
|
-
* control names to {@link
|
|
115
|
+
* control names to {@link GamepadButton} channel values.
|
|
115
116
|
*/
|
|
116
117
|
class GamepadPromptLayouts {
|
|
117
118
|
/** Complete ordered list of every {@link GamepadPromptControl} token. */
|
|
@@ -152,8 +153,8 @@ class GamepadPromptLayouts {
|
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* Returns the static mapping from each {@link GamepadPromptControl} to its
|
|
155
|
-
* corresponding {@link
|
|
156
|
-
* channel entry and is absent from the returned map.
|
|
156
|
+
* corresponding {@link GamepadButton} channel. The composite `'DPad'`
|
|
157
|
+
* control has no channel entry and is absent from the returned map.
|
|
157
158
|
*/
|
|
158
159
|
static getControlChannelMap() {
|
|
159
160
|
return channelMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GamepadPromptLayouts.js","sources":["../../../../src/input/GamepadPromptLayouts.ts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"GamepadPromptLayouts.js","sources":["../../../../src/input/GamepadPromptLayouts.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAiCA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAkD;AAC3E,IAAA,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,IAAA,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxB,IAAA,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC1B,IAAA,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC1B,IAAA,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC3B,IAAA,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7B,IAAA,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5B,IAAA,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,IAA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og controllers that follow the standard
|
|
4
4
|
* W3C Gamepad API layout (axes 0–3 for both sticks, axes 4–7 auxiliary).
|
|
5
5
|
*
|
|
6
|
-
* Each signed axis is
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Each signed stick axis is exposed three ways for ergonomic binding:
|
|
7
|
+
* - Two direction-split, non-negative channels (e.g. `LeftStickLeft` /
|
|
8
|
+
* `LeftStickRight`) for "buttons-style" subscriptions.
|
|
9
|
+
* - One signed aggregate channel (e.g. `LeftStickX`) for direct -1..1
|
|
10
|
+
* consumption — useful for movement or aiming.
|
|
11
|
+
*
|
|
9
12
|
* Device-specific subclasses (Xbox, PlayStation, Switch Pro, etc.) inherit
|
|
10
13
|
* this layout and override only {@link GamepadMapping.family}.
|
|
11
14
|
*/
|
|
@@ -1,61 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GamepadAxis } from './GamepadAxis.js';
|
|
2
|
+
import { GamepadButton } from './GamepadButton.js';
|
|
2
3
|
import { GamepadMapping, GamepadMappingFamily } from './GamepadMapping.js';
|
|
3
4
|
|
|
4
|
-
const genericDualAnalogButtonDefinitions = [
|
|
5
|
-
[0, GamepadChannel.ButtonSouth],
|
|
6
|
-
[1, GamepadChannel.ButtonEast],
|
|
7
|
-
[2, GamepadChannel.ButtonWest],
|
|
8
|
-
[3, GamepadChannel.ButtonNorth],
|
|
9
|
-
[4, GamepadChannel.LeftShoulder],
|
|
10
|
-
[5, GamepadChannel.RightShoulder],
|
|
11
|
-
[6, GamepadChannel.LeftTrigger],
|
|
12
|
-
[7, GamepadChannel.RightTrigger],
|
|
13
|
-
[8, GamepadChannel.Select],
|
|
14
|
-
[9, GamepadChannel.Start],
|
|
15
|
-
[10, GamepadChannel.LeftStick],
|
|
16
|
-
[11, GamepadChannel.RightStick],
|
|
17
|
-
[12, GamepadChannel.DPadUp],
|
|
18
|
-
[13, GamepadChannel.DPadDown],
|
|
19
|
-
[14, GamepadChannel.DPadLeft],
|
|
20
|
-
[15, GamepadChannel.DPadRight],
|
|
21
|
-
[16, GamepadChannel.Guide],
|
|
22
|
-
[17, GamepadChannel.Share],
|
|
23
|
-
[18, GamepadChannel.Capture],
|
|
24
|
-
[19, GamepadChannel.Touchpad],
|
|
25
|
-
[20, GamepadChannel.Paddle1],
|
|
26
|
-
];
|
|
27
|
-
const genericDualAnalogAxisDefinitions = [
|
|
28
|
-
[0, GamepadChannel.LeftStickLeft, { invert: true }],
|
|
29
|
-
[0, GamepadChannel.LeftStickRight],
|
|
30
|
-
[1, GamepadChannel.LeftStickUp, { invert: true }],
|
|
31
|
-
[1, GamepadChannel.LeftStickDown],
|
|
32
|
-
[2, GamepadChannel.RightStickLeft, { invert: true }],
|
|
33
|
-
[2, GamepadChannel.RightStickRight],
|
|
34
|
-
[3, GamepadChannel.RightStickUp, { invert: true }],
|
|
35
|
-
[3, GamepadChannel.RightStickDown],
|
|
36
|
-
[4, GamepadChannel.AuxiliaryAxis0Negative, { invert: true }],
|
|
37
|
-
[4, GamepadChannel.AuxiliaryAxis0Positive],
|
|
38
|
-
[5, GamepadChannel.AuxiliaryAxis1Negative, { invert: true }],
|
|
39
|
-
[5, GamepadChannel.AuxiliaryAxis1Positive],
|
|
40
|
-
[6, GamepadChannel.AuxiliaryAxis2Negative, { invert: true }],
|
|
41
|
-
[6, GamepadChannel.AuxiliaryAxis2Positive],
|
|
42
|
-
[7, GamepadChannel.AuxiliaryAxis3Negative, { invert: true }],
|
|
43
|
-
[7, GamepadChannel.AuxiliaryAxis3Positive],
|
|
44
|
-
];
|
|
45
5
|
/**
|
|
46
6
|
* Baseline mapping for dual-analog controllers that follow the standard
|
|
47
7
|
* W3C Gamepad API layout (axes 0–3 for both sticks, axes 4–7 auxiliary).
|
|
48
8
|
*
|
|
49
|
-
* Each signed axis is
|
|
50
|
-
*
|
|
51
|
-
*
|
|
9
|
+
* Each signed stick axis is exposed three ways for ergonomic binding:
|
|
10
|
+
* - Two direction-split, non-negative channels (e.g. `LeftStickLeft` /
|
|
11
|
+
* `LeftStickRight`) for "buttons-style" subscriptions.
|
|
12
|
+
* - One signed aggregate channel (e.g. `LeftStickX`) for direct -1..1
|
|
13
|
+
* consumption — useful for movement or aiming.
|
|
14
|
+
*
|
|
52
15
|
* Device-specific subclasses (Xbox, PlayStation, Switch Pro, etc.) inherit
|
|
53
16
|
* this layout and override only {@link GamepadMapping.family}.
|
|
54
17
|
*/
|
|
55
18
|
class GenericDualAnalogGamepadMapping extends GamepadMapping {
|
|
56
19
|
family = GamepadMappingFamily.GenericDualAnalog;
|
|
57
20
|
constructor() {
|
|
58
|
-
super(
|
|
21
|
+
super([
|
|
22
|
+
new GamepadButton(0, GamepadButton.South),
|
|
23
|
+
new GamepadButton(1, GamepadButton.East),
|
|
24
|
+
new GamepadButton(2, GamepadButton.West),
|
|
25
|
+
new GamepadButton(3, GamepadButton.North),
|
|
26
|
+
new GamepadButton(4, GamepadButton.LeftShoulder),
|
|
27
|
+
new GamepadButton(5, GamepadButton.RightShoulder),
|
|
28
|
+
new GamepadButton(6, GamepadButton.LeftTrigger),
|
|
29
|
+
new GamepadButton(7, GamepadButton.RightTrigger),
|
|
30
|
+
new GamepadButton(8, GamepadButton.Select),
|
|
31
|
+
new GamepadButton(9, GamepadButton.Start),
|
|
32
|
+
new GamepadButton(10, GamepadButton.LeftStick),
|
|
33
|
+
new GamepadButton(11, GamepadButton.RightStick),
|
|
34
|
+
new GamepadButton(12, GamepadButton.DPadUp),
|
|
35
|
+
new GamepadButton(13, GamepadButton.DPadDown),
|
|
36
|
+
new GamepadButton(14, GamepadButton.DPadLeft),
|
|
37
|
+
new GamepadButton(15, GamepadButton.DPadRight),
|
|
38
|
+
new GamepadButton(16, GamepadButton.Guide),
|
|
39
|
+
new GamepadButton(17, GamepadButton.Share),
|
|
40
|
+
new GamepadButton(18, GamepadButton.Capture),
|
|
41
|
+
new GamepadButton(19, GamepadButton.Touchpad),
|
|
42
|
+
new GamepadButton(20, GamepadButton.Paddle1),
|
|
43
|
+
], [
|
|
44
|
+
// Direction-split (0..1).
|
|
45
|
+
new GamepadAxis(0, GamepadAxis.LeftStickLeft, { invert: true }),
|
|
46
|
+
new GamepadAxis(0, GamepadAxis.LeftStickRight),
|
|
47
|
+
new GamepadAxis(1, GamepadAxis.LeftStickUp, { invert: true }),
|
|
48
|
+
new GamepadAxis(1, GamepadAxis.LeftStickDown),
|
|
49
|
+
new GamepadAxis(2, GamepadAxis.RightStickLeft, { invert: true }),
|
|
50
|
+
new GamepadAxis(2, GamepadAxis.RightStickRight),
|
|
51
|
+
new GamepadAxis(3, GamepadAxis.RightStickUp, { invert: true }),
|
|
52
|
+
new GamepadAxis(3, GamepadAxis.RightStickDown),
|
|
53
|
+
// Aggregate signed channels (-1..1).
|
|
54
|
+
new GamepadAxis(0, GamepadAxis.LeftStickX, { bipolar: true }),
|
|
55
|
+
new GamepadAxis(1, GamepadAxis.LeftStickY, { bipolar: true }),
|
|
56
|
+
new GamepadAxis(2, GamepadAxis.RightStickX, { bipolar: true }),
|
|
57
|
+
new GamepadAxis(3, GamepadAxis.RightStickY, { bipolar: true }),
|
|
58
|
+
// Auxiliary axes (4 bipolar physical axes split into 8 half-channels).
|
|
59
|
+
new GamepadAxis(4, GamepadAxis.AuxiliaryAxis0Negative, { invert: true }),
|
|
60
|
+
new GamepadAxis(4, GamepadAxis.AuxiliaryAxis0Positive),
|
|
61
|
+
new GamepadAxis(5, GamepadAxis.AuxiliaryAxis1Negative, { invert: true }),
|
|
62
|
+
new GamepadAxis(5, GamepadAxis.AuxiliaryAxis1Positive),
|
|
63
|
+
new GamepadAxis(6, GamepadAxis.AuxiliaryAxis2Negative, { invert: true }),
|
|
64
|
+
new GamepadAxis(6, GamepadAxis.AuxiliaryAxis2Positive),
|
|
65
|
+
new GamepadAxis(7, GamepadAxis.AuxiliaryAxis3Negative, { invert: true }),
|
|
66
|
+
new GamepadAxis(7, GamepadAxis.AuxiliaryAxis3Positive),
|
|
67
|
+
]);
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericDualAnalogGamepadMapping.js","sources":["../../../../src/input/GenericDualAnalogGamepadMapping.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GenericDualAnalogGamepadMapping.js","sources":["../../../../src/input/GenericDualAnalogGamepadMapping.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;AAYG;AACG,MAAO,+BAAgC,SAAQ,cAAc,CAAA;AAC/C,IAAA,MAAM,GAAyB,oBAAoB,CAAC,iBAAiB;AAErF,IAAA,WAAA,GAAA;AACI,QAAA,KAAK,CACD;AACI,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC;AACzC,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC;AACxC,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC;AACxC,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC;AACzC,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC;AAChD,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC;AACjD,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;AAC/C,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC;AAChD,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC;AAC1C,YAAA,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC;AACzC,YAAA,IAAI,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,SAAS,CAAC;AAC9C,YAAA,IAAI,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,UAAU,CAAC;AAC/C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|
|
|
1
|
+
import { Signal } from '@/core/Signal';
|
|
2
|
+
import type { Keyboard } from '@/input/types';
|
|
3
|
+
import type { GamepadButtonChannel } from './GamepadButton';
|
|
4
|
+
import type { GamepadAxisChannel } from './GamepadAxis';
|
|
5
|
+
/** Channel a single {@link InputBinding} can subscribe to. */
|
|
6
|
+
export type InputChannel = GamepadButtonChannel | GamepadAxisChannel | Keyboard;
|
|
7
|
+
/** Construction options shared by every binding factory method. */
|
|
8
|
+
export interface InputBindingOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Tap-window for {@link InputBinding.onTrigger} in milliseconds. The
|
|
11
|
+
* trigger fires when the input is released within this window after
|
|
12
|
+
* activation. Defaults to {@link InputBinding.defaultTriggerThreshold}
|
|
13
|
+
* (300 ms).
|
|
14
|
+
*/
|
|
15
|
+
threshold?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Pin this binding to a specific gamepad slot (0..3). Channel offsets
|
|
18
|
+
* are resolved at construction time. When unset, gamepad channels read
|
|
19
|
+
* from slot 0 (the primary pad).
|
|
20
|
+
*/
|
|
21
|
+
gamepadSlot?: 0 | 1 | 2 | 3;
|
|
22
|
+
}
|
|
23
|
+
interface InternalChannelDetacher {
|
|
24
|
+
detach(binding: InputBinding): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One subscription to one or more input channels. Tracks active state, fires
|
|
28
|
+
* the {@link onStart} / {@link onActive} / {@link onStop} / {@link onTrigger}
|
|
29
|
+
* Signals each frame, and registers itself with whichever owner created it
|
|
30
|
+
* (typically an {@link InputManager}, {@link Gamepad}, or scene-bound
|
|
31
|
+
* proxy).
|
|
32
|
+
*
|
|
33
|
+
* Construct via the owner's `onStart` / `onActive` / `onStop` /
|
|
34
|
+
* `onTrigger` factory methods rather than `new InputBinding(...)` directly.
|
|
35
|
+
*
|
|
36
|
+
* Lifecycle: a binding lives until {@link unbind} is called, the owner
|
|
37
|
+
* disposes it, or — for scene-bound bindings — the scene unloads.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare class InputBinding {
|
|
42
|
+
/**
|
|
43
|
+
* Default tap-window for `onTrigger`. Override per binding via the
|
|
44
|
+
* `threshold` option. Mutating this static affects only newly created
|
|
45
|
+
* bindings.
|
|
46
|
+
*/
|
|
47
|
+
static defaultTriggerThreshold: number;
|
|
48
|
+
readonly channels: ReadonlyArray<number>;
|
|
49
|
+
readonly onStart: Signal<[number]>;
|
|
50
|
+
readonly onActive: Signal<[number]>;
|
|
51
|
+
readonly onStop: Signal<[number]>;
|
|
52
|
+
readonly onTrigger: Signal<[number]>;
|
|
53
|
+
private readonly _triggerTimer;
|
|
54
|
+
private readonly _detacher;
|
|
55
|
+
private _value;
|
|
56
|
+
private _unbound;
|
|
57
|
+
constructor(channels: ReadonlyArray<number>, options?: InputBindingOptions, detacher?: InternalChannelDetacher | null);
|
|
58
|
+
/** Last value sampled this frame. 0 when inactive. */
|
|
59
|
+
get value(): number;
|
|
60
|
+
/** `true` when the last sampled value exceeded the channel's threshold. */
|
|
61
|
+
get active(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Read the latest values from the unified channel buffer and dispatch
|
|
64
|
+
* the appropriate Signals. Called once per frame by the owning manager.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
update(channels: Float32Array): void;
|
|
69
|
+
/**
|
|
70
|
+
* Detach this binding from its owner and release its Signals. Idempotent.
|
|
71
|
+
*/
|
|
72
|
+
unbind(): void;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Signal } from '../core/Signal.js';
|
|
2
|
+
import { Timer } from '../core/Timer.js';
|
|
3
|
+
import { milliseconds } from '../core/utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One subscription to one or more input channels. Tracks active state, fires
|
|
7
|
+
* the {@link onStart} / {@link onActive} / {@link onStop} / {@link onTrigger}
|
|
8
|
+
* Signals each frame, and registers itself with whichever owner created it
|
|
9
|
+
* (typically an {@link InputManager}, {@link Gamepad}, or scene-bound
|
|
10
|
+
* proxy).
|
|
11
|
+
*
|
|
12
|
+
* Construct via the owner's `onStart` / `onActive` / `onStop` /
|
|
13
|
+
* `onTrigger` factory methods rather than `new InputBinding(...)` directly.
|
|
14
|
+
*
|
|
15
|
+
* Lifecycle: a binding lives until {@link unbind} is called, the owner
|
|
16
|
+
* disposes it, or — for scene-bound bindings — the scene unloads.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
class InputBinding {
|
|
21
|
+
/**
|
|
22
|
+
* Default tap-window for `onTrigger`. Override per binding via the
|
|
23
|
+
* `threshold` option. Mutating this static affects only newly created
|
|
24
|
+
* bindings.
|
|
25
|
+
*/
|
|
26
|
+
static defaultTriggerThreshold = 300;
|
|
27
|
+
channels;
|
|
28
|
+
onStart = new Signal();
|
|
29
|
+
onActive = new Signal();
|
|
30
|
+
onStop = new Signal();
|
|
31
|
+
onTrigger = new Signal();
|
|
32
|
+
_triggerTimer;
|
|
33
|
+
_detacher;
|
|
34
|
+
_value = 0;
|
|
35
|
+
_unbound = false;
|
|
36
|
+
constructor(channels, options = {}, detacher = null) {
|
|
37
|
+
this.channels = channels;
|
|
38
|
+
this._triggerTimer = new Timer(milliseconds(options.threshold ?? InputBinding.defaultTriggerThreshold));
|
|
39
|
+
this._detacher = detacher;
|
|
40
|
+
}
|
|
41
|
+
/** Last value sampled this frame. 0 when inactive. */
|
|
42
|
+
get value() {
|
|
43
|
+
return this._value;
|
|
44
|
+
}
|
|
45
|
+
/** `true` when the last sampled value exceeded the channel's threshold. */
|
|
46
|
+
get active() {
|
|
47
|
+
return this._value > 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Read the latest values from the unified channel buffer and dispatch
|
|
51
|
+
* the appropriate Signals. Called once per frame by the owning manager.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
update(channels) {
|
|
56
|
+
if (this._unbound) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let value = 0;
|
|
60
|
+
for (const channel of this.channels) {
|
|
61
|
+
const sample = channels[channel];
|
|
62
|
+
if (Math.abs(sample) > Math.abs(value)) {
|
|
63
|
+
value = sample;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this._value = value;
|
|
67
|
+
if (value !== 0) {
|
|
68
|
+
if (!this._triggerTimer.running) {
|
|
69
|
+
this._triggerTimer.restart();
|
|
70
|
+
this.onStart.dispatch(value);
|
|
71
|
+
}
|
|
72
|
+
this.onActive.dispatch(value);
|
|
73
|
+
}
|
|
74
|
+
else if (this._triggerTimer.running) {
|
|
75
|
+
this.onStop.dispatch(0);
|
|
76
|
+
if (!this._triggerTimer.expired) {
|
|
77
|
+
this.onTrigger.dispatch(0);
|
|
78
|
+
}
|
|
79
|
+
this._triggerTimer.stop();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Detach this binding from its owner and release its Signals. Idempotent.
|
|
84
|
+
*/
|
|
85
|
+
unbind() {
|
|
86
|
+
if (this._unbound) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this._unbound = true;
|
|
90
|
+
this._detacher?.detach(this);
|
|
91
|
+
this._triggerTimer.destroy();
|
|
92
|
+
this.onStart.destroy();
|
|
93
|
+
this.onActive.destroy();
|
|
94
|
+
this.onStop.destroy();
|
|
95
|
+
this.onTrigger.destroy();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { InputBinding };
|
|
100
|
+
//# sourceMappingURL=InputBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputBinding.js","sources":["../../../../src/input/InputBinding.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAgCA;;;;;;;;;;;;;;AAcG;MACU,YAAY,CAAA;AACrB;;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K,KAAK,CAAC,EAAE;AACb,YAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC7B,gBAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC5B,gBAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;YAChC;AAEA,YAAA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjC;AAAO,aAAA,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AACnC,YAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEvB,YAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC7B,gBAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9B;AAEA,YAAA,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;QAC7B;IACJ;AAEA;;AAEG;IACI,MAAM,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf;QACJ;AAEA,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,QAAA,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC;AAC5B,QAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC5B,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;AACtB,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;IAC5B;;;;;"}
|
|
@@ -2,8 +2,23 @@ import { Vector } from '@/math/Vector';
|
|
|
2
2
|
import { Signal } from '@/core/Signal';
|
|
3
3
|
import { Gamepad } from './Gamepad';
|
|
4
4
|
import { Pointer } from './Pointer';
|
|
5
|
+
import { InputBinding } from './InputBinding';
|
|
5
6
|
import type { Application } from '@/core/Application';
|
|
6
|
-
import type {
|
|
7
|
+
import type { GamepadAxis } from './GamepadAxis';
|
|
8
|
+
import type { GamepadButton } from './GamepadButton';
|
|
9
|
+
import type { InputBindingOptions, InputChannel } from './InputBinding';
|
|
10
|
+
/**
|
|
11
|
+
* Strategy used by {@link InputManager} when assigning physical gamepads to
|
|
12
|
+
* slot indices in {@link InputManager.gamepads}.
|
|
13
|
+
*
|
|
14
|
+
* - `'sticky'` (default): each physical pad keeps its slot until a new pad
|
|
15
|
+
* fills an empty slot. A disconnect leaves a gap; reconnect later fills
|
|
16
|
+
* the lowest empty slot. Best for player-stable-binding semantics.
|
|
17
|
+
* - `'compact'`: on disconnect, higher-numbered slots shift down to keep
|
|
18
|
+
* `gamepads[0..N-1]` densely populated. Good for "the first N pads are
|
|
19
|
+
* the N players" workflows.
|
|
20
|
+
*/
|
|
21
|
+
export type GamepadSlotStrategy = 'sticky' | 'compact';
|
|
7
22
|
/**
|
|
8
23
|
* Owns the unified input pipeline for an {@link Application}: keyboard
|
|
9
24
|
* events, pointer (mouse/touch/pen) events with multi-touch slot
|
|
@@ -12,10 +27,11 @@ import type { Input } from './Input';
|
|
|
12
27
|
* rotate / long-press).
|
|
13
28
|
*
|
|
14
29
|
* All raw inputs are written into a shared `Float32Array` channel buffer.
|
|
15
|
-
* Bind {@link
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
30
|
+
* Bind input listeners via the {@link onTrigger} / {@link onActive} /
|
|
31
|
+
* {@link onStart} / {@link onStop} factory methods (or via
|
|
32
|
+
* {@link Gamepad.onTrigger}-style methods on individual pads), or
|
|
33
|
+
* subscribe to the signal-style notifications
|
|
34
|
+
* (`onKeyDown`, `onPointerDown`, `onGamepadConnected`, `onAnyGamepadButtonDown`, …).
|
|
19
35
|
*
|
|
20
36
|
* Driven each frame by {@link Application.update}; constructed
|
|
21
37
|
* automatically — you do not instantiate this class yourself.
|
|
@@ -23,16 +39,17 @@ import type { Input } from './Input';
|
|
|
23
39
|
export declare class InputManager {
|
|
24
40
|
private readonly canvas;
|
|
25
41
|
private readonly channels;
|
|
26
|
-
private readonly inputs;
|
|
27
42
|
private readonly pointers;
|
|
28
|
-
private readonly
|
|
29
|
-
private readonly
|
|
30
|
-
private readonly
|
|
43
|
+
private readonly _gamepads;
|
|
44
|
+
private readonly gamepadsByBrowserIndex;
|
|
45
|
+
private readonly bindings;
|
|
46
|
+
private readonly bindingDetacher;
|
|
31
47
|
private readonly wheelOffset;
|
|
32
48
|
private readonly flags;
|
|
33
49
|
private readonly channelsPressed;
|
|
34
50
|
private readonly channelsReleased;
|
|
35
51
|
private readonly gamepadDefinitions;
|
|
52
|
+
private readonly slotStrategy;
|
|
36
53
|
private readonly pointerSlots;
|
|
37
54
|
private readonly freeSlots;
|
|
38
55
|
private readonly gestureRecognizer;
|
|
@@ -62,9 +79,22 @@ export declare class InputManager {
|
|
|
62
79
|
readonly onMouseWheel: Signal<[Vector]>;
|
|
63
80
|
readonly onKeyDown: Signal<[number]>;
|
|
64
81
|
readonly onKeyUp: Signal<[number]>;
|
|
65
|
-
|
|
66
|
-
readonly
|
|
67
|
-
|
|
82
|
+
/** Fires when a physical pad connects to any slot. */
|
|
83
|
+
readonly onGamepadConnected: Signal<[Gamepad]>;
|
|
84
|
+
/** Fires when a physical pad disconnects from any slot. */
|
|
85
|
+
readonly onGamepadDisconnected: Signal<[Gamepad]>;
|
|
86
|
+
/**
|
|
87
|
+
* Fires when a `'compact'`-strategy disconnect shifts a higher-numbered
|
|
88
|
+
* slot's pad into a lower one. Dispatched once per moved pad with the
|
|
89
|
+
* destination slot and the slot index it came from.
|
|
90
|
+
*/
|
|
91
|
+
readonly onAnyGamepadReassigned: Signal<[Gamepad, fromSlot: 0 | 1 | 2 | 3]>;
|
|
92
|
+
/** Fires whenever any pad reports a button press transition. */
|
|
93
|
+
readonly onAnyGamepadButtonDown: Signal<[Gamepad, GamepadButton, number]>;
|
|
94
|
+
/** Fires whenever any pad reports a button release transition. */
|
|
95
|
+
readonly onAnyGamepadButtonUp: Signal<[Gamepad, GamepadButton, number]>;
|
|
96
|
+
/** Fires whenever any pad reports an axis value change. */
|
|
97
|
+
readonly onAnyGamepadAxisChange: Signal<[Gamepad, GamepadAxis, number]>;
|
|
68
98
|
/** Fires on every two-touch-pointer move where the distance between them changed. `scale` > 1 = spreading, < 1 = pinching. */
|
|
69
99
|
readonly onPinch: Signal<[scale: number, center: Vector]>;
|
|
70
100
|
/** Fires on every two-touch-pointer move where the angle between them changed. `angleDelta` is in radians. */
|
|
@@ -83,30 +113,52 @@ export declare class InputManager {
|
|
|
83
113
|
} | null;
|
|
84
114
|
get pointersInCanvas(): boolean;
|
|
85
115
|
get canvasFocused(): boolean;
|
|
86
|
-
get gamepads(): Array<Gamepad>;
|
|
87
|
-
getGamepad(index: number): Gamepad | null;
|
|
88
116
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
117
|
+
* Always-4 array of {@link Gamepad} slot mailboxes. Each entry exists for
|
|
118
|
+
* the application's full lifetime; check `pad.connected` for hardware
|
|
119
|
+
* presence. Listeners attached to a slot survive disconnect/reconnect.
|
|
92
120
|
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
121
|
+
get gamepads(): readonly [Gamepad, Gamepad, Gamepad, Gamepad];
|
|
122
|
+
/** The slot strategy active for this `InputManager`. */
|
|
123
|
+
get gamepadSlotStrategy(): GamepadSlotStrategy;
|
|
96
124
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* `false` leaves them intact for re-registration.
|
|
125
|
+
* Direct accessor for a single gamepad slot. Equivalent to
|
|
126
|
+
* `app.input.gamepads[slot]` but reads more clearly at call sites.
|
|
100
127
|
*/
|
|
101
|
-
|
|
128
|
+
getGamepad(slot: 0 | 1 | 2 | 3): Gamepad;
|
|
129
|
+
/** Subset of {@link gamepads} containing only currently connected pads, in slot order. */
|
|
130
|
+
get connectedGamepads(): ReadonlyArray<Gamepad>;
|
|
131
|
+
/** Number of slots currently occupied by a physical gamepad. */
|
|
132
|
+
get connectedGamepadCount(): number;
|
|
133
|
+
/** First connected gamepad in slot order, or `null` when no pads are attached. */
|
|
134
|
+
get firstConnectedGamepad(): Gamepad | null;
|
|
135
|
+
/** `true` when at least one slot is occupied by a physical gamepad. */
|
|
136
|
+
get hasGamepad(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Register a callback fired once when any of `channels` becomes active.
|
|
139
|
+
* Manual lifecycle — call `.unbind()` on the returned binding to detach.
|
|
140
|
+
*/
|
|
141
|
+
onStart(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
142
|
+
/** Register a callback fired every frame while any of `channels` is active. */
|
|
143
|
+
onActive(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
144
|
+
/** Register a callback fired once when all of `channels` become inactive. */
|
|
145
|
+
onStop(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
146
|
+
/**
|
|
147
|
+
* Register a callback fired when the input is released within
|
|
148
|
+
* {@link InputBindingOptions.threshold} ms of activation (a "tap").
|
|
149
|
+
*/
|
|
150
|
+
onTrigger(channel: InputChannel | ReadonlyArray<InputChannel>, callback: (value: number) => void, options?: InputBindingOptions): InputBinding;
|
|
102
151
|
/**
|
|
103
152
|
* Per-frame entry point invoked by {@link Application.update}. Polls
|
|
104
153
|
* the gamepad API, drains queued keyboard/pointer/wheel deltas into
|
|
105
154
|
* the channel buffer, fires the corresponding Signals, then evaluates
|
|
106
|
-
* each registered
|
|
155
|
+
* each registered binding.
|
|
107
156
|
*/
|
|
108
157
|
update(): this;
|
|
109
158
|
destroy(): void;
|
|
159
|
+
private createBinding;
|
|
160
|
+
private resolveExternalChannel;
|
|
161
|
+
private wireGamepadEvents;
|
|
110
162
|
private _assignSlot;
|
|
111
163
|
private _releaseSlot;
|
|
112
164
|
private handleKeyDown;
|
|
@@ -121,18 +173,12 @@ export declare class InputManager {
|
|
|
121
173
|
private handleCanvasFocus;
|
|
122
174
|
private handleCanvasBlur;
|
|
123
175
|
private handleWindowBlur;
|
|
124
|
-
/**
|
|
125
|
-
* Force every currently-held keyboard channel back to zero and emit
|
|
126
|
-
* onKeyUp for each. Called on canvas/window blur so keys held when
|
|
127
|
-
* focus leaves don't stay stuck "down" forever — without this, a user
|
|
128
|
-
* who alt-tabs while pressing W would have W register as held until
|
|
129
|
-
* they manually release while focus is back.
|
|
130
|
-
*/
|
|
131
176
|
private releaseAllKeyboardChannels;
|
|
132
177
|
private addEventListeners;
|
|
133
178
|
private removeEventListeners;
|
|
134
179
|
private updateGamepads;
|
|
135
|
-
private
|
|
180
|
+
private assignSlotForNewPad;
|
|
181
|
+
private handleGamepadDisconnect;
|
|
136
182
|
private updateEvents;
|
|
137
183
|
private updatePointerEvents;
|
|
138
184
|
}
|