From b3d486c7d1d0424b7376be0891d1bf2eb3d3273d Mon Sep 17 00:00:00 2001 From: z Date: Sun, 18 Jan 2026 12:16:09 +1300 Subject: [PATCH] combine similar if/else blocks for keyboard autofire --- data/src/emulator.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/data/src/emulator.js b/data/src/emulator.js index 6095d19..b33c114 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -3569,18 +3569,13 @@ class EmulatorJS { if (this.controls[i][j] && this.controls[i][j].value === e.keyCode) { const isAnalog = this.analogAxes.includes(j); const inputValue = isAnalog ? 0x7fff : 1; - if (e.type === "keyup") { - if (this.isAutofireEnabled(i, j) && !isAnalog) { - this.stopAutofire(i, j); - } else { - this.gameManager.simulateInput(i, j, 0); - } + const isKeyUp = e.type === "keyup"; + const value = isKeyUp ? 0 : inputValue; + + if (this.isAutofireEnabled(i, j) && !isAnalog) { + isKeyUp ? this.stopAutofire(i, j) : this.startAutofire(i, j, inputValue); } else { - if (this.isAutofireEnabled(i, j) && !isAnalog) { - this.startAutofire(i, j, inputValue); - } else { - this.gameManager.simulateInput(i, j, inputValue); - } + this.gameManager.simulateInput(i, j, value); } } }