three-gamepad-controls 0.10.6 → 0.12.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.
@@ -1,6 +1,5 @@
1
1
  import { GAMEPAD_AXIS, GAMEPAD_BUTTON } from "./core.js";
2
2
  import { GamepadControls } from "./gamepad-controls.js";
3
- import { applyGamepadDeadzone, getGamepadButtonPressed } from "./utils.js";
4
3
  import { Matrix4, Vector2, Vector3 } from "three";
5
4
  //#region src/gamepad-drag-controls.ts
6
5
  /**
@@ -38,7 +37,6 @@ var GamepadDragControls = class extends GamepadControls {
38
37
  #viewSize;
39
38
  #hovered = null;
40
39
  #selected = null;
41
- #selectButtonPressed = false;
42
40
  /**
43
41
  * @param controls - A Three.js `DragControls` instance.
44
42
  * @param options - Optional overrides for the default behavior.
@@ -68,13 +66,10 @@ var GamepadDragControls = class extends GamepadControls {
68
66
  * and rotate behavior.
69
67
  *
70
68
  * @param deltaTime - Seconds since the last frame.
71
- * @param gamepad - Fresh gamepad snapshot provided by the base class.
72
69
  */
73
- onUpdate(deltaTime, gamepad) {
70
+ onUpdate(deltaTime) {
74
71
  const controls = this.#controls;
75
- const selectPressed = getGamepadButtonPressed(gamepad, this.#options.buttonSelect);
76
- const selectStarted = selectPressed && !this.#selectButtonPressed;
77
- this.#selectButtonPressed = selectPressed;
72
+ const selectStarted = this.gamepadInput.wasPressed(this.#options.buttonSelect);
78
73
  if (!controls.enabled) {
79
74
  this.#releaseSelected();
80
75
  this.#clearHover();
@@ -85,7 +80,7 @@ var GamepadDragControls = class extends GamepadControls {
85
80
  this.#releaseSelected();
86
81
  return;
87
82
  }
88
- this.#updateSelected(deltaTime, gamepad);
83
+ this.#updateSelected(deltaTime);
89
84
  return;
90
85
  }
91
86
  const hit = this.#intersectCenter();
@@ -111,14 +106,20 @@ var GamepadDragControls = class extends GamepadControls {
111
106
  this.#clearHover();
112
107
  super.onGamepadDisconnected(gamepad);
113
108
  }
114
- #updateSelected(deltaTime, gamepad) {
109
+ /**
110
+ * Updates the selected object from gamepad drag and rotation input.
111
+ *
112
+ * @param deltaTime - Seconds since the last frame.
113
+ */
114
+ #updateSelected(deltaTime) {
115
115
  const selected = this.#selected;
116
116
  if (selected === null) return;
117
117
  const { dragSpeed, rotateSpeed, deadzone, axisDragX, axisDragY, axisRotateX, axisRotateY } = this.#options;
118
- const dragX = applyGamepadDeadzone(gamepad.axes[axisDragX] ?? 0, deadzone);
119
- const dragY = applyGamepadDeadzone(gamepad.axes[axisDragY] ?? 0, deadzone);
120
- const rotateX = applyGamepadDeadzone(gamepad.axes[axisRotateX] ?? 0, deadzone);
121
- const rotateY = applyGamepadDeadzone(gamepad.axes[axisRotateY] ?? 0, deadzone);
118
+ const input = this.gamepadInput;
119
+ const dragX = input.axis(axisDragX, { deadzone });
120
+ const dragY = input.axis(axisDragY, { deadzone });
121
+ const rotateX = input.axis(axisRotateX, { deadzone });
122
+ const rotateY = input.axis(axisRotateY, { deadzone });
122
123
  const dragged = this.#applyDrag(deltaTime, dragX, dragY, dragSpeed);
123
124
  const rotated = this.#applyRotation(deltaTime, rotateX, rotateY, rotateSpeed);
124
125
  if (dragged || rotated) this.#controls.dispatchEvent({
@@ -126,6 +127,15 @@ var GamepadDragControls = class extends GamepadControls {
126
127
  object: selected
127
128
  });
128
129
  }
130
+ /**
131
+ * Moves the selected object in the camera-facing plane.
132
+ *
133
+ * @param deltaTime - Seconds since the last frame.
134
+ * @param dragX - Horizontal drag input after dead zone processing.
135
+ * @param dragY - Vertical drag input after dead zone processing.
136
+ * @param dragSpeed - User-configured drag speed multiplier.
137
+ * @returns `true` when the selected object moved.
138
+ */
129
139
  #applyDrag(deltaTime, dragX, dragY, dragSpeed) {
130
140
  if (this.#selected === null || dragX === 0 && dragY === 0) return false;
131
141
  this.#updateCameraAxes();
@@ -136,6 +146,15 @@ var GamepadDragControls = class extends GamepadControls {
136
146
  this.#applySelectedWorldPosition();
137
147
  return true;
138
148
  }
149
+ /**
150
+ * Rotates the selected object around camera-relative world axes.
151
+ *
152
+ * @param deltaTime - Seconds since the last frame.
153
+ * @param rotateX - Horizontal rotation input after dead zone processing.
154
+ * @param rotateY - Vertical rotation input after dead zone processing.
155
+ * @param rotateSpeed - User-configured rotation speed multiplier.
156
+ * @returns `true` when the selected object rotated.
157
+ */
139
158
  #applyRotation(deltaTime, rotateX, rotateY, rotateSpeed) {
140
159
  const selected = this.#selected;
141
160
  if (selected === null || rotateX === 0 && rotateY === 0) return false;
@@ -145,6 +164,11 @@ var GamepadDragControls = class extends GamepadControls {
145
164
  if (rotateY !== 0) selected.rotateOnWorldAxis(this.#cameraRight, rotateY * scale);
146
165
  return true;
147
166
  }
167
+ /**
168
+ * Raycasts from the center of the viewport into DragControls objects.
169
+ *
170
+ * @returns The closest center hit, or `undefined` when nothing is hit.
171
+ */
148
172
  #intersectCenter() {
149
173
  const controls = this.#controls;
150
174
  this.#intersections.length = 0;
@@ -152,6 +176,11 @@ var GamepadDragControls = class extends GamepadControls {
152
176
  controls.raycaster.intersectObjects(controls.objects, controls.recursive, this.#intersections);
153
177
  return this.#intersections[0];
154
178
  }
179
+ /**
180
+ * Updates DragControls hover state for the object under the center reticle.
181
+ *
182
+ * @param object - Object currently under the reticle, or `null`.
183
+ */
155
184
  #updateHover(object) {
156
185
  if (this.#hovered === object) return;
157
186
  this.#clearHover();
@@ -162,6 +191,9 @@ var GamepadDragControls = class extends GamepadControls {
162
191
  object
163
192
  });
164
193
  }
194
+ /**
195
+ * Clears the current hover object and dispatches `hoveroff` when needed.
196
+ */
165
197
  #clearHover() {
166
198
  if (this.#hovered === null) return;
167
199
  const object = this.#hovered;
@@ -171,6 +203,11 @@ var GamepadDragControls = class extends GamepadControls {
171
203
  object
172
204
  });
173
205
  }
206
+ /**
207
+ * Selects an object and dispatches DragControls `dragstart`.
208
+ *
209
+ * @param object - Object hit by the center reticle.
210
+ */
174
211
  #grabObject(object) {
175
212
  const selected = this.#getSelectedObject(object);
176
213
  selected.updateWorldMatrix(true, false);
@@ -181,6 +218,9 @@ var GamepadDragControls = class extends GamepadControls {
181
218
  object: selected
182
219
  });
183
220
  }
221
+ /**
222
+ * Releases the selected object and dispatches DragControls `dragend`.
223
+ */
184
224
  #releaseSelected() {
185
225
  if (this.#selected === null) return;
186
226
  const selected = this.#selected;
@@ -190,10 +230,22 @@ var GamepadDragControls = class extends GamepadControls {
190
230
  object: selected
191
231
  });
192
232
  }
