diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index c25457931..94bba5dac 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -140,7 +140,7 @@ export class InputsController { } setupGamepad(thisGamepad: Phaser.Input.Gamepad.Gamepad): void { - let gamepadID = thisGamepad.id.toLowerCase(); + let gamepadID = this.chosenGamepad?.toLowerCase() || thisGamepad.id.toLowerCase(); const mappedPad = this.mapGamepad(gamepadID); this.player['mapping'] = mappedPad.gamepadMapping; } @@ -181,7 +181,7 @@ export class InputsController { } gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { - if (!this.gamepadSupport) return; + if (!this.gamepadSupport || pad.id.toLowerCase() !== this.chosenGamepad.toLowerCase()) return; const actionMapping = this.getActionGamepadMapping(); const buttonDown = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; if (buttonDown !== undefined) { @@ -194,7 +194,7 @@ export class InputsController { } gamepadButtonUp(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { - if (!this.gamepadSupport) return; + if (!this.gamepadSupport || pad.id.toLowerCase() !== this.chosenGamepad.toLowerCase()) return; const actionMapping = this.getActionGamepadMapping(); const buttonUp = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; if (buttonUp !== undefined) {