Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aderumier/2c8c558aa91405c0b1d81017a5e2db21 to your computer and use it in GitHub Desktop.
Save aderumier/2c8c558aa91405c0b1d81017a5e2db21 to your computer and use it in GitHub Desktop.
cat emulatorlauncher
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
import yaml
from importlib import import_module
import configgen
from configgen.Emulator import Emulator, _dict_merge, _load_defaults
from configgen.emulatorlauncher import launch
from typing import TYPE_CHECKING, Any
from pathlib import Path
def _new_load_system_config(system_name: str, default_yml: Path, default_arch_yml: Path, /) -> dict[str, Any]:
defaults = _load_defaults(system_name, default_yml, default_arch_yml)
###RGS LOADING###
default_rgs_yml = Path('/userdata/system/rgs/configgen-defaults.yml')
with default_rgs_yml.open('r') as f:
rgs_defaults = yaml.load(f, Loader=yaml.CLoader)
if system_name in rgs_defaults:
_dict_merge(defaults, rgs_defaults[system_name])
###END RGS LOADING###
# In the yaml files, the "options" structure is not flat, so we have to flatten it here
# because the options are flat in batocera.conf to make it easier for end users to edit
data: dict[str, Any] = {'emulator': defaults['emulator'], 'core': defaults['core']}
if 'options' in defaults:
_dict_merge(data, defaults['options'])
return data
def _new_get_generator(emulator: str):
yuzuemu = {}
yuzuemu['yuzu'] = 1
yuzuemu['citron'] = 1
yuzuemu['citron-optimized-pgo'] = 1
yuzuemu['torzu'] = 1
yuzuemu['sudachi'] = 1
if emulator in yuzuemu:
from generators.yuzu.yuzuMainlineGenerator import YuzuMainlineGenerator
return YuzuMainlineGenerator()
if emulator == 'ryujinx':
from generators.ryujinx.ryujinxMainlineGenerator import RyujinxMainlineGenerator
return RyujinxMainlineGenerator()
if emulator == 'clonehero':
from generators.clonehero.CloneHeroGenerator import CloneHeroGenerator
return CloneHeroGenerator()
if emulator == 'gemrb':
from generators.gemrb.GemRBGenerator import GemRBGenerator
return GemRBGenerator()
if emulator == 'shadps4':
from generators.shadps4.shadPS4Generator import shadPS4Generator
return shadPS4Generator()
if emulator == 'wine':
from generators.winebat.WineBatGenerator import WineBatGenerator
return WineBatGenerator()
if emulator == 'fpinball':
from generators.fpinball.fpinballGenerator import FpinballGenerator
return FpinballGenerator()
configgen.Emulator._load_system_config = _new_load_system_config
configgen.emulatorlauncher.get_generator = _new_get_generator
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(launch())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment