[HOTFIX] getEjsControls should return null if no controls for core or default

This commit is contained in:
Georges-Antoine Assi
2025-09-04 17:56:53 -04:00
parent 5c824b3120
commit e2bbddc84d
2 changed files with 32 additions and 17 deletions

View File

@@ -79,31 +79,45 @@ export default defineStore("config", {
},
getEJSControls(
core: string | null,
): Record<number, Record<number, EjsControlsButton>> {
const defaultControls = {
0: this.config.EJS_CONTROLS["default"]?.["_0"] || {},
1: this.config.EJS_CONTROLS["default"]?.["_1"] || {},
2: this.config.EJS_CONTROLS["default"]?.["_2"] || {},
3: this.config.EJS_CONTROLS["default"]?.["_3"] || {},
};
if (!core) return defaultControls;
): Record<number, Record<number, EjsControlsButton>> | null {
const defaultControls = this.config.EJS_CONTROLS["default"];
if (!core) {
if (!defaultControls) return null;
return {
0: defaultControls["_0"],
1: defaultControls["_1"],
2: defaultControls["_2"],
3: defaultControls["_3"],
};
}
const coreControls = this.config.EJS_CONTROLS[core];
if (!coreControls) return null;
if (!defaultControls) {
return {
0: coreControls["_0"],
1: coreControls["_1"],
2: coreControls["_2"],
3: coreControls["_3"],
};
}
return {
0: {
...defaultControls[0],
...(this.config.EJS_CONTROLS[core]?.["_0"] || {}),
...defaultControls["_0"],
...coreControls["_0"],
},
1: {
...defaultControls[1],
...(this.config.EJS_CONTROLS[core]?.["_1"] || {}),
...defaultControls["_1"],
...coreControls["_1"],
},
2: {
...defaultControls[2],
...(this.config.EJS_CONTROLS[core]?.["_2"] || {}),
...defaultControls["_2"],
...coreControls["_2"],
},
3: {
...defaultControls[3],
...(this.config.EJS_CONTROLS[core]?.["_3"] || {}),
...defaultControls["_3"],
...coreControls["_3"],
},
};
},

View File

@@ -125,7 +125,8 @@ window.EJS_defaultOptions = {
rewindEnabled: "enabled",
...coreOptions,
};
window.EJS_defaultControls = configStore.getEJSControls(props.core);
const ejsControls = configStore.getEJSControls(props.core);
if (ejsControls) window.EJS_defaultControls = ejsControls;
// Set a valid game name
window.EJS_gameName = romRef.value.fs_name_no_tags
.replace(INVALID_CHARS_REGEX, "")