From d1408b42d5d1167624db9d6ed396a713768e03b7 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Sun, 11 May 2025 10:48:38 -0500 Subject: [PATCH 1/5] Change retroarch.cfg path --- data/src/GameManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/src/GameManager.js b/data/src/GameManager.js index 6e74eae..d99a4d9 100644 --- a/data/src/GameManager.js +++ b/data/src/GameManager.js @@ -33,7 +33,7 @@ class EJS_GameManager { setVideoRoation: this.Module.cwrap('set_video_rotation', 'null', ['number']) } - this.writeFile("/home/web_user/retroarch/userdata/retroarch.cfg", this.getRetroArchCfg()); + this.writeFile("/home/web_user/.config/retroarch/retroarch.cfg", this.getRetroArchCfg()); this.writeConfigFile(); this.initShaders(); From b8061eaeef6405279ff719f6e4267a8b8d81df6a Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Sun, 11 May 2025 23:19:56 -0500 Subject: [PATCH 2/5] Add joystickInput for button inputs --- data/src/emulator.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/data/src/emulator.js b/data/src/emulator.js index 7720584..9565536 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -3409,15 +3409,15 @@ class EmulatorJS { { "type": "button", "text": "B", "id": "b", "location": "right", "left": -10, "top": 95, "input_value": 1, "bold": true }, { "type": "button", "text": "A", "id": "a", "location": "right", "left": 40, "top": 150, "input_value": 0, "bold": true }, { "type": "zone", "id": "stick", "location": "left", "left": "50%", "top": "100%", "joystickInput": true, "inputValues": [16, 17, 18, 19] }, - { "type": "zone", "id": "dpad", "location": "left", "left": "50%", "top": "0%", "joystickInput": true, "inputValues": [20, 21, 22, 23] }, + { "type": "zone", "id": "dpad", "location": "left", "left": "50%", "top": "0%", "joystickInput": false, "inputValues": [4, 5, 6, 7] }, { "type": "button", "text": "Start", "id": "start", "location": "center", "left": 30, "top": -10, "fontSize": 15, "block": true, "input_value": 3 }, { "type": "button", "text": "L", "id": "l", "block": true, "location": "top", "left": 10, "top": -40, "bold": true, "input_value": 10 }, { "type": "button", "text": "R", "id": "r", "block": true, "location": "top", "right": 10, "top": -40, "bold": true, "input_value": 11 }, { "type": "button", "text": "Z", "id": "z", "block": true, "location": "top", "left": 10, "bold": true, "input_value": 12 }, - { "fontSize": 20, "type": "button", "text": "CU", "id": "cu", "location": "right", "left": 25, "top": -65, "input_value": 23 }, - { "fontSize": 20, "type": "button", "text": "CD", "id": "cd", "location": "right", "left": 25, "top": 15, "input_value": 22 }, - { "fontSize": 20, "type": "button", "text": "CL", "id": "cl", "location": "right", "left": -15, "top": -25, "input_value": 21 }, - { "fontSize": 20, "type": "button", "text": "CR", "id": "cr", "location": "right", "left": 65, "top": -25, "input_value": 20 } + { "fontSize": 20, "type": "button", "text": "CU", "id": "cu", "joystickInput": true, "location": "right", "left": 25, "top": -65, "input_value": 23 }, + { "fontSize": 20, "type": "button", "text": "CD", "id": "cd", "joystickInput": true, "location": "right", "left": 25, "top": 15, "input_value": 22 }, + { "fontSize": 20, "type": "button", "text": "CL", "id": "cl", "joystickInput": true, "location": "right", "left": -15, "top": -25, "input_value": 21 }, + { "fontSize": 20, "type": "button", "text": "CR", "id": "cr", "joystickInput": true, "location": "right", "left": 65, "top": -25, "input_value": 20 } ]; info.push(...speedControlButtons); } else if ("nds" === this.getControlScheme()) { @@ -3683,6 +3683,7 @@ class EmulatorJS { } elems[info[i].location].appendChild(button); const value = info[i].input_new_cores || info[i].input_value; + let downValue = info[i].joystickInput === true ? 0x7fff : 1; this.addEventListener(button, "touchstart touchend touchcancel", (e) => { e.preventDefault(); if (e.type === 'touchend' || e.type === 'touchcancel') { @@ -3692,7 +3693,7 @@ class EmulatorJS { }) } else { e.target.classList.add("ejs_virtualGamepad_button_down"); - this.gameManager.simulateInput(0, value, 1); + this.gameManager.simulateInput(0, value, downValue); } }) } From 908bccd63c247f3f70d0b979d7bc2181fdf11985 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Sun, 11 May 2025 23:53:56 -0500 Subject: [PATCH 3/5] Cleanup gamepad dropdown --- data/src/emulator.js | 14 ++++++++++---- data/src/gamepad.js | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/src/emulator.js b/data/src/emulator.js index 9565536..131543c 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -1114,13 +1114,19 @@ class EmulatorJS { if (!this.gamepadLabels) return; for (let i = 0; i < this.gamepadSelection.length; i++) { if (this.gamepadSelection[i] === "") { - this.gamepadSelection[i] = this.gamepad.gamepads[e.gamepadIndex].id; + this.gamepadSelection[i] = this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index; break; } } this.updateGamepadLabels(); }) this.gamepad.on('disconnected', (e) => { + const gamepadSelection = this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index; + for (let i = 0; i < this.gamepadSelection.length; i++) { + if (this.gamepadSelection[i] === gamepadSelection) { + this.gamepadSelection[i] = ""; + } + } setTimeout(this.updateGamepadLabels.bind(this), 10); }) this.gamepad.on('axischanged', this.gamepadEvent.bind(this)); @@ -1148,8 +1154,8 @@ class EmulatorJS { this.gamepadLabels[i].appendChild(def); for (let j = 0; j < this.gamepad.gamepads.length; j++) { const opt = this.createElement("option"); - opt.setAttribute("value", this.gamepad.gamepads[j].id); - opt.innerText = this.gamepad.gamepads[j].id; + opt.setAttribute("value", this.gamepad.gamepads[j].id + "_" + this.gamepad.gamepads[j].index); + opt.innerText = this.gamepad.gamepads[j].id + "_" + this.gamepad.gamepads[j].index; this.gamepadLabels[i].appendChild(opt); } this.gamepadLabels[i].value = this.gamepadSelection[i] || "notconnected"; @@ -3234,7 +3240,7 @@ class EmulatorJS { } gamepadEvent(e) { if (!this.started) return; - const gamepadIndex = this.gamepadSelection.indexOf(this.gamepad.gamepads[e.gamepadIndex].id); + const gamepadIndex = this.gamepadSelection.indexOf(this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index); if (gamepadIndex < 0) { return; // Gamepad not set anywhere } diff --git a/data/src/gamepad.js b/data/src/gamepad.js index 5b05e25..c0fb4dc 100644 --- a/data/src/gamepad.js +++ b/data/src/gamepad.js @@ -100,6 +100,12 @@ class GamepadHandler { }) if (!hasGamepad) { this.gamepads.push(gamepads[index]); + this.gamepads.sort((a, b) => { + if (a == null && b == null) return 0; + if (a == null) return 1; + if (b == null) return -1; + return a.index - b.index; + }); this.dispatchEvent('connected', {gamepadIndex: gamepad.index}); } }); From a1efedfbead8c0c95827f4b0fb95b95aa97c22e4 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Mon, 12 May 2025 00:01:23 -0500 Subject: [PATCH 4/5] Fix case where 2 gamepads are disconnected at once --- data/src/emulator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/src/emulator.js b/data/src/emulator.js index 131543c..b632a4f 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -1121,7 +1121,8 @@ class EmulatorJS { this.updateGamepadLabels(); }) this.gamepad.on('disconnected', (e) => { - const gamepadSelection = this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index; + const gamepadIndex = this.gamepad.gamepads.indexOf(this.gamepad.gamepads.find(f => f.index == e.gamepadIndex)); + const gamepadSelection = this.gamepad.gamepads[gamepadIndex].id + "_" + this.gamepad.gamepads[gamepadIndex].index; for (let i = 0; i < this.gamepadSelection.length; i++) { if (this.gamepadSelection[i] === gamepadSelection) { this.gamepadSelection[i] = ""; From f70e897bd168adac581f9a887bbf63c9239d9b16 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Mon, 12 May 2025 20:57:12 -0500 Subject: [PATCH 5/5] Remove this.listeners property --- data/src/emulator.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/data/src/emulator.js b/data/src/emulator.js index b632a4f..1205d84 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -80,7 +80,6 @@ class EmulatorJS { element.addEventListener(listeners[i], callback); const data = { cb: callback, elem: element, listener: listeners[i] }; rv.push(data); - this.listeners.push(data); } return rv; } @@ -221,7 +220,6 @@ class EmulatorJS { if (this.config.defaultControllers) this.defaultControllers = this.config.defaultControllers; this.muted = false; this.paused = true; - this.listeners = []; this.missingLang = []; this.setElements(element); this.setColor(this.config.color || "");