233
+ /**
234
+ * Resolves which object should be dragged for a reticle hit.
235
+ *
236
+ * @param object - Object hit by the center reticle.
237
+ * @returns The hit object, or its outermost group when group dragging is enabled.
238
+ */
193
239
  #getSelectedObject(object) {
194
240
  if (!this.#controls.transformGroup) return object;
195
241
  return this.#findOutermostGroup(object) ?? object;
196
242
  }
243
+ /**
244
+ * Finds the highest ancestor that is a Three.js `Group`.
245
+ *
246
+ * @param object - Object where the ancestor search starts.
247
+ * @returns The outermost group ancestor, or `null` when none exists.
248
+ */
197
249
  #findOutermostGroup(object) {
198
250
  let group = null;
199
251
  let current = object;
@@ -203,6 +255,9 @@ var GamepadDragControls = class extends GamepadControls {
203
255
  }
204
256
  return group;
205
257
  }
258
+ /**
259
+ * Writes the accumulated world-space selected position back to the object.
260
+ */
206
261
  #applySelectedWorldPosition() {
207
262
  const selected = this.#selected;
208
263
  if (selected === null) return;
@@ -217,12 +272,18 @@ var GamepadDragControls = class extends GamepadControls {
217
272
  selected.position.copy(this.#selectedLocalPosition);
218
273
  selected.updateMatrixWorld();
219
274
  }
275
+ /**
276
+ * Refreshes camera-relative axes used for dragging and rotation.
277
+ */
220
278
  #updateCameraAxes() {
221
279
  const camera = this.#controls.object;
222
280
  this.#cameraRight.set(1, 0, 0).applyQuaternion(camera.quaternion).normalize();
223
281
  this.#cameraUp.set(0, 1, 0).applyQuaternion(camera.quaternion).normalize();
224
282
  camera.getWorldDirection(this.#cameraForward).normalize();
225
283
  }
284
+ /**
285
+ * Computes the world-space viewport size at the selected object's depth.
286
+ */
226
287
  #updateViewSizeAtSelectedDepth() {
227
288
  const camera = this.#controls.object;
228
289
  if (this.#isOrthographicCamera(camera)) {
@@ -238,9 +299,21 @@ var GamepadDragControls = class extends GamepadControls {
238
299
  }
239
300
  this.#viewSize.set(1, 1);
240
301
  }
302
+ /**
303
+ * Narrows a Three.js camera to `PerspectiveCamera`.
304
+ *
305
+ * @param camera - Camera to inspect.
306
+ * @returns `true` when the camera is perspective.
307
+ */
241
308
  #isPerspectiveCamera(camera) {
242
309
  return camera.isPerspectiveCamera === true;
243
310
  }
