mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
Fix non-player specific gamepad bug
This commit is contained in:
parent
16d18d543d
commit
f4ffcb3873
2 changed files with 18 additions and 17 deletions
|
@ -2463,6 +2463,7 @@ class EmulatorJS {
|
||||||
if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
|
if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
|
||||||
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
||||||
for (let i=0; i<4; i++) {
|
for (let i=0; i<4; i++) {
|
||||||
|
if (e.gamepadIndex !== i) continue;
|
||||||
for (let j=0; j<30; j++) {
|
for (let j=0; j<30; j++) {
|
||||||
if (['buttonup', 'buttondown'].includes(e.type) && (this.controls[i][j] && this.controls[i][j].value2 === e.index)) {
|
if (['buttonup', 'buttondown'].includes(e.type) && (this.controls[i][j] && this.controls[i][j].value2 === e.index)) {
|
||||||
this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
||||||
|
@ -2471,35 +2472,35 @@ class EmulatorJS {
|
||||||
if (special.includes(j)) {
|
if (special.includes(j)) {
|
||||||
if (e.axis === 'LEFT_STICK_X') {
|
if (e.axis === 'LEFT_STICK_X') {
|
||||||
if (e.value > 0) {
|
if (e.value > 0) {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 16, 0x7fff * e.value);
|
this.gameManager.simulateInput(i, 16, 0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 17, 0);
|
this.gameManager.simulateInput(i, 17, 0);
|
||||||
} else {
|
} else {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 17, -0x7fff * e.value);
|
this.gameManager.simulateInput(i, 17, -0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 16, 0);
|
this.gameManager.simulateInput(i, 16, 0);
|
||||||
}
|
}
|
||||||
} else if (e.axis === 'LEFT_STICK_Y') {
|
} else if (e.axis === 'LEFT_STICK_Y') {
|
||||||
if (e.value > 0) {
|
if (e.value > 0) {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 18, 0x7fff * e.value);
|
this.gameManager.simulateInput(i, 18, 0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 19, 0);
|
this.gameManager.simulateInput(i, 19, 0);
|
||||||
} else {
|
} else {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 19, -0x7fff * e.value);
|
this.gameManager.simulateInput(i, 19, -0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 18, 0);
|
this.gameManager.simulateInput(i, 18, 0);
|
||||||
}
|
}
|
||||||
} else if (e.axis === 'RIGHT_STICK_X') {
|
} else if (e.axis === 'RIGHT_STICK_X') {
|
||||||
if (e.value > 0) {
|
if (e.value > 0) {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 20, 0x7fff * e.value);
|
this.gameManager.simulateInput(i, 20, 0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 21, 0);
|
this.gameManager.simulateInput(i, 21, 0);
|
||||||
} else {
|
} else {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 21, -0x7fff * e.value);
|
this.gameManager.simulateInput(i, 21, -0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 20, 0);
|
this.gameManager.simulateInput(i, 20, 0);
|
||||||
}
|
}
|
||||||
} else if (e.axis === 'RIGHT_STICK_Y') {
|
} else if (e.axis === 'RIGHT_STICK_Y') {
|
||||||
if (e.value > 0) {
|
if (e.value > 0) {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 22, 0x7fff * e.value);
|
this.gameManager.simulateInput(i, 22, 0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 23, 0);
|
this.gameManager.simulateInput(i, 23, 0);
|
||||||
} else {
|
} else {
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 23, 0x7fff * e.value);
|
this.gameManager.simulateInput(i, 23, 0x7fff * e.value);
|
||||||
this.gameManager.simulateInput(e.gamepadIndex, 22, 0);
|
this.gameManager.simulateInput(i, 22, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.controls[i][j].value2 === e.axis+":"+value || value === 0) {
|
} else if (this.controls[i][j].value2 === e.axis+":"+value || value === 0) {
|
||||||
|
|
2
data/emulator.min.js
vendored
2
data/emulator.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue