three-gamepad-controls 0.14.0 → 0.15.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/dist/core.d.ts +14 -1
- package/dist/core.js +14 -1
- package/dist/gamepad-arcball-controls.d.ts +0 -1
- package/dist/gamepad-controls.d.ts +2 -3
- package/dist/gamepad-controls.js +2 -2
- package/dist/gamepad-drag-controls.d.ts +0 -1
- package/dist/gamepad-first-person-controls.d.ts +0 -1
- package/dist/gamepad-fly-controls.d.ts +0 -1
- package/dist/gamepad-input.d.ts +4 -4
- package/dist/gamepad-input.js +4 -3
- package/dist/gamepad-manager.js +3 -3
- package/dist/gamepad-map-controls.d.ts +0 -1
- package/dist/gamepad-orbit-controls.d.ts +0 -1
- package/dist/gamepad-pointer-lock-controls.d.ts +0 -1
- package/dist/gamepad-trackball-controls.d.ts +0 -1
- package/dist/gamepad-transform-controls.d.ts +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +6 -6
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
//#region src/core.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Smallest valid browser-assigned gamepad index.
|
|
4
|
+
*
|
|
5
|
+
* Gamepad slots cannot be negative.
|
|
6
|
+
*/
|
|
7
|
+
declare const MIN_GAMEPAD_INDEX = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Largest valid browser-assigned gamepad index.
|
|
10
|
+
*
|
|
11
|
+
* `Gamepad.index` is a Web IDL `long`, a signed 32-bit integer. Because
|
|
12
|
+
* gamepad slots cannot be negative, the largest valid index is 2^31 - 1.
|
|
13
|
+
*/
|
|
14
|
+
declare const MAX_GAMEPAD_INDEX = 2147483647;
|
|
2
15
|
/**
|
|
3
16
|
* Button indices for the W3C Standard Gamepad mapping.
|
|
4
17
|
* @see https://www.w3.org/TR/gamepad/#dfn-standard-gamepad
|
|
@@ -49,4 +62,4 @@ type GamepadAxisKey = keyof typeof GAMEPAD_AXIS;
|
|
|
49
62
|
*/
|
|
50
63
|
type GamepadAxisValue = (typeof GAMEPAD_AXIS)[keyof typeof GAMEPAD_AXIS];
|
|
51
64
|
//#endregion
|
|
52
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue };
|
|
65
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX };
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
//#region src/core.ts
|
|
2
2
|
/**
|
|
3
|
+
* Smallest valid browser-assigned gamepad index.
|
|
4
|
+
*
|
|
5
|
+
* Gamepad slots cannot be negative.
|
|
6
|
+
*/
|
|
7
|
+
const MIN_GAMEPAD_INDEX = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Largest valid browser-assigned gamepad index.
|
|
10
|
+
*
|
|
11
|
+
* `Gamepad.index` is a Web IDL `long`, a signed 32-bit integer. Because
|
|
12
|
+
* gamepad slots cannot be negative, the largest valid index is 2^31 - 1.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_GAMEPAD_INDEX = 2147483647;
|
|
15
|
+
/**
|
|
3
16
|
* Button indices for the W3C Standard Gamepad mapping.
|
|
4
17
|
* @see https://www.w3.org/TR/gamepad/#dfn-standard-gamepad
|
|
5
18
|
*/
|
|
@@ -33,4 +46,4 @@ const GAMEPAD_AXIS = {
|
|
|
33
46
|
RightY: 3
|
|
34
47
|
};
|
|
35
48
|
//#endregion
|
|
36
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON };
|
|
49
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GamepadInput, GamepadInputOptions } from "./gamepad-input.js";
|
|
2
2
|
import { EventDispatcher } from "three";
|
|
3
|
-
|
|
4
3
|
//#region src/gamepad-controls.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Event map for {@link GamepadControls}.
|
|
@@ -53,8 +52,8 @@ declare abstract class GamepadControls extends EventDispatcher<GamepadControlsEv
|
|
|
53
52
|
* Creates the base input reader and attaches lifecycle listeners.
|
|
54
53
|
*
|
|
55
54
|
* @param options - Shared gamepad selection options.
|
|
56
|
-
* @throws {RangeError} When `gamepadIndex` is not an integer
|
|
57
|
-
*
|
|
55
|
+
* @throws {RangeError} When `gamepadIndex` is not an integer from
|
|
56
|
+
* `MIN_GAMEPAD_INDEX` through `MAX_GAMEPAD_INDEX`.
|
|
58
57
|
*/
|
|
59
58
|
constructor(options?: GamepadControlsOptions);
|
|
60
59
|
/**
|
package/dist/gamepad-controls.js
CHANGED
|
@@ -24,8 +24,8 @@ var GamepadControls = class extends EventDispatcher {
|
|
|
24
24
|
* Creates the base input reader and attaches lifecycle listeners.
|
|
25
25
|
*
|
|
26
26
|
* @param options - Shared gamepad selection options.
|
|
27
|
-
* @throws {RangeError} When `gamepadIndex` is not an integer
|
|
28
|
-
*
|
|
27
|
+
* @throws {RangeError} When `gamepadIndex` is not an integer from
|
|
28
|
+
* `MIN_GAMEPAD_INDEX` through `MAX_GAMEPAD_INDEX`.
|
|
29
29
|
*/
|
|
30
30
|
constructor(options) {
|
|
31
31
|
super();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GamepadControls, GamepadControlsOptions } from "./gamepad-controls.js";
|
|
2
2
|
import { FirstPersonControls } from "three/addons/controls/FirstPersonControls.js";
|
|
3
|
-
|
|
4
3
|
//#region src/gamepad-first-person-controls.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Configuration for {@link GamepadFirstPersonControls}.
|
package/dist/gamepad-input.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EventDispatcher } from "three";
|
|
2
|
-
|
|
3
2
|
//#region src/gamepad-input.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Event map for {@link GamepadInput}.
|
|
@@ -37,7 +36,8 @@ type GamepadInputOptions = {
|
|
|
37
36
|
* Browser-assigned gamepad slot to use.
|
|
38
37
|
*
|
|
39
38
|
* When omitted, the connected gamepad with the lowest index is selected.
|
|
40
|
-
* The index must be an integer
|
|
39
|
+
* The index must be an integer from `MIN_GAMEPAD_INDEX` through
|
|
40
|
+
* `MAX_GAMEPAD_INDEX`.
|
|
41
41
|
* A valid but empty slot keeps this input disconnected without falling back
|
|
42
42
|
* to another gamepad.
|
|
43
43
|
*/
|
|
@@ -81,8 +81,8 @@ declare class GamepadInput extends EventDispatcher<GamepadInputEventMap> {
|
|
|
81
81
|
* Creates a gamepad input reader.
|
|
82
82
|
*
|
|
83
83
|
* @param options - Optional overrides for the default input behavior.
|
|
84
|
-
* @throws {RangeError} When `gamepadIndex` is not an integer
|
|
85
|
-
*
|
|
84
|
+
* @throws {RangeError} When `gamepadIndex` is not an integer from
|
|
85
|
+
* `MIN_GAMEPAD_INDEX` through `MAX_GAMEPAD_INDEX`.
|
|
86
86
|
*/
|
|
87
87
|
constructor(options?: Partial<GamepadInputOptions>);
|
|
88
88
|
/**
|
package/dist/gamepad-input.js
CHANGED
|
@@ -66,8 +66,8 @@ var GamepadInput = class extends EventDispatcher {
|
|
|
66
66
|
* Creates a gamepad input reader.
|
|
67
67
|
*
|
|
68
68
|
* @param options - Optional overrides for the default input behavior.
|
|
69
|
-
* @throws {RangeError} When `gamepadIndex` is not an integer
|
|
70
|
-
*
|
|
69
|
+
* @throws {RangeError} When `gamepadIndex` is not an integer from
|
|
70
|
+
* `MIN_GAMEPAD_INDEX` through `MAX_GAMEPAD_INDEX`.
|
|
71
71
|
*/
|
|
72
72
|
constructor(options) {
|
|
73
73
|
super();
|
|
@@ -224,7 +224,8 @@ var GamepadInput = class extends EventDispatcher {
|
|
|
224
224
|
* @returns Axis value after dead zone processing, or `0` when unavailable.
|
|
225
225
|
*/
|
|
226
226
|
axis(axis, options) {
|
|
227
|
-
|
|
227
|
+
const value = this.#gamepad?.axes[axis] ?? 0;
|
|
228
|
+
return applyGamepadDeadzone(value, this.#getDeadzone(options));
|
|
228
229
|
}
|
|
229
230
|
/**
|
|
230
231
|
* Returns a two-axis stick after dead zone processing.
|
package/dist/gamepad-manager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { MAX_GAMEPAD_INDEX } from "./core.js";
|
|
1
2
|
//#region src/gamepad-manager.ts
|
|
2
|
-
const MAX_GAMEPAD_INDEX = 2147483647;
|
|
3
3
|
const EMPTY_UPDATE_RESULT = {
|
|
4
4
|
gamepad: null,
|
|
5
5
|
connected: null,
|
|
@@ -151,11 +151,11 @@ var GamepadManager = class {
|
|
|
151
151
|
* @param gamepadIndex - Browser-assigned gamepad index option.
|
|
152
152
|
* @returns Internal active-gamepad selection mode.
|
|
153
153
|
* @throws {RangeError} When the explicit index is not an integer in the
|
|
154
|
-
* inclusive range
|
|
154
|
+
* inclusive range [{@link MIN_GAMEPAD_INDEX}, {@link MAX_GAMEPAD_INDEX}].
|
|
155
155
|
*/
|
|
156
156
|
#resolveSelection(gamepadIndex) {
|
|
157
157
|
if (gamepadIndex === void 0) return { type: "first-available" };
|
|
158
|
-
if (!Number.isInteger(gamepadIndex) || gamepadIndex < 0 || gamepadIndex >
|
|
158
|
+
if (!Number.isInteger(gamepadIndex) || gamepadIndex < 0 || gamepadIndex > 2147483647) throw new RangeError(`gamepadIndex must be an integer between 0 and ${MAX_GAMEPAD_INDEX}.`);
|
|
159
159
|
return {
|
|
160
160
|
type: "index",
|
|
161
161
|
index: gamepadIndex
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GamepadControls, GamepadControlsOptions } from "./gamepad-controls.js";
|
|
2
2
|
import { PointerLockControls } from "three/addons/controls/PointerLockControls.js";
|
|
3
|
-
|
|
4
3
|
//#region src/gamepad-pointer-lock-controls.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Configuration for {@link GamepadPointerLockControls}.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GamepadControls, GamepadControlsOptions } from "./gamepad-controls.js";
|
|
2
2
|
import { TrackballControls } from "three/addons/controls/TrackballControls.js";
|
|
3
|
-
|
|
4
3
|
//#region src/gamepad-trackball-controls.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Configuration for {@link GamepadTrackballControls}.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GamepadControls, GamepadControlsOptions } from "./gamepad-controls.js";
|
|
2
2
|
import { TransformControls } from "three/addons/controls/TransformControls.js";
|
|
3
|
-
|
|
4
3
|
//#region src/gamepad-transform-controls.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Configuration for {@link GamepadTransformControls}.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue } from "./core.js";
|
|
1
|
+
import { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX } from "./core.js";
|
|
2
2
|
import { GamepadAxisOptions, GamepadInput, GamepadInputEventMap, GamepadInputOptions, GamepadStick } from "./gamepad-input.js";
|
|
3
3
|
import { GamepadControls, GamepadControlsEventMap, GamepadControlsOptions } from "./gamepad-controls.js";
|
|
4
4
|
import { GamepadArcballControls, GamepadArcballControlsOptions } from "./gamepad-arcball-controls.js";
|
|
@@ -10,4 +10,4 @@ import { GamepadMapControls } from "./gamepad-map-controls.js";
|
|
|
10
10
|
import { GamepadPointerLockControls, GamepadPointerLockControlsOptions } from "./gamepad-pointer-lock-controls.js";
|
|
11
11
|
import { GamepadTrackballControls, GamepadTrackballControlsOptions } from "./gamepad-trackball-controls.js";
|
|
12
12
|
import { GamepadTransformControls, GamepadTransformControlsOptions } from "./gamepad-transform-controls.js";
|
|
13
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadArcballControls, GamepadArcballControlsOptions, GamepadAxisKey, GamepadAxisOptions, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, GamepadControls, GamepadControlsEventMap, GamepadControlsOptions, GamepadDragControls, GamepadDragControlsOptions, GamepadFirstPersonControls, GamepadFirstPersonControlsOptions, GamepadFlyControls, GamepadFlyControlsOptions, GamepadInput, GamepadInputEventMap, GamepadInputOptions, GamepadMapControls, GamepadOrbitControls, GamepadOrbitControlsOptions, GamepadPointerLockControls, GamepadPointerLockControlsOptions, GamepadStick, GamepadTrackballControls, GamepadTrackballControlsOptions, GamepadTransformControls, GamepadTransformControlsOptions };
|
|
13
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadArcballControls, GamepadArcballControlsOptions, GamepadAxisKey, GamepadAxisOptions, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, GamepadControls, GamepadControlsEventMap, GamepadControlsOptions, GamepadDragControls, GamepadDragControlsOptions, GamepadFirstPersonControls, GamepadFirstPersonControlsOptions, GamepadFlyControls, GamepadFlyControlsOptions, GamepadInput, GamepadInputEventMap, GamepadInputOptions, GamepadMapControls, GamepadOrbitControls, GamepadOrbitControlsOptions, GamepadPointerLockControls, GamepadPointerLockControlsOptions, GamepadStick, GamepadTrackballControls, GamepadTrackballControlsOptions, GamepadTransformControls, GamepadTransformControlsOptions, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GAMEPAD_AXIS, GAMEPAD_BUTTON } from "./core.js";
|
|
1
|
+
import { GAMEPAD_AXIS, GAMEPAD_BUTTON, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX } from "./core.js";
|
|
2
2
|
import { GamepadInput } from "./gamepad-input.js";
|
|
3
3
|
import { GamepadControls } from "./gamepad-controls.js";
|
|
4
4
|
import { GamepadArcballControls } from "./gamepad-arcball-controls.js";
|
|
@@ -10,4 +10,4 @@ import { GamepadMapControls } from "./gamepad-map-controls.js";
|
|
|
10
10
|
import { GamepadPointerLockControls } from "./gamepad-pointer-lock-controls.js";
|
|
11
11
|
import { GamepadTrackballControls } from "./gamepad-trackball-controls.js";
|
|
12
12
|
import { GamepadTransformControls } from "./gamepad-transform-controls.js";
|
|
13
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadArcballControls, GamepadControls, GamepadDragControls, GamepadFirstPersonControls, GamepadFlyControls, GamepadInput, GamepadMapControls, GamepadOrbitControls, GamepadPointerLockControls, GamepadTrackballControls, GamepadTransformControls };
|
|
13
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadArcballControls, GamepadControls, GamepadDragControls, GamepadFirstPersonControls, GamepadFlyControls, GamepadInput, GamepadMapControls, GamepadOrbitControls, GamepadPointerLockControls, GamepadTrackballControls, GamepadTransformControls, MAX_GAMEPAD_INDEX, MIN_GAMEPAD_INDEX };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-gamepad-controls",
|
|
3
3
|
"description": "Gamepad support for Three.js controls.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"homepage": "https://github.com/luckasnix/three-gamepad-controls#readme",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Kasnix",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "2.5.
|
|
50
|
-
"@commitlint/cli": "21.2.
|
|
49
|
+
"@biomejs/biome": "2.5.4",
|
|
50
|
+
"@commitlint/cli": "21.2.1",
|
|
51
51
|
"@commitlint/config-conventional": "21.2.0",
|
|
52
52
|
"@commitlint/types": "21.2.0",
|
|
53
|
-
"@types/node": "24.13.
|
|
53
|
+
"@types/node": "24.13.3",
|
|
54
54
|
"@types/three": "0.184.0",
|
|
55
55
|
"husky": "9.1.7",
|
|
56
56
|
"three": "0.184.0",
|
|
57
|
-
"tsdown": "0.22.
|
|
58
|
-
"typescript": "
|
|
57
|
+
"tsdown": "0.22.8",
|
|
58
|
+
"typescript": "7.0.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@types/three": ">=0.184.0",
|