def generate(self, system, rom, playersControllers): if not system.config['configfile']: dolphinSettings = UnixSettings(rhgamestationFiles.dolphinIni, separator=' ') dolphinControllers.generateControllerConfig( system, playersControllers) dolphinGFX = UnixSettings(rhgamestationFiles.dolphinGFX, separator=' ') #Draw or not FPS showFPS = "True" if system.config['showFPS'] == 'true' else "False" dolphinGFX.save("ShowFPS", showFPS) # Disable analytics dolphinSettings.save("PermissionAsked", "True") dolphinSettings.save("Enabled", "True") dolphinSettings.save("AutoHideCursor", "True") dolphinSettings.save("WiimoteContinuousScanning", "True") dolphinSettings.save("ConfirmStop", "False") commandArray = [ rhgamestationFiles.rhgamestationBins[system.config['emulator']], "-e", rom ] if 'args' in system.config and system.config['args'] is not None: commandArray.extend(system.config['args']) return Command.Command(videomode=system.config['videomode'], array=commandArray, env={ "XDG_CONFIG_HOME": rhgamestationFiles.CONF, "XDG_DATA_HOME": rhgamestationFiles.SAVES })
def updateLibretroConfigCustom(version): # Version is unsued so far, but who knows, one day try: # Read files sourceSettings = UnixSettings(rhgamestationFiles.retroarchInitCustomOrigin, separator=' ') sourceConf = sourceSettings.loadFile() destFiles = [rhgamestationFiles.retroarchCustomOrigin, rhgamestationFiles.retroarchCustom] for file in destFiles: if not os.path.isfile(file) : continue destSettings = UnixSettings(file, separator=' ') destConf = destSettings.loadFile() missingKeys = {} # Compare missing keysoprint "Compare keys ..." for key, value in sourceConf.iteritems(): if key not in destConf: missingKeys[key] = value # Save print "Save {}".format(file) for key, value in missingKeys.iteritems(): destSettings.save(key, value) missingKeys.clear() print("LibretroConfig 's configuration successfully upgraded") return True except: print "Libretro update failed !" return False
def generateAdf(fullName, romPath, uaeName, amigaHardware, controller): print("execute ADF : <%s> on <%s>" % ("/amiberry", romPath + "/" + uaeName)) # ----- check Bios ----- if not amiberryConfig.hasKickstarts(amigaHardware, whdl=False): raise IOError("No %s kickstarts found" % amigaHardware) amiberryConfig.initMountpoint(rhgamestationFiles.amiberryMountPoint) # ----- Create uae configuration file ----- uaeconfig = os.path.join(rhgamestationFiles.amiberryMountPoint, "amiberry", "conf", "uaeconfig.uae") if os.path.exists(uaeconfig): os.remove(uaeconfig) fUaeConfig = UnixSettings(uaeconfig, separator='', defaultComment=';') amiberryController.generateControllerConf(fUaeConfig) amiberryController.generateSpecialKeys(fUaeConfig, controller) amiberryConfig.generateGUIConf(fUaeConfig) amiberryConfig.generateKickstartPath(fUaeConfig, amigaHardware) amiberryConfig.generateHardwareConf(fUaeConfig, amigaHardware) floppiesManagement(fUaeConfig, romPath, uaeName) amiberryConfig.generateGraphicConf(fUaeConfig)
def generateCD(fullName, romPath, uaeName, amigaHardware, controller): # TODO Also allow to use Amiga CD ? # ----- check Bios ----- if not amiberryConfig.hasCD32Kickstarts(): raise IOError("No CD32 kickstarts found") print("execute CD32 : <%s> on <%s>" % ("/amiberry", romPath + "/" + uaeName)) amiberryConfig.initMountpoint(rhgamestationFiles.amiberryMountPoint) # ----- Create uae configuration file ----- uaeconfig = os.path.join(rhgamestationFiles.amiberryMountPoint, "amiberry", "conf", "uaeconfig.uae") if os.path.exists(uaeconfig): os.remove(uaeconfig) fUaeConfig = UnixSettings(uaeconfig, separator='', defaultComment=';') amiberryController.generateCD32ControllerConf(fUaeConfig, controller) amiberryConfig.generateGUIConf(fUaeConfig, "false") amiberryConfig.generateKickstartPathCD32(fUaeConfig, amigaHardware) amiberryConfig.generateHardwareConf(fUaeConfig, amigaHardware) generateCD32Conf(fUaeConfig, romPath, uaeName) amiberryConfig.generateCD32GraphicConf(fUaeConfig)
def setPreffered(): recalSettings = UnixSettings(recalboxFiles.recalboxConf) esVideoMode = recalSettings.load('system.es.videomode') if esVideoMode is None: os.system("tvservice -p") else: setVideoMode(esVideoMode)
def configure(self, system): recalSettings = UnixSettings(recalboxFiles.recalboxConf) globalSettings = recalSettings.loadAll('global') system.config['specials'] = recalSettings.load( 'system.emulators.specialkeys', 'default') self.updateConfiguration(system, globalSettings) self.updateConfiguration(system, recalSettings.loadAll(system.name))
def configure(self, emulator='default', core='default', ratio='auto', netplay=None): recalSettings = UnixSettings(recalboxFiles.recalboxConf) globalSettings = recalSettings.loadAll('global') self.config['specials'] = recalSettings.load('system.emulators.specialkeys', 'default') self.updateConfiguration(globalSettings) self.updateConfiguration(recalSettings.loadAll(self.name)) self.updateForcedConfig(emulator, core, ratio)
def __init__(self, name, rom): self.name = name # read the configuration from the system name self.config = Emulator.get_system_config(self.name, "/recalbox/system/configgen/configgen-defaults.yml", "/recalbox/system/configgen/configgen-defaults-arch.yml") if "emulator" not in self.config or self.config["emulator"] == "": eslog.log("no emulator defined. exiting.") raise Exception("No emulator found") # load configuration from batocera.conf recalSettings = UnixSettings(batoceraFiles.batoceraConf) globalSettings = recalSettings.loadAll('global') systemSettings = recalSettings.loadAll(self.name) gameSettings = recalSettings.loadAll(os.path.basename(rom)) # update config Emulator.updateConfiguration(self.config, globalSettings) Emulator.updateConfiguration(self.config, systemSettings) Emulator.updateConfiguration(self.config, gameSettings) self.updateDrawFPS() # update renderconfig self.renderconfig = {} if "shaderset" in self.config and self.config["shaderset"] != "none": self.renderconfig = Emulator.get_generic_config(self.name, "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults-arch.yml") if "shaderset" not in self.config: # auto self.renderconfig = Emulator.get_generic_config(self.name, "/usr/share/batocera/shaders/configs/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/rendering-defaults-arch.yml") systemSettings = recalSettings.loadAll(self.name + "-renderer") gameSettings = recalSettings.loadAll(os.path.basename(rom) + "-renderer") # es only allow to update systemSettings and gameSettings in fact for the moment Emulator.updateConfiguration(self.renderconfig, systemSettings) Emulator.updateConfiguration(self.renderconfig, gameSettings)
def updateConfiguration(self, settings): systemSettings = self.config # Special case of auto ratio if 'ratio' in settings and settings['ratio'] == 'auto': del settings['ratio'] if 'emulator' in settings and settings['emulator'] == 'default': del settings['emulator'] if 'core' in settings and settings['core'] == 'default': del settings['core'] systemSettings.update(settings) # ShaderSets if ('shaderset' in settings and settings['shaderset'] != ''): self.updateShaders(settings['shaderset']) # Draw FPS if self.config['showFPS'] is None or self.config['showFPS'] not in [ 'false', 'true' ]: self.updateDrawFPS() # Optionnal emulator args ONLY if security is disabled recalSettings = UnixSettings(rhgamestationFiles.rhgamestationConf) security = recalSettings.load("system.security.enabled") if (security != "1" and 'args' in settings and settings['args'] != ''): self.config['args'] = shlex.split(settings['args']) else: self.config['args'] = None
def generate(self, system, rom, playersControllers, gameResolution): dolphinControllers.generateControllerConfig(system, playersControllers, rom) dolphinSettings = UnixSettings(gamestationFiles.dolphinIni, separator=' ') #Draw or not FPS if system.config['showFPS'] == 'true': dolphinSettings.save("ShowLag", "True") dolphinSettings.save("ShowFrameCount", "True") else: dolphinSettings.save("ShowLag", "False") dolphinSettings.save("ShowFrameCount", "False") # don't ask about statistics dolphinSettings.save("PermissionAsked", "True") # don't confirm at stop dolphinSettings.save("ConfirmStop", "False") # language (for gamecube at least) dolphinSettings.save("SelectedLanguage", getGameCubeLangFromEnvironment()) dolphinSettings.save("GameCubeLanguage", getGameCubeLangFromEnvironment()) # update GFX dolphinGFXSettings = ConfigParser.ConfigParser() # To prevent ConfigParser from converting to lower case dolphinGFXSettings.optionxform = str dolphinGFXSettings.read(gamestationFiles.dolphinGfxIni) if not dolphinGFXSettings.has_section("Settings"): dolphinGFXSettings.add_section("Settings") dolphinGFXSettings.set( "Settings", "AspectRatio", getGfxRatioFromConfig(system.config, gameResolution)) cfgfile = open(gamestationFiles.dolphinGfxIni, 'w+') dolphinGFXSettings.write(cfgfile) cfgfile.close() # update SYSCONF try: dolphinSYSCONF.update(system.config, gamestationFiles.dolphinSYSCONF, gameResolution) except Exception: pass # don't fail in case of SYSCONF update commandArray = [ gamestationFiles.gamestationBins[system.config['emulator']], "-e", rom ] return Command.Command(array=commandArray, env={ "XDG_CONFIG_HOME": gamestationFiles.CONF, "XDG_DATA_HOME": gamestationFiles.SAVES })
def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(gamestationFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname( gamestationFiles.amiberryRetroarchCustom)): os.makedirs(dirname(gamestationFiles.amiberryRetroarchCustom)) romIsWhd = self.isWhdFile(rom) commandArray = [ gamestationFiles.gamestationBins[system.config['emulator']], "-G" ] if not romIsWhd: commandArray.append("-core=" + system.config['core']) # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path if romIsWhd: commandArray.append("-autowhdload=" + rom) else: commandArray.append("-s") commandArray.append( "pandora.floppy_path=/gamestation/share/roms/amiga/" + system.config['core']) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) if not os.path.exists(gamestationFiles.amiberryRetroarchInputsDir): os.makedirs(gamestationFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_': '_'} playerInputFilename = gamestationFiles.amiberryRetroarchInputsDir + "/" + pad.realName + ".cfg" with open( gamestationFiles.amiberryRetroarchCustom) as infile, open( playerInputFilename, 'w') as outfile: for line in infile: for src, target in replacements.iteritems(): newline = line.replace(src, target) if not newline.isspace(): outfile.write(newline) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") os.chdir("/usr/share/amiberry") return Command.Command(array=commandArray)
def resetResolution(): recalSettings = UnixSettings(recalboxFiles.recalboxConf) esVideoMode = recalSettings.load('system.es.videomode') if esVideoMode is None: cmd = "tvservice -p" eslog.log("resetting video mode: " + cmd) os.system(cmd) else: setVideoMode(esVideoMode)
def setPreffered(): recalSettings = UnixSettings(rhgamestationFiles.rhgamestationConf) esVideoMode = recalSettings.load('system.es.videomode') # Scary bug in tvservice : setting preferred mode on composite makes CEA 1 DVI ! # See https://github.com/raspberrypi/firmware/issues/901 # Once this issue is solved, just tvservice -p if esVideoMode is None or esVideoMode == "auto": os.system("tvservice -p") else: setVideoMode(esVideoMode)
def __init__(self, name, rom): self.name = name # read the configuration from the system name self.config = Emulator.get_system_config(self.name, "/usr/share/batocera/configgen/configgen-defaults.yml", "/usr/share/batocera/configgen/configgen-defaults-arch.yml") if "emulator" not in self.config or self.config["emulator"] == "": eslog.error("no emulator defined. exiting.") raise Exception("No emulator found") system_emulator = self.config["emulator"] system_core = self.config["core"] # load configuration from batocera.conf recalSettings = UnixSettings(batoceraFiles.batoceraConf) globalSettings = recalSettings.loadAll('global') systemSettings = recalSettings.loadAll(self.name) gameSettings = recalSettings.loadAll(self.name + "[\"" + os.path.basename(rom) + "\"]") # add some other options displaySettings = recalSettings.loadAll('display') for opt in displaySettings: self.config["display." + opt] = displaySettings[opt] # update config Emulator.updateConfiguration(self.config, globalSettings) Emulator.updateConfiguration(self.config, systemSettings) Emulator.updateConfiguration(self.config, gameSettings) self.updateFromESSettings() eslog.debug("uimode: {}".format(self.config['uimode'])) # forced emulators ? self.config["emulator-forced"] = False self.config["core-forced"] = False if "emulator" in globalSettings or "emulator" in systemSettings or "emulator" in gameSettings: self.config["emulator-forced"] = True if "core" in globalSettings or "core" in systemSettings or "core" in gameSettings: self.config["core-forced"] = True # update renderconfig self.renderconfig = {} if "shaderset" in self.config and self.config["shaderset"] != "none": self.renderconfig = Emulator.get_generic_config(self.name, "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults-arch.yml") if "shaderset" not in self.config: # auto self.renderconfig = Emulator.get_generic_config(self.name, "/usr/share/batocera/shaders/configs/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/rendering-defaults-arch.yml") # for compatibility with earlier Batocera versions, let's keep -renderer # but it should be reviewed when we refactor configgen (to Python3?) # so that we can fetch them from system.shader without -renderer systemSettings = recalSettings.loadAll(self.name + "-renderer") gameSettings = recalSettings.loadAll(self.name + "[\"" + os.path.basename(rom) + "\"]" + "-renderer") # es only allow to update systemSettings and gameSettings in fact for the moment Emulator.updateConfiguration(self.renderconfig, systemSettings) Emulator.updateConfiguration(self.renderconfig, gameSettings)
def generate(self, system, rom, playersControllers, gameResolution): configDir = batoceraFiles.CONF + '/openbor' if not os.path.exists(configDir): os.makedirs(configDir) savesDir = batoceraFiles.SAVES + '/openbor' if not os.path.exists(savesDir): os.makedirs(savesDir) # guess the version to run core = system.config['core'] if system.config["core-forced"] == False: core = OpenborGenerator.guessCore(rom) eslog.log("core taken is {}".format(core)) # config file configfilename = "config6510.ini" if core == "openbor4432": configfilename = "config4432.ini" elif core == "openbor6330": configfilename = "config6330.ini" elif core == "openbor6412": configfilename = "config6412.ini" elif core == "openbor6510": configfilename = "config6510.ini" config = UnixSettings(configDir + "/" + configfilename, separator='') # general config.save("fullscreen", "1") config.save("vsync", "1") config.save("usegl", "1") config.save("usejoy", "1") # options if system.isOptSet("ratio"): config.save("stretch", system.config["ratio"]) else: config.remove("stretch") if system.isOptSet("filter"): config.save("swfilter", system.config["filter"]) else: config.remove("swfilter") # controllers openborControllers.generateControllerConfig(config, playersControllers, core) config.write() return OpenborGenerator.executeCore(core, rom)
def configureGFX(config_directory, system): configFileName = "{}/{}".format(config_directory + "/inis", "GSdx.ini") if not os.path.exists(config_directory): os.makedirs(config_directory + "/inis") #create the config file if it doesn't exist if not os.path.exists(configFileName): f = open(configFileName, "w") f.write("osd_fontname = /usr/share/fonts/dejavu/DejaVuSans.ttf\n") f.close() # Update settings pcsx2GFXSettings = UnixSettings(configFileName, separator=' ') pcsx2GFXSettings.save("osd_fontname", "/usr/share/fonts/dejavu/DejaVuSans.ttf") pcsx2GFXSettings.save("osd_indicator_enabled", 1) pcsx2GFXSettings.save("UserHacks", 1) #showFPS if system.isOptSet('showFPS') and system.getOptBoolean('showFPS'): pcsx2GFXSettings.save("osd_monitor_enabled", 1) else: pcsx2GFXSettings.save("osd_monitor_enabled", 0) #internal resolution if system.isOptSet('internalresolution'): pcsx2GFXSettings.save("upscale_multiplier", system.config["internalresolution"]) else: pcsx2GFXSettings.save("upscale_multiplier", "1") #skipdraw if system.isOptSet('skipdraw'): pcsx2GFXSettings.save('UserHacks_SkipDraw', system.config['skipdraw']) else: pcsx2GFXSettings.save('UserHacks_SkipDraw', '0') #align sprite if system.isOptSet('align_sprite'): pcsx2GFXSettings.save('UserHacks_align_sprite_X', system.config['align_sprite']) else: pcsx2GFXSettings.save('UserHacks_align_sprite_X', '0') if system.isOptSet('vsync'): pcsx2GFXSettings.save("vsync", system.config["vsync"]) else: pcsx2GFXSettings.save("vsync", "1") if system.isOptSet('anisotropic_filtering'): pcsx2GFXSettings.save("MaxAnisotropy", system.config["anisotropic_filtering"]) else: pcsx2GFXSettings.save("MaxAnisotropy", "0") pcsx2GFXSettings.write()
def updateLibretroConfig(version): # Version is unsued so far, but who knows, one day try: # Read files sourceSettings = UnixSettings(recalboxFiles.retroarchInitCustomOrigin, separator=' ') sourceConf = sourceSettings.loadFile() destFiles = [recalboxFiles.retroarchCustomOrigin, recalboxFiles.retroarchCustom] for file in destFiles: destSettings = UnixSettings(file, separator=' ') destConf = destSettings.loadFile() # Compare missing keys for key, value in sourceConf.iteritems(): if key not in destConf: destConf[key] = value # Save for key, value in destConf.iteritems(): destSettings.save(key, value) print("LibretroConfig 's configuration successfully upgraded") return True except: print "Libretro update failed !" return False
def __init__(self, name): self.name = name # read the configuration from the system name self.config = Emulator.get_system_config( self.name, "/recalbox/system/configgen/configgen-defaults.yml", "/recalbox/system/configgen/configgen-defaults-arch.yml") if "emulator" not in self.config or self.config["emulator"] == "": eslog.log("no emulator defined. exiting.") raise Exception("No emulator found") # load configuration from batocera.conf recalSettings = UnixSettings(batoceraFiles.batoceraConf) globalSettings = recalSettings.loadAll('global') systemSettings = recalSettings.loadAll(self.name) # update config Emulator.updateConfiguration(self.config, globalSettings) Emulator.updateConfiguration(self.config, systemSettings) self.updateDrawFPS() # update renderconfig self.renderconfig = Emulator.get_generic_config( self.name, "/usr/share/batocera/shaders/configs/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/rendering-defaults-arch.yml") if "shaderset" in self.config and self.config["shaderset"] != "none": eslog.log("shaderset={}".format(self.config["shaderset"])) globalSettings = recalSettings.loadAll('global-renderer-' + self.config["shaderset"]) systemSettings = recalSettings.loadAll(self.name + "-renderer-" + self.config["shaderset"]) self.renderconfig = Emulator.get_generic_config( self.name, "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults.yml", "/usr/share/batocera/shaders/configs/" + self.config["shaderset"] + "/rendering-defaults-arch.yml") Emulator.updateConfiguration(self.renderconfig, globalSettings) Emulator.updateConfiguration(self.renderconfig, systemSettings) eslog.log("shader file={}".format(self.renderconfig["shader"])) else: eslog.log("no shader")
def generateAdf(fullName, romPath, uaeName, amigaHardware, controller): print("execute ADF : <%s> on <%s>" % (amiberryPath + "/amiberry", romPath + "/" + uaeName)) amiberryConfig.initMountpoint(mountPoint, amiberryPath) # ----- Create uae configuration file ----- uaeconfig = os.path.join(mountPoint, "amiberry", "conf", "uaeconfig.uae") if os.path.exists(uaeconfig): os.remove(uaeconfig) fUaeConfig = UnixSettings(uaeconfig, separator='', defaultComment=';') amiberryController.generateControllerConf(fUaeConfig) amiberryController.generateSpecialKeys(fUaeConfig, controller) amiberryConfig.generateGUIConf(fUaeConfig) amiberryConfig.generateKickstartPath(fUaeConfig, amigaHardware) amiberryConfig.generateHardwareConf(fUaeConfig, amigaHardware) floppiesManagement(fUaeConfig, romPath, uaeName) amiberryConfig.generateGraphicConf(fUaeConfig)
def configure(self, emulator='default', core='default', ratio='auto', netplay=None, netplay_ip=None, netplay_port=None, hash=None): recalSettings = UnixSettings(rhgamestationFiles.rhgamestationConf) globalSettings = recalSettings.loadAll('global') self.config['specials'] = recalSettings.load( 'system.emulators.specialkeys', 'default') self.config['netplay_nickname'] = recalSettings.load( 'global.netplay.nickname', 'default') self.config['netplaymode'] = netplay self.config['netplay_ip'] = netplay_ip self.config['netplay_port'] = netplay_port self.config['hash'] = hash self.updateConfiguration(globalSettings) self.updateConfiguration(recalSettings.loadAll(self.name)) self.updateForcedConfig(emulator, core, ratio)
def configureGFX(config_directory, system): configFileName = "{}/{}".format(config_directory + "/inis", "GS.ini") if not os.path.exists(config_directory): os.makedirs(config_directory + "/inis") # Create the config file if it doesn't exist if not os.path.exists(configFileName): f = open(configFileName, "w") f.close() # Update settings pcsx2GFXSettings = UnixSettings(configFileName, separator=' ') # Internal resolution if system.isOptSet('internal_resolution'): pcsx2GFXSettings.save("upscale_multiplier", system.config["internal_resolution"]) else: pcsx2GFXSettings.save("upscale_multiplier", "1") pcsx2GFXSettings.write()
def generate(self, system, rom, playersControllers): dolphinControllers.generateControllerConfig(system, playersControllers, rom) dolphinSettings = UnixSettings(recalboxFiles.dolphinIni, separator=' ') #Draw or not FPS if system.config['showFPS'] == 'true': dolphinSettings.save("ShowLag", "True") dolphinSettings.save("ShowFrameCount", "True") else: dolphinSettings.save("ShowLag", "False") dolphinSettings.save("ShowFrameCount", "False") # don't ask about statistics dolphinSettings.save("PermissionAsked", "True") # don't confirm at stop dolphinSettings.save("ConfirmStop", "False") # language (for gamecube at least) dolphinSettings.save("SelectedLanguage", getDolphinLangFromEnvironment()) # update SYSCONF try: dolphinSYSCONF.update(system.config, recalboxFiles.dolphinSYSCONF) except Exception: pass # don't fail in case of SYSCONF update commandArray = [ recalboxFiles.recalboxBins[system.config['emulator']], "-e", rom ] if 'args' in system.config and system.config['args'] is not None: commandArray.extend(system.config['args']) return Command.Command(videomode=system.config['videomode'], array=commandArray, env={ "XDG_CONFIG_HOME": recalboxFiles.CONF, "XDG_DATA_HOME": recalboxFiles.SAVES })
def generate(self, system, rom, playersControllers): dolphinControllers.generateControllerConfig(system, playersControllers) dolphinSettings = UnixSettings(recalboxFiles.dolphinIni, separator=' ') #Draw or not FPS if system.config['showFPS'] == 'true': dolphinSettings.save("ShowLag", "True") dolphinSettings.save("ShowFrameCount", "True") else: dolphinSettings.save("ShowLag", "False") dolphinSettings.save("ShowFrameCount", "False") commandArray = [ recalboxFiles.recalboxBins[system.config['emulator']], "-e", rom ] if 'args' in system.config and system.config['args'] is not None: commandArray.extend(system.config['args']) return Command.Command(videomode=system.config['videomode'], array=commandArray, env={ "XDG_CONFIG_HOME": recalboxFiles.CONF, "XDG_DATA_HOME": recalboxFiles.SAVES })
def configureGFX(config_directory, printFPS): configFileName = "{}/{}".format(config_directory + "/inis", "GSdx.ini") if not os.path.exists(config_directory): os.makedirs(config_directory + "/inis") if os.path.exists(configFileName): # existing configuration file pcsx2GFXSettings = UnixSettings(configFileName, separator=' ') pcsx2GFXSettings.save("osd_fontname", "/usr/share/fonts/dejavu/DejaVuSans.ttf") pcsx2GFXSettings.save("osd_indicator_enabled", 1) if printFPS: pcsx2GFXSettings.save("osd_monitor_enabled", 1) else: pcsx2GFXSettings.save("osd_monitor_enabled", 0) else: f = open(configFileName, "w") f.write("osd_fontname = /usr/share/fonts/dejavu/DejaVuSans.ttf\n") f.write("osd_indicator_enabled = 1\n") if printFPS: f.write("osd_monitor_enabled = 1\n") else: f.write("osd_monitor_enabled = 0\n") f.close()
def configureUI(config_directory, bios_directory, system_config, gameResolution): configFileName = "{}/{}".format(config_directory + "/inis", "PCSX2_ui.ini") if not os.path.exists(config_directory + "/inis"): os.makedirs(config_directory + "/inis") # find the first bios bios = [ "PS2 Bios 30004R V6 Pal.bin", "scph10000.bin", "scph39001.bin", "SCPH-70004_BIOS_V12_PAL_200.BIN" ] biosFound = False for bio in bios: if os.path.exists(bios_directory + "/" + bio): biosFile = bios_directory + "/" + bio biosFound = True break if not biosFound: raise Exception("No bios found") resolution = getGfxRatioFromConfig(system_config, gameResolution) if os.path.exists(configFileName): # existing configuration file pcsx2Settings = UnixSettings(configFileName) pcsx2Settings.save("BIOS", biosFile) pcsx2Settings.save("AspectRatio", resolution) else: # new configuration file f = open(configFileName, "w") f.write("[ProgramLog]\n") f.write("Visible=disabled\n") f.write("[Filenames]\n") f.write("BIOS=" + biosFile + "\n") f.write("[GSWindow]\n") f.write("AspectRatio=" + resolution + "\n") f.close()
def generate(self, system, rom, playersControllers, gameResolution): # Settings batocera default config file if no user defined one if not 'configfile' in system.config: # Using batocera config file system.config['configfile'] = batoceraFiles.retroarchCustom # Create retroarchcustom.cfg if does not exists if not os.path.isfile(batoceraFiles.retroarchCustom): libretroRetroarchCustom.generateRetroarchCustom() # Write controllers configuration files retroconfig = UnixSettings(batoceraFiles.retroarchCustom, separator=' ') if system.isOptSet('lightgun_map'): lightgun = system.getOptBoolean('lightgun_map') else: # Lightgun button mapping breaks lr-mame's inputs, disable if left on auto if system.config['core'] in ['mame', 'mess', 'mamevirtual']: lightgun = False else: lightgun = True libretroControllers.writeControllersConfig(retroconfig, system, playersControllers, lightgun) # force pathes libretroRetroarchCustom.generateRetroarchCustomPathes(retroconfig) # Write configuration to retroarchcustom.cfg if 'bezel' not in system.config or system.config['bezel'] == '': bezel = None else: bezel = system.config['bezel'] # some systems (ie gw) won't bezels if system.isOptSet('forceNoBezel') and system.getOptBoolean( 'forceNoBezel'): bezel = None # Get the graphics backend prior to writing the config gfxBackend = getGFXBackend(system) libretroConfig.writeLibretroConfig(retroconfig, system, playersControllers, rom, bezel, gameResolution, gfxBackend) retroconfig.write() # duplicate config to mapping files while ra now split in 2 parts remapconfigDir = batoceraFiles.retroarchRoot + "/config/remaps/common" if not os.path.exists(remapconfigDir): os.makedirs(remapconfigDir) shutil.copyfile(batoceraFiles.retroarchCustom, remapconfigDir + "/common.rmp") # Retroarch core on the filesystem retroarchCore = batoceraFiles.retroarchCores + system.config[ 'core'] + "_libretro.so" # for each core, a file /usr/lib/<core>.info must exit, otherwise, info such as rewinding/netplay will not work # to do a global check : cd /usr/lib/libretro && for i in *.so; do INF=$(echo $i | sed -e s+/usr/lib/libretro+/usr/share/libretro/info+ -e s+\.so+.info+); test -e "$INF" || echo $i; done #infoFile = batoceraFiles.retroarchCores + system.config['core'] + "_libretro.info" #if not os.path.exists(infoFile): # raise Exception("missing file " + infoFile) romName = os.path.basename(rom) # The command to run dontAppendROM = False # For the NeoGeo CD (lr-fbneo) it is necessary to add the parameter: --subsystem neocd if system.name == 'neogeocd' and system.config['core'] == "fbneo": commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--subsystem", "neocd", "--config", system.config['configfile'] ] # Set up GB/GBC Link games to use 2 different ROMs if needed if system.name == 'gb2players' or system.name == 'gbc2players': GBMultiROM = list() GBMultiFN = list() GBMultiSys = list() romGBName, romExtension = os.path.splitext(romName) # If ROM file is a .gb2 text, retrieve the filenames if romExtension.lower() in ['.gb2', '.gbc2']: with open(rom) as fp: for line in fp: GBMultiText = line.strip() if GBMultiText.lower().startswith("gb:"): GBMultiROM.append("/userdata/roms/gb/" + GBMultiText.split(":")[1]) GBMultiFN.append(GBMultiText.split(":")[1]) GBMultiSys.append("gb") elif GBMultiText.lower().startswith("gbc:"): GBMultiROM.append("/userdata/roms/gbc/" + GBMultiText.split(":")[1]) GBMultiFN.append(GBMultiText.split(":")[1]) GBMultiSys.append("gbc") else: GBMultiROM.append("/userdata/roms/" + system.name + "/" + GBMultiText) GBMultiFN.append(GBMultiText.split(":")[1]) if system.name == "gb2players": GBMultiSys.append("gb") else: GBMultiSys.append("gbc") else: # Otherwise fill in the list with the single game GBMultiROM.append(rom) GBMultiFN.append(romName) if system.name == "gb2players": GBMultiSys.append("gb") else: GBMultiSys.append("gbc") # If there are at least 2 games in the list, use the alternate command line if len(GBMultiROM) >= 2: commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, GBMultiROM[0], "--subsystem", "gb_link_2p", GBMultiROM[1], "--config", system.config['configfile'] ] dontAppendROM = True else: commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] # Handling for the save copy if (system.isOptSet('sync_saves') and system.config["sync_saves"] == '1'): if len(GBMultiROM) >= 2: GBMultiSave = [ os.path.splitext(GBMultiFN[0])[0] + ".srm", os.path.splitext(GBMultiFN[1])[0] + ".srm" ] else: GBMultiSave = [os.path.splitext(GBMultiFN[0])[0] + ".srm"] # Verifies all the save paths exist # Prevents copy errors if they don't if not os.path.exists("/userdata/saves/gb"): os.mkdir("/userdata/saves/gb") if not os.path.exists("/userdata/saves/gbc"): os.mkdir("/userdata/saves/gbc") if not os.path.exists("/userdata/saves/gb2players"): os.mkdir("/userdata/saves/gb2players") if not os.path.exists("/userdata/saves/gbc2players"): os.mkdir("/userdata/saves/gbc2players") # Copies the saves if they exist for x in range(len(GBMultiSave)): saveFile = "/userdata/saves/" + GBMultiSys[ x] + "/" + GBMultiSave[x] newSaveFile = "/userdata/saves/" + system.name + "/" + GBMultiSave[ x] if os.path.exists(saveFile): shutil.copy(saveFile, newSaveFile) # Generates a script to copy the saves back on exit # Starts by making sure script paths exist if not os.path.exists("/userdata/system/scripts/"): os.mkdir("/userdata/system/scripts") if not os.path.exists("/userdata/system/scripts/gb2savesync/"): os.mkdir("/userdata/system/scripts/gb2savesync") scriptFile = "/userdata/system/scripts/gb2savesync/exitsync.sh" if os.path.exists(scriptFile): os.remove(scriptFile) GBMultiScript = open(scriptFile, "w") GBMultiScript.write("#!/bin/bash\n") GBMultiScript.write( "#This script is created by the Game Boy link cable system to sync save files.\n" ) GBMultiScript.write("#\n") GBMultiScript.write("\n") GBMultiScript.write("case $1 in\n") GBMultiScript.write(" gameStop)\n") # The only event is gameStop, checks to make sure it was called by the right system GBMultiScript.write( " if [ $2 = 'gb2players' ] || [ $2 = 'gbc2players' ]\n" ) GBMultiScript.write(" then\n") for x in range(len(GBMultiSave)): saveFile = "/userdata/saves/" + GBMultiSys[ x] + "/" + GBMultiSave[x] newSaveFile = "/userdata/saves/" + system.name + "/" + GBMultiSave[ x] GBMultiScript.write(' cp "' + newSaveFile + '" "' + saveFile + '"\n') GBMultiScript.write(" fi\n") # Deletes itself after running GBMultiScript.write(" rm " + scriptFile + "\n") GBMultiScript.write(" ;;\n") GBMultiScript.write("esac\n") GBMultiScript.close() # Make it executable fileStat = os.stat(scriptFile) os.chmod(scriptFile, fileStat.st_mode | 0o111) # PURE zip games uses the same commandarray of all cores. .pc and .rom uses owns elif system.name == 'dos': romDOSName = os.path.splitext(romName)[0] romDOSName, romExtension = os.path.splitext(romName) if romExtension == '.dos' or romExtension == '.pc': commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'], os.path.join(rom, romDOSName + ".bat") ] else: commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] # Pico-8 multi-carts (might work only with official Lexaloffe engine right now) elif system.name == 'pico8': romext = os.path.splitext(romName)[1] if (romext.lower() == ".m3u"): with open(rom, "r") as fpin: lines = fpin.readlines() rom = os.path.dirname( os.path.abspath(rom)) + '/' + lines[0].strip() commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] else: commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] configToAppend = [] # Custom configs - per core customCfg = "{}/{}.cfg".format(batoceraFiles.retroarchRoot, system.name) if os.path.isfile(customCfg): configToAppend.append(customCfg) # Custom configs - per game customGameCfg = "{}/{}/{}.cfg".format(batoceraFiles.retroarchRoot, system.name, romName) if os.path.isfile(customGameCfg): configToAppend.append(customGameCfg) # Overlay management overlayFile = "{}/{}/{}.cfg".format(batoceraFiles.OVERLAYS, system.name, romName) if os.path.isfile(overlayFile): configToAppend.append(overlayFile) # RetroArch 1.7.8 (Batocera 5.24) now requires the shaders to be passed as command line argument renderConfig = system.renderconfig gameSpecial = videoMode.getGameSpecial(system.name, rom, True) gameShader = None if gameSpecial == "0": if 'shader' in renderConfig: gameShader = renderConfig['shader'] else: if ('shader-' + str(gameSpecial)) in renderConfig: gameShader = renderConfig['shader-' + str(gameSpecial)] else: gameShader = renderConfig['shader'] if 'shader' in renderConfig and gameShader != None: if (gfxBackend == 'glcore' or gfxBackend == 'vulkan') or (system.config['core'] in libretroConfig.coreForceSlangShaders): shaderFilename = gameShader + ".slangp" else: shaderFilename = gameShader + ".glslp" eslog.debug("searching shader {}".format(shaderFilename)) if os.path.exists("/userdata/shaders/" + shaderFilename): video_shader_dir = "/userdata/shaders" eslog.debug("shader {} found in /userdata/shaders".format( shaderFilename)) else: video_shader_dir = "/usr/share/batocera/shaders" video_shader = video_shader_dir + "/" + shaderFilename commandArray.extend(["--set-shader", video_shader]) # Generate the append if configToAppend: commandArray.extend(["--appendconfig", "|".join(configToAppend)]) # Netplay mode if 'netplay.mode' in system.config: if system.config['netplay.mode'] == 'host': commandArray.append("--host") elif system.config['netplay.mode'] == 'client' or system.config[ 'netplay.mode'] == 'spectator': commandArray.extend( ["--connect", system.config['netplay.server.ip']]) if 'netplay.server.port' in system.config: commandArray.extend( ["--port", system.config['netplay.server.port']]) if 'netplay.nickname' in system.config: commandArray.extend( ["--nick", system.config['netplay.nickname']]) # Verbose logs commandArray.extend(['--verbose']) # Extension used by hypseus .daphne but lr-daphne starts with .zip if system.name == 'daphne': romName = os.path.splitext(os.path.basename(rom))[0] rom = batoceraFiles.daphneDatadir + '/roms/' + romName + '.zip' if system.name == 'scummvm': rom = os.path.dirname(rom) + '/' + romName[0:-8] # Use command line instead of ROM file for MAME variants if system.config['core'] in ['mame', 'mess', 'mamevirtual']: dontAppendROM = True commandArray.append("/var/run/lr-mame.cmd") if dontAppendROM == False: commandArray.append(rom) return Command.Command(array=commandArray, env={"XDG_CONFIG_HOME": batoceraFiles.CONF})
def updateShaders(self, system, shaderSet): if shaderSet != None and shaderSet != "none": shaderfile = recalboxFiles.shaderPresetRoot + "/" + shaderSet + ".cfg" systemShader = UnixSettings(shaderfile).load(system.name) if systemShader != None: system.config['shaders'] = systemShader
import sys import os import ConfigParser from controllersConfig import Input from xml.dom import minidom sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from settings.unixSettings import UnixSettings import gamestationFiles # Must read : # http://mupen64plus.org/wiki/index.php?title=Mupen64Plus_Plugin_Parameters mupenSettings = UnixSettings(gamestationFiles.mupenCustom, separator=' ') Config = ConfigParser.ConfigParser() # To prevent ConfigParser from converting to lower case Config.optionxform = str # Mupen doesn't like to have 2 buttons mapped for N64 pad entry. That's why r2 is commented for now. 1 axis and 1 button is ok mupenHatToAxis = {'1': 'Up', '2': 'Right', '4': 'Down', '8': 'Left'} mupenDoubleAxis = {0:'X Axis', 1:'Y Axis'} def getMupenMappingFile(): if os.path.exists(gamestationFiles.mupenMappingUser): return gamestationFiles.mupenMappingUser else: return gamestationFiles.mupenMappingSystem def getMupenMapping():
def generateCoreSettings(retroarchCore, system): # retroarch-core-options.cfg if not os.path.exists(os.path.dirname(retroarchCore)): os.makedirs(os.path.dirname(retroarchCore)) try: coreSettings = UnixSettings(retroarchCore, separator=' ') except UnicodeError: # invalid retroarch-core-options.cfg # remove it and try again os.remove(retroarchCore) coreSettings = UnixSettings(retroarchCore, separator=' ') # Atari 800 and 5200 if (system.config['core'] == 'atari800'): if (system.name == 'atari800'): coreSettings.save('atari800_system', '"130XE (128K)"') coreSettings.save('RAM_SIZE', '"64"') coreSettings.save('STEREO_POKEY', '"1"') coreSettings.save('BUILTIN_BASIC', '"1"') else: coreSettings.save('atari800_system', '"5200"') coreSettings.save('RAM_SIZE', '"16"') coreSettings.save('STEREO_POKEY', '"0"') coreSettings.save('BUILTIN_BASIC', '"0"') # Colecovision and MSX if (system.config['core'] == 'bluemsx'): coreSettings.save('bluemsx_overscan', '"enabled"') if (system.name == 'colecovision'): coreSettings.save('bluemsx_msxtype', '"ColecoVision"') elif (system.name == 'msx1'): coreSettings.save('bluemsx_msxtype', '"MSX"') elif (system.name == 'msx2'): coreSettings.save('bluemsx_msxtype', '"MSX2"') elif (system.name == 'msx2+'): coreSettings.save('bluemsx_msxtype', '"MSX2+"') elif (system.name == 'msxturbor'): coreSettings.save('bluemsx_msxtype', '"MSXturboR"') if (system.config['core'] == 'citra'): if not os.path.exists(batoceraFiles.CONF + "/retroarch/3ds.cfg"): f = open(batoceraFiles.CONF + "/retroarch/3ds.cfg", "w") f.write("video_driver = \"glcore\"\n") f.close() if (system.config['core'] == 'tgbdual'): coreSettings.save('tgbdual_audio_output', '"Game Boy #1"') coreSettings.save('tgbdual_gblink_enable', '"enabled"') coreSettings.save('tgbdual_screen_placement', '"left-right"') coreSettings.save('tgbdual_single_screen_mp', '"both players"') coreSettings.save('tgbdual_switch_screens', '"normal"') if (system.config['core'] == 'gambatte'): if 'colorization' in system.renderconfig and system.renderconfig['colorization'] != None: coreSettings.save('gambatte_gb_colorization', '"internal"') coreSettings.save('gambatte_gb_internal_palette', '"' + system.renderconfig['colorization'] + '"') else: coreSettings.save('gambatte_gb_colorization', '"disabled"') if (system.config['core'] == 'desmume'): coreSettings.save('desmume_pointer_device_r', '"emulated"') # multisampling aa if system.isOptSet('multisampling'): coreSettings.save('desmume_gfx_multisampling', system.config['multisampling']) else: coreSettings.save('desmume_gfx_multisampling', '"disabled"') # texture smoothing if system.isOptSet('texture_smoothing'): coreSettings.save('desmume_gfx_texture_smoothing', system.config['texture_smoothing']) else: coreSettings.save('desmume_gfx_texture_smoothing', '"disabled"') # texture scaling (xBrz) if system.isOptSet('texture_scaling'): coreSettings.save('desmume_gfx_texture_scaling', system.config['texture_scaling']) else: coreSettings.save('desmume_gfx_texture_scaling', '"1"') if (system.config['core'] == 'mame078'): coreSettings.save('mame2003_skip_disclaimer', '"enabled"') coreSettings.save('mame2003_skip_warnings', '"enabled"') if (system.config['core'] == 'mame078plus'): coreSettings.save('mame2003-plus_skip_disclaimer', '"enabled"') coreSettings.save('mame2003-plus_skip_warnings', '"enabled"') coreSettings.save('mame2003-plus_analog', '"digital"') if (system.config['core'] == 'puae'): coreSettings.save('puae_video_options_display ', '"enabled"') # video resolution if system.isOptSet('video_resolution'): coreSettings.save('puae_video_resolution', system.config['video_resolution']) else: coreSettings.save('puae_video_resolution', '"auto"') # zoom mode if system.isOptSet('zoom_mode'): coreSettings.save('puae_zoom_mode', system.config['zoom_mode']) else: coreSettings.save('puae_zoom_mode', '"auto"') # standard video if system.isOptSet('video_standard'): coreSettings.save('puae_video_standard', system.config['video_standard']) else: coreSettings.save('puae_video_standard', '"PAL"') # keypad mapping 2p if system.isOptSet('keyrah_mapping'): coreSettings.save('puae_keyrah_keypad_mappings', system.config['keyrah_mapping']) else: coreSettings.save('puae_keyrah_keypad_mappings', '"enabled"') # mouse speed if system.isOptSet('mouse_speed'): coreSettings.save('puae_mouse_speed', system.config['mouse_speed']) else: coreSettings.save('puae_mouse_speed', '"200"') # whdload if system.isOptSet('whdload'): coreSettings.save('puae_use_whdload_prefs', system.config['whdload']) else: coreSettings.save('puae_use_whdload_prefs', '"config"') # retropad options if system.isOptSet('pad_options'): coreSettings.save('puae_retropad_options', system.config['pad_options']) else: coreSettings.save('puae_retropad_options', '"jump"') if (system.config['core'] == 'pce'): coreSettings.save('pce_keepaspect', '"enabled"') coreSettings.save('pce_nospritelimit', '"enabled"') if (system.config['core'] == 'pce_fast'): coreSettings.save('pce_keepaspect', '"enabled"') if (system.config['core'] == 'mupen64plus-next'): # BilinearMode if system.isOptSet('BilinearMode'): coreSettings.save('mupen64plus-BilinearMode', system.config['BilinearMode']) else: coreSettings.save('mupen64plus-BilinearMode', '"standard"') # multisampling aa if system.isOptSet('MultiSampling'): coreSettings.save('mupen64plus-MultiSampling', system.config['MultiSampling']) else: coreSettings.save('mupen64plus-MultiSampling', '"0"') # Texture filter if system.isOptSet('Texture_filter'): coreSettings.save('mupen64plus-txFilterMode', '"' + system.config['Texture_filter'] + '"') else: coreSettings.save('mupen64plus-txFilterMode', '"None"') # Texture Enhancement if system.isOptSet('Texture_Enhancement'): coreSettings.save('mupen64plus-txEnhancementMode', '"' + system.config['Texture_Enhancement'] + '"') else: coreSettings.save('mupen64plus-txEnhancementMode', '"None"') if (system.config['core'] == 'vb'): # 2D color mode if system.isOptSet('2d_color_mode'): coreSettings.save('vb_color_mode', '"' + system.config['2d_color_mode'] + '"') else: coreSettings.save('vb_color_mode', '"black & red"') # 3D color mode if system.isOptSet('3d_color_mode'): coreSettings.save('vb_anaglyph_preset', '"' + system.config['3d_color_mode'] + '"') else: coreSettings.save('vb_anaglyph_preset', '"disabled"') if (system.config['core'] == 'picodrive'): coreSettings.save('picodrive_input1', '"6 button pad"') coreSettings.save('picodrive_input2', '"6 button pad"') coreSettings.save('picodrive_sprlim', '"enabled"') if (system.config['core'] == '81'): coreSettings.save('81_sound', '"Zon X-81"') if (system.config['core'] == 'cap32'): if (system.name == 'gx4000'): coreSettings.save('cap32_model', '"6128+"') else: coreSettings.save('cap32_model', '"6128"') if (system.config['core'] == 'fuse'): coreSettings.save('fuse_machine', '"Spectrum 128K"') if (system.config['core'] == 'opera'): coreSettings.save('opera_dsp_threaded', '"enabled"') if (system.config['core'] == 'virtualjaguar'): coreSettings.save('virtualjaguar_usefastblitter', '"enabled"') if (system.config['core'] == 'vice'): coreSettings.save('vice_Controller', '"joystick"') coreSettings.save('vice_datasette_hotkeys', '"enabled"') coreSettings.save('vice_read_vicerc', '"disabled"') coreSettings.save('vice_retropad_options', '"jump"') coreSettings.save('vice_JoyPort', '"port_1"') # aspect ratio if system.isOptSet('aspect_ratio'): coreSettings.save('vice_aspect_ratio', system.config['aspect_ratio']) else: coreSettings.save('vice_aspect_ratio', '"pal"') # zoom mode if system.isOptSet('zoom_mode'): coreSettings.save('vice_zoom_mode', system.config['zoom_mode']) else: coreSettings.save('vice_zoom_mode', '"medium"') # external palette if system.isOptSet('external_palette'): coreSettings.save('vice_external_palette', system.config['external_palette']) else: coreSettings.save('vice_external_palette', '"colodore"') if (system.config['core'] == 'theodore'): coreSettings.save('theodore_autorun', '"enabled"') if (system.config['core'] == 'genesisplusgx'): coreSettings.save('genesis_plus_gx_no_sprite_limit', '"enabled"') if (system.config['core'] == 'snes9x_next'): coreSettings.save('snes9x_2010_reduce_sprite_flicker', '"enabled"') # reduce slowdown if system.isOptSet('reduce_slowdown'): coreSettings.save('snes9x_2010_overclock_cycles', system.config['reduce_slowdown']) else: coreSettings.save('snes9x_2010_overclock_cycles', '"compatible"') if (system.config['core'] == 'yabasanshiro'): # resolution mode if system.isOptSet('resolution_mode'): coreSettings.save('yabasanshiro_resolution_mode', system.config['resolution_mode']) else: coreSettings.save('yabasanshiro_resolution_mode', '"original"') if (system.config['core'] == 'nestopia'): coreSettings.save('nestopia_nospritelimit', '"enabled"') coreSettings.save('nestopia_overscan_h', '"enabled"') coreSettings.save('nestopia_overscan_v', '"enabled"') # palette if system.isOptSet('palette'): coreSettings.save('nestopia_palette', system.config['palette']) else: coreSettings.save('nestopia_palette', '"consumer"') if (system.config['core'] == 'fceumm'): coreSettings.save('fceumm_nospritelimit', '"enabled"') if (system.config['core'] == 'flycast'): coreSettings.save('reicast_threaded_rendering', '"enabled"') coreSettings.save('reicast_mipmapping', '"disabled"') # widescreen hack if system.isOptSet('widescreen_hack'): coreSettings.save('reicast_widescreen_hack', system.config['widescreen_hack']) else: coreSettings.save('reicast_widescreen_hack', '"disabled"') # anisotropic filtering if system.isOptSet('anisotropic_filtering'): coreSettings.save('reicast_anisotropic_filtering', system.config['anisotropic_filtering']) else: coreSettings.save('reicast_anisotropic_filtering', '"off"') # texture upscaling (xBRZ) if system.isOptSet('texture_upscaling'): coreSettings.save('reicast_texupscale', system.config['texture_upscaling']) else: coreSettings.save('reicast_texupscale', '"off"') # render to texture upscaling if system.isOptSet('render_to_texture_upscaling'): coreSettings.save('reicast_render_to_texture_upscaling', system.config['render_to_texture_upscaling']) else: coreSettings.save('reicast_render_to_texture_upscaling', '"1x"') if (system.config['core'] == 'dosbox'): coreSettings.save('dosbox_svn_pcspeaker', '"true"') if (system.config['core'] == 'px68k'): coreSettings.save('px68k_disk_path', '"disabled"') if (system.config['core'] == 'mednafen_psx'): coreSettings.save('beetle_psx_hw_cpu_freq_scale', '"110%"') # internal resolution if system.isOptSet('internal_resolution'): coreSettings.save('beetle_psx_hw_internal_resolution', system.config['internal_resolution']) else: coreSettings.save('beetle_psx_hw_internal_resolution', '"1x(native)"') # texture filtering if system.isOptSet('texture_filtering'): coreSettings.save('beetle_psx_hw_filter', system.config['texture_filtering']) else: coreSettings.save('beetle_psx_hw_filter', '"nearest"') # widescreen hack if system.isOptSet('widescreen_hack'): coreSettings.save('beetle_psx_hw_widescreen_hack', system.config['widescreen_hack']) else: coreSettings.save('beetle_psx_hw_widescreen_hack', '"disabled"') if (system.config['core'] == 'duckstation'): # resolution scale (default 1) if system.isOptSet('resolution_scale'): coreSettings.save('duckstation_GPU.ResolutionScale', system.config['resolution_scale']) else: coreSettings.save('duckstation_GPU.ResolutionScale', '"1"') # multisampling antialiasing (default 1x) if system.isOptSet('antialiasing'): coreSettings.save('duckstation_GPU.MSAA', system.config['antialiasing']) else: coreSettings.save('duckstation_GPU.MSAA', '"1"') # texture filtering (default nearest) if system.isOptSet('texture_filtering'): coreSettings.save('duckstation_GPU.TextureFilter', system.config['texture_filtering']) else: coreSettings.save('duckstation_GPU.TextureFilter', '"Nearest"') # widescreen hack (default off) if system.isOptSet('widescreen_hack'): coreSettings.save('duckstation_GPU.WidescreenHack', system.config['widescreen_hack']) else: coreSettings.save('duckstation_GPU.WidescreenHack', '"false"') if (system.config['core'] == 'pcsx_rearmed'): for n in range(1, 8+1): val = coreSettings.load('pcsx_rearmed_pad{}type'.format(n)) if val == '"none"' or val == "" or val is None: coreSettings.save('pcsx_rearmed_pad{}type'.format(n), '"standard"') # force multitap no value / auto to disable # only let enabled when it is forced while previous values enable it val = coreSettings.load('pcsx_rearmed_multitap1') if val == '"auto"' or val == "" or val is None: coreSettings.save('pcsx_rearmed_multitap1', '"disabled"') val = coreSettings.load('pcsx_rearmed_multitap2') if val == '"auto"' or val == "" or val is None: coreSettings.save('pcsx_rearmed_multitap2', '"disabled"') # custom : allow the user to configure directly retroarchcore.cfg via batocera.conf via lines like : snes.retroarchcore.opt=val for user_config in system.config: if user_config[:14] == "retroarchcore.": coreSettings.save(user_config[14:], system.config[user_config]) coreSettings.write()
def generate(self, system, rom, playersControllers, gameResolution): # Settings batocera default config file if no user defined one if not 'configfile' in system.config: # Using batocera config file system.config['configfile'] = batoceraFiles.retroarchCustom # Create retroarchcustom.cfg if does not exists if not os.path.isfile(batoceraFiles.retroarchCustom): libretroRetroarchCustom.generateRetroarchCustom() # Write controllers configuration files retroconfig = UnixSettings(batoceraFiles.retroarchCustom, separator=' ') libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) # force pathes libretroRetroarchCustom.generateRetroarchCustomPathes(retroconfig) # Write configuration to retroarchcustom.cfg if 'bezel' not in system.config or system.config['bezel'] == '': bezel = None else: bezel = system.config['bezel'] # some systems (ie gw) won't bezels if system.isOptSet('forceNoBezel') and system.getOptBoolean( 'forceNoBezel'): bezel = None libretroConfig.writeLibretroConfig(retroconfig, system, playersControllers, rom, bezel, gameResolution) # Retroarch core on the filesystem retroarchCore = batoceraFiles.retroarchCores + system.config[ 'core'] + batoceraFiles.libretroExt romName = os.path.basename(rom) # the command to run # For the NeoGeo CD (lr-fbneo) it is necessary to add the parameter: --subsystem neocd if system.name == 'neogeocd' and system.config['core'] == "fbneo": commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--subsystem", "neocd", "--config", system.config['configfile'] ] elif system.name == 'dos': commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'], rom + "/dosbox.bat" ] else: commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] configToAppend = [] # Custom configs - per core customCfg = "{}/{}.cfg".format(batoceraFiles.retroarchRoot, system.name) if os.path.isfile(customCfg): configToAppend.append(customCfg) # Custom configs - per game customGameCfg = "{}/{}/{}.cfg".format(batoceraFiles.retroarchRoot, system.name, romName) if os.path.isfile(customGameCfg): configToAppend.append(customGameCfg) # Overlay management overlayFile = "{}/{}/{}.cfg".format(batoceraFiles.OVERLAYS, system.name, romName) if os.path.isfile(overlayFile): configToAppend.append(overlayFile) # RetroArch 1.7.8 (Batocera 5.24) now requires the shaders to be passed as command line argument renderConfig = system.renderconfig if 'shader' in renderConfig and renderConfig['shader'] != None: shaderFilename = renderConfig['shader'] + ".glslp" eslog.log("searching shader {}".format(shaderFilename)) if os.path.exists("/userdata/shaders/" + shaderFilename): video_shader_dir = "/userdata/shaders" eslog.log("shader {} found in /userdata/shaders".format( shaderFilename)) else: video_shader_dir = "/usr/share/batocera/shaders" video_shader = video_shader_dir + "/" + shaderFilename commandArray.extend(["--set-shader", video_shader]) # Generate the append if configToAppend: commandArray.extend(["--appendconfig", "|".join(configToAppend)]) # Netplay mode if 'netplay.mode' in system.config: if system.config['netplay.mode'] == 'host': commandArray.append("--host") elif system.config['netplay.mode'] == 'client': commandArray.extend( ["--connect", system.config['netplay.server.ip']]) if 'netplay.server.port' in system.config: commandArray.extend( ["--port", system.config['netplay.server.port']]) if 'netplay.nickname' in system.config: commandArray.extend( ["--nick", system.config['netplay.nickname']]) # Verbose logs commandArray.extend(['--verbose']) # Extension used by hypseus .daphne but lr-daphne starts with .zip if system.name == 'daphne': romName = os.path.splitext(os.path.basename(rom))[0] rom = batoceraFiles.daphneDatadir + '/roms/' + romName + '.zip' if system.name == 'dos': rom = 'set ROOT=' + rom commandArray.append(rom) return Command.Command(array=commandArray)