From 34f19cec040fd0ff0c191696546d7532d0eb405d Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Fri, 17 May 2024 21:27:11 +0200 Subject: [PATCH] removed the selected device in the storage, allowing changing main gamepad with a refresh --- src/inputs-controller.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 3bbce891e6c..77a7cc88817 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -136,9 +136,6 @@ export class InputsController { init(): void { this.events = this.scene.game.events; - if (localStorage.hasOwnProperty('selectedDevice')) { - this.selectedDevice = JSON.parse(localStorage.getItem('selectedDevice')); - } this.scene.game.events.on(Phaser.Core.Events.BLUR, () => { this.loseFocus() }) @@ -275,7 +272,6 @@ export class InputsController { initChosenGamepad(gamepadName?: String): void { if (gamepadName) this.selectedDevice[Device.GAMEPAD] = gamepadName.toLowerCase(); - localStorage.setItem('selectedDevice', JSON.stringify(this.selectedDevice)); const handler = this.scene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; handler && handler.updateChosenGamepadDisplay() } @@ -288,7 +284,6 @@ export class InputsController { initChosenLayoutKeyboard(layoutKeyboard?: String): void { if (layoutKeyboard) this.selectedDevice[Device.KEYBOARD] = layoutKeyboard.toLowerCase(); - localStorage.setItem('selectedDevice', JSON.stringify(this.selectedDevice)); const handler = this.scene.ui?.handlers[Mode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler; handler && handler.updateChosenKeyboardDisplay() } @@ -325,7 +320,6 @@ export class InputsController { * @param thisGamepad The gamepad that is being set up. */ setupGamepad(thisGamepad: Phaser.Input.Gamepad.Gamepad): void { - this.lastSource = 'gamepad'; const allGamepads = this.getGamepadsName(); for (const gamepad of allGamepads) { const gamepadID = gamepad.toLowerCase(); @@ -336,7 +330,7 @@ export class InputsController { this.configs[gamepadID] = config; this.scene.gameData?.saveMappingConfigs(gamepadID, this.configs[gamepadID]); } - this.initChosenGamepad(this.selectedDevice[Device.GAMEPAD]) + this.lastSource = 'gamepad'; } /**