Merge 'main-upstream' into screenshot

This commit is contained in:
Allan Niles 2025-05-14 09:54:30 -06:00
commit 9e2a5d2aab
No known key found for this signature in database
GPG Key ID: 4801D0A65C62A5B6
3 changed files with 25 additions and 13 deletions

View File

@ -34,7 +34,7 @@ class EJS_GameManager {
getVideoDimensions: this.Module.cwrap("get_video_dimensions", "number", ["string"])
}
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();

View File

@ -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 || "");
@ -1125,13 +1123,20 @@ 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 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] = "";
}
}
setTimeout(this.updateGamepadLabels.bind(this), 10);
})
this.gamepad.on("axischanged", this.gamepadEvent.bind(this));
@ -1159,8 +1164,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";
@ -3249,7 +3254,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
}
@ -3424,15 +3429,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()) {
@ -3698,6 +3703,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") {
@ -3707,7 +3713,7 @@ class EmulatorJS {
})
} else {
e.target.classList.add("ejs_virtualGamepad_button_down");
this.gameManager.simulateInput(0, value, 1);
this.gameManager.simulateInput(0, value, downValue);
}
})
}

View File

@ -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});
}
});