From 2a9b07037304324da02597237554a859604e4774 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 26 May 2024 07:46:09 +0700 Subject: [PATCH] Minor optimization for the shortcuts feature --- src/modules/controller-shortcut.ts | 4 ++-- src/modules/patches/controller-shortcuts.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/controller-shortcut.ts b/src/modules/controller-shortcut.ts index eade7c4..cbfba39 100644 --- a/src/modules/controller-shortcut.ts +++ b/src/modules/controller-shortcut.ts @@ -69,9 +69,9 @@ export class ControllerShortcut { otherButtonPressed = true; pressed[index] = true; - // If this is newly pressed button > run action + // If this is newly pressed button -> run action if (actions[index] && !ControllerShortcut.#buttonsCache[gamepadIndex][index]) { - ControllerShortcut.#runAction(actions[index]!); + setTimeout(() => ControllerShortcut.#runAction(actions[index]!), 0); } } }); diff --git a/src/modules/patches/controller-shortcuts.js b/src/modules/patches/controller-shortcuts.js index 03dc14a..18e269d 100644 --- a/src/modules/patches/controller-shortcuts.js +++ b/src/modules/patches/controller-shortcuts.js @@ -1,7 +1,7 @@ const currentGamepad = ${gamepadVar}; // Share button on XS controller -if (currentGamepad.buttons[17] && currentGamepad.buttons[17].value === 1) { +if (currentGamepad.buttons[17] && currentGamepad.buttons[17].pressed) { window.dispatchEvent(new Event(BxEvent.CAPTURE_SCREENSHOT)); } @@ -35,7 +35,7 @@ if (btnHome) { } // Listen to next button press - const intervalMs = 50; + const intervalMs = 16; this.inputConfiguration.useIntervalWorkerThreadForInput && this.intervalWorker ? this.intervalWorker.scheduleTimer(intervalMs) : this.pollGamepadssetTimeoutTimerID = setTimeout(this.pollGamepads, intervalMs); // Hijack this button