311
+ /**
312
+ * Narrows a Three.js camera to `OrthographicCamera`.
313
+ *
314
+ * @param camera - Camera to inspect.
315
+ * @returns `true` when the camera is orthographic.
316
+ */
244
317
  #isOrthographicCamera(camera) {
245
318
  return camera.isOrthographicCamera === true;
246
319
  }
@@ -73,9 +73,8 @@ declare class GamepadFirstPersonControls extends GamepadControls {
73
73
  * Maps the current gamepad state to `FirstPersonControls` translation and look.
74
74
  *
75
75
  * @param deltaTime - Seconds since the last frame.
76
- * @param gamepad - Fresh gamepad snapshot provided by the base class.
77
76
  */
78
- protected onUpdate(deltaTime: number, gamepad: Gamepad): void;
77
+ protected onUpdate(deltaTime: number): void;
79
78
  }
80
79
  //#endregion
81
80
  export { GamepadFirstPersonControls, GamepadFirstPersonControlsOptions };
@@ -1,6 +1,5 @@
1
1
  import { GAMEPAD_AXIS, GAMEPAD_BUTTON } from "./core.js";
2
2
  import { GamepadControls } from "./gamepad-controls.js";
3
- import { applyGamepadDeadzone, getGamepadButtonValue } from "./utils.js";
4
3
  import { MathUtils, Spherical, Vector3 } from "three";
