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) retroconfig.write() # 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 if system.name == 'scummvm': rom = os.path.dirname(rom) + '/' + romName[1:-8] commandArray.append(rom) return Command.Command(array=commandArray)
def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(batoceraFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname(batoceraFiles.amiberryRetroarchCustom)): os.makedirs(dirname(batoceraFiles.amiberryRetroarchCustom)) romType = self.getRomType(rom) eslog.log("romType" + romType) if romType != 'UNKNOWN': commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-G" ] if romType != 'WHDL': commandArray.append("-model=" + system.config['core']) if romType == 'WHDL': commandArray.append("-autoload=" + rom) elif romType == 'HDF': commandArray.append("-s") commandArray.append("hardfile2=rw,DH0:" + rom + ",32,1,2,512,0,,uae0") commandArray.append("-s") commandArray.append("uaehf0=hdf,rw,DH0:" + rom + ",32,1,2,512,0,,uae0") elif romType == 'CD': commandArray.append("-cdimage=" + rom) elif romType == 'DISK': # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path commandArray.append("-s") # Use disk folder as floppy path romPathIndex = rom.rfind('/') commandArray.append("amiberry.floppy_path=" + rom[0:romPathIndex]) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) retroconfig.write() if not os.path.exists(batoceraFiles.amiberryRetroarchInputsDir): os.makedirs(batoceraFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_': '_'} # amiberry remove / included in pads names like "USB Downlo01.80 PS3/USB Corded Gamepad" padfilename = pad.realName.replace("/", "") playerInputFilename = batoceraFiles.amiberryRetroarchInputsDir + "/" + padfilename + ".cfg" with open( batoceraFiles.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) if nplayer == 1: # 1 = joystick port commandArray.append("-s") commandArray.append("joyport1_friendlyname=" + padfilename) if romType == 'CD': commandArray.append("-s") commandArray.append("joyport1_mode=cd32joy") if nplayer == 2: # 0 = mouse for the player 2 commandArray.append("-s") commandArray.append("joyport0_friendlyname=" + padfilename) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") # disable port 2 (otherwise, the joystick goes on it) commandArray.append("-s") commandArray.append("joyport2=") # display vertical centering commandArray.append("-s") commandArray.append("gfx_center_vertical=smart") os.chdir("/usr/share/amiberry") return Command.Command(array=commandArray)
#!/usr/bin/env python import sys import os import recalboxFiles import settings from Emulator import Emulator from settings.unixSettings import UnixSettings sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) ppssppSettings = UnixSettings(recalboxFiles.ppssppConfig, separator=' ') def writePPSSPPConfig(system): writePPSSPPConfigDefault() writePPSSPPConfigToFile(createPPSSPPConfig(system)) def writePPSSPPConfigDefault(): if not os.path.exists(recalboxFiles.ppssppConfig): if not os.path.exists(os.path.dirname(recalboxFiles.ppssppConfig)): os.makedirs(os.path.dirname(recalboxFiles.ppssppConfig)) # write default values template, so that the rest of the config can set values f = open(recalboxFiles.ppssppConfig, "w") f.write("[Graphics]\n") f.write("FrameSkip = 0\n") f.write("ShowFPSCounter = 0\n") f.write("FrameSkipType = 0\n") f.write("InternalResolution = 1\n") f.close() def createPPSSPPConfig(system):
#!/usr/bin/env python import sys import os import recalboxFiles import settings from settings.unixSettings import UnixSettings sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) libretroSettings = UnixSettings(recalboxFiles.retroarchCustom, separator=' ') coreSettings = UnixSettings(recalboxFiles.retroarchCoreCustom, separator=' ') # return true if the option is considered enabled (for boolean options) def enabled(key, dict): return key in dict and (dict[key] == '1' or dict[key] == 'true') # return true if the option is considered defined def defined(key, dict): return key in dict and isinstance(dict[key], str) and len(dict[key]) > 0 # Warning the values in the array must be exactly at the same index than # https://github.com/libretro/RetroArch/blob/master/gfx/video_driver.c#L132 ratioIndexes = ["4/3", "16/9", "16/10", "16/15", "1/1", "2/1", "3/2", "3/4", "4/1", "4/4", "5/4", "6/5", "7/9", "8/3", "8/7", "19/12", "19/14", "30/17", "32/9", "config", "squarepixel"] # Define the libretro device type corresponding to the libretro cores, when needed.
def generate(self, system, rom, playersControllers, gameResolution): if not os.path.exists(CONFIGDIR): os.makedirs(CONFIGDIR) config = UnixSettings(CONFIGFILE, separator=' ') rombase=os.path.basename(rom) romext=os.path.splitext(rombase)[1] if (romext.lower() in ['.dsk', '.do', '.nib']): config.save("s6d1", rom) config.save("s5d1", '') config.save("s7d1", '') config.save("bram1[00]", '00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00') config.save("bram1[10]", '00 00 07 06 02 01 01 00 00 00 0f 06 06 00 05 06') config.save("bram1[20]", '01 00 00 00 00 00 00 01 06 00 00 00 03 02 02 02') config.save("bram1[30]", '00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06') config.save("bram1[40]", '07 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d') config.save("bram1[50]", '0e 0f ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[60]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[70]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[80]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[90]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[a0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[b0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[c0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[d0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[e0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[f0]", 'ff ff ff ff ff ff ff ff ff ff ff ff fe 17 54 bd') config.save("bram3[00]", '00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00') config.save("bram3[10]", '00 00 07 06 02 01 01 00 00 00 0f 06 00 00 05 06') config.save("bram3[20]", '01 00 00 00 00 00 00 01 00 00 00 00 05 02 02 00') config.save("bram3[30]", '00 00 2d 2d 00 00 00 00 00 00 02 02 02 06 08 00') config.save("bram3[40]", '01 02 03 04 05 06 07 0a 00 01 02 03 04 05 06 07') config.save("bram3[50]", '08 09 0a 0b 0c 0d 0e 0f 00 00 ff ff ff ff ff ff') config.save("bram3[60]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[70]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[80]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[90]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[a0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[b0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[c0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[d0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[e0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram3[f0]", 'ff ff ff ff ff ff ff ff ff ff ff ff 05 cf af 65') else: # .po and .2mg config.save("s7d1", rom) config.save("s5d1", '') config.save("s6d1", '') config.save("bram1[00]", '00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00') config.save("bram1[10]", '00 00 07 06 02 01 01 00 00 00 0f 06 06 00 05 06') config.save("bram1[20]", '01 00 00 00 00 00 00 01 00 00 00 00 03 02 02 02') config.save("bram1[30]", '00 00 00 00 00 00 00 00 08 00 01 02 03 04 05 06') config.save("bram1[40]", '07 0a 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d') config.save("bram1[50]", '0e 0f ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[60]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[70]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[80]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[90]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[a0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[b0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[c0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[d0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[e0]", 'ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff') config.save("bram1[f0]", 'ff ff ff ff ff ff ff ff ff ff ff ff 13 24 b9 8e') config.save("bram3[00]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[10]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[20]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[30]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[40]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[50]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[60]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[70]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[80]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[90]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[a0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[b0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[c0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[d0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[e0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("bram3[f0]", '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00') config.save("g_cfg_rom_path", batoceraFiles.BIOS) # config.save("g_limit_speed", "0") config.write() commandArray = ["GSplus", "-fullscreen"] return Command.Command( array=commandArray, env={ 'SDL_GAMECONTROLLERCONFIG': controllersConfig.generateSdlGameControllerConfig(playersControllers) })
def generateMoonlightConfig(): # conf file try: moonlightConfig = UnixSettings(batoceraFiles.moonlightConfigFile, separator=' ') except UnicodeError: # remove it and try again os.remove(batoceraFiles.moonlightConfigFile) moonlightConfig = UnixSettings(batoceraFiles.moonlightConfigFile, separator=' ') ## Hostname or IP-address of host to connect to ## By default host is autodiscovered using mDNS #address = ## Video streaming configuration moonlightConfig.save('width', '1280') moonlightConfig.save('height', '720') moonlightConfig.save('fps', '60') ## Bitrate depends by default on resolution and fps ## Set to -1 to enable default ## 20Mbps (20000) for 1080p (60 fps) ## 10Mbps (10000) for 1080p or 60 fps ## 5Mbps (5000) for lower resolution or fps moonlightConfig.save('bitrate', '-1') ## Size of network packets should be lower than MTU #packetsize = 1024 ## Select video codec (auto/h264/h265) #codec = auto ## Default started application on host #app = Steam ## Default used mapping for streaming ## Searched for in $XDG_DATA_DIRS/moonlight or /usr/share/moonlight and /usr/local/share/moonlight ## Mapping can also be user overrided in $XDG_CONFIG_DIR/moonlight or ~/.config/moonlight or current directory #mapping = gamecontrollerdb.txt ## Enable selected input devices ## By default all available input devices should be used ## Only evdev devices /dev/input/event* are allowed ## To use a different mapping then default another mapping should be declared above the input #input = /dev/input/event1 ## Enable GFE for changing graphical game settings for optimal performance and quality moonlightConfig.save('sops', 'true') ## Play audio on host instead of streaming to client #localaudio = false ## Send quit app request to remote after quitting session #quitappafter = false ## Disable all input processing (view-only mode) #viewonly = false ## Select audio device to play sound on #audio = sysdefault ## Select the audio and video decoder to use ## default - autodetect ## aml - hardware video decoder for ODROID-C1/C2 ## rk - hardware video decoder for ODROID-N1 Rockchip ## omx - hardware video decoder for Raspberry Pi ## imx - hardware video decoder for i.MX6 devices ## x11 - software decoder ## sdl - software decoder with SDL input and audio ## fake - no audio and video #platform = default ## Directory to store encryption keys ## By default keys are stored in $XDG_CACHE_DIR/moonlight or ~/.cache/moonlight moonlightConfig.save('keydir', '/userdata/system/configs/moonlight/keydir')
def createLibretroConfig(system, controllers, rom, bezel, gameResolution): # retroarch-core-options.cfg retroarchCore = batoceraFiles.retroarchCoreCustom 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=' ') # Create/update retroarch-core-options.cfg libretroOptions.generateCoreSettings(coreSettings, system, rom) # Create/update hatari.cfg if system.name == 'atarist': libretroOptions.generateHatariConf(batoceraFiles.hatariConf) retroarchConfig = dict() systemConfig = system.config renderConfig = system.renderconfig # Basic configuration retroarchConfig[ 'quit_press_twice'] = 'false' # not aligned behavior on other emus retroarchConfig[ 'menu_show_restart_retroarch'] = 'false' # this option messes everything up on Batocera if ever clicked retroarchConfig['video_driver'] = '"gl"' # needed for the ozone menu if system.isOptSet("display.rotate"): # 0 => 0 ; 1 => 270; 2 => 180 ; 3 => 90 if system.config["display.rotate"] == "0": retroarchConfig['video_rotation'] = "0" elif system.config["display.rotate"] == "1": retroarchConfig['video_rotation'] = "3" elif system.config["display.rotate"] == "2": retroarchConfig['video_rotation'] = "2" elif system.config["display.rotate"] == "3": retroarchConfig['video_rotation'] = "1" else: retroarchConfig['video_rotation'] = '0' if system.isOptSet( "gfxbackend") and system.config["gfxbackend"] == "vulkan": retroarchConfig['video_driver'] = '"vulkan"' retroarchConfig[ 'video_black_frame_insertion'] = 'false' # don't use anymore this value while it doesn't allow the shaders to work retroarchConfig[ 'pause_nonactive'] = 'false' # required at least on x86 x86_64 otherwise, the game is paused at launch retroarchConfig[ 'audio_driver'] = 'alsa' # force ALSA. TODO: check audio.backend retroarchConfig['midi_driver'] = 'alsa' retroarchConfig['cache_directory'] = '/userdata/system/.cache' retroarchConfig[ 'video_fullscreen'] = 'true' # Fullscreen is required at least for x86* and odroidn2 retroarchConfig[ 'savestate_directory'] = batoceraFiles.savesDir + system.name retroarchConfig[ 'savefile_directory'] = batoceraFiles.savesDir + system.name # Forced values (so that if the config is not correct, fix it) if system.config['core'] == 'tgbdual': retroarchConfig['aspect_ratio_index'] = str( ratioIndexes.index("core")) # Reset each time in this function # Disable internal image viewer (ES does it, and pico-8 won't load .p8.png) retroarchConfig['builtin_imageviewer_enable'] = 'false' # Disable the threaded video while it is causing issues to several people ? # This must be set to true on xu4 for performance issues if system.config['video_threaded']: retroarchConfig['video_threaded'] = 'true' else: retroarchConfig['video_threaded'] = 'false' # Input configuration retroarchConfig['input_joypad_driver'] = 'udev' retroarchConfig['input_max_users'] = "16" # Allow up to 16 players retroarchConfig[ 'input_libretro_device_p1'] = '1' # Default devices choices retroarchConfig['input_libretro_device_p2'] = '1' ## Specific choices if (system.config['core'] in coreToP1Device): retroarchConfig['input_libretro_device_p1'] = coreToP1Device[ system.config['core']] if (system.config['core'] in coreToP2Device): retroarchConfig['input_libretro_device_p2'] = coreToP2Device[ system.config['core']] ## AMICA CD32 if system.config['core'] == 'puae' and system.name == 'amigacd32': retroarchConfig['input_libretro_device_p1'] = '517' # CD 32 Pad ## BlueMSX choices by System if (system.name in systemToBluemsx): if system.config['core'] == 'bluemsx': retroarchConfig['input_libretro_device_p1'] = systemToP1Device[ system.name] retroarchConfig['input_libretro_device_p2'] = systemToP2Device[ system.name] ## SNES9x and SNES9x_next (2010) controller if system.config['core'] == 'snes9x' or system.config[ 'core'] == 'snes9x_next': if system.isOptSet('controller1_snes9x'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_snes9x'] elif system.isOptSet('controller1_snes9x_next'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_snes9x_next'] else: retroarchConfig['input_libretro_device_p1'] = '1' # Player 2 if system.isOptSet('controller2_snes9x'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_snes9x'] elif system.isOptSet('controller2_snes9x_next'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_snes9x_next'] elif len(controllers) > 2: # More than 2 controller connected retroarchConfig['input_libretro_device_p2'] = '257' else: retroarchConfig['input_libretro_device_p2'] = '1' # Player 3 if system.isOptSet('Controller3_snes9x'): retroarchConfig['input_libretro_device_p3'] = system.config[ 'Controller3_snes9x'] else: retroarchConfig['input_libretro_device_p3'] = '1' ## NES controller if system.config['core'] == 'fceumm': if system.isOptSet('controller1_nes'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_nes'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_nes'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_nes'] else: retroarchConfig['input_libretro_device_p2'] = '1' ## PlayStation controller if (system.config['core'] == 'mednafen_psx'): # Madnafen if system.isOptSet('beetle_psx_Controller1'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'beetle_psx_Controller1'] if system.isOptSet('beetle_psx_Controller2'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'beetle_psx_Controller2'] if (system.config['core'] == 'pcsx_rearmed'): # PCSX Rearmed if system.isOptSet('controller1_pcsx'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_pcsx'] if system.isOptSet('controller2_pcsx'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_pcsx'] ## Sega Dreamcast controller if system.config['core'] == 'flycast': if system.isOptSet('controller1_dc'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_dc'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_dc'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_dc'] else: retroarchConfig['input_libretro_device_p2'] = '1' if system.isOptSet('controller3_dc'): retroarchConfig['input_libretro_device_p3'] = system.config[ 'controller3_dc'] else: retroarchConfig['input_libretro_device_p3'] = '1' if system.isOptSet('controller4_dc'): retroarchConfig['input_libretro_device_p4'] = system.config[ 'controller4_dc'] else: retroarchConfig['input_libretro_device_p4'] = '1' ## Sega Megadrive controller if system.config['core'] == 'genesisplusgx' and system.name == 'megadrive': if system.isOptSet('controller1_md'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_md'] else: retroarchConfig['input_libretro_device_p1'] = '513' # 6 button if system.isOptSet('controller2_md'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_md'] else: retroarchConfig['input_libretro_device_p2'] = '513' # 6 button ## Sega Mastersystem controller if system.config[ 'core'] == 'genesisplusgx' and system.name == 'mastersystem': if system.isOptSet('controller1_ms'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_ms'] else: retroarchConfig['input_libretro_device_p1'] = '769' if system.isOptSet('controller2_ms'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_ms'] else: retroarchConfig['input_libretro_device_p2'] = '769' ## NEC PCEngine controller if system.config['core'] == 'pce' or system.config['core'] == 'pce_fast': if system.isOptSet('controller1_pce'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_pce'] else: retroarchConfig['input_libretro_device_p1'] = '1' ## MS-DOS controller if (system.config['core'] == 'dosbox_pure'): # Dosbox-Pure if system.isOptSet('controller1_dosbox_pure'): retroarchConfig['input_libretro_device_p1'] = system.config[ 'controller1_dosbox_pure'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_dosbox_pure'): retroarchConfig['input_libretro_device_p2'] = system.config[ 'controller2_dosbox_pure'] else: retroarchConfig['input_libretro_device_p2'] = '1' # Smooth option if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: retroarchConfig['video_smooth'] = 'true' else: retroarchConfig['video_smooth'] = 'false' # Shader option if 'shader' in renderConfig and renderConfig['shader'] != None: retroarchConfig['video_shader_enable'] = 'true' retroarchConfig[ 'video_smooth'] = 'false' # seems to be necessary for weaker SBCs shaderFilename = renderConfig['shader'] + ".glslp" if os.path.exists("/userdata/shaders/" + shaderFilename): retroarchConfig['video_shader_dir'] = "/userdata/shaders" eslog.log( "shader {} found in /userdata/shaders".format(shaderFilename)) else: retroarchConfig['video_shader_dir'] = "/usr/share/batocera/shaders" else: retroarchConfig['video_shader_enable'] = 'false' # Ratio option retroarchConfig[ 'aspect_ratio_index'] = '' # reset in case config was changed (or for overlays) if defined('ratio', systemConfig): if systemConfig['ratio'] in ratioIndexes: retroarchConfig['aspect_ratio_index'] = ratioIndexes.index( systemConfig['ratio']) retroarchConfig['video_aspect_ratio_auto'] = 'false' elif systemConfig['ratio'] == "custom": retroarchConfig['video_aspect_ratio_auto'] = 'false' else: retroarchConfig['video_aspect_ratio_auto'] = 'true' retroarchConfig['aspect_ratio_index'] = '' # Rewind option retroarchConfig['rewind_enable'] = 'false' if system.isOptSet('rewind') and system.getOptBoolean('rewind') == True: if (not system.name in systemNoRewind): retroarchConfig['rewind_enable'] = 'true' else: retroarchConfig['rewind_enable'] = 'false' else: retroarchConfig['rewind_enable'] = 'false' # Retroachievement option retroarchConfig['run_ahead_enabled'] = 'false' retroarchConfig['run_ahead_frames'] = '0' retroarchConfig['run_ahead_secondary_instance'] = 'false' if system.isOptSet('runahead') and int(system.config['runahead']) > 0: if (not system.name in systemNoRunahead): retroarchConfig['run_ahead_enabled'] = 'true' retroarchConfig['run_ahead_frames'] = system.config['runahead'] if system.isOptSet('secondinstance') and system.getOptBoolean( 'secondinstance') == True: retroarchConfig['run_ahead_secondary_instance'] = 'true' if system.isOptSet("retroachievements_sound") and system.config[ "retroachievements_sound"] != "none": retroarchConfig['cheevos_unlock_sound_enable'] = 'true' retroarchConfig['cheevos_unlock_sound'] = system.config[ "retroachievements_sound"] else: retroarchConfig['cheevos_unlock_sound_enable'] = 'false' # Autosave option if system.isOptSet('autosave') and system.getOptBoolean( 'autosave') == True: retroarchConfig['savestate_auto_save'] = 'true' retroarchConfig['savestate_auto_load'] = 'true' else: retroarchConfig['savestate_auto_save'] = 'false' retroarchConfig['savestate_auto_load'] = 'false' # state_slot option if system.isOptSet('state_slot'): retroarchConfig['state_slot'] = system.config['state_slot'] else: retroarchConfig['state_slot'] = '0' # Retroachievements option retroarchConfig['cheevos_enable'] = 'false' retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' retroarchConfig['cheevos_leaderboards_enable'] = 'false' retroarchConfig['cheevos_verbose_enable'] = 'false' retroarchConfig['cheevos_auto_screenshot'] = 'false' if system.isOptSet('retroachievements') and system.getOptBoolean( 'retroachievements') == True: if (system.name in systemToRetroachievements): retroarchConfig['cheevos_enable'] = 'true' retroarchConfig['cheevos_username'] = systemConfig.get( 'retroachievements.username', "") retroarchConfig['cheevos_password'] = systemConfig.get( 'retroachievements.password', "") # retroachievements_hardcore_mode if system.isOptSet( 'retroachievements.hardcore') and system.getOptBoolean( 'retroachievements.hardcore') == True: retroarchConfig['cheevos_hardcore_mode_enable'] = 'true' else: retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' # retroachievements_leaderboards if system.isOptSet( 'retroachievements.leaderboards') and system.getOptBoolean( 'retroachievements.leaderboards') == True: retroarchConfig['cheevos_leaderboards_enable'] = 'true' else: retroarchConfig['cheevos_leaderboards_enable'] = 'false' # retroachievements_verbose_mode if system.isOptSet( 'retroachievements.verbose') and system.getOptBoolean( 'retroachievements.verbose') == True: retroarchConfig['cheevos_verbose_enable'] = 'true' else: retroarchConfig['cheevos_verbose_enable'] = 'false' # retroachievements_automatic_screenshot if system.isOptSet( 'retroachievements.screenshot') and system.getOptBoolean( 'retroachievements.screenshot') == True: retroarchConfig['cheevos_auto_screenshot'] = 'true' else: retroarchConfig['cheevos_auto_screenshot'] = 'false' else: retroarchConfig['cheevos_enable'] = 'false' if system.isOptSet('integerscale') and system.getOptBoolean( 'integerscale') == True: retroarchConfig['video_scale_integer'] = 'true' else: retroarchConfig['video_scale_integer'] = 'false' # Netplay management if 'netplay.mode' in system.config and system.config[ 'netplay.mode'] in systemNetplayModes: # Security : hardcore mode disables save states, which would kill netplay retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' # Quite strangely, host mode requires netplay_mode to be set to false when launched from command line retroarchConfig['netplay_mode'] = "false" retroarchConfig['netplay_ip_port'] = systemConfig.get( 'netplay.port', "") retroarchConfig['netplay_delay_frames'] = systemConfig.get( 'netplay.frames', "") retroarchConfig['netplay_nickname'] = systemConfig.get( 'netplay.nickname', "") retroarchConfig['netplay_client_swap_input'] = "false" if system.config['netplay.mode'] == 'client' or system.config[ 'netplay.mode'] == 'spectator': # But client needs netplay_mode = true ... bug ? retroarchConfig['netplay_mode'] = "true" retroarchConfig['netplay_ip_address'] = systemConfig.get( 'netplay.server.ip', "") retroarchConfig['netplay_ip_port'] = systemConfig.get( 'netplay.server.port', "") retroarchConfig['netplay_client_swap_input'] = "true" # Connect as client if system.config['netplay.mode'] == 'client': if 'netplay.password' in system.config: retroarchConfig['netplay_password'] = '******' + systemConfig.get( "netplay.password", "") + '"' else: retroarchConfig['netplay_password'] = "" # Connect as spectator if system.config['netplay.mode'] == 'spectator': retroarchConfig['netplay_start_as_spectator'] = "true" if 'netplay.password' in system.config: retroarchConfig[ 'netplay_spectate_password'] = '******' + systemConfig.get( "netplay.password", "") + '"' else: retroarchConfig['netplay_spectate_password'] = "" else: retroarchConfig['netplay_start_as_spectator'] = "false" # Netplay host passwords if system.config['netplay.mode'] == 'host': retroarchConfig['netplay_password'] = '******' + systemConfig.get( "netplay.password", "") + '"' retroarchConfig[ 'netplay_spectate_password'] = '******' + systemConfig.get( "netplay.spectatepassword", "") + '"' # Netplay hide the gameplay if system.isOptSet('netplay_public_announce') and system.getOptBoolean( 'netplay_public_announce') == False: retroarchConfig['netplay_public_announce'] = 'false' else: retroarchConfig['netplay_public_announce'] = 'true' # Enable or disable server spectator mode if system.isOptSet('netplay.spectator') and system.getOptBoolean( 'netplay.spectator') == True: retroarchConfig['netplay_spectator_mode_enable'] = 'true' else: retroarchConfig['netplay_spectator_mode_enable'] = 'false' # Relay if 'netplay.relay' in system.config and system.config[ 'netplay.relay'] != "" and system.config[ 'netplay.relay'] != "none": retroarchConfig['netplay_use_mitm_server'] = "true" retroarchConfig['netplay_mitm_server'] = systemConfig.get( 'netplay.relay', "") else: retroarchConfig['netplay_use_mitm_server'] = "false" # Display FPS if system.isOptSet('showFPS') and system.getOptBoolean('showFPS') == True: retroarchConfig['fps_show'] = 'true' else: retroarchConfig['fps_show'] = 'false' # Adaptation for small resolution if isLowResolution(gameResolution): retroarchConfig['video_font_size'] = '12' retroarchConfig['menu_driver'] = 'rgui' retroarchConfig['width'] = gameResolution[ "width"] * 2 # on low resolution, higher values for width and height makes a nicer image (640x480 on the gpi case) retroarchConfig[ 'height'] = gameResolution["height"] * 2 # default value retroarchConfig['menu_linear_filter'] = 'true' retroarchConfig['rgui_aspect_ratio'] = '0' retroarchConfig['rgui_aspect_ratio_lock'] = '3' else: retroarchConfig['video_font_size'] = '32' retroarchConfig['menu_driver'] = 'ozone' # force the assets directory while it was wrong in some beta versions retroarchConfig['assets_directory'] = '/usr/share/libretro/assets' retroarchConfig['width'] = gameResolution["width"] # default value retroarchConfig['height'] = gameResolution["height"] # default value # AI option (service for game translations) if system.isOptSet('ai_service_enabled') and system.getOptBoolean( 'ai_service_enabled') == True: retroarchConfig['ai_service_enable'] = 'true' retroarchConfig['ai_service_mode'] = '0' retroarchConfig['ai_service_source_lang'] = '0' if system.isOptSet('ai_target_lang'): chosen_lang = system.config['ai_target_lang'] else: chosen_lang = 'En' if system.isOptSet( 'ai_service_url') and system.config['ai_service_url']: retroarchConfig['ai_service_url'] = system.config[ 'ai_service_url'] + '&mode=Fast&output=png&target_lang=' + chosen_lang else: retroarchConfig[ 'ai_service_url'] = 'http://ztranslate.net/service?api_key=BATOCERA&mode=Fast&output=png&target_lang=' + chosen_lang if system.isOptSet('ai_service_pause') and system.getOptBoolean( 'ai_service_pause') == True: retroarchConfig['ai_service_pause'] = 'true' else: retroarchConfig['ai_service_pause'] = 'false' else: retroarchConfig['ai_service_enable'] = 'false' # Bezel option if system.isOptSet('bezel_stretch') and system.getOptBoolean( 'bezel_stretch') == True: bezel_stretch = True else: bezel_stretch = False try: writeBezelConfig(bezel, retroarchConfig, system.name, rom, gameResolution, bezel_stretch) except: # error with bezels, disabling them writeBezelConfig(None, retroarchConfig, system.name, rom, gameResolution, bezel_stretch) # custom : allow the user to configure directly retroarch.cfg via batocera.conf via lines like : snes.retroarch.menu_driver=rgui for user_config in systemConfig: if user_config[:10] == "retroarch.": retroarchConfig[user_config[10:]] = systemConfig[user_config] return retroarchConfig
def generate(self, system, rom, playersControllers, gameResolution): # Settings recalbox default config file if no user defined one if not 'configfile' in system.config: # Using recalbox config file system.config['configfile'] = recalboxFiles.retroarchCustom # Create retroarchcustom.cfg if does not exists if not os.path.isfile(recalboxFiles.retroarchCustom): shutil.copyfile(recalboxFiles.retroarchCustomOrigin, recalboxFiles.retroarchCustom) # Write controllers configuration files retroconfig = UnixSettings(recalboxFiles.retroarchCustom, separator=' ') libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) # Write configuration to retroarchcustom.cfg if 'bezel' not in system.config or system.config['bezel'] == '': bezel = None else: bezel = system.config['bezel'] libretroConfig.writeLibretroConfig(retroconfig, system, playersControllers, rom, bezel, gameResolution) # Retroarch core on the filesystem retroarchCore = recalboxFiles.retroarchCores + system.config[ 'core'] + recalboxFiles.libretroExt romName = os.path.basename(rom) # the command to run commandArray = [ recalboxFiles.recalboxBins[system.config['emulator']], "-L", retroarchCore, "--config", system.config['configfile'] ] configToAppend = [] # Custom configs - per core customCfg = "{}/{}.cfg".format(recalboxFiles.retroarchRoot, system.name) if os.path.isfile(customCfg): configToAppend.append(customCfg) # Custom configs - per game customGameCfg = "{}/{}/{}.cfg".format(recalboxFiles.retroarchRoot, system.name, romName) if os.path.isfile(customGameCfg): configToAppend.append(customGameCfg) # Overlay management overlayFile = "{}/{}/{}.cfg".format(recalboxFiles.OVERLAYS, system.name, romName) if os.path.isfile(overlayFile): configToAppend.append(overlayFile) # Generate the append if configToAppend: commandArray.extend(["--appendconfig", "|".join(configToAppend)]) # Netplay mode if 'netplaymode' in system.config: if system.config['netplaymode'] == 'host': commandArray.append("--host") elif system.config['netplaymode'] == 'client': commandArray.extend( ["--connect", system.config['netplay.server.address']]) commandArray.append(rom) return Command.Command(array=commandArray)
#!/usr/bin/env python import sys import os import gamestationFiles import settings from Emulator import Emulator from settings.unixSettings import UnixSettings sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) ppssppSettings = UnixSettings(gamestationFiles.ppssppConfig, separator=' ') def writePPSSPPConfig(system): writePPSSPPConfigDefault() writePPSSPPConfigToFile(createPPSSPPConfig(system)) def writePPSSPPConfigDefault(): if not os.path.exists(gamestationFiles.ppssppConfig): # write default values template, so that the rest of the config can set values f = open(gamestationFiles.ppssppConfig, "w") f.write("[Graphics]\n") f.write("FrameSkip = 0\n") f.write("ShowFPSCounter = 0\n") f.close() def createPPSSPPConfig(system): ppssppConfig = dict()
def generateCoreSettings(retroarchCore, system): # retroarch-core-options.cfg if not os.path.exists(os.path.dirname(retroarchCore)): os.makedirs(os.path.dirname(retroarchCore)) coreSettings = UnixSettings(retroarchCore, separator=' ') # Atari 800 and 5200 if (system.config['core'] == 'atari800'): if (system.name == 'atari800'): coreSettings.save('atari800_system', '"800XL (64K)"') 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_msxtype', '"Auto"') if (system.config['core'] == 'fmsx'): coreSettings.save('fmsx_mode', '"MSX2"') coreSettings.save('fmsx_mapper_type_mode', '"Guess Mapper Type A"') 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"') 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'] == 'pce'): coreSettings.save('pce_keepaspect', '"enabled"') if (system.config['core'] == 'picodrive'): coreSettings.save('picodrive_input1', '"6 button pad"') coreSettings.save('picodrive_input2', '"6 button pad"') 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'] == '4do'): coreSettings.save('4do_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_JoyPort', '"port_1"')
#!/usr/bin/env python import sys import os import gamestationFiles from Emulator import Emulator from settings.unixSettings import UnixSettings sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) fbaSettings = UnixSettings(gamestationFiles.fbaCustom) # return true if the option is considered defined def defined(key, dict): return key in dict and isinstance(dict[key], str) and len(dict[key]) > 0 ratioIndexes = {'16/9': '0', '4/3': '1'} def writeFBAConfig(system): writeFBAConfigToFile(createFBAConfig(system)) # take a system, and returns a dict of retroarch.cfg compatible parameters def createFBAConfig(system): fbaConfig = dict() gamestationConfig = system.config if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: fbaConfig['DisplaySmoothStretch'] = '1'
#!/usr/bin/env python import sys import os sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from settings.unixSettings import UnixSettings import recalboxFiles mupenSettings = UnixSettings(recalboxFiles.mupenCustom, separator=' ') # Write a configuration for a specified controller def writeControllersConfig(controllers): writeHotKeyConfig(controllers) def writeHotKeyConfig(controllers): if '1' in controllers: if 'hotkey' in controllers['1'].inputs: mupenSettings.save( 'Joy Mapping Stop', "\"J{}B{}\"".format(controllers['1'].index, controllers['1'].inputs['hotkey'].id))
def createLibretroConfig(system, controllers, rom, bezel, gameResolution, gfxBackend): # retroarch-core-options.cfg retroarchCore = batoceraFiles.retroarchCoreCustom 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=' ') # Create/update retroarch-core-options.cfg libretroOptions.generateCoreSettings(coreSettings, system, rom) # Create/update hatari.cfg if system.name == 'atarist': libretroOptions.generateHatariConf(batoceraFiles.hatariConf) retroarchConfig = dict() systemConfig = system.config renderConfig = system.renderconfig # Basic configuration retroarchConfig['quit_press_twice'] = 'false' # not aligned behavior on other emus retroarchConfig['menu_show_restart_retroarch'] = 'false' # this option messes everything up on Batocera if ever clicked retroarchConfig['video_driver'] = '"' + gfxBackend + '"' # needed for the ozone menu retroarchConfig['audio_latency'] = '64' # best balance with audio perf if (system.isOptSet("audio_latency")): retroarchConfig['audio_latency'] = system.config['audio_latency'] with open("/usr/share/batocera/batocera.arch") as fb: arch = fb.readline().strip() if (system.isOptSet("display.rotate") and arch not in [ 'x86_64', 'x86']): # 0 => 0 ; 1 => 270; 2 => 180 ; 3 => 90 if system.config["display.rotate"] == "0": retroarchConfig['video_rotation'] = "0" elif system.config["display.rotate"] == "1": retroarchConfig['video_rotation'] = "3" elif system.config["display.rotate"] == "2": retroarchConfig['video_rotation'] = "2" elif system.config["display.rotate"] == "3": retroarchConfig['video_rotation'] = "1" else: retroarchConfig['video_rotation'] = '0' if system.isOptSet('video_threaded') and system.getOptBoolean('video_threaded') == True: retroarchConfig['video_threaded'] = 'true' else: retroarchConfig['video_threaded'] = 'false' if system.isOptSet('video_allow_rotate') and system.getOptBoolean('video_allow_rotate') == False: retroarchConfig['video_allow_rotate'] = 'false' else: retroarchConfig['video_allow_rotate'] = 'true' # variable refresh rate if system.isOptSet("vrr_runloop_enable") and system.getOptBoolean("vrr_runloop_enable") == False: retroarchConfig['vrr_runloop_enable'] = 'false' else: retroarchConfig['vrr_runloop_enable'] = 'true' # required at least for vulkan (to get the correct resolution) retroarchConfig['video_fullscreen_x'] = gameResolution["width"] retroarchConfig['video_fullscreen_y'] = gameResolution["height"] retroarchConfig['video_black_frame_insertion'] = 'false' # don't use anymore this value while it doesn't allow the shaders to work retroarchConfig['pause_nonactive'] = 'false' # required at least on x86 x86_64 otherwise, the game is paused at launch retroarchConfig['cache_directory'] = '/userdata/system/.cache' retroarchConfig['video_fullscreen'] = 'true' # Fullscreen is required at least for x86* and odroidn2 retroarchConfig['savestate_directory'] = batoceraFiles.savesDir + system.name retroarchConfig['savefile_directory'] = batoceraFiles.savesDir + system.name # Forced values (so that if the config is not correct, fix it) if system.config['core'] == 'tgbdual': retroarchConfig['aspect_ratio_index'] = str(ratioIndexes.index("core")) # Reset each time in this function # Disable internal image viewer (ES does it, and pico-8 won't load .p8.png) retroarchConfig['builtin_imageviewer_enable'] = 'false' # Input configuration retroarchConfig['input_joypad_driver'] = 'udev' retroarchConfig['input_max_users'] = "16" # Allow up to 16 players retroarchConfig['input_libretro_device_p1'] = '1' # Default devices choices retroarchConfig['input_libretro_device_p2'] = '1' # D-pad = Left analog stick forcing on PUAE and VICE (New D2A system on RA doesn't work with these cores.) if system.config['core'] == 'puae' or system.config['core'] == 'vice_x64': retroarchConfig['input_player1_analog_dpad_mode'] = '3' retroarchConfig['input_player2_analog_dpad_mode'] = '3' # force notification messages retroarchConfig['video_font_enable'] = '"true"' # prevent displaying "QUICK MENU" with "No Items" after DOSBox Pure, TyrQuake and PrBoom games exit retroarchConfig['load_dummy_on_core_shutdown'] = '"false"' ## Specific choices if(system.config['core'] in coreToP1Device): retroarchConfig['input_libretro_device_p1'] = coreToP1Device[system.config['core']] if(system.config['core'] in coreToP2Device): retroarchConfig['input_libretro_device_p2'] = coreToP2Device[system.config['core']] ## AMIGA OCS-ECS/AGA/CD32 if system.config['core'] == 'puae': if system.name != 'amigacd32': if system.isOptSet('controller1_puae'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_puae'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_puae'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_puae'] else: retroarchConfig['input_libretro_device_p2'] = '1' else: retroarchConfig['input_libretro_device_p1'] = '517' # CD 32 Pad ## BlueMSX choices by System if(system.name in systemToBluemsx): if system.config['core'] == 'bluemsx': retroarchConfig['input_libretro_device_p1'] = systemToP1Device[system.name] retroarchConfig['input_libretro_device_p2'] = systemToP2Device[system.name] ## SNES9x and SNES9x_next (2010) controller if system.config['core'] == 'snes9x' or system.config['core'] == 'snes9x_next': if system.isOptSet('controller1_snes9x'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_snes9x'] elif system.isOptSet('controller1_snes9x_next'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_snes9x_next'] else: retroarchConfig['input_libretro_device_p1'] = '1' # Player 2 if system.isOptSet('controller2_snes9x'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_snes9x'] elif system.isOptSet('controller2_snes9x_next'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_snes9x_next'] elif len(controllers) > 2: # More than 2 controller connected retroarchConfig['input_libretro_device_p2'] = '257' else: retroarchConfig['input_libretro_device_p2'] = '1' # Player 3 if system.isOptSet('Controller3_snes9x'): retroarchConfig['input_libretro_device_p3'] = system.config['Controller3_snes9x'] else: retroarchConfig['input_libretro_device_p3'] = '1' ## NES controller if system.config['core'] == 'fceumm': if system.isOptSet('controller1_nes'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_nes'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_nes'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_nes'] else: retroarchConfig['input_libretro_device_p2'] = '1' ## PlayStation controller if (system.config['core'] == 'mednafen_psx'): # Madnafen if system.isOptSet('beetle_psx_Controller1'): retroarchConfig['input_libretro_device_p1'] = system.config['beetle_psx_Controller1'] if system.config['beetle_psx_Controller1'] != '1': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '1' if system.isOptSet('beetle_psx_Controller2'): retroarchConfig['input_libretro_device_p2'] = system.config['beetle_psx_Controller2'] if system.config['beetle_psx_Controller2'] != '1': retroarchConfig['input_player2_analog_dpad_mode'] = '0' else: retroarchConfig['input_player2_analog_dpad_mode'] = '1' if (system.config['core'] == 'pcsx_rearmed'): # PCSX Rearmed if system.isOptSet('controller1_pcsx'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_pcsx'] if system.config['controller1_pcsx'] != '1': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '1' if system.isOptSet('controller2_pcsx'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_pcsx'] if system.config['controller2_pcsx'] != '1': retroarchConfig['input_player2_analog_dpad_mode'] = '0' else: retroarchConfig['input_player2_analog_dpad_mode'] = '1' ## Sega Dreamcast controller if system.config['core'] == 'flycast': if system.name != 'dreamcast': retroarchConfig['input_player1_analog_dpad_mode'] = '3' retroarchConfig['input_player2_analog_dpad_mode'] = '3' retroarchConfig['input_player3_analog_dpad_mode'] = '3' retroarchConfig['input_player4_analog_dpad_mode'] = '3' else: retroarchConfig['input_player1_analog_dpad_mode'] = '1' retroarchConfig['input_player2_analog_dpad_mode'] = '1' retroarchConfig['input_player3_analog_dpad_mode'] = '1' retroarchConfig['input_player4_analog_dpad_mode'] = '1' if system.isOptSet('controller1_dc'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_dc'] else: retroarchConfig['input_libretro_device_p1'] = '1' if system.isOptSet('controller2_dc'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_dc'] else: retroarchConfig['input_libretro_device_p2'] = '1' if system.isOptSet('controller3_dc'): retroarchConfig['input_libretro_device_p3'] = system.config['controller3_dc'] else: retroarchConfig['input_libretro_device_p3'] = '1' if system.isOptSet('controller4_dc'): retroarchConfig['input_libretro_device_p4'] = system.config['controller4_dc'] else: retroarchConfig['input_libretro_device_p4'] = '1' ## Sega Megadrive controller if system.config['core'] == 'genesisplusgx' and system.name == 'megadrive': if system.isOptSet('controller1_md'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_md'] else: retroarchConfig['input_libretro_device_p1'] = '513' # 6 button if system.isOptSet('controller2_md'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_md'] else: retroarchConfig['input_libretro_device_p2'] = '513' # 6 button ## Sega Mastersystem controller if system.config['core'] == 'genesisplusgx' and system.name == 'mastersystem': if system.isOptSet('controller1_ms'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_ms'] else: retroarchConfig['input_libretro_device_p1'] = '769' if system.isOptSet('controller2_ms'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_ms'] else: retroarchConfig['input_libretro_device_p2'] = '769' ## NEC PCEngine controller if system.config['core'] == 'pce' or system.config['core'] == 'pce_fast': if system.isOptSet('controller1_pce'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_pce'] else: retroarchConfig['input_libretro_device_p1'] = '1' ## MS-DOS controller if (system.config['core'] == 'dosbox_pure'): # Dosbox-Pure if system.isOptSet('controller1_dosbox_pure'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_dosbox_pure'] if system.config['controller1_dosbox_pure'] != '3': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '3' if system.isOptSet('controller2_dosbox_pure'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_dosbox_pure'] if system.config['controller2_dosbox_pure'] != '3': retroarchConfig['input_player2_analog_dpad_mode'] = '0' else: retroarchConfig['input_player2_analog_dpad_mode'] = '3' ## PS1 Swanstation and Duckstation if (system.config['core'] == 'swanstation'): # Swanstation # Controller 1 Type if system.isOptSet('duckstation_Controller1'): coreSettings.save('duckstation_Controller1.Type', system.config['duckstation_Controller1']) else: coreSettings.save('duckstation_Controller1.Type', '"DigitalController"') # Controller 2 Type if system.isOptSet('duckstation_Controller2'): coreSettings.save('duckstation_Controller2.Type', system.config['duckstation_Controller2']) else: coreSettings.save('duckstation_Controller2.Type', '"DigitalController"') if (system.config['core'] == 'duckstation'): # Duckstation if system.isOptSet('duckstation_Controller1'): retroarchConfig['input_libretro_device_p1'] = system.config['duckstation_Controller1'] if system.config['duckstation_Controller1'] != '1': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '3' if system.isOptSet('duckstation_Controller2'): retroarchConfig['input_libretro_device_p2'] = system.config['duckstation_Controller2'] if system.config['duckstation_Controller2'] != '1': retroarchConfig['input_player2_analog_dpad_mode'] = '0' else: retroarchConfig['input_player2_analog_dpad_mode'] = '3' ## PORTS ## Quake if (system.config['core'] == 'tyrquake'): if system.isOptSet('tyrquake_controller1'): retroarchConfig['input_libretro_device_p1'] = system.config['tyrquake_controller1'] if system.config['tyrquake_controller1'] == '773' or system.config['tyrquake_controller1'] == '3': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '1' else: retroarchConfig['input_libretro_device_p1'] = '1' ## DOOM if (system.config['core'] == 'prboom'): if system.isOptSet('prboom_controller1'): retroarchConfig['input_libretro_device_p1'] = system.config['prboom_controller1'] if system.config['prboom_controller1'] != '1' or system.config['prboom_controller1'] == '3': retroarchConfig['input_player1_analog_dpad_mode'] = '0' else: retroarchConfig['input_player1_analog_dpad_mode'] = '1' else: retroarchConfig['input_libretro_device_p1'] = '1' ## ZX Spectrum if (system.config['core'] == 'fuse'): if system.isOptSet('controller1_zxspec'): retroarchConfig['input_libretro_device_p1'] = system.config['controller1_zxspec'] else: retroarchConfig['input_libretro_device_p1'] = '769' #Sinclair 1 controller - most used on games if system.isOptSet('controller2_zxspec'): retroarchConfig['input_libretro_device_p2'] = system.config['controller2_zxspec'] else: retroarchConfig['input_libretro_device_p2'] = '1025' #Sinclair 2 controller if system.isOptSet('controller3_zxspec'): retroarchConfig['input_libretro_device_p3'] = system.config['controller3_zxspec'] else: retroarchConfig['input_libretro_device_p3'] = '0' # Smooth option if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: retroarchConfig['video_smooth'] = 'true' else: retroarchConfig['video_smooth'] = 'false' # Shader option if 'shader' in renderConfig and renderConfig['shader'] != None: retroarchConfig['video_shader_enable'] = 'true' retroarchConfig['video_smooth'] = 'false' # seems to be necessary for weaker SBCs else: retroarchConfig['video_shader_enable'] = 'false' # Ratio option retroarchConfig['aspect_ratio_index'] = '' # reset in case config was changed (or for overlays) if defined('ratio', systemConfig): if systemConfig['ratio'] in ratioIndexes: retroarchConfig['aspect_ratio_index'] = ratioIndexes.index(systemConfig['ratio']) retroarchConfig['video_aspect_ratio_auto'] = 'false' elif systemConfig['ratio'] == "custom": retroarchConfig['video_aspect_ratio_auto'] = 'false' else: retroarchConfig['video_aspect_ratio_auto'] = 'true' retroarchConfig['aspect_ratio_index'] = '22' # Rewind option retroarchConfig['rewind_enable'] = 'false' if system.isOptSet('rewind') and system.getOptBoolean('rewind') == True: if(not system.name in systemNoRewind): retroarchConfig['rewind_enable'] = 'true' else: retroarchConfig['rewind_enable'] = 'false' else: retroarchConfig['rewind_enable'] = 'false' # Run-ahead option (latency reduction) retroarchConfig['run_ahead_enabled'] = 'false' retroarchConfig['run_ahead_frames'] = '0' retroarchConfig['run_ahead_secondary_instance'] = 'false' if system.isOptSet('runahead') and int(system.config['runahead']) >0: if (not system.name in systemNoRunahead): retroarchConfig['run_ahead_enabled'] = 'true' retroarchConfig['run_ahead_frames'] = system.config['runahead'] if system.isOptSet('secondinstance') and system.getOptBoolean('secondinstance') == True: retroarchConfig['run_ahead_secondary_instance'] = 'true' # Auto frame delay (input delay reduction via frame timing) if system.isOptSet('video_frame_delay_auto') and system.getOptBoolean('video_frame_delay_auto') == True: retroarchConfig['video_frame_delay_auto'] = 'true' else: retroarchConfig['video_frame_delay_auto'] = 'false' # Retroachievement option if system.isOptSet("retroachievements.sound") and system.config["retroachievements.sound"] != "none": retroarchConfig['cheevos_unlock_sound_enable'] = 'true' retroarchConfig['cheevos_unlock_sound'] = system.config["retroachievements.sound"] else: retroarchConfig['cheevos_unlock_sound_enable'] = 'false' # Autosave option if system.isOptSet('autosave') and system.getOptBoolean('autosave') == True: retroarchConfig['savestate_auto_save'] = 'true' retroarchConfig['savestate_auto_load'] = 'true' else: retroarchConfig['savestate_auto_save'] = 'false' retroarchConfig['savestate_auto_load'] = 'false' if system.isOptSet('incrementalsavestates') and not system.getOptBoolean('incrementalsavestates'): retroarchConfig['savestate_auto_index'] = 'false' retroarchConfig['savestate_max_keep'] = '50' else: retroarchConfig['savestate_auto_index'] = 'true' retroarchConfig['savestate_max_keep'] = '0' # state_slot option if system.isOptSet('state_slot'): retroarchConfig['state_slot'] = system.config['state_slot'] else: retroarchConfig['state_slot'] = '0' # Retroachievements option retroarchConfig['cheevos_enable'] = 'false' retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' retroarchConfig['cheevos_leaderboards_enable'] = 'false' retroarchConfig['cheevos_verbose_enable'] = 'false' retroarchConfig['cheevos_auto_screenshot'] = 'false' retroarchConfig['cheevos_challenge_indicators'] = 'false' if system.isOptSet('retroachievements') and system.getOptBoolean('retroachievements') == True: if(system.name in systemToRetroachievements) or (system.config['core'] in coreToRetroachievements) or (system.isOptSet('cheevos_force') and system.getOptBoolean('cheevos_force') == True): retroarchConfig['cheevos_enable'] = 'true' retroarchConfig['cheevos_username'] = systemConfig.get('retroachievements.username', "") retroarchConfig['cheevos_password'] = systemConfig.get('retroachievements.password', "") # retroachievements_hardcore_mode if system.isOptSet('retroachievements.hardcore') and system.getOptBoolean('retroachievements.hardcore') == True: retroarchConfig['cheevos_hardcore_mode_enable'] = 'true' else: retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' # retroachievements_leaderboards if system.isOptSet('retroachievements.leaderboards') and system.getOptBoolean('retroachievements.leaderboards') == True: retroarchConfig['cheevos_leaderboards_enable'] = 'true' else: retroarchConfig['cheevos_leaderboards_enable'] = 'false' # retroachievements_verbose_mode if system.isOptSet('retroachievements.verbose') and system.getOptBoolean('retroachievements.verbose') == True: retroarchConfig['cheevos_verbose_enable'] = 'true' else: retroarchConfig['cheevos_verbose_enable'] = 'false' # retroachievements_automatic_screenshot if system.isOptSet('retroachievements.screenshot') and system.getOptBoolean('retroachievements.screenshot') == True: retroarchConfig['cheevos_auto_screenshot'] = 'true' else: retroarchConfig['cheevos_auto_screenshot'] = 'false' # retroarchievements_challenge_indicators if system.isOptSet('retroachievements.challenge_indicators') and system.getOptBoolean('retroachievements.challenge_indicators') == True: retroarchConfig['cheevos_challenge_indicators'] = 'true' else: retroarchConfig['cheevos_challenge_indicators'] = 'false' else: retroarchConfig['cheevos_enable'] = 'false' if system.isOptSet('integerscale') and system.getOptBoolean('integerscale') == True: retroarchConfig['video_scale_integer'] = 'true' else: retroarchConfig['video_scale_integer'] = 'false' # Netplay management if 'netplay.mode' in system.config and system.config['netplay.mode'] in systemNetplayModes: # Security : hardcore mode disables save states, which would kill netplay retroarchConfig['cheevos_hardcore_mode_enable'] = 'false' # Quite strangely, host mode requires netplay_mode to be set to false when launched from command line retroarchConfig['netplay_mode'] = "false" retroarchConfig['netplay_ip_port'] = systemConfig.get('netplay.port', "") retroarchConfig['netplay_delay_frames'] = systemConfig.get('netplay.frames', "") retroarchConfig['netplay_nickname'] = systemConfig.get('netplay.nickname', "") retroarchConfig['netplay_client_swap_input'] = "false" if system.config['netplay.mode'] == 'client' or system.config['netplay.mode'] == 'spectator': # But client needs netplay_mode = true ... bug ? retroarchConfig['netplay_mode'] = "true" retroarchConfig['netplay_ip_address'] = systemConfig.get('netplay.server.ip', "") retroarchConfig['netplay_ip_port'] = systemConfig.get('netplay.server.port', "") retroarchConfig['netplay_client_swap_input'] = "true" # Connect as client if system.config['netplay.mode'] == 'client': if 'netplay.password' in system.config: retroarchConfig['netplay_password'] = '******' + systemConfig.get("netplay.password", "") + '"' else: retroarchConfig['netplay_password'] = "" # Connect as spectator if system.config['netplay.mode'] == 'spectator': retroarchConfig['netplay_start_as_spectator'] = "true" if 'netplay.password' in system.config: retroarchConfig['netplay_spectate_password'] = '******' + systemConfig.get("netplay.password", "") + '"' else: retroarchConfig['netplay_spectate_password'] = "" else: retroarchConfig['netplay_start_as_spectator'] = "false" # Netplay host passwords if system.config['netplay.mode'] == 'host': retroarchConfig['netplay_password'] = '******' + systemConfig.get("netplay.password", "") + '"' retroarchConfig['netplay_spectate_password'] = '******' + systemConfig.get("netplay.spectatepassword", "") + '"' # Netplay hide the gameplay if system.isOptSet('netplay_public_announce') and system.getOptBoolean('netplay_public_announce') == False: retroarchConfig['netplay_public_announce'] = 'false' else: retroarchConfig['netplay_public_announce'] = 'true' # Enable or disable server spectator mode if system.isOptSet('netplay.spectator') and system.getOptBoolean('netplay.spectator') == True: retroarchConfig['netplay_spectator_mode_enable'] = 'true' else: retroarchConfig['netplay_spectator_mode_enable'] = 'false' # Relay if 'netplay.relay' in system.config and system.config['netplay.relay'] != "" and system.config['netplay.relay'] != "none" : retroarchConfig['netplay_use_mitm_server'] = "true" retroarchConfig['netplay_mitm_server'] = systemConfig.get('netplay.relay', "") else: retroarchConfig['netplay_use_mitm_server'] = "false" # Display FPS if system.isOptSet('showFPS') and system.getOptBoolean('showFPS') == True: retroarchConfig['fps_show'] = 'true' else: retroarchConfig['fps_show'] = 'false' # Adaptation for small resolution (GPICase) if isLowResolution(gameResolution): retroarchConfig['width'] = gameResolution["width"] retroarchConfig['height'] = gameResolution["height"] retroarchConfig['video_font_size'] = '12' retroarchConfig['menu_widget_scale_auto'] = 'false' retroarchConfig['menu_widget_scale_factor'] = '2.0000' retroarchConfig['menu_widget_scale_factor_windowed'] = '2.0000' else: retroarchConfig['video_font_size'] = '32' retroarchConfig['menu_widget_scale_auto'] = 'true' # don't force any so that the user can choose #retroarchConfig['menu_driver'] = 'ozone' # force the assets directory while it was wrong in some beta versions retroarchConfig['assets_directory'] = '/usr/share/libretro/assets' retroarchConfig['width'] = gameResolution["width"] # default value retroarchConfig['height'] = gameResolution["height"] # default value # AI option (service for game translations) if system.isOptSet('ai_service_enabled') and system.getOptBoolean('ai_service_enabled') == True: retroarchConfig['ai_service_enable'] = 'true' retroarchConfig['ai_service_mode'] = '0' retroarchConfig['ai_service_source_lang'] = '0' if system.isOptSet('ai_target_lang'): chosen_lang=system.config['ai_target_lang'] else: chosen_lang='En' if system.isOptSet('ai_service_url') and system.config['ai_service_url']: retroarchConfig['ai_service_url'] = system.config['ai_service_url']+'&mode=Fast&output=png&target_lang='+chosen_lang else: retroarchConfig['ai_service_url'] = 'http://ztranslate.net/service?api_key=BATOCERA&mode=Fast&output=png&target_lang='+chosen_lang if system.isOptSet('ai_service_pause') and system.getOptBoolean('ai_service_pause') == True: retroarchConfig['ai_service_pause'] = 'true' else: retroarchConfig['ai_service_pause'] = 'false' else: retroarchConfig['ai_service_enable'] = 'false' # Bezel option try: writeBezelConfig(bezel, retroarchConfig, rom, gameResolution, system) except Exception as e: # error with bezels, disabling them writeBezelConfig(None, retroarchConfig, rom, gameResolution, system) eslog.error("Error with bezel {}: {}".format(bezel, e)) # custom : allow the user to configure directly retroarch.cfg via batocera.conf via lines like : snes.retroarch.menu_driver=rgui for user_config in systemConfig: if user_config[:10] == "retroarch.": retroarchConfig[user_config[10:]] = systemConfig[user_config] return retroarchConfig
def configureGFXdx(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) # Graphical Backend if system.isOptSet('gfxbackend'): pcsx2GFXSettings.save("Renderer", system.config["gfxbackend"]) else: pcsx2GFXSettings.save("Renderer", "12") # Internal resolution if system.isOptSet('internal_resolution'): pcsx2GFXSettings.save("upscale_multiplier", system.config["internal_resolution"]) else: pcsx2GFXSettings.save("upscale_multiplier", "1") # Skipdraw Hack if system.isOptSet('skipdraw'): pcsx2GFXSettings.save('UserHacks_SkipDraw', system.config['skipdraw']) else: pcsx2GFXSettings.save('UserHacks_SkipDraw', '0') # Align sprite Hack if system.isOptSet('align_sprite'): pcsx2GFXSettings.save('UserHacks_align_sprite_X', system.config['align_sprite']) else: pcsx2GFXSettings.save('UserHacks_align_sprite_X', '0') # Vsync if system.isOptSet('vsync'): pcsx2GFXSettings.save("vsync", system.config["vsync"]) else: pcsx2GFXSettings.save("vsync", "1") # Anisotropic Filtering if system.isOptSet('anisotropic_filtering'): pcsx2GFXSettings.save("MaxAnisotropy", system.config["anisotropic_filtering"]) else: pcsx2GFXSettings.save("MaxAnisotropy", "0") pcsx2GFXSettings.write()
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.log("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.log("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): 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", getGameCubeLangFromEnvironment()) dolphinSettings.save("GameCubeLanguage", getGameCubeLangFromEnvironment()) # update GFX dolphinGFXSettings = ConfigParser.ConfigParser() # To prevent ConfigParser from converting to lower case dolphinGFXSettings.optionxform = str dolphinGFXSettings.read(recalboxFiles.dolphinGfxIni) if not dolphinGFXSettings.has_section("Settings"): dolphinGFXSettings.add_section("Settings") dolphinGFXSettings.set("Settings", "AspectRatio", getGfxRatioFromConfig(system.config, gameResolution)) cfgfile = open(recalboxFiles.dolphinGfxIni,'w+') dolphinGFXSettings.write(cfgfile) cfgfile.close() # update SYSCONF try: dolphinSYSCONF.update(system.config, recalboxFiles.dolphinSYSCONF, gameResolution) 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(array=commandArray, env={"XDG_CONFIG_HOME":recalboxFiles.CONF, "XDG_DATA_HOME":recalboxFiles.SAVES})
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 generateRetroarchCustom(): # retroarchcustom.cfg if not os.path.exists(os.path.dirname(batoceraFiles.retroarchCustom)): os.makedirs(os.path.dirname(batoceraFiles.retroarchCustom)) try: retroarchSettings = UnixSettings(batoceraFiles.retroarchCustom, separator=' ') except UnicodeError: os.remove(batoceraFiles.retroarchCustom) retroarchSettings = UnixSettings(batoceraFiles.retroarchCustom, separator=' ') # Use Interface retroarchSettings.save('menu_driver', '"ozone"') retroarchSettings.save('content_show_favorites', '"false"') retroarchSettings.save('content_show_images', '"false"') retroarchSettings.save('content_show_music', '"false"') retroarchSettings.save('content_show_video', '"false"') retroarchSettings.save('content_show_history', '"false"') retroarchSettings.save('content_show_playlists', '"false"') retroarchSettings.save('content_show_add', '"false"') retroarchSettings.save('menu_show_load_core', '"false"') retroarchSettings.save('menu_show_load_content', '"false"') retroarchSettings.save('menu_show_online_updater', '"false"') retroarchSettings.save('menu_show_core_updater', '"false"') # Input retroarchSettings.save('input_autodetect_enable', '"false"') retroarchSettings.save('input_joypad_driver', '"sdl2"') retroarchSettings.save('input_player1_analog_dpad_mode', '"1"') retroarchSettings.save('input_player2_analog_dpad_mode', '"1"') retroarchSettings.save('input_player3_analog_dpad_mode', '"1"') retroarchSettings.save('input_player4_analog_dpad_mode', '"1"') retroarchSettings.save('input_enable_hotkey_btn', '"16"') retroarchSettings.save('input_enable_hotkey', '"escape"') retroarchSettings.save('input_exit_emulator', '"escape"') # Video retroarchSettings.save('video_aspect_ratio_auto', '"true"') retroarchSettings.save('video_gpu_screenshot', '"true"') retroarchSettings.save('video_shader_enable', '"false"') # Audio retroarchSettings.save('audio_volume', '"2.0"') # Settings retroarchSettings.save('global_core_options', '"true"') retroarchSettings.save('config_save_on_exit', '"false"') retroarchSettings.save('savestate_auto_save', '"false"') retroarchSettings.save('savestate_auto_load', '"false"') retroarchSettings.save('menu_swap_ok_cancel_buttons', '"true"') # Accentuation retroarchSettings.save('rgui_extended_ascii', '"true"') # Hide the welcome message in Retroarch retroarchSettings.save('rgui_show_start_screen', '"false"') # Enable usage of OSD messages (Text messages not in badge) retroarchSettings.save('video_font_enable', '"true"') # Take a screenshot of the savestate retroarchSettings.save('savestate_thumbnail_enable', '"true"') # Allow any RetroPad to control the menu (Only the player 1) retroarchSettings.save('all_users_control_menu', '"false"') # Show badges in Retroarch cheevos list retroarchSettings.save('cheevos_badges_enable', '"true"') # Disable builtin image viewer (done in ES, and prevents from loading pico-8 .png carts) retroarchSettings.save('builtin_imageviewer_enable', '"false"') retroarchSettings.write()