three-gamepad-controls 0.13.0 → 0.13.1
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/gamepad-manager.js +8 -7
- package/package.json +1 -1
package/dist/gamepad-manager.js
CHANGED
|
@@ -47,18 +47,19 @@ var GamepadManager = class {
|
|
|
47
47
|
return selectedGamepad;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Clears the active gamepad when
|
|
50
|
+
* Clears the active gamepad when its browser-assigned index matches the
|
|
51
|
+
* disconnecting gamepad.
|
|
51
52
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Gamepad API snapshots are not guaranteed to preserve JavaScript object
|
|
54
|
+
* identity between events and polls, so the active device is correlated by
|
|
55
|
+
* its logical slot. A matching disconnection defers any replacement until
|
|
56
|
+
* the next update.
|
|
56
57
|
*
|
|
57
58
|
* @param gamepad - Gamepad snapshot that disconnected.
|
|
58
59
|
* @returns The previously active gamepad when it was cleared, otherwise `null`.
|
|
59
60
|
*/
|
|
60
61
|
disconnect(gamepad) {
|
|
61
|
-
if (this.activeGamepad !== gamepad) return null;
|
|
62
|
+
if (this.activeGamepad === null || this.activeGamepad.index !== gamepad.index) return null;
|
|
62
63
|
const disconnectedGamepad = this.activeGamepad;
|
|
63
64
|
this.activeGamepad = null;
|
|
64
65
|
this.#connectionDeferredUntilUpdate = true;
|
|
@@ -86,7 +87,7 @@ var GamepadManager = class {
|
|
|
86
87
|
}
|
|
87
88
|
const previousGamepad = this.activeGamepad;
|
|
88
89
|
const nextGamepad = this.#getGamepadByIndex(previousGamepad.index);
|
|
89
|
-
if (
|
|
90
|
+
if (nextGamepad === null) {
|
|
90
91
|
this.activeGamepad = null;
|
|
91
92
|
this.#connectionDeferredUntilUpdate = true;
|
|
92
93
|
return {
|
package/package.json
CHANGED