5
4
  //#region src/gamepad-first-person-controls.ts
6
5
  /**
@@ -51,17 +50,28 @@ var GamepadFirstPersonControls = class extends GamepadControls {
51
50
  * Maps the current gamepad state to `FirstPersonControls` translation and look.
52
51
  *
53
52
  * @param deltaTime - Seconds since the last frame.
54
- * @param gamepad - Fresh gamepad snapshot provided by the base class.
55
53
  */
56
- onUpdate(deltaTime, gamepad) {
54
+ onUpdate(deltaTime) {
57
55
  const { moveSpeed, lookSpeed, deadzone, axisMoveForward, axisMoveRight, axisLookX, axisLookY, buttonMoveUp, buttonMoveDown } = this.#options;
58
- this.#applyMovement(deltaTime, gamepad, moveSpeed, deadzone, axisMoveForward, axisMoveRight, buttonMoveUp, buttonMoveDown);
59
- this.#applyLook(deltaTime, gamepad, lookSpeed, deadzone, axisLookX, axisLookY);
56
+ this.#applyMovement(deltaTime, moveSpeed, deadzone, axisMoveForward, axisMoveRight, buttonMoveUp, buttonMoveDown);
57
+ this.#applyLook(deltaTime, lookSpeed, deadzone, axisLookX, axisLookY);
60
58
  }
61
- #applyMovement(deltaTime, gamepad, moveSpeed, deadzone, axisMoveForward, axisMoveRight, buttonMoveUp, buttonMoveDown) {
59
+ /**
60
+ * Applies local translation input to FirstPersonControls' object.
61
+ *
62
+ * @param deltaTime - Seconds since the last frame.
63
+ * @param moveSpeed - User-configured movement speed multiplier.
64
+ * @param deadzone - Axis and trigger dead zone threshold.
65
+ * @param axisMoveForward - Axis index for forward and backward movement.
66
+ * @param axisMoveRight - Axis index for right and left strafe movement.
67
+ * @param buttonMoveUp - Button index for upward movement.
68
+ * @param buttonMoveDown - Button index for downward movement.
69
+ */
70
+ #applyMovement(deltaTime, moveSpeed, deadzone, axisMoveForward, axisMoveRight, buttonMoveUp, buttonMoveDown) {
62
71
  const controls = this.#controls;
72
+ const input = this.gamepadInput;
63
73
  const moveMult = deltaTime * controls.movementSpeed * moveSpeed;
64
- const forward = applyGamepadDeadzone(gamepad.axes[axisMoveForward] ?? 0, deadzone);
74
+ const forward = input.axis(axisMoveForward, { deadzone });
65
75
  if (forward !== 0) {
66
76
  let distance = forward * moveMult;
67
77
  if (forward < 0 && controls.heightSpeed) {
@@ -70,16 +80,26 @@ var GamepadFirstPersonControls = class extends GamepadControls {
70
80
  }
71
81
  controls.object.translateZ(distance);
72
82
  }
73
- const strafe = applyGamepadDeadzone(gamepad.axes[axisMoveRight] ?? 0, deadzone);
83
+ const strafe = input.axis(axisMoveRight, { deadzone });
74
84
  if (strafe !== 0) controls.object.translateX(strafe * moveMult);
75
- const up = getGamepadButtonValue(gamepad, buttonMoveUp);
76
- const down = getGamepadButtonValue(gamepad, buttonMoveDown);
85
+ const up = input.buttonValue(buttonMoveUp);
86
+ const down = input.buttonValue(buttonMoveDown);
77
87
  if (up > deadzone) controls.object.translateY(up * moveMult);
78
88
  if (down > deadzone) controls.object.translateY(-down * moveMult);
79
89
  }
80
- #applyLook(deltaTime, gamepad, lookSpeed, deadzone, axisLookX, axisLookY) {
81
- const lookX = applyGamepadDeadzone(gamepad.axes[axisLookX] ?? 0, deadzone);
82
- const lookY = applyGamepadDeadzone(gamepad.axes[axisLookY] ?? 0, deadzone);
90
+ /**
91
+ * Applies camera look input while keeping FirstPersonControls state in sync.
92
+ *
93
+ * @param deltaTime - Seconds since the last frame.
94
+ * @param lookSpeed - User-configured look speed multiplier.
95
+ * @param deadzone - Axis dead zone threshold.
96
+ * @param axisLookX - Axis index for yaw input.
97
+ * @param axisLookY - Axis index for pitch input.
98
+ */
99
+ #applyLook(deltaTime, lookSpeed, deadzone, axisLookX, axisLookY) {
100
+ const input = this.gamepadInput;
101
+ const lookX = input.axis(axisLookX, { deadzone });
102
+ const lookY = input.axis(axisLookY, { deadzone });
83
103
  if (lookX === 0 && lookY === 0) return;
84
104
  const controls = this.#controls;
85
105
  const actualLookSpeed = controls.lookSpeed * lookSpeed * deltaTime * LOOK_SPEED_SCALE;
@@ -98,6 +118,11 @@ var GamepadFirstPersonControls = class extends GamepadControls {
98
118
  controls._lat = lat;
99
119
  controls._lon = lon;
100
120
  }
121
+ /**
122
+ * Reads the current FirstPersonControls orientation, deriving it if needed.
123
+ *
124
+ * @returns Current latitude and longitude in degrees.
125
+ */
101
126
  #getOrientation() {
102
127
  const { _lat, _lon } = this.#controls;
103
128
  if (Number.isFinite(_lat) && Number.isFinite(_lon)) return {
@@ -83,9 +83,8 @@ declare class GamepadFlyControls extends GamepadControls {
83
83
  * Maps the current gamepad state to `FlyControls` translation and rotation.
84
84
  *
85
85
  * @param deltaTime - Seconds since the last frame.
86
- * @param gamepad - Fresh gamepad snapshot provided by the base class.
87
86
  */
88
- protected onUpdate(deltaTime: number, gamepad: Gamepad): void;
87
+ protected onUpdate(deltaTime: number): void;
89
88
  }
90
89
  //#endregion
91
90
  export { GamepadFlyControls, GamepadFlyControlsOptions };
@@ -1,6 +1,5 @@
1
1
  import { GAMEPAD_AXIS, GAMEPAD_BUTTON } from "./core.js";
2
2
  import { GamepadControls } from "./gamepad-controls.js";
3
- import { applyGamepadDeadzone, getGamepadButtonPressed, getGamepadButtonValue } from "./utils.js";
4
3
  import { Quaternion } from "three";
5
4
  //#region src/gamepad-fly-controls.ts
6
5
  /**
@@ -48,23 +47,23 @@ var GamepadFlyControls = class extends GamepadControls {
48
47
  * Maps the current gamepad state to `FlyControls` translation and rotation.
49
48
  *
50
49
  * @param deltaTime - Seconds since the last frame.
51
- * @param gamepad - Fresh gamepad snapshot provided by the base class.
52
50
  */
53
- onUpdate(deltaTime, gamepad) {
51
+ onUpdate(deltaTime) {
54
52
  const { moveSpeed, rotateSpeed, deadzone, axisMoveForward, axisMoveRight, axisLookX, axisLookY, buttonRollLeft, buttonRollRight, buttonMoveUp, buttonMoveDown } = this.#options;
53
+ const input = this.gamepadInput;
55
54
  const moveMult = deltaTime * this.#controls.movementSpeed * moveSpeed;
56
- const fwd = applyGamepadDeadzone(gamepad.axes[axisMoveForward] ?? 0, deadzone);
55
+ const fwd = input.axis(axisMoveForward, { deadzone });
57
56
  if (fwd !== 0) this.#controls.object.translateZ(fwd * moveMult);
58
- const strafe = applyGamepadDeadzone(gamepad.axes[axisMoveRight] ?? 0, deadzone);
57
+ const strafe = input.axis(axisMoveRight, { deadzone });
59
58
  if (strafe !== 0) this.#controls.object.translateX(strafe * moveMult);
60
- const up = getGamepadButtonValue(gamepad, buttonMoveUp);
61
- const down = getGamepadButtonValue(gamepad, buttonMoveDown);
59
+ const up = input.buttonValue(buttonMoveUp);
60
+ const down = input.buttonValue(buttonMoveDown);
62
61
  if (up > deadzone) this.#controls.object.translateY(up * moveMult);
63
62
  if (down > deadzone) this.#controls.object.translateY(-down * moveMult);
64
63
  const rotMult = deltaTime * this.#controls.rollSpeed * rotateSpeed;
65
- const pitch = -applyGamepadDeadzone(gamepad.axes[axisLookY] ?? 0, deadzone);
66
- const yaw = -applyGamepadDeadzone(gamepad.axes[axisLookX] ?? 0, deadzone);
67
- const roll = (getGamepadButtonPressed(gamepad, buttonRollLeft) ? 1 : 0) - (getGamepadButtonPressed(gamepad, buttonRollRight) ? 1 : 0);
64
+ const pitch = -input.axis(axisLookY, { deadzone });
65
+ const yaw = -input.axis(axisLookX, { deadzone });
66
+ const roll = (input.isPressed(buttonRollLeft) ? 1 : 0) - (input.isPressed(buttonRollRight) ? 1 : 0);
68
67
  if (pitch !== 0 || yaw !== 0 || roll !== 0) {
69
68
  this.#tmpQuaternion.set(pitch * rotMult, yaw * rotMult, roll * rotMult, 1).normalize();
70
69
  this.#controls.object.quaternion.multiply(this.#tmpQuaternion);
@@ -0,0 +1,156 @@
1
+ import { EventDispatcher } from "three";
2
+
3
+ //#region src/gamepad-input.d.ts
4
+ /**
5
+ * Event map for {@link GamepadInput}.
6
+ */
7
+ type GamepadInputEventMap = {
8
+ /**
9
+ * Fired when a gamepad is connected and becomes active.
10
+ */
11
+ connected: {
12
+ /**
13
+ * Gamepad snapshot that became active.
14
+ */
15
+ gamepad: Gamepad;
16
+ };
17
+ /**
18
+ * Fired when the active gamepad is disconnected.
19
+ */
20
+ disconnected: {
21
+ /**
22
+ * Gamepad snapshot that was active before disconnection.
23
+ */
24
+ gamepad: Gamepad;
25
+ };
26
+ };
27
+ /**
28
+ * Configuration for {@link GamepadInput}.
29
+ */
30
+ type GamepadInputOptions = {
31
+ /**
32
+ * Default axis dead zone threshold in the range `[0, 1]`.
33
+ * @default 0.1
34
+ */
35
+ deadzone: number;
36
+ };
37
+ /**
38
+ * Options for axis and stick reads.
39
+ */
40
+ type GamepadAxisOptions = {
41
+ /**
42
+ * Axis dead zone threshold for this read.
43
+ */
44
+ deadzone?: number;
45
+ };
46
+ /**
47
+ * Two-dimensional stick input after dead zone processing.
48
+ */
49
+ type GamepadStick = {
50
+ /**
51
+ * Horizontal stick value.
52
+ */
53
+ x: number;
54
+ /**
55
+ * Vertical stick value.
56
+ */
57
+ y: number;
58
+ };
59
+ /**
60
+ * Gamepad input state reader for gameplay, menus, and custom actions.
61
+ *
62
+ * Call {@link update} once per frame before reading button transitions or axes.
63
+ */
64
+ declare class GamepadInput extends EventDispatcher<GamepadInputEventMap> {
65
+ #private;
66
+ /**
67
+ * When `false`, input polling is paused.
68
+ * @default true
69
+ */
70
+ enabled: boolean;
71
+ /**
72
+ * Creates a gamepad input reader.
73
+ *
74
+ * @param options - Optional overrides for the default input behavior.
75
+ */
76
+ constructor(options?: Partial<GamepadInputOptions>);
77
+ /**
78
+ * The currently active gamepad, or `null` if no gamepad is connected.
79
+ *
80
+ * @returns The active gamepad snapshot, or `null`.
81
+ */
82
+ get gamepad(): Gamepad | null;
83
+ /**
84
+ * Whether a gamepad is currently active.
85
+ *
86
+ * @returns `true` when a gamepad is active, otherwise `false`.
87
+ */
88
+ get connected(): boolean;
89
+ /**
90
+ * Mapping reported by the active gamepad, or `null` when none is active.
91
+ *
92
+ * @returns The active gamepad mapping, or `null`.
93
+ */
94
+ get mapping(): GamepadMappingType | null;
95
+ /**
96
+ * Raw active gamepad snapshot, or `null` if no gamepad is connected.
97
+ *
98
+ * @returns The raw active gamepad snapshot, or `null`.
99
+ */
100
+ get rawGamepad(): Gamepad | null;
101
+ /**
102
+ * Polls the gamepad and refreshes current and previous button state.
103
+ */
104
+ update(): void;
105
+ /**
106
+ * Removes all window-level event listeners attached by this input reader.
107
+ */
108
+ dispose(): void;
109
+ /**
110
+ * Returns whether a button is currently pressed.
111
+ *
112
+ * @param button - Button index to inspect.
113
+ * @returns `true` when the button is currently pressed, otherwise `false`.
114
+ */
115
+ isPressed(button: number): boolean;
116
+ /**
117
+ * Returns whether a button was pressed during the latest update.
118
+ *
119
+ * @param button - Button index to inspect.
120
+ * @returns `true` only on the frame where the button transitions to pressed.
121
+ */
122
+ wasPressed(button: number): boolean;
123
+ /**
124
+ * Returns whether a button was released during the latest update.
125
+ *
126
+ * @param button - Button index to inspect.
127
+ * @returns `true` only on the frame where the button transitions to released.
128
+ */
129
+ wasReleased(button: number): boolean;
130
+ /**
131
+ * Returns the current analog value for a button.
132
+ *
133
+ * @param button - Button index to inspect.
134
+ * @returns The button value, `1` for pressed digital buttons, or `0`.
135
+ */
136
+ buttonValue(button: number): number;
137
+ /**
138
+ * Returns the current value of an axis after dead zone processing.
139
+ *
140
+ * @param axis - Axis index to inspect.
141
+ * @param options - Optional per-read axis options.
142
+ * @returns Axis value after dead zone processing, or `0` when unavailable.
143
+ */
144
+ axis(axis: number, options?: GamepadAxisOptions): number;
145
+ /**
146
+ * Returns a two-axis stick after dead zone processing.
147
+ *
148
+ * @param xAxis - Horizontal axis index.
149
+ * @param yAxis - Vertical axis index.
150
+ * @param options - Optional per-read axis options.
151
+ * @returns Object containing processed `x` and `y` values.
152
+ */
153
+ stick(xAxis: number, yAxis: number, options?: GamepadAxisOptions): GamepadStick;
154
+ }
155
+ //#endregion
156
+ export { GamepadAxisOptions, GamepadInput, GamepadInputEventMap, GamepadInputOptions, GamepadStick };