mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 10:56:30 +00:00
Fix gamepad support (see changelog)
This commit is contained in:
parent
6ea21a9748
commit
093eb492e5
3 changed files with 12 additions and 4 deletions
|
@ -8,6 +8,11 @@
|
||||||
- Added picodrive core (sega32x)
|
- Added picodrive core (sega32x)
|
||||||
- Cleaned up documentation
|
- Cleaned up documentation
|
||||||
- Fixed/updated rar de-compression
|
- Fixed/updated rar de-compression
|
||||||
|
- Added segaMD, segaCD, sega32x button labels and virtual gamepad (Thanks to [@n-at](https://github.com/n-at))
|
||||||
|
- Added ability to use threads (pre compiled cores not yet available)
|
||||||
|
- Fixed reversed gamepad button events (down was up, up was down)
|
||||||
|
- Fixed Gamepad axis release not triggering
|
||||||
|
- Add ***highly beta*** psp core - see readme
|
||||||
|
|
||||||
# 4.0.4 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/41491a738cf92ef9cee7d53f323aa2ab9732c053)
|
# 4.0.4 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/41491a738cf92ef9cee7d53f323aa2ab9732c053)
|
||||||
- Fix cheats "x" button
|
- Fix cheats "x" button
|
||||||
|
|
|
@ -2228,7 +2228,7 @@ class EmulatorJS {
|
||||||
for (let i=0; i<4; i++) {
|
for (let i=0; i<4; i++) {
|
||||||
for (let j=0; j<27; j++) {
|
for (let j=0; j<27; 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 === 'buttondown' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
||||||
} else if (e.type === "axischanged") {
|
} else if (e.type === "axischanged") {
|
||||||
if (this.controls[i][j] && typeof this.controls[i][j].value2 === 'string' && this.controls[i][j].value2.split(":")[0] === e.axis) {
|
if (this.controls[i][j] && typeof this.controls[i][j].value2 === 'string' && this.controls[i][j].value2.split(":")[0] === e.axis) {
|
||||||
if (special.includes(j)) {
|
if (special.includes(j)) {
|
||||||
|
|
|
@ -42,13 +42,16 @@ class GamepadHandler {
|
||||||
hasGamepad = true;
|
hasGamepad = true;
|
||||||
|
|
||||||
oldGamepad.axes.forEach((axis, axisIndex) => {
|
oldGamepad.axes.forEach((axis, axisIndex) => {
|
||||||
if (gamepad.axes[axisIndex] !== axis) {
|
const val = (axis < 0.01 && axis > -0.01) ? 0 : axis;
|
||||||
|
const newVal = (gamepad.axes[axisIndex] < 0.01 && gamepad.axes[axisIndex] > -0.01) ? 0 : gamepad.axes[axisIndex];
|
||||||
|
if (newVal !== val) {
|
||||||
const axis = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'][axisIndex];
|
const axis = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'][axisIndex];
|
||||||
if (!axis) return;
|
if (!axis) return;
|
||||||
this.dispatchEvent('axischanged', {axis: axis, value: gamepad.axes[axisIndex], index: gamepad.index, gamepadIndex: gamepad.index});
|
this.dispatchEvent('axischanged', {axis: axis, value: newVal, index: gamepad.index, gamepadIndex: gamepad.index});
|
||||||
}
|
}
|
||||||
gamepadToSave.axes[axisIndex] = axis;
|
gamepadToSave.axes[axisIndex] = newVal;
|
||||||
})
|
})
|
||||||
|
|
||||||
gamepad.buttons.forEach((button, buttonIndex) => {
|
gamepad.buttons.forEach((button, buttonIndex) => {
|
||||||
let pressed = oldGamepad.buttons[buttonIndex] === 1.0;
|
let pressed = oldGamepad.buttons[buttonIndex] === 1.0;
|
||||||
if (typeof oldGamepad.buttons[buttonIndex] === "object") {
|
if (typeof oldGamepad.buttons[buttonIndex] === "object") {
|
||||||
|
|
Loading…
Reference in a new issue