@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.
Files changed (219) hide show
  1. package/CHANGELOG.md +737 -0
  2. package/dist/esm/core/Application.d.ts +3 -1
  3. package/dist/esm/core/Application.js +7 -6
  4. package/dist/esm/core/Application.js.map +1 -1
  5. package/dist/esm/core/Scene.d.ts +30 -0
  6. package/dist/esm/core/Scene.js +56 -0
  7. package/dist/esm/core/Scene.js.map +1 -1
  8. package/dist/esm/core/SceneManager.js +2 -2
  9. package/dist/esm/core/SceneManager.js.map +1 -1
  10. package/dist/esm/debug/DebugOverlay.js +2 -2
  11. package/dist/esm/debug/DebugOverlay.js.map +1 -1
  12. package/dist/esm/debug/PointerStackLayer.js +1 -1
  13. package/dist/esm/debug/PointerStackLayer.js.map +1 -1
  14. package/dist/esm/index.js +32 -10
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/input/ArcadeStickGamepadMapping.js +18 -19
  17. package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
  18. package/dist/esm/input/Gamepad.d.ts +164 -62
  19. package/dist/esm/input/Gamepad.js +290 -134
  20. package/dist/esm/input/Gamepad.js.map +1 -1
  21. package/dist/esm/input/GamepadAxis.d.ts +120 -0
  22. package/dist/esm/input/GamepadAxis.js +106 -0
  23. package/dist/esm/input/GamepadAxis.js.map +1 -0
  24. package/dist/esm/input/GamepadButton.d.ts +110 -0
  25. package/dist/esm/input/GamepadButton.js +99 -0
  26. package/dist/esm/input/GamepadButton.js.map +1 -0
  27. package/dist/esm/input/GamepadDefinitions.js +4 -0
  28. package/dist/esm/input/GamepadDefinitions.js.map +1 -1
  29. package/dist/esm/input/GamepadMapping.d.ts +28 -24
  30. package/dist/esm/input/GamepadMapping.js +33 -16
  31. package/dist/esm/input/GamepadMapping.js.map +1 -1
  32. package/dist/esm/input/GamepadPromptLayouts.d.ts +10 -8
  33. package/dist/esm/input/GamepadPromptLayouts.js +21 -20
  34. package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
  35. package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +6 -3
  36. package/dist/esm/input/GenericDualAnalogGamepadMapping.js +55 -46
  37. package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
  38. package/dist/esm/input/InputBinding.d.ts +74 -0
  39. package/dist/esm/input/InputBinding.js +100 -0
  40. package/dist/esm/input/InputBinding.js.map +1 -0
  41. package/dist/esm/input/InputManager.d.ts +79 -33
  42. package/dist/esm/input/InputManager.js +229 -104
  43. package/dist/esm/input/InputManager.js.map +1 -1
  44. package/dist/esm/input/InteractionManager.d.ts +1 -1
  45. package/dist/esm/input/InteractionManager.js +13 -13
  46. package/dist/esm/input/InteractionManager.js.map +1 -1
  47. package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +14 -9
  48. package/dist/esm/input/JoyConLeftGamepadMapping.js +39 -9
  49. package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
  50. package/dist/esm/input/JoyConRightGamepadMapping.d.ts +14 -9
  51. package/dist/esm/input/JoyConRightGamepadMapping.js +35 -9
  52. package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
  53. package/dist/esm/input/Pointer.d.ts +84 -71
  54. package/dist/esm/input/Pointer.js +71 -71
  55. package/dist/esm/input/Pointer.js.map +1 -1
  56. package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
  57. package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
  58. package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
  59. package/dist/esm/input/index.d.ts +7 -4
  60. package/dist/esm/input/types.d.ts +0 -76
  61. package/dist/esm/input/types.js +1 -80
  62. package/dist/esm/input/types.js.map +1 -1
  63. package/dist/esm/particles/ParticleSystem.d.ts +180 -83
  64. package/dist/esm/particles/ParticleSystem.js +446 -133
  65. package/dist/esm/particles/ParticleSystem.js.map +1 -1
  66. package/dist/esm/particles/distributions/BoxArea.d.ts +17 -0
  67. package/dist/esm/particles/distributions/BoxArea.js +48 -0
  68. package/dist/esm/particles/distributions/BoxArea.js.map +1 -0
  69. package/dist/esm/particles/distributions/CircleArea.d.ts +19 -0
  70. package/dist/esm/particles/distributions/CircleArea.js +33 -0
  71. package/dist/esm/particles/distributions/CircleArea.js.map +1 -0
  72. package/dist/esm/particles/distributions/ConeDirection.d.ts +28 -0
  73. package/dist/esm/particles/distributions/ConeDirection.js +44 -0
  74. package/dist/esm/particles/distributions/ConeDirection.js.map +1 -0
  75. package/dist/esm/particles/distributions/Constant.d.ts +17 -0
  76. package/dist/esm/particles/distributions/Constant.js +35 -0
  77. package/dist/esm/particles/distributions/Constant.js.map +1 -0
  78. package/dist/esm/particles/distributions/Curve.d.ts +30 -0
  79. package/dist/esm/particles/distributions/Curve.js +53 -0
  80. package/dist/esm/particles/distributions/Curve.js.map +1 -0
  81. package/dist/esm/particles/distributions/Distribution.d.ts +45 -0
  82. package/dist/esm/particles/distributions/Gradient.d.ts +40 -0
  83. package/dist/esm/particles/distributions/Gradient.js +72 -0
  84. package/dist/esm/particles/distributions/Gradient.js.map +1 -0
  85. package/dist/esm/particles/distributions/LineSegment.d.ts +15 -0
  86. package/dist/esm/particles/distributions/LineSegment.js +27 -0
  87. package/dist/esm/particles/distributions/LineSegment.js.map +1 -0
  88. package/dist/esm/particles/distributions/Range.d.ts +12 -0
  89. package/dist/esm/particles/distributions/Range.js +19 -0
  90. package/dist/esm/particles/distributions/Range.js.map +1 -0
  91. package/dist/esm/particles/distributions/VectorRange.d.ts +20 -0
  92. package/dist/esm/particles/distributions/VectorRange.js +31 -0
  93. package/dist/esm/particles/distributions/VectorRange.js.map +1 -0
  94. package/dist/esm/particles/distributions/index.d.ts +12 -0
  95. package/dist/esm/particles/gpu/ParticleGpuState.d.ts +57 -0
  96. package/dist/esm/particles/gpu/ParticleGpuState.js +508 -0
  97. package/dist/esm/particles/gpu/ParticleGpuState.js.map +1 -0
  98. package/dist/esm/particles/index.d.ts +2 -10
  99. package/dist/esm/particles/modules/AlphaFadeOverLifetime.d.ts +24 -0
  100. package/dist/esm/particles/modules/AlphaFadeOverLifetime.js +60 -0
  101. package/dist/esm/particles/modules/AlphaFadeOverLifetime.js.map +1 -0
  102. package/dist/esm/particles/modules/ApplyForce.d.ts +20 -0
  103. package/dist/esm/particles/modules/ApplyForce.js +48 -0
  104. package/dist/esm/particles/modules/ApplyForce.js.map +1 -0
  105. package/dist/esm/particles/modules/AttractToPoint.d.ts +27 -0
  106. package/dist/esm/particles/modules/AttractToPoint.js +73 -0
  107. package/dist/esm/particles/modules/AttractToPoint.js.map +1 -0
  108. package/dist/esm/particles/modules/BurstSpawn.d.ts +53 -0
  109. package/dist/esm/particles/modules/BurstSpawn.js +94 -0
  110. package/dist/esm/particles/modules/BurstSpawn.js.map +1 -0
  111. package/dist/esm/particles/modules/ColorOverLifetime.d.ts +22 -0
  112. package/dist/esm/particles/modules/ColorOverLifetime.js +65 -0
  113. package/dist/esm/particles/modules/ColorOverLifetime.js.map +1 -0
  114. package/dist/esm/particles/modules/ColorOverSpeed.d.ts +27 -0
  115. package/dist/esm/particles/modules/ColorOverSpeed.js +86 -0
  116. package/dist/esm/particles/modules/ColorOverSpeed.js.map +1 -0
  117. package/dist/esm/particles/modules/DeathModule.d.ts +24 -0
  118. package/dist/esm/particles/modules/DeathModule.js +25 -0
  119. package/dist/esm/particles/modules/DeathModule.js.map +1 -0
  120. package/dist/esm/particles/modules/Drag.d.ts +20 -0
  121. package/dist/esm/particles/modules/Drag.js +45 -0
  122. package/dist/esm/particles/modules/Drag.js.map +1 -0
  123. package/dist/esm/particles/modules/OrbitalForce.d.ts +28 -0
  124. package/dist/esm/particles/modules/OrbitalForce.js +65 -0
  125. package/dist/esm/particles/modules/OrbitalForce.js.map +1 -0
  126. package/dist/esm/particles/modules/RateSpawn.d.ts +41 -0
  127. package/dist/esm/particles/modules/RateSpawn.js +76 -0
  128. package/dist/esm/particles/modules/RateSpawn.js.map +1 -0
  129. package/dist/esm/particles/modules/RepelFromPoint.d.ts +24 -0
  130. package/dist/esm/particles/modules/RepelFromPoint.js +76 -0
  131. package/dist/esm/particles/modules/RepelFromPoint.js.map +1 -0
  132. package/dist/esm/particles/modules/RotateOverLifetime.d.ts +20 -0
  133. package/dist/esm/particles/modules/RotateOverLifetime.js +43 -0
  134. package/dist/esm/particles/modules/RotateOverLifetime.js.map +1 -0
  135. package/dist/esm/particles/modules/ScaleOverLifetime.d.ts +26 -0
  136. package/dist/esm/particles/modules/ScaleOverLifetime.js +59 -0
  137. package/dist/esm/particles/modules/ScaleOverLifetime.js.map +1 -0
  138. package/dist/esm/particles/modules/SpawnModule.d.ts +30 -0
  139. package/dist/esm/particles/modules/SpawnModule.js +31 -0
  140. package/dist/esm/particles/modules/SpawnModule.js.map +1 -0
  141. package/dist/esm/particles/modules/SpawnOnDeath.d.ts +24 -0
  142. package/dist/esm/particles/modules/SpawnOnDeath.js +47 -0
  143. package/dist/esm/particles/modules/SpawnOnDeath.js.map +1 -0
  144. package/dist/esm/particles/modules/Turbulence.d.ts +30 -0
  145. package/dist/esm/particles/modules/Turbulence.js +122 -0
  146. package/dist/esm/particles/modules/Turbulence.js.map +1 -0
  147. package/dist/esm/particles/modules/UpdateModule.d.ts +95 -0
  148. package/dist/esm/particles/modules/UpdateModule.js +66 -0
  149. package/dist/esm/particles/modules/UpdateModule.js.map +1 -0
  150. package/dist/esm/particles/modules/VelocityOverLifetime.d.ts +30 -0
  151. package/dist/esm/particles/modules/VelocityOverLifetime.js +84 -0
  152. package/dist/esm/particles/modules/VelocityOverLifetime.js.map +1 -0
  153. package/dist/esm/particles/modules/WgslContribution.d.ts +81 -0
  154. package/dist/esm/particles/modules/WgslContribution.js +34 -0
  155. package/dist/esm/particles/modules/WgslContribution.js.map +1 -0
  156. package/dist/esm/particles/modules/index.d.ts +22 -0
  157. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +9 -14
  158. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js +90 -61
  159. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js.map +1 -1
  160. package/dist/esm/rendering/webgl2/glsl/particle.vert.js +1 -1
  161. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +9 -0
  162. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +107 -23
  163. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
  164. package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.d.ts +52 -0
  165. package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.d.ts +29 -0
  166. package/dist/esm/rendering/webgpu/compute/index.d.ts +3 -0
  167. package/dist/esm/resources/CacheFirstStrategy.d.ts +7 -4
  168. package/dist/esm/resources/CacheFirstStrategy.js +11 -8
  169. package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
  170. package/dist/esm/resources/CacheStrategy.d.ts +14 -6
  171. package/dist/esm/resources/Loader.d.ts +8 -3
  172. package/dist/esm/resources/Loader.js +19 -37
  173. package/dist/esm/resources/Loader.js.map +1 -1
  174. package/dist/esm/resources/NetworkOnlyStrategy.d.ts +3 -0
  175. package/dist/esm/resources/NetworkOnlyStrategy.js +8 -3
  176. package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
  177. package/dist/esm/resources/factories/ImageFactory.d.ts +2 -2
  178. package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
  179. package/dist/esm/resources/factories/TextureFactory.d.ts +2 -2
  180. package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
  181. package/dist/esm/resources/factories/VttFactory.d.ts +3 -3
  182. package/dist/esm/resources/factories/VttFactory.js +83 -6
  183. package/dist/esm/resources/factories/VttFactory.js.map +1 -1
  184. package/dist/exo.esm.js +4028 -1518
  185. package/dist/exo.esm.js.map +1 -1
  186. package/package.json +2 -1
  187. package/dist/esm/input/GamepadChannels.d.ts +0 -47
  188. package/dist/esm/input/GamepadChannels.js +0 -53
  189. package/dist/esm/input/GamepadChannels.js.map +0 -1
  190. package/dist/esm/input/GamepadControl.d.ts +0 -33
  191. package/dist/esm/input/GamepadControl.js +0 -42
  192. package/dist/esm/input/GamepadControl.js.map +0 -1
  193. package/dist/esm/input/Input.d.ts +0 -52
  194. package/dist/esm/input/Input.js +0 -90
  195. package/dist/esm/input/Input.js.map +0 -1
  196. package/dist/esm/particles/Particle.d.ts +0 -77
  197. package/dist/esm/particles/Particle.js +0 -143
  198. package/dist/esm/particles/Particle.js.map +0 -1
  199. package/dist/esm/particles/ParticleProperties.d.ts +0 -29
  200. package/dist/esm/particles/affectors/ColorAffector.d.ts +0 -30
  201. package/dist/esm/particles/affectors/ColorAffector.js +0 -55
  202. package/dist/esm/particles/affectors/ColorAffector.js.map +0 -1
  203. package/dist/esm/particles/affectors/ForceAffector.d.ts +0 -24
  204. package/dist/esm/particles/affectors/ForceAffector.js +0 -39
  205. package/dist/esm/particles/affectors/ForceAffector.js.map +0 -1
  206. package/dist/esm/particles/affectors/ParticleAffector.d.ts +0 -19
  207. package/dist/esm/particles/affectors/ScaleAffector.d.ts +0 -23
  208. package/dist/esm/particles/affectors/ScaleAffector.js +0 -38
  209. package/dist/esm/particles/affectors/ScaleAffector.js.map +0 -1
  210. package/dist/esm/particles/affectors/TorqueAffector.d.ts +0 -23
  211. package/dist/esm/particles/affectors/TorqueAffector.js +0 -37
  212. package/dist/esm/particles/affectors/TorqueAffector.js.map +0 -1
  213. package/dist/esm/particles/emitters/ParticleEmitter.d.ts +0 -19
  214. package/dist/esm/particles/emitters/ParticleOptions.d.ts +0 -62
  215. package/dist/esm/particles/emitters/ParticleOptions.js +0 -120
  216. package/dist/esm/particles/emitters/ParticleOptions.js.map +0 -1
  217. package/dist/esm/particles/emitters/UniversalEmitter.d.ts +0 -40
  218. package/dist/esm/particles/emitters/UniversalEmitter.js +0 -68
  219. package/dist/esm/particles/emitters/UniversalEmitter.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { GamepadChannel } from './GamepadChannels.js';
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', GamepadChannel.ButtonNorth],
25
- ['ButtonWest', GamepadChannel.ButtonWest],
26
- ['ButtonEast', GamepadChannel.ButtonEast],
27
- ['ButtonSouth', GamepadChannel.ButtonSouth],
28
- ['LeftShoulder', GamepadChannel.LeftShoulder],
29
- ['RightShoulder', GamepadChannel.RightShoulder],
30
- ['LeftTrigger', GamepadChannel.LeftTrigger],
31
- ['RightTrigger', GamepadChannel.RightTrigger],
32
- ['Select', GamepadChannel.Select],
33
- ['Start', GamepadChannel.Start],
34
- ['LeftStick', GamepadChannel.LeftStick],
35
- ['RightStick', GamepadChannel.RightStick],
36
- ['DPadUp', GamepadChannel.DPadUp],
37
- ['DPadDown', GamepadChannel.DPadDown],
38
- ['DPadLeft', GamepadChannel.DPadLeft],
39
- ['DPadRight', GamepadChannel.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 GamepadChannel} values.
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 GamepadChannel}. The composite `'DPad'` control has no
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":";;;AA6BA,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,EA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;AAC/C,IAAA,CAAC,oBAAoB,CAAC,WAAW,EAAE,aAAa,CAAC;AACpD,CAAA,CAAC;AAEF;;;;;;;AAOG;MACU,oBAAoB,CAAA;;IAEtB,OAAgB,QAAQ,GAAgC;QAC3D,MAAM;QACN,QAAQ;QACR,UAAU;QACV,UAAU;QACV,WAAW;QACX,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,cAAc;QACd,eAAe;QACf,aAAa;QACb,cAAc;QACd,QAAQ;QACR,OAAO;QACP,WAAW;QACX,YAAY;KACf;AAED;;;;AAIG;IACI,OAAO,kBAAkB,CAAC,OAA6B,EAAA;AAC1D,QAAA,OAAO,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACnD;AAEA;;;;AAIG;IACI,OAAO,gBAAgB,CAAC,MAA4B,EAAA;QACvD,OAAO,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,aAAa;IAC5D;AAEA;;;;AAIG;AACI,IAAA,OAAO,oBAAoB,GAAA;AAC9B,QAAA,OAAO,UAAU;IACrB;;;;;"}
@@ -3,9 +3,12 @@ import { GamepadMapping, GamepadMappingFamily } from './GamepadMapping';
3
3
  * Baseline mapping for dual-analog 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 split into two directional channels — one for the
7
- * negative half and one for the positive half — with the negative channel
8
- * inverted so all channel values are non-negative during normal use.
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 { GamepadChannel } from './GamepadChannels.js';
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 split into two directional channels — one for the
50
- * negative half and one for the positive half — with the negative channel
51
- * inverted so all channel values are non-negative during normal use.
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(GamepadMapping.createControls(genericDualAnalogButtonDefinitions), GamepadMapping.createControls(genericDualAnalogAxisDefinitions));
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":";;;AAKA,MAAM,kCAAkC,GAA4C;AAChF,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;AAC/B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC;AAC9B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC;AAC9B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;AAC/B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC;AAChC,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC;AACjC,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;AAC/B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC;AAChC,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;AAC1B,IAAA,CAAC,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC;AACzB,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,SAAS,CAAC;AAC9B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,UAAU,CAAC;AAC/B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC;AAC3B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC;AAC7B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC;AAC7B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,SAAS,CAAC;AAC9B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC;AAC1B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC;AAC1B,IAAA,CAAC,EAAE,EAAE,cAAc,CAAC,OAAO,CAAC;AAC5B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AAC,CAAC,EAAE,cAAc,CAAC,sBAAsB,CAAC;CAC7C;AAED;;;;;;;;;AASG;AACG,MAAO,+BAAgC,SAAQ,cAAc,CAAA;AAC/C,IAAA,MAAM,GAAyB,oBAAoB,CAAC,iBAAiB;AAErF,IAAA,WAAA,GAAA;AACI,QAAA,KAAK,CACD,cAAc,CAAC,cAAc,CAAC,kCAAkC,CAAC,EACjE,cAAc,CAAC,cAAc,CAAC,gCAAgC,CAAC,CAClE;IACL;AACH;;;;"}
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,KAA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E,IAAI,EAAE,CAAC;AACxE,YAAA,IAAI,WAAW,CAAC,CAAC,EAAE,WAAW,CAAC,sBAAsB,CAAC;AACzD,SAAA,CACJ;IACL;AACH;;;;"}
@@ -0,0 +1,74 @@
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"],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MAAM;YAClB;QACJ;AAEA,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AAEnB,QAAA,IAAI,KAAK,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 { Input } from './Input';
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 Input} instances to channel indices to react to specific
16
- * keys, gamepad controls, or pointer slots without rolling your own event
17
- * routing. Direct subscribers can use the per-event Signals
18
- * (`onKeyDown`, `onPointerDown`, `onGamepadConnected`, `onPinch`, …).
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 gamepadsValue;
29
- private readonly gamepadsByIndex;
30
- private readonly gamepadSlotsActive;
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
- readonly onGamepadConnected: Signal<[Gamepad, Gamepad[]]>;
66
- readonly onGamepadDisconnected: Signal<[Gamepad, Gamepad[]]>;
67
- readonly onGamepadUpdated: Signal<[Gamepad, Gamepad[]]>;
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
- * Register one or more {@link Input} bindings so they participate in the
90
- * per-frame channel-buffer reads. Idempotent for already-registered
91
- * inputs; chainable.
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
- add(inputs: Input | Array<Input>): this;
94
- /** Unregister one or more {@link Input} bindings. */
95
- remove(inputs: Input | Array<Input>): this;
121
+ get gamepads(): readonly [Gamepad, Gamepad, Gamepad, Gamepad];
122
+ /** The slot strategy active for this `InputManager`. */
123
+ get gamepadSlotStrategy(): GamepadSlotStrategy;
96
124
  /**
97
- * Drop every registered {@link Input}. Pass `destroyInputs = true` to
98
- * also call `.destroy()` on each one (releases its Signals); default
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
- clear(destroyInputs?: boolean): this;
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 {@link Input}.
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 insertGamepadByIndex;
180
+ private assignSlotForNewPad;
181
+ private handleGamepadDisconnect;
136
182
  private updateEvents;
137
183
  private updatePointerEvents;
138
184
  }