Minor optimization for the shortcuts feature

This commit is contained in:
redphx 2024-05-26 07:46:09 +07:00
parent 8ba305af2b
commit 2a9b070373
2 changed files with 4 additions and 4 deletions

View File

@ -69,9 +69,9 @@ export class ControllerShortcut {
otherButtonPressed = true; otherButtonPressed = true;
pressed[index] = 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]) { if (actions[index] && !ControllerShortcut.#buttonsCache[gamepadIndex][index]) {
ControllerShortcut.#runAction(actions[index]!); setTimeout(() => ControllerShortcut.#runAction(actions[index]!), 0);
} }
} }
}); });

View File

@ -1,7 +1,7 @@
const currentGamepad = ${gamepadVar}; const currentGamepad = ${gamepadVar};
// Share button on XS controller // 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)); window.dispatchEvent(new Event(BxEvent.CAPTURE_SCREENSHOT));
} }
@ -35,7 +35,7 @@ if (btnHome) {
} }
// Listen to next button press // 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); this.inputConfiguration.useIntervalWorkerThreadForInput && this.intervalWorker ? this.intervalWorker.scheduleTimer(intervalMs) : this.pollGamepadssetTimeoutTimerID = setTimeout(this.pollGamepads, intervalMs);
// Hijack this button // Hijack this button