mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 11:17:36 +00:00
combine similar if/else blocks for keyboard autofire
This commit is contained in:
parent
e90f286abd
commit
b3d486c7d1
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user