diff --git a/backend/config/config_manager.py b/backend/config/config_manager.py index fc65e257d..bba192195 100644 --- a/backend/config/config_manager.py +++ b/backend/config/config_manager.py @@ -41,6 +41,7 @@ class Config: PLATFORMS_VERSIONS: dict[str, str] ROMS_FOLDER_NAME: str FIRMWARE_FOLDER_NAME: str + EJS_CORE_OPTIONS: dict[str, dict[str, str]] HIGH_PRIO_STRUCTURE_PATH: str def __init__(self, **entries): @@ -149,6 +150,7 @@ class ConfigManager: FIRMWARE_FOLDER_NAME=pydash.get( self._raw_config, "filesystem.firmware_folder", "bios" ), + EJS_CORE_OPTIONS=pydash.get(self._raw_config, "emulatorjs", {}), ) def _validate_config(self): @@ -231,6 +233,17 @@ class ConfigManager: ) sys.exit(3) + if not isinstance(self.config.EJS_CORE_OPTIONS, dict): + log.critical("Invalid config.yml: emulatorjs must be a dictionary") + sys.exit(3) + else: + for core, options in self.config.EJS_CORE_OPTIONS.items(): + if not isinstance(options, dict): + log.critical( + f"Invalid config.yml: emulatorjs.{core} must be a dictionary" + ) + sys.exit(3) + def get_config(self) -> Config: with open(self.config_file) as config_file: self._raw_config = yaml.load(config_file, Loader=SafeLoader) or {} diff --git a/backend/endpoints/configs.py b/backend/endpoints/configs.py index 67f92e2e2..eef5fc9bb 100644 --- a/backend/endpoints/configs.py +++ b/backend/endpoints/configs.py @@ -35,6 +35,7 @@ def get_config() -> ConfigResponse: EXCLUDED_MULTI_PARTS_FILES=cfg.EXCLUDED_MULTI_PARTS_FILES, PLATFORMS_BINDING=cfg.PLATFORMS_BINDING, PLATFORMS_VERSIONS=cfg.PLATFORMS_VERSIONS, + EJS_CORE_OPTIONS=cfg.EJS_CORE_OPTIONS, ) except ConfigNotReadableException as exc: log.critical(exc.message) diff --git a/backend/endpoints/responses/config.py b/backend/endpoints/responses/config.py index 0b537501c..3fcb28b40 100644 --- a/backend/endpoints/responses/config.py +++ b/backend/endpoints/responses/config.py @@ -10,3 +10,4 @@ class ConfigResponse(TypedDict): EXCLUDED_MULTI_PARTS_FILES: list[str] PLATFORMS_BINDING: dict[str, str] PLATFORMS_VERSIONS: dict[str, str] + EJS_CORE_OPTIONS: dict[str, dict[str, str]] diff --git a/backend/tests/config/fixtures/config/config.yml b/backend/tests/config/fixtures/config/config.yml index 72a368b23..7bcce587a 100644 --- a/backend/tests/config/fixtures/config/config.yml +++ b/backend/tests/config/fixtures/config/config.yml @@ -29,3 +29,9 @@ system: filesystem: roms_folder: "ROMS" firmware_folder: "BIOS" + +emulatorjs: + parallel_n64: + vsync: disable + snes9x: + snes9x_region: ntsc diff --git a/backend/tests/config/test_config_loader.py b/backend/tests/config/test_config_loader.py index ab8ffdad0..fdeb2c5bf 100644 --- a/backend/tests/config/test_config_loader.py +++ b/backend/tests/config/test_config_loader.py @@ -19,6 +19,10 @@ def test_config_loader(): assert loader.config.PLATFORMS_VERSIONS == {"naomi": "arcade"} assert loader.config.ROMS_FOLDER_NAME == "ROMS" assert loader.config.FIRMWARE_FOLDER_NAME == "BIOS" + assert loader.config.EJS_CORE_OPTIONS == { + "parallel_n64": {"vsync": "disable"}, + "snes9x": {"snes9x_region": "ntsc"}, + } def test_empty_config_loader(): @@ -38,3 +42,4 @@ def test_empty_config_loader(): assert loader.config.PLATFORMS_VERSIONS == {} assert loader.config.ROMS_FOLDER_NAME == "roms" assert loader.config.FIRMWARE_FOLDER_NAME == "bios" + assert loader.config.EJS_CORE_OPTIONS == {} diff --git a/examples/config.example.yml b/examples/config.example.yml index d4f7656b2..10d5be04c 100644 --- a/examples/config.example.yml +++ b/examples/config.example.yml @@ -46,3 +46,12 @@ system: # The folder name where your roms are located filesystem: {} # { roms_folder: 'roms' } For example if your folder structure is /home/user/library/roms_folder + +# EmulatorJS per-core options +emulatorjs: + parallel_n64: # Use the exact core name + vsync: disable + snes9x: + snes9x_region: ntsc + default: # These settings apply to all cores + fps: show diff --git a/frontend/src/__generated__/models/ConfigResponse.ts b/frontend/src/__generated__/models/ConfigResponse.ts index 387c5b00f..09718a036 100644 --- a/frontend/src/__generated__/models/ConfigResponse.ts +++ b/frontend/src/__generated__/models/ConfigResponse.ts @@ -11,5 +11,6 @@ export type ConfigResponse = { EXCLUDED_MULTI_PARTS_FILES: Array; PLATFORMS_BINDING: Record; PLATFORMS_VERSIONS: Record; + EJS_CORE_OPTIONS: Record>; }; diff --git a/frontend/src/components/Settings/UserInterface/LanguageSelector.vue b/frontend/src/components/Settings/UserInterface/LanguageSelector.vue index 6e64c09c5..4ace8acee 100644 --- a/frontend/src/components/Settings/UserInterface/LanguageSelector.vue +++ b/frontend/src/components/Settings/UserInterface/LanguageSelector.vue @@ -1,5 +1,4 @@