@codexo/exojs 0.7.12 → 0.8.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.
- package/CHANGELOG.md +737 -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 +32 -10
- 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/particles/ParticleSystem.d.ts +180 -83
- package/dist/esm/particles/ParticleSystem.js +446 -133
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/distributions/BoxArea.d.ts +17 -0
- package/dist/esm/particles/distributions/BoxArea.js +48 -0
- package/dist/esm/particles/distributions/BoxArea.js.map +1 -0
- package/dist/esm/particles/distributions/CircleArea.d.ts +19 -0
- package/dist/esm/particles/distributions/CircleArea.js +33 -0
- package/dist/esm/particles/distributions/CircleArea.js.map +1 -0
- package/dist/esm/particles/distributions/ConeDirection.d.ts +28 -0
- package/dist/esm/particles/distributions/ConeDirection.js +44 -0
- package/dist/esm/particles/distributions/ConeDirection.js.map +1 -0
- package/dist/esm/particles/distributions/Constant.d.ts +17 -0
- package/dist/esm/particles/distributions/Constant.js +35 -0
- package/dist/esm/particles/distributions/Constant.js.map +1 -0
- package/dist/esm/particles/distributions/Curve.d.ts +30 -0
- package/dist/esm/particles/distributions/Curve.js +53 -0
- package/dist/esm/particles/distributions/Curve.js.map +1 -0
- package/dist/esm/particles/distributions/Distribution.d.ts +45 -0
- package/dist/esm/particles/distributions/Gradient.d.ts +40 -0
- package/dist/esm/particles/distributions/Gradient.js +72 -0
- package/dist/esm/particles/distributions/Gradient.js.map +1 -0
- package/dist/esm/particles/distributions/LineSegment.d.ts +15 -0
- package/dist/esm/particles/distributions/LineSegment.js +27 -0
- package/dist/esm/particles/distributions/LineSegment.js.map +1 -0
- package/dist/esm/particles/distributions/Range.d.ts +12 -0
- package/dist/esm/particles/distributions/Range.js +19 -0
- package/dist/esm/particles/distributions/Range.js.map +1 -0
- package/dist/esm/particles/distributions/VectorRange.d.ts +20 -0
- package/dist/esm/particles/distributions/VectorRange.js +31 -0
- package/dist/esm/particles/distributions/VectorRange.js.map +1 -0
- package/dist/esm/particles/distributions/index.d.ts +12 -0
- package/dist/esm/particles/gpu/ParticleGpuState.d.ts +57 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js +508 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js.map +1 -0
- package/dist/esm/particles/index.d.ts +2 -10
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.d.ts +24 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js +60 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ApplyForce.d.ts +20 -0
- package/dist/esm/particles/modules/ApplyForce.js +48 -0
- package/dist/esm/particles/modules/ApplyForce.js.map +1 -0
- package/dist/esm/particles/modules/AttractToPoint.d.ts +27 -0
- package/dist/esm/particles/modules/AttractToPoint.js +73 -0
- package/dist/esm/particles/modules/AttractToPoint.js.map +1 -0
- package/dist/esm/particles/modules/BurstSpawn.d.ts +53 -0
- package/dist/esm/particles/modules/BurstSpawn.js +94 -0
- package/dist/esm/particles/modules/BurstSpawn.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverLifetime.d.ts +22 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js +65 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverSpeed.d.ts +27 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js +86 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js.map +1 -0
- package/dist/esm/particles/modules/DeathModule.d.ts +24 -0
- package/dist/esm/particles/modules/DeathModule.js +25 -0
- package/dist/esm/particles/modules/DeathModule.js.map +1 -0
- package/dist/esm/particles/modules/Drag.d.ts +20 -0
- package/dist/esm/particles/modules/Drag.js +45 -0
- package/dist/esm/particles/modules/Drag.js.map +1 -0
- package/dist/esm/particles/modules/OrbitalForce.d.ts +28 -0
- package/dist/esm/particles/modules/OrbitalForce.js +65 -0
- package/dist/esm/particles/modules/OrbitalForce.js.map +1 -0
- package/dist/esm/particles/modules/RateSpawn.d.ts +41 -0
- package/dist/esm/particles/modules/RateSpawn.js +76 -0
- package/dist/esm/particles/modules/RateSpawn.js.map +1 -0
- package/dist/esm/particles/modules/RepelFromPoint.d.ts +24 -0
- package/dist/esm/particles/modules/RepelFromPoint.js +76 -0
- package/dist/esm/particles/modules/RepelFromPoint.js.map +1 -0
- package/dist/esm/particles/modules/RotateOverLifetime.d.ts +20 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js +43 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.d.ts +26 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js +59 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/SpawnModule.d.ts +30 -0
- package/dist/esm/particles/modules/SpawnModule.js +31 -0
- package/dist/esm/particles/modules/SpawnModule.js.map +1 -0
- package/dist/esm/particles/modules/SpawnOnDeath.d.ts +24 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js +47 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js.map +1 -0
- package/dist/esm/particles/modules/Turbulence.d.ts +30 -0
- package/dist/esm/particles/modules/Turbulence.js +122 -0
- package/dist/esm/particles/modules/Turbulence.js.map +1 -0
- package/dist/esm/particles/modules/UpdateModule.d.ts +95 -0
- package/dist/esm/particles/modules/UpdateModule.js +66 -0
- package/dist/esm/particles/modules/UpdateModule.js.map +1 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.d.ts +30 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js +84 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/WgslContribution.d.ts +81 -0
- package/dist/esm/particles/modules/WgslContribution.js +34 -0
- package/dist/esm/particles/modules/WgslContribution.js.map +1 -0
- package/dist/esm/particles/modules/index.d.ts +22 -0
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +9 -14
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js +90 -61
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/glsl/particle.vert.js +1 -1
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +9 -0
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +107 -23
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.d.ts +52 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.d.ts +29 -0
- package/dist/esm/rendering/webgpu/compute/index.d.ts +3 -0
- 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 +4028 -1518
- 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
- package/dist/esm/particles/Particle.d.ts +0 -77
- package/dist/esm/particles/Particle.js +0 -143
- package/dist/esm/particles/Particle.js.map +0 -1
- package/dist/esm/particles/ParticleProperties.d.ts +0 -29
- package/dist/esm/particles/affectors/ColorAffector.d.ts +0 -30
- package/dist/esm/particles/affectors/ColorAffector.js +0 -55
- package/dist/esm/particles/affectors/ColorAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +0 -24
- package/dist/esm/particles/affectors/ForceAffector.js +0 -39
- package/dist/esm/particles/affectors/ForceAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +0 -19
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/ScaleAffector.js +0 -38
- package/dist/esm/particles/affectors/ScaleAffector.js.map +0 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/TorqueAffector.js +0 -37
- package/dist/esm/particles/affectors/TorqueAffector.js.map +0 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +0 -19
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +0 -62
- package/dist/esm/particles/emitters/ParticleOptions.js +0 -120
- package/dist/esm/particles/emitters/ParticleOptions.js.map +0 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +0 -40
- package/dist/esm/particles/emitters/UniversalEmitter.js +0 -68
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { clamp } from '../math/utils.js';
|
|
2
|
+
import { ChannelOffset } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Single mappable analog axis on a physical gamepad. Holds the raw browser
|
|
6
|
+
* `Gamepad.axes[]` index, the canonical channel the value is written to, and
|
|
7
|
+
* the transform pipeline applied each frame by {@link transformValue}.
|
|
8
|
+
*
|
|
9
|
+
* Direction-split axis channels (e.g. `LeftStickLeft`, `LeftStickRight`)
|
|
10
|
+
* live in the 0..1 range — set `invert: true` on the negative half so it
|
|
11
|
+
* reads positive when pushed in its direction.
|
|
12
|
+
*
|
|
13
|
+
* Aggregate channels (e.g. `LeftStickX`, `LeftStickY`) live in the full
|
|
14
|
+
* -1..1 range — set `bipolar: true` to preserve sign through the pipeline.
|
|
15
|
+
*
|
|
16
|
+
* The static namespace exports (`GamepadAxis.LeftStickLeft`,
|
|
17
|
+
* `.LeftStickX`, ...) carry the canonical channel offsets used to address
|
|
18
|
+
* each axis.
|
|
19
|
+
*/
|
|
20
|
+
class GamepadAxis {
|
|
21
|
+
index;
|
|
22
|
+
channel;
|
|
23
|
+
invert;
|
|
24
|
+
normalize;
|
|
25
|
+
threshold;
|
|
26
|
+
bipolar;
|
|
27
|
+
constructor(index, channel, options = {}) {
|
|
28
|
+
this.index = index;
|
|
29
|
+
this.channel = channel;
|
|
30
|
+
this.invert = options.invert ?? false;
|
|
31
|
+
this.normalize = options.normalize ?? false;
|
|
32
|
+
this.threshold = clamp(options.threshold ?? 0.2, 0, 1);
|
|
33
|
+
this.bipolar = options.bipolar ?? false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Apply the axis transform pipeline to a raw browser axis value
|
|
37
|
+
* (typically `Gamepad.axes[i]`, in -1..1).
|
|
38
|
+
*
|
|
39
|
+
* Pipeline: clamp to [-1, 1] → optional invert → optional normalize to
|
|
40
|
+
* [0, 1] → bipolar passthrough OR deadzone (returns 0 when the absolute
|
|
41
|
+
* value is at or below `threshold`).
|
|
42
|
+
*/
|
|
43
|
+
transformValue(value) {
|
|
44
|
+
let result = clamp(value, -1, 1);
|
|
45
|
+
if (this.invert) {
|
|
46
|
+
result *= -1;
|
|
47
|
+
}
|
|
48
|
+
if (this.normalize) {
|
|
49
|
+
result = (result + 1) / 2;
|
|
50
|
+
}
|
|
51
|
+
if (this.bipolar) {
|
|
52
|
+
return Math.abs(result) > this.threshold ? result : 0;
|
|
53
|
+
}
|
|
54
|
+
return result > this.threshold ? result : 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const axis = (offset) => (ChannelOffset.Gamepads + offset);
|
|
58
|
+
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/naming-convention */
|
|
59
|
+
/**
|
|
60
|
+
* Channel-identifier constants. The axis section starts after the 32-slot
|
|
61
|
+
* button block: 24 named axes (offsets 32..55) plus 8 reserved slots
|
|
62
|
+
* (offsets 56..63).
|
|
63
|
+
*/
|
|
64
|
+
(function (GamepadAxis) {
|
|
65
|
+
// Direction-split (0..1, "buttons-style").
|
|
66
|
+
GamepadAxis.LeftStickLeft = axis(32);
|
|
67
|
+
GamepadAxis.LeftStickRight = axis(33);
|
|
68
|
+
GamepadAxis.LeftStickUp = axis(34);
|
|
69
|
+
GamepadAxis.LeftStickDown = axis(35);
|
|
70
|
+
GamepadAxis.RightStickLeft = axis(36);
|
|
71
|
+
GamepadAxis.RightStickRight = axis(37);
|
|
72
|
+
GamepadAxis.RightStickUp = axis(38);
|
|
73
|
+
GamepadAxis.RightStickDown = axis(39);
|
|
74
|
+
// Aggregate (-1..1, "stick-style").
|
|
75
|
+
/** Signed left-stick X axis (-1..1). Negative = left, positive = right. */
|
|
76
|
+
GamepadAxis.LeftStickX = axis(40);
|
|
77
|
+
/** Signed left-stick Y axis (-1..1). Negative = up (screen-up), positive = down. */
|
|
78
|
+
GamepadAxis.LeftStickY = axis(41);
|
|
79
|
+
/** Signed right-stick X axis (-1..1). */
|
|
80
|
+
GamepadAxis.RightStickX = axis(42);
|
|
81
|
+
/** Signed right-stick Y axis (-1..1). */
|
|
82
|
+
GamepadAxis.RightStickY = axis(43);
|
|
83
|
+
// Touchpad XY (PlayStation 4/5, Steam Deck, dual-touchpad Steam-class hardware).
|
|
84
|
+
/** Primary touchpad X (0..1, left to right). PlayStation, Steam Deck (left pad), Steam Controller. */
|
|
85
|
+
GamepadAxis.TouchpadX = axis(44);
|
|
86
|
+
/** Primary touchpad Y (0..1, top to bottom). */
|
|
87
|
+
GamepadAxis.TouchpadY = axis(45);
|
|
88
|
+
/** Secondary touchpad X (0..1). Steam Deck (right pad), other dual-touchpad hardware. */
|
|
89
|
+
GamepadAxis.Touchpad2X = axis(46);
|
|
90
|
+
/** Secondary touchpad Y (0..1). */
|
|
91
|
+
GamepadAxis.Touchpad2Y = axis(47);
|
|
92
|
+
// Auxiliary axes (4 bipolar axes split into 8 non-negative channels).
|
|
93
|
+
GamepadAxis.AuxiliaryAxis0Negative = axis(48);
|
|
94
|
+
GamepadAxis.AuxiliaryAxis0Positive = axis(49);
|
|
95
|
+
GamepadAxis.AuxiliaryAxis1Negative = axis(50);
|
|
96
|
+
GamepadAxis.AuxiliaryAxis1Positive = axis(51);
|
|
97
|
+
GamepadAxis.AuxiliaryAxis2Negative = axis(52);
|
|
98
|
+
GamepadAxis.AuxiliaryAxis2Positive = axis(53);
|
|
99
|
+
GamepadAxis.AuxiliaryAxis3Negative = axis(54);
|
|
100
|
+
GamepadAxis.AuxiliaryAxis3Positive = axis(55);
|
|
101
|
+
// Offsets 56..63 reserved for future named axes / custom mapping use.
|
|
102
|
+
})(GamepadAxis || (GamepadAxis = {}));
|
|
103
|
+
/* eslint-enable @typescript-eslint/no-namespace, @typescript-eslint/naming-convention */
|
|
104
|
+
|
|
105
|
+
export { GamepadAxis };
|
|
106
|
+
//# sourceMappingURL=GamepadAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GamepadAxis.js","sources":["../../../../src/input/GamepadAxis.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAuDA;;;;;;;;;;;;;;;AAeG;MACU,WAAW,CAAA;AACJ,IAAA,KAAK;AACL,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,SAAS;AACT,IAAA,OAAO;AAEvB,IAAA,WAAA,CAAmB,KAAa,EAAE,OAA2B,EAAE,UAA8B,EAAE,EAAA;AAC3F,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;QACtB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,KAAK;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK;AAC3C,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,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
+
* input channel. Members are absolute offsets into the engine's shared
|
|
5
|
+
* {@link Float32Array} input channel buffer (relative to slot 0): the 32
|
|
6
|
+
* slots reserved for a gamepad slot's button section, computed as
|
|
7
|
+
* `ChannelOffset.Gamepads + 0..31` (512..543 with the default layout —
|
|
8
|
+
* `ChannelSize.Category = 256`, `Gamepads = 2 * Category = 512`).
|
|
9
|
+
*
|
|
10
|
+
* The 24 named buttons (`South`-`Paddle4`) cover offsets 0..23; offsets
|
|
11
|
+
* 24..31 are reserved for forward-compat / custom-mapping use and remain
|
|
12
|
+
* part of this type so custom `GamepadMapping` subclasses can address them
|
|
13
|
+
* without casting.
|
|
14
|
+
*
|
|
15
|
+
* The brand keeps the type system from confusing button channels with
|
|
16
|
+
* {@link GamepadAxisChannel} or raw `number`s during mapping authoring.
|
|
17
|
+
* User code does not construct values of this type directly — read them
|
|
18
|
+
* from the {@link GamepadButton} namespace (`GamepadButton.South`, ...).
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export type GamepadButtonChannel = (512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543) & {
|
|
23
|
+
readonly [gamepadButtonChannelBrand]: void;
|
|
24
|
+
};
|
|
25
|
+
/** Construction options for a {@link GamepadButton}. */
|
|
26
|
+
export interface GamepadButtonOptions {
|
|
27
|
+
/** Negate the raw value before threshold comparison. Default `false`. */
|
|
28
|
+
invert?: boolean;
|
|
29
|
+
/** Activation threshold in 0..1 — values at or below this read as 0 (deadzone). Default 0.2. */
|
|
30
|
+
threshold?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Single mappable button on a physical gamepad. Holds the raw browser
|
|
34
|
+
* `Gamepad.buttons[]` index, the canonical channel the value is written to,
|
|
35
|
+
* and the deadzone/inversion transform applied each frame by
|
|
36
|
+
* {@link transformValue}.
|
|
37
|
+
*
|
|
38
|
+
* Used by concrete {@link GamepadMapping} subclasses to declare a device's
|
|
39
|
+
* button layout. User code typically constructs these via
|
|
40
|
+
* `new GamepadButton(rawIndex, GamepadButton.South)` only when authoring a
|
|
41
|
+
* custom mapping.
|
|
42
|
+
*
|
|
43
|
+
* The static namespace exports (`GamepadButton.South`, `.East`, ...) carry
|
|
44
|
+
* the canonical channel offsets used to address each button.
|
|
45
|
+
*/
|
|
46
|
+
export declare class GamepadButton {
|
|
47
|
+
readonly index: number;
|
|
48
|
+
readonly channel: GamepadButtonChannel;
|
|
49
|
+
readonly invert: boolean;
|
|
50
|
+
readonly threshold: number;
|
|
51
|
+
constructor(index: number, channel: GamepadButtonChannel, options?: GamepadButtonOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Apply the button's transform pipeline to a raw browser button value
|
|
54
|
+
* (typically `Gamepad.buttons[i].value`, in 0..1).
|
|
55
|
+
*
|
|
56
|
+
* Pipeline: clamp to [0, 1] → optional invert → deadzone (returns 0 when
|
|
57
|
+
* the result is at or below `threshold`).
|
|
58
|
+
*/
|
|
59
|
+
transformValue(value: number): number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Channel-identifier constants — same convention as `Pointer.X` /
|
|
63
|
+
* `Keyboard.Space`. The first 32 slots of each gamepad sub-buffer are
|
|
64
|
+
* reserved for buttons (24 named, 8 buffer for future / custom mappings).
|
|
65
|
+
*/
|
|
66
|
+
export declare namespace GamepadButton {
|
|
67
|
+
/** Bottom face button. Xbox=A, PlayStation=✕, Switch (horizontal Joy-Con)=B. Conventional usage: confirm / primary action / jump. */
|
|
68
|
+
const South: GamepadButtonChannel;
|
|
69
|
+
/** Right face button. Xbox=B, PlayStation=○, Switch=A. Conventional usage: cancel / back / secondary. */
|
|
70
|
+
const East: GamepadButtonChannel;
|
|
71
|
+
/** Left face button. Xbox=X, PlayStation=□, Switch=Y. Conventional usage: tertiary action. */
|
|
72
|
+
const West: GamepadButtonChannel;
|
|
73
|
+
/** Top face button. Xbox=Y, PlayStation=△, Switch=X. Conventional usage: quaternary action. */
|
|
74
|
+
const North: GamepadButtonChannel;
|
|
75
|
+
const LeftShoulder: GamepadButtonChannel;
|
|
76
|
+
const RightShoulder: GamepadButtonChannel;
|
|
77
|
+
/** Left trigger as a button (analog 0..1 reported through the same channel). */
|
|
78
|
+
const LeftTrigger: GamepadButtonChannel;
|
|
79
|
+
/** Right trigger as a button. */
|
|
80
|
+
const RightTrigger: GamepadButtonChannel;
|
|
81
|
+
/** Select / Back / Minus button. */
|
|
82
|
+
const Select: GamepadButtonChannel;
|
|
83
|
+
/** Start / Options / Plus button. */
|
|
84
|
+
const Start: GamepadButtonChannel;
|
|
85
|
+
/** Left analog stick click (L3). */
|
|
86
|
+
const LeftStick: GamepadButtonChannel;
|
|
87
|
+
/** Right analog stick click (R3). */
|
|
88
|
+
const RightStick: GamepadButtonChannel;
|
|
89
|
+
const DPadUp: GamepadButtonChannel;
|
|
90
|
+
const DPadDown: GamepadButtonChannel;
|
|
91
|
+
const DPadLeft: GamepadButtonChannel;
|
|
92
|
+
const DPadRight: GamepadButtonChannel;
|
|
93
|
+
/** Home / Guide / PS button. */
|
|
94
|
+
const Guide: GamepadButtonChannel;
|
|
95
|
+
/** Share / Create button (PS4/PS5, Xbox Series). */
|
|
96
|
+
const Share: GamepadButtonChannel;
|
|
97
|
+
/** Capture / Screenshot button (Switch, Xbox Series). */
|
|
98
|
+
const Capture: GamepadButtonChannel;
|
|
99
|
+
/** Touchpad click (PlayStation). */
|
|
100
|
+
const Touchpad: GamepadButtonChannel;
|
|
101
|
+
/** First paddle / extra button (Xbox Elite, Steam Controller, PS5 Edge, Steam Deck L4). */
|
|
102
|
+
const Paddle1: GamepadButtonChannel;
|
|
103
|
+
/** Second paddle / extra button (Xbox Elite, Steam Deck R4, PS5 Edge). */
|
|
104
|
+
const Paddle2: GamepadButtonChannel;
|
|
105
|
+
/** Third paddle / extra button (Xbox Elite, Steam Deck L5). */
|
|
106
|
+
const Paddle3: GamepadButtonChannel;
|
|
107
|
+
/** Fourth paddle / extra button (Xbox Elite, Steam Deck R5). */
|
|
108
|
+
const Paddle4: GamepadButtonChannel;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { clamp } from '../math/utils.js';
|
|
2
|
+
import { ChannelOffset } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Single mappable button on a physical gamepad. Holds the raw browser
|
|
6
|
+
* `Gamepad.buttons[]` index, the canonical channel the value is written to,
|
|
7
|
+
* and the deadzone/inversion transform applied each frame by
|
|
8
|
+
* {@link transformValue}.
|
|
9
|
+
*
|
|
10
|
+
* Used by concrete {@link GamepadMapping} subclasses to declare a device's
|
|
11
|
+
* button layout. User code typically constructs these via
|
|
12
|
+
* `new GamepadButton(rawIndex, GamepadButton.South)` only when authoring a
|
|
13
|
+
* custom mapping.
|
|
14
|
+
*
|
|
15
|
+
* The static namespace exports (`GamepadButton.South`, `.East`, ...) carry
|
|
16
|
+
* the canonical channel offsets used to address each button.
|
|
17
|
+
*/
|
|
18
|
+
class GamepadButton {
|
|
19
|
+
index;
|
|
20
|
+
channel;
|
|
21
|
+
invert;
|
|
22
|
+
threshold;
|
|
23
|
+
constructor(index, channel, options = {}) {
|
|
24
|
+
this.index = index;
|
|
25
|
+
this.channel = channel;
|
|
26
|
+
this.invert = options.invert ?? false;
|
|
27
|
+
this.threshold = clamp(options.threshold ?? 0.2, 0, 1);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Apply the button's transform pipeline to a raw browser button value
|
|
31
|
+
* (typically `Gamepad.buttons[i].value`, in 0..1).
|
|
32
|
+
*
|
|
33
|
+
* Pipeline: clamp to [0, 1] → optional invert → deadzone (returns 0 when
|
|
34
|
+
* the result is at or below `threshold`).
|
|
35
|
+
*/
|
|
36
|
+
transformValue(value) {
|
|
37
|
+
let result = clamp(value, 0, 1);
|
|
38
|
+
if (this.invert) {
|
|
39
|
+
result = 1 - result;
|
|
40
|
+
}
|
|
41
|
+
return result > this.threshold ? result : 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const button = (offset) => (ChannelOffset.Gamepads + offset);
|
|
45
|
+
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/naming-convention */
|
|
46
|
+
/**
|
|
47
|
+
* Channel-identifier constants — same convention as `Pointer.X` /
|
|
48
|
+
* `Keyboard.Space`. The first 32 slots of each gamepad sub-buffer are
|
|
49
|
+
* reserved for buttons (24 named, 8 buffer for future / custom mappings).
|
|
50
|
+
*/
|
|
51
|
+
(function (GamepadButton) {
|
|
52
|
+
/** Bottom face button. Xbox=A, PlayStation=✕, Switch (horizontal Joy-Con)=B. Conventional usage: confirm / primary action / jump. */
|
|
53
|
+
GamepadButton.South = button(0);
|
|
54
|
+
/** Right face button. Xbox=B, PlayStation=○, Switch=A. Conventional usage: cancel / back / secondary. */
|
|
55
|
+
GamepadButton.East = button(1);
|
|
56
|
+
/** Left face button. Xbox=X, PlayStation=□, Switch=Y. Conventional usage: tertiary action. */
|
|
57
|
+
GamepadButton.West = button(2);
|
|
58
|
+
/** Top face button. Xbox=Y, PlayStation=△, Switch=X. Conventional usage: quaternary action. */
|
|
59
|
+
GamepadButton.North = button(3);
|
|
60
|
+
GamepadButton.LeftShoulder = button(4);
|
|
61
|
+
GamepadButton.RightShoulder = button(5);
|
|
62
|
+
/** Left trigger as a button (analog 0..1 reported through the same channel). */
|
|
63
|
+
GamepadButton.LeftTrigger = button(6);
|
|
64
|
+
/** Right trigger as a button. */
|
|
65
|
+
GamepadButton.RightTrigger = button(7);
|
|
66
|
+
/** Select / Back / Minus button. */
|
|
67
|
+
GamepadButton.Select = button(8);
|
|
68
|
+
/** Start / Options / Plus button. */
|
|
69
|
+
GamepadButton.Start = button(9);
|
|
70
|
+
/** Left analog stick click (L3). */
|
|
71
|
+
GamepadButton.LeftStick = button(10);
|
|
72
|
+
/** Right analog stick click (R3). */
|
|
73
|
+
GamepadButton.RightStick = button(11);
|
|
74
|
+
GamepadButton.DPadUp = button(12);
|
|
75
|
+
GamepadButton.DPadDown = button(13);
|
|
76
|
+
GamepadButton.DPadLeft = button(14);
|
|
77
|
+
GamepadButton.DPadRight = button(15);
|
|
78
|
+
/** Home / Guide / PS button. */
|
|
79
|
+
GamepadButton.Guide = button(16);
|
|
80
|
+
/** Share / Create button (PS4/PS5, Xbox Series). */
|
|
81
|
+
GamepadButton.Share = button(17);
|
|
82
|
+
/** Capture / Screenshot button (Switch, Xbox Series). */
|
|
83
|
+
GamepadButton.Capture = button(18);
|
|
84
|
+
/** Touchpad click (PlayStation). */
|
|
85
|
+
GamepadButton.Touchpad = button(19);
|
|
86
|
+
/** First paddle / extra button (Xbox Elite, Steam Controller, PS5 Edge, Steam Deck L4). */
|
|
87
|
+
GamepadButton.Paddle1 = button(20);
|
|
88
|
+
/** Second paddle / extra button (Xbox Elite, Steam Deck R4, PS5 Edge). */
|
|
89
|
+
GamepadButton.Paddle2 = button(21);
|
|
90
|
+
/** Third paddle / extra button (Xbox Elite, Steam Deck L5). */
|
|
91
|
+
GamepadButton.Paddle3 = button(22);
|
|
92
|
+
/** Fourth paddle / extra button (Xbox Elite, Steam Deck R5). */
|
|
93
|
+
GamepadButton.Paddle4 = button(23);
|
|
94
|
+
// Offsets 24..31 reserved for future named buttons / custom mapping use.
|
|
95
|
+
})(GamepadButton || (GamepadButton = {}));
|
|
96
|
+
/* eslint-enable @typescript-eslint/no-namespace, @typescript-eslint/naming-convention */
|
|
97
|
+
|
|
98
|
+
export { GamepadButton };
|
|
99
|
+
//# sourceMappingURL=GamepadButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GamepadButton.js","sources":["../../../../src/input/GamepadButton.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAwCA;;;;;;;;;;;;;AAaG;MACU,aAAa,CAAA;AACN,IAA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ping.js';
|
|
|
5
5
|
import { JoyConRightGamepadMapping } from './JoyConRightGamepadMapping.js';
|
|
6
6
|
import { PlayStationGamepadMapping } from './PlayStationGamepadMapping.js';
|
|
7
7
|
import { SteamControllerGamepadMapping } from './SteamControllerGamepadMapping.js';
|
|
8
|
+
import { SteamDeckGamepadMapping } from './SteamDeckGamepadMapping.js';
|
|
8
9
|
import { SwitchProGamepadMapping } from './SwitchProGamepadMapping.js';
|
|
9
10
|
import { XboxGamepadMapping } from './XboxGamepadMapping.js';
|
|
10
11
|
|
|
@@ -173,6 +174,8 @@ const exactDeviceDefinitions = [
|
|
|
173
174
|
createStaticGamepadDefinition('Switch 2 Pro Controller', () => new SwitchProGamepadMapping(), '057e:2069'),
|
|
174
175
|
createStaticGamepadDefinition('Switch 2 GameCube Controller', () => new GameCubeGamepadMapping(), '057e:2073'),
|
|
175
176
|
createStaticGamepadDefinition('Steam Controller', () => new SteamControllerGamepadMapping(), ['28de:1102', '28de:1142']),
|
|
177
|
+
createStaticGamepadDefinition('Steam Virtual Gamepad', () => new GenericDualAnalogGamepadMapping(), '28de:11ff'),
|
|
178
|
+
createStaticGamepadDefinition('Steam Deck', () => new SteamDeckGamepadMapping(), '28de:1205'),
|
|
176
179
|
createStaticGamepadDefinition('F310 Gamepad', () => new GenericDualAnalogGamepadMapping(), '046d:c216'),
|
|
177
180
|
createStaticGamepadDefinition('F710 Gamepad', () => new GenericDualAnalogGamepadMapping(), ['046d:c219', '046d:c21f']),
|
|
178
181
|
createStaticGamepadDefinition('8BitDo P30 Controller', () => new GenericDualAnalogGamepadMapping(), ['2dc8:5107', '2dc8:5108']),
|
|
@@ -195,6 +198,7 @@ const exactDeviceDefinitions = [
|
|
|
195
198
|
const vendorFallbackDefinitions = [
|
|
196
199
|
createStaticGamepadDefinition('Microsoft Controller', () => new XboxGamepadMapping(), '045e'),
|
|
197
200
|
createStaticGamepadDefinition('Sony Controller', () => new PlayStationGamepadMapping(), '054c'),
|
|
201
|
+
createStaticGamepadDefinition('Valve Controller', () => new SteamDeckGamepadMapping(), '28de'),
|
|
198
202
|
];
|
|
199
203
|
const genericFallbackDefinition = createStaticGamepadDefinition('Generic Gamepad', () => new GenericDualAnalogGamepadMapping());
|
|
200
204
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GamepadDefinitions.js","sources":["../../../../src/input/GamepadDefinitions.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GamepadDefinitions.js","sources":["../../../../src/input/GamepadDefinitions.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AA2EA,MAAM,oBAAoB,GAAG,yDAAyD;AACtF,MAAM,uBAAuB,GAAG,6DAA6D;AAC7F,MAAM,wBAAwB,GAAG,sCAAsC;AACvE,MAAM,aAAa,GAAG,uDAAuD;AAE7E,MAAM,6BAA6B,GAAG,CAClC,IAAY,EACZ,aAAmC,EACnC,GAA4B,MACP;IACrB,GAAG;IACH,IAAI;AACJ,IAAA,OAAO,EAAE,OAAO;QACZ,IAAI;QACJ,OAAO,EAAE,aAAa,EAAE;KAC3B,CAAC;AACL,CAAA,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,EAAU,KAAa,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAEnE,MAAM,eAAe,GAAG,CAAC,EAAU,KAAmB;AAClD,IAAA,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,EAAE;AACtC,WAAA,oBAAoB,CAAC,IAAI,CAAC,EAAE;AAC5B,WAAA,aAAa,CAAC,IAAI,CAAC,EAAE;AACrB,WAAA,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAExC,IAAI,CAAC,KAAK,EAAE;AACR,QAAA,OAAO,IAAI;IACf;AAEA,IAAA,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA,CAAA,EAAI,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EA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|
2
|
+
import type { GamepadAxis } from './GamepadAxis';
|
|
3
|
+
import type { GamepadButtonChannel } from './GamepadButton';
|
|
4
|
+
import type { GamepadAxisChannel } from './GamepadAxis';
|
|
4
5
|
/**
|
|
5
6
|
* Discriminant tag identifying which device family a {@link GamepadMapping} belongs to.
|
|
6
7
|
* Used to select the correct mapping at runtime when a gamepad connects.
|
|
@@ -14,40 +15,43 @@ export declare enum GamepadMappingFamily {
|
|
|
14
15
|
JoyConRight = "joyConRight",
|
|
15
16
|
GameCube = "gameCube",
|
|
16
17
|
SteamController = "steamController",
|
|
18
|
+
SteamDeck = "steamDeck",
|
|
17
19
|
ArcadeStick = "arcadeStick"
|
|
18
20
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Compact descriptor for a single gamepad control.
|
|
21
|
-
* Tuple of `[rawIndex, channel, options?]` where `rawIndex` is the
|
|
22
|
-
* Gamepad API button or axis index reported by the browser.
|
|
23
|
-
*/
|
|
24
|
-
export type GamepadControlDefinition = readonly [number, GamepadChannel, GamepadControlOptions?];
|
|
25
21
|
/**
|
|
26
22
|
* Abstract translation layer between the browser's raw {@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad Gamepad API}
|
|
27
|
-
* indices and ExoJS-canonical
|
|
23
|
+
* indices and ExoJS-canonical channel buffers.
|
|
28
24
|
*
|
|
29
25
|
* Each concrete subclass encodes one device family's button/axis layout as
|
|
30
|
-
* ordered arrays of {@link
|
|
31
|
-
* appropriate mapping when a gamepad connects and
|
|
32
|
-
* values to the correct input channels every frame.
|
|
26
|
+
* ordered arrays of {@link GamepadButton} / {@link GamepadAxis} instances.
|
|
27
|
+
* The engine selects the appropriate mapping when a gamepad connects and
|
|
28
|
+
* uses it to route raw values to the correct input channels every frame.
|
|
33
29
|
*/
|
|
34
30
|
export declare abstract class GamepadMapping {
|
|
35
31
|
/** Identifies the device family this mapping targets. */
|
|
36
32
|
abstract readonly family: GamepadMappingFamily;
|
|
37
|
-
/** Ordered list of
|
|
38
|
-
readonly buttons: ReadonlyArray<
|
|
39
|
-
/** Ordered list of
|
|
40
|
-
readonly axes: ReadonlyArray<
|
|
41
|
-
protected constructor(buttons:
|
|
33
|
+
/** Ordered list of buttons, indexed by the Gamepad API button index. */
|
|
34
|
+
readonly buttons: ReadonlyArray<GamepadButton>;
|
|
35
|
+
/** Ordered list of axes, indexed by the Gamepad API axis index. */
|
|
36
|
+
readonly axes: ReadonlyArray<GamepadAxis>;
|
|
37
|
+
protected constructor(buttons: ReadonlyArray<GamepadButton>, axes: ReadonlyArray<GamepadAxis>);
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` when this mapping declares at least one button or axis
|
|
40
|
+
* control that writes to `channel`. Use to detect device-specific
|
|
41
|
+
* capabilities at runtime — e.g. before binding an input to a
|
|
42
|
+
* right-stick channel that may not exist on a single Joy-Con.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* if (gamepad.mapping?.hasChannel(GamepadAxis.RightStickX)) {
|
|
47
|
+
* pad.onActive(GamepadAxis.RightStickX, (v) => crosshair.x += v * 8);
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
hasChannel(channel: GamepadButtonChannel | GamepadAxisChannel): boolean;
|
|
42
52
|
/**
|
|
43
53
|
* Releases all button and axis control references held by this mapping.
|
|
44
54
|
* Call when the associated gamepad disconnects to allow garbage collection.
|
|
45
55
|
*/
|
|
46
56
|
destroy(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Converts an array of {@link GamepadControlDefinition} tuples into fully
|
|
49
|
-
* constructed {@link GamepadControl} instances.
|
|
50
|
-
* Shared factory used by all concrete mapping constructors.
|
|
51
|
-
*/
|
|
52
|
-
static createControls(definitions: ReadonlyArray<GamepadControlDefinition>): Array<GamepadControl>;
|
|
53
57
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { GamepadControl } from './GamepadControl.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Discriminant tag identifying which device family a {@link GamepadMapping} belongs to.
|
|
5
3
|
* Used to select the correct mapping at runtime when a gamepad connects.
|
|
@@ -14,26 +12,53 @@ var GamepadMappingFamily;
|
|
|
14
12
|
GamepadMappingFamily["JoyConRight"] = "joyConRight";
|
|
15
13
|
GamepadMappingFamily["GameCube"] = "gameCube";
|
|
16
14
|
GamepadMappingFamily["SteamController"] = "steamController";
|
|
15
|
+
GamepadMappingFamily["SteamDeck"] = "steamDeck";
|
|
17
16
|
GamepadMappingFamily["ArcadeStick"] = "arcadeStick";
|
|
18
17
|
})(GamepadMappingFamily || (GamepadMappingFamily = {}));
|
|
19
18
|
/**
|
|
20
19
|
* Abstract translation layer between the browser's raw {@link https://developer.mozilla.org/en-US/docs/Web/API/Gamepad Gamepad API}
|
|
21
|
-
* indices and ExoJS-canonical
|
|
20
|
+
* indices and ExoJS-canonical channel buffers.
|
|
22
21
|
*
|
|
23
22
|
* Each concrete subclass encodes one device family's button/axis layout as
|
|
24
|
-
* ordered arrays of {@link
|
|
25
|
-
* appropriate mapping when a gamepad connects and
|
|
26
|
-
* values to the correct input channels every frame.
|
|
23
|
+
* ordered arrays of {@link GamepadButton} / {@link GamepadAxis} instances.
|
|
24
|
+
* The engine selects the appropriate mapping when a gamepad connects and
|
|
25
|
+
* uses it to route raw values to the correct input channels every frame.
|
|
27
26
|
*/
|
|
28
27
|
class GamepadMapping {
|
|
29
|
-
/** Ordered list of
|
|
28
|
+
/** Ordered list of buttons, indexed by the Gamepad API button index. */
|
|
30
29
|
buttons;
|
|
31
|
-
/** Ordered list of
|
|
30
|
+
/** Ordered list of axes, indexed by the Gamepad API axis index. */
|
|
32
31
|
axes;
|
|
33
32
|
constructor(buttons, axes) {
|
|
34
33
|
this.buttons = buttons;
|
|
35
34
|
this.axes = axes;
|
|
36
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns `true` when this mapping declares at least one button or axis
|
|
38
|
+
* control that writes to `channel`. Use to detect device-specific
|
|
39
|
+
* capabilities at runtime — e.g. before binding an input to a
|
|
40
|
+
* right-stick channel that may not exist on a single Joy-Con.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* if (gamepad.mapping?.hasChannel(GamepadAxis.RightStickX)) {
|
|
45
|
+
* pad.onActive(GamepadAxis.RightStickX, (v) => crosshair.x += v * 8);
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
hasChannel(channel) {
|
|
50
|
+
for (const button of this.buttons) {
|
|
51
|
+
if (button.channel === channel) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const axis of this.axes) {
|
|
56
|
+
if (axis.channel === channel) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
37
62
|
/**
|
|
38
63
|
* Releases all button and axis control references held by this mapping.
|
|
39
64
|
* Call when the associated gamepad disconnects to allow garbage collection.
|
|
@@ -42,14 +67,6 @@ class GamepadMapping {
|
|
|
42
67
|
this.buttons.length = 0;
|
|
43
68
|
this.axes.length = 0;
|
|
44
69
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Converts an array of {@link GamepadControlDefinition} tuples into fully
|
|
47
|
-
* constructed {@link GamepadControl} instances.
|
|
48
|
-
* Shared factory used by all concrete mapping constructors.
|
|
49
|
-
*/
|
|
50
|
-
static createControls(definitions) {
|
|
51
|
-
return definitions.map(([index, channel, options]) => new GamepadControl(index, channel, options));
|
|
52
|
-
}
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
export { GamepadMapping, GamepadMappingFamily };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GamepadMapping.js","sources":["../../../../src/input/GamepadMapping.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GamepadMapping.js","sources":["../../../../src/input/GamepadMapping.ts"],"sources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;AAEA,QAAA,OAAO,KAAK;IAChB;AAEA;;;AAGG;IACI,OAAO,GAAA;AACT,QAAA,IAAI,CAAC,OAAgC,CAAC,MAAM,GAAG,CAAC;AAChD,QAAA,IAAI,CAAC,IAA2B,CAAC,MAAM,GAAG,CAAC;IAChD;AACH;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { GamepadChannel } from './GamepadChannels';
|
|
2
1
|
import { GamepadMappingFamily } from './GamepadMapping';
|
|
2
|
+
import type { GamepadButtonChannel } from './GamepadButton';
|
|
3
3
|
/**
|
|
4
4
|
* Named controls that can appear in an in-game prompt or button-hint UI.
|
|
5
5
|
*
|
|
6
|
-
* Intentionally a subset of {@link
|
|
7
|
-
* typical prompt overlay needs to label, including the composite
|
|
8
|
-
* which has no single channel equivalent.
|
|
6
|
+
* Intentionally a subset of {@link GamepadButton} channels — covers the
|
|
7
|
+
* controls a typical prompt overlay needs to label, including the composite
|
|
8
|
+
* `'DPad'` token which has no single channel equivalent. The names retain
|
|
9
|
+
* a `'Button'` prefix on the face cluster for compatibility with prompt
|
|
10
|
+
* artwork file names.
|
|
9
11
|
*/
|
|
10
12
|
export type GamepadPromptControl = 'DPad' | 'DPadUp' | 'DPadDown' | 'DPadLeft' | 'DPadRight' | 'ButtonNorth' | 'ButtonWest' | 'ButtonEast' | 'ButtonSouth' | 'LeftShoulder' | 'RightShoulder' | 'LeftTrigger' | 'RightTrigger' | 'Select' | 'Start' | 'LeftStick' | 'RightStick';
|
|
11
13
|
/**
|
|
@@ -14,7 +16,7 @@ export type GamepadPromptControl = 'DPad' | 'DPadUp' | 'DPadDown' | 'DPadLeft' |
|
|
|
14
16
|
* Provides the canonical set of prompt controls, their normalised [x, y] positions
|
|
15
17
|
* on a generic controller silhouette, device-family label strings (e.g. "A" for
|
|
16
18
|
* Xbox, "Cross" for PlayStation, "B" for Switch), and the mapping from prompt
|
|
17
|
-
* control names to {@link
|
|
19
|
+
* control names to {@link GamepadButton} channel values.
|
|
18
20
|
*/
|
|
19
21
|
export declare class GamepadPromptLayouts {
|
|
20
22
|
/** Complete ordered list of every {@link GamepadPromptControl} token. */
|
|
@@ -33,8 +35,8 @@ export declare class GamepadPromptLayouts {
|
|
|
33
35
|
static getControlLabels(family: GamepadMappingFamily): ReadonlyMap<GamepadPromptControl, string>;
|
|
34
36
|
/**
|
|
35
37
|
* Returns the static mapping from each {@link GamepadPromptControl} to its
|
|
36
|
-
* corresponding {@link
|
|
37
|
-
* channel entry and is absent from the returned map.
|
|
38
|
+
* corresponding {@link GamepadButton} channel. The composite `'DPad'`
|
|
39
|
+
* control has no channel entry and is absent from the returned map.
|
|
38
40
|
*/
|
|
39
|
-
static getControlChannelMap(): ReadonlyMap<GamepadPromptControl,
|
|
41
|
+
static getControlChannelMap(): ReadonlyMap<GamepadPromptControl, GamepadButtonChannel>;
|
|
40
42
|
}
|