def createLibretroConfig(system, controllers, rom, bezel, gameResolution): # Create/update retroarch-core-options.cfg libretroOptions.generateCoreSettings(batoceraFiles.retroarchCoreCustom, system) # 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['video_driver'] = '"gl"' # needed for the ozone menu 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' # fs is required at least for x86* and odroidn2 retroarchConfig['video_fullscreen'] = 'true' if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: retroarchConfig['video_smooth'] = 'true' else: retroarchConfig['video_smooth'] = 'false' 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' 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'] = '' 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' 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('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' retroarchConfig['input_joypad_driver'] = 'udev' retroarchConfig['input_max_users'] = "16" # allow up to 16 players retroarchConfig[ 'savestate_directory'] = batoceraFiles.savesDir + system.name retroarchConfig[ 'savefile_directory'] = batoceraFiles.savesDir + system.name retroarchConfig['input_libretro_device_p1'] = '1' retroarchConfig['input_libretro_device_p2'] = '1' 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']] if len(controllers) > 2 and (system.config['core'] == 'snes9x_next' or system.config['core'] == 'snes9x'): retroarchConfig['input_libretro_device_p2'] = '257' if system.config['core'] == 'atari800': retroarchConfig['input_libretro_device_p1'] = '513' retroarchConfig['input_libretro_device_p2'] = '513' 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' # 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' # core options 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] # 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 # Virtual keyboard for Amstrad CPC (select+start) if system.config['core'] == 'cap32': retroarchConfig['cap32_combokey'] = 'y' # 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.server.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': # But client needs netplay_mode = true ... bug ? retroarchConfig['netplay_mode'] = "true" retroarchConfig['netplay_ip_address'] = systemConfig.get( 'netplay.server.ip', "") retroarchConfig['netplay_client_swap_input'] = "true" # mode spectator 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'] != "": 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 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 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 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 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['video_driver'] = '"gl"' # needed for the ozone menu 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']] if len(controllers) > 2 and (system.config['core'] == 'snes9x_next' or system.config['core'] == 'snes9x'): retroarchConfig['input_libretro_device_p2'] = '257' ## 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] ## 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 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' # 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' # 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' # 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' # 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", "") + '"' # 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 createLibretroConfig(system, controllers, rom, bezel, gameResolution): # Create/update retroarch-core-options.cfg libretroOptions.generateCoreSettings(batoceraFiles.retroarchCoreCustom, system) # Create/update hatari.cfg if system.name == 'atarist': libretroOptions.generateHatariConf(batoceraFiles.hatariConf) retroarchConfig = dict() systemConfig = system.config # basic configuration retroarchConfig[ 'quit_press_twice'] = 'false' # not aligned behavior on other emus retroarchConfig[ 'video_driver'] = '' # keep the default one, always the best 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 # fs is required at least for x86* and odroidn2 retroarchConfig['video_fullscreen'] = 'true' if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: retroarchConfig['video_smooth'] = 'true' else: retroarchConfig['video_smooth'] = 'false' 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'] = '' 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' 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' retroarchConfig['input_joypad_driver'] = 'udev' retroarchConfig[ 'savestate_directory'] = batoceraFiles.savesDir + system.name retroarchConfig[ 'savefile_directory'] = batoceraFiles.savesDir + system.name retroarchConfig['input_libretro_device_p1'] = '1' retroarchConfig['input_libretro_device_p2'] = '1' 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']] if len(controllers) > 2 and (system.config['core'] == 'snes9x_next' or system.config['core'] == 'snes9x'): retroarchConfig['input_libretro_device_p2'] = '257' if system.config['core'] == 'atari800': retroarchConfig['input_libretro_device_p1'] = '513' retroarchConfig['input_libretro_device_p2'] = '513' 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' # 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' # core options 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] # 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 # Netplay management if 'netplaymode' in system.config and system.config[ 'netplaymode'] 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.server.port', "") retroarchConfig['netplay_delay_frames'] = systemConfig.get( 'netplay.frames', "") retroarchConfig['netplay_nickname'] = systemConfig.get( 'netplay.nick', "") retroarchConfig['netplay_client_swap_input'] = "false" if system.config['netplaymode'] == 'client': # But client needs netplay_mode = true ... bug ? retroarchConfig['netplay_mode'] = "true" retroarchConfig['netplay_ip_address'] = systemConfig.get( 'netplay.server.ip', "") retroarchConfig['netplay_client_swap_input'] = "true" # 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 gameResolution["width"] < 400 and gameResolution["height"] < 400: retroarchConfig['video_font_size'] = '12' retroarchConfig['menu_driver'] = 'rgui' 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' # bezel writeBezelConfig(bezel, retroarchConfig, system.name, rom, gameResolution) return retroarchConfig
def createLibretroConfig(system, controllers, rom, bezel, gameResolution): # Create/update retroarch-core-options.cfg libretroOptions.generateCoreSettings(batoceraFiles.retroarchCoreCustom, system) # Create/update hatari.cfg if system.name == 'atarist': libretroOptions.generateHatariConf(batoceraFiles.hatariConf) retroarchConfig = dict() systemConfig = system.config renderConfig = system.renderconfig # fs is required at least for x86* and odroidn2 retroarchConfig['video_fullscreen'] = 'true' if system.isOptSet('smooth') and system.getOptBoolean('smooth') == True: retroarchConfig['video_smooth'] = 'true' else: retroarchConfig['video_smooth'] = 'false' if 'shader' in renderConfig and renderConfig['shader'] != None: retroarchConfig['video_shader_enable'] = 'true' retroarchConfig['video_smooth'] = 'false' shaderFilename = renderConfig['shader'] + ".glslp" eslog.log("searching shader {}".format(shaderFilename)) 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" retroarchConfig['video_shader'] = retroarchConfig[ 'video_shader_dir'] + "/" + shaderFilename else: retroarchConfig['video_shader_enable'] = 'false' 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'] = '' 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' 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' retroarchConfig['input_joypad_driver'] = 'udev' retroarchConfig[ 'savestate_directory'] = batoceraFiles.savesDir + system.name retroarchConfig[ 'savefile_directory'] = batoceraFiles.savesDir + system.name retroarchConfig['input_libretro_device_p1'] = '1' retroarchConfig['input_libretro_device_p2'] = '1' 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']] if len(controllers) > 2 and (system.config['core'] == 'snes9x_next' or system.config['core'] == 'snes9x'): retroarchConfig['input_libretro_device_p2'] = '257' if system.config['core'] == 'atari800': retroarchConfig['input_libretro_device_p1'] = '513' retroarchConfig['input_libretro_device_p2'] = '513' 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' # 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' # core options 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] # 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 # Netplay management if 'netplaymode' in system.config and system.config[ 'netplaymode'] 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.server.port', "") retroarchConfig['netplay_delay_frames'] = systemConfig.get( 'netplay.frames', "") retroarchConfig['netplay_nickname'] = systemConfig.get( 'netplay.nick', "") retroarchConfig['netplay_client_swap_input'] = "false" if system.config['netplaymode'] == 'client': # But client needs netplay_mode = true ... bug ? retroarchConfig['netplay_mode'] = "true" retroarchConfig['netplay_ip_address'] = systemConfig.get( 'netplay.server.ip', "") retroarchConfig['netplay_client_swap_input'] = "true" # Display FPS if system.isOptSet('showFPS') and system.getOptBoolean('showFPS') == True: retroarchConfig['fps_show'] = 'true' else: retroarchConfig['fps_show'] = 'false' # bezel writeBezelConfig(bezel, retroarchConfig, system.name, rom, gameResolution) return retroarchConfig