def updateLibretroConfigCustom(version):
    # Version is unsued so far, but who knows, one day
    try: 
        # Read files
        sourceSettings = UnixSettings(rhgamestationFiles.retroarchInitCustomOrigin, separator=' ')
        sourceConf = sourceSettings.loadFile()
        destFiles = [rhgamestationFiles.retroarchCustomOrigin, rhgamestationFiles.retroarchCustom]
        
        for file in destFiles:
            if not os.path.isfile(file) : continue
            destSettings = UnixSettings(file, separator=' ')
            destConf = destSettings.loadFile()
            missingKeys = {}
            # Compare missing keysoprint "Compare keys ..."
            for key, value in sourceConf.iteritems():
                if key not in destConf:
                    missingKeys[key] = value
            # Save
            print "Save {}".format(file)
            for key, value in missingKeys.iteritems():
                destSettings.save(key, value)
            missingKeys.clear()
            
        print("LibretroConfig 's configuration successfully upgraded")
        return True
    except:
        print "Libretro update failed !"
        return False
Exemple #2
0
    def generate(self, system, rom, playersControllers, gameResolution):
        configDir = batoceraFiles.CONF + '/openbor'
        if not os.path.exists(configDir):
            os.makedirs(configDir)

        savesDir = batoceraFiles.SAVES + '/openbor'
        if not os.path.exists(savesDir):
            os.makedirs(savesDir)

        # guess the version to run
        core = system.config['core']
        if system.config["core-forced"] == False:
            core = OpenborGenerator.guessCore(rom)
        eslog.log("core taken is {}".format(core))

        # config file
        configfilename = "config6510.ini"
        if core == "openbor4432":
            configfilename = "config4432.ini"
        elif core == "openbor6330":
            configfilename = "config6330.ini"
        elif core == "openbor6412":
            configfilename = "config6412.ini"
        elif core == "openbor6510":
            configfilename = "config6510.ini"

        config = UnixSettings(configDir + "/" + configfilename, separator='')

        # general
        config.save("fullscreen", "1")
        config.save("vsync", "1")
        config.save("usegl", "1")
        config.save("usejoy", "1")

        # options
        if system.isOptSet("ratio"):
            config.save("stretch", system.config["ratio"])
        else:
            config.remove("stretch")

        if system.isOptSet("filter"):
            config.save("swfilter", system.config["filter"])
        else:
            config.remove("swfilter")

        # controllers
        openborControllers.generateControllerConfig(config, playersControllers,
                                                    core)

        config.write()

        return OpenborGenerator.executeCore(core, rom)
Exemple #3
0
def configureGFX(config_directory, system):
    configFileName = "{}/{}".format(config_directory + "/inis", "GS.ini")
    if not os.path.exists(config_directory):
        os.makedirs(config_directory + "/inis")

    # Create the config file if it doesn't exist
    if not os.path.exists(configFileName):
        f = open(configFileName, "w")
        f.close()

    # Update settings
    pcsx2GFXSettings = UnixSettings(configFileName, separator=' ')

    # Internal resolution
    if system.isOptSet('internal_resolution'):
        pcsx2GFXSettings.save("upscale_multiplier",
                              system.config["internal_resolution"])
    else:
        pcsx2GFXSettings.save("upscale_multiplier", "1")

    pcsx2GFXSettings.write()
Exemple #4
0
def updateLibretroConfig(version):
    # Version is unsued so far, but who knows, one day
    try: 
        # Read files
        sourceSettings = UnixSettings(recalboxFiles.retroarchInitCustomOrigin, separator=' ')
        sourceConf = sourceSettings.loadFile()
        destFiles = [recalboxFiles.retroarchCustomOrigin, recalboxFiles.retroarchCustom]
        
        for file in destFiles:
            destSettings = UnixSettings(file, separator=' ')
            destConf = destSettings.loadFile()
            # Compare missing keys
            for key, value in sourceConf.iteritems():
                if key not in destConf: destConf[key] = value
            # Save
            for key, value in destConf.iteritems():
                destSettings.save(key, value)
            
        print("LibretroConfig 's configuration successfully upgraded")
        return True
    except:
        print "Libretro update failed !"
        return False
def configureUI(config_directory, bios_directory, system_config,
                gameResolution):
    configFileName = "{}/{}".format(config_directory + "/inis", "PCSX2_ui.ini")
    if not os.path.exists(config_directory + "/inis"):
        os.makedirs(config_directory + "/inis")

    # find the first bios
    bios = [
        "PS2 Bios 30004R V6 Pal.bin", "scph10000.bin", "scph39001.bin",
        "SCPH-70004_BIOS_V12_PAL_200.BIN"
    ]
    biosFound = False
    for bio in bios:
        if os.path.exists(bios_directory + "/" + bio):
            biosFile = bios_directory + "/" + bio
            biosFound = True
            break
    if not biosFound:
        raise Exception("No bios found")

    resolution = getGfxRatioFromConfig(system_config, gameResolution)
    if os.path.exists(configFileName):
        # existing configuration file
        pcsx2Settings = UnixSettings(configFileName)
        pcsx2Settings.save("BIOS", biosFile)
        pcsx2Settings.save("AspectRatio", resolution)
    else:
        # new configuration file
        f = open(configFileName, "w")
        f.write("[ProgramLog]\n")
        f.write("Visible=disabled\n")
        f.write("[Filenames]\n")
        f.write("BIOS=" + biosFile + "\n")
        f.write("[GSWindow]\n")
        f.write("AspectRatio=" + resolution + "\n")
        f.close()
    def generate(self, system, rom, playersControllers):
        dolphinControllers.generateControllerConfig(system, playersControllers)

        dolphinSettings = UnixSettings(recalboxFiles.dolphinIni, separator=' ')
        #Draw or not FPS
        if system.config['showFPS'] == 'true':
            dolphinSettings.save("ShowLag", "True")
            dolphinSettings.save("ShowFrameCount", "True")
        else:
            dolphinSettings.save("ShowLag", "False")
            dolphinSettings.save("ShowFrameCount", "False")

        commandArray = [
            recalboxFiles.recalboxBins[system.config['emulator']], "-e", rom
        ]
        if 'args' in system.config and system.config['args'] is not None:
            commandArray.extend(system.config['args'])
        return Command.Command(videomode=system.config['videomode'],
                               array=commandArray,
                               env={
                                   "XDG_CONFIG_HOME": recalboxFiles.CONF,
                                   "XDG_DATA_HOME": recalboxFiles.SAVES
                               })
def configureGFX(config_directory, printFPS):
    configFileName = "{}/{}".format(config_directory + "/inis", "GSdx.ini")
    if not os.path.exists(config_directory):
        os.makedirs(config_directory + "/inis")

    if os.path.exists(configFileName):
        # existing configuration file
        pcsx2GFXSettings = UnixSettings(configFileName, separator=' ')
        pcsx2GFXSettings.save("osd_fontname",
                              "/usr/share/fonts/dejavu/DejaVuSans.ttf")
        pcsx2GFXSettings.save("osd_indicator_enabled", 1)
        if printFPS:
            pcsx2GFXSettings.save("osd_monitor_enabled", 1)
        else:
            pcsx2GFXSettings.save("osd_monitor_enabled", 0)
    else:
        f = open(configFileName, "w")
        f.write("osd_fontname = /usr/share/fonts/dejavu/DejaVuSans.ttf\n")
        f.write("osd_indicator_enabled = 1\n")
        if printFPS:
            f.write("osd_monitor_enabled = 1\n")
        else:
            f.write("osd_monitor_enabled = 0\n")
        f.close()
Exemple #8
0
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',                 '"false"')

    # 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()
Exemple #9
0
def configureGFX(config_directory, system):
    configFileName = "{}/{}".format(config_directory + "/inis", "GSdx.ini")
    if not os.path.exists(config_directory):
        os.makedirs(config_directory + "/inis")

    #create the config file if it doesn't exist
    if not os.path.exists(configFileName):
        f = open(configFileName, "w")
        f.write("osd_fontname = /usr/share/fonts/dejavu/DejaVuSans.ttf\n")
        f.close()

    # Update settings
    pcsx2GFXSettings = UnixSettings(configFileName, separator=' ')
    pcsx2GFXSettings.save("osd_fontname",
                          "/usr/share/fonts/dejavu/DejaVuSans.ttf")
    pcsx2GFXSettings.save("osd_indicator_enabled", 1)
    pcsx2GFXSettings.save("UserHacks", 1)
    #showFPS
    if system.isOptSet('showFPS') and system.getOptBoolean('showFPS'):
        pcsx2GFXSettings.save("osd_monitor_enabled", 1)
    else:
        pcsx2GFXSettings.save("osd_monitor_enabled", 0)
    #internal resolution
    if system.isOptSet('internalresolution'):
        pcsx2GFXSettings.save("upscale_multiplier",
                              system.config["internalresolution"])
    else:
        pcsx2GFXSettings.save("upscale_multiplier", "1")
    #skipdraw
    if system.isOptSet('skipdraw'):
        pcsx2GFXSettings.save('UserHacks_SkipDraw', system.config['skipdraw'])
    else:
        pcsx2GFXSettings.save('UserHacks_SkipDraw', '0')
    #align sprite
    if system.isOptSet('align_sprite'):
        pcsx2GFXSettings.save('UserHacks_align_sprite_X',
                              system.config['align_sprite'])
    else:
        pcsx2GFXSettings.save('UserHacks_align_sprite_X', '0')

    if system.isOptSet('vsync'):
        pcsx2GFXSettings.save("vsync", system.config["vsync"])
    else:
        pcsx2GFXSettings.save("vsync", "1")

    if system.isOptSet('anisotropic_filtering'):
        pcsx2GFXSettings.save("MaxAnisotropy",
                              system.config["anisotropic_filtering"])
    else:
        pcsx2GFXSettings.save("MaxAnisotropy", "0")

    pcsx2GFXSettings.write()
Exemple #10
0
def generateCoreSettings(retroarchCore, system):
    # retroarch-core-options.cfg
    if not os.path.exists(os.path.dirname(retroarchCore)):
        os.makedirs(os.path.dirname(retroarchCore))

    try:
        coreSettings = UnixSettings(retroarchCore, separator=' ')
    except UnicodeError:
        # invalid retroarch-core-options.cfg
        # remove it and try again
        os.remove(retroarchCore)
        coreSettings = UnixSettings(retroarchCore, separator=' ')

    # Atari 800 and 5200
    if (system.config['core'] == 'atari800'):
        if (system.name == 'atari800'):
            coreSettings.save('atari800_system', '"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_overscan', '"enabled"')
        if (system.name == 'colecovision'):
            coreSettings.save('bluemsx_msxtype', '"ColecoVision"')
        elif (system.name == 'msx1'):
            coreSettings.save('bluemsx_msxtype', '"MSX"')
        elif (system.name == 'msx2'):
            coreSettings.save('bluemsx_msxtype', '"MSX2"')
        elif (system.name == 'msx2+'):
            coreSettings.save('bluemsx_msxtype', '"MSX2+"')
        elif (system.name == 'msxturbor'):
            coreSettings.save('bluemsx_msxtype', '"MSXturboR"')

    if (system.config['core'] == '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"')

    if (system.config['core'] == 'theodore'):
        coreSettings.save('theodore_autorun', '"enabled"')
def generateCoreSettings(retroarchCore, system):
    # retroarch-core-options.cfg
    if not os.path.exists(os.path.dirname(retroarchCore)):
        os.makedirs(os.path.dirname(retroarchCore))

    try:
        coreSettings = UnixSettings(retroarchCore, separator=' ')
    except UnicodeError:
        # invalid retroarch-core-options.cfg
        # remove it and try again
        os.remove(retroarchCore)
        coreSettings = UnixSettings(retroarchCore, separator=' ')

    # Atari 800 and 5200
    if (system.config['core'] == 'atari800'):
        if (system.name == 'atari800'):
            coreSettings.save('atari800_system', '"130XE (128K)"')
            coreSettings.save('RAM_SIZE', '"64"')
            coreSettings.save('STEREO_POKEY', '"1"')
            coreSettings.save('BUILTIN_BASIC', '"1"')
        else:
            coreSettings.save('atari800_system', '"5200"')
            coreSettings.save('RAM_SIZE', '"16"')
            coreSettings.save('STEREO_POKEY', '"0"')
            coreSettings.save('BUILTIN_BASIC', '"0"')

    # Colecovision and MSX
    if (system.config['core'] == 'bluemsx'):
        coreSettings.save('bluemsx_overscan', '"enabled"')
        if (system.name == 'colecovision'):
            coreSettings.save('bluemsx_msxtype', '"ColecoVision"')
        elif (system.name == 'msx1'):
            coreSettings.save('bluemsx_msxtype', '"MSX"')
        elif (system.name == 'msx2'):
            coreSettings.save('bluemsx_msxtype', '"MSX2"')
        elif (system.name == 'msx2+'):
            coreSettings.save('bluemsx_msxtype', '"MSX2+"')
        elif (system.name == 'msxturbor'):
            coreSettings.save('bluemsx_msxtype', '"MSXturboR"')

    if (system.config['core'] == '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'] == 'pce_fast'):
        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'] == 'opera'):
        coreSettings.save('opera_dsp_threaded', '"enabled"')

    if (system.config['core'] == 'virtualjaguar'):
        coreSettings.save('virtualjaguar_usefastblitter', '"enabled"')

    if (system.config['core'] == 'vice'):
        coreSettings.save('vice_Controller', '"joystick"')
        coreSettings.save('vice_JoyPort', '"port_1"')

    if (system.config['core'] == 'theodore'):
        coreSettings.save('theodore_autorun', '"enabled"')

    if (system.config['core'] == 'flycast'):
        coreSettings.save('reicast_threaded_rendering', '"enabled"')

    if (system.config['core'] == 'dosbox'):
        coreSettings.save('dosbox_svn_pcspeaker', '"true"')

    if (system.config['core'] == 'px68k'):
        coreSettings.save('px68k_disk_path', '"disabled"')

    if (system.config['core'] == 'pcsx_rearmed'):
        for n in range(1, 8 + 1):
            val = coreSettings.load('pcsx_rearmed_pad{}type'.format(n))
            if val == '"none"' or val == "" or val is None:
                coreSettings.save('pcsx_rearmed_pad{}type'.format(n),
                                  '"standard"')
        # force multitap no value / auto to disable
        # only let enabled when it is forced while previous values enable it
        val = coreSettings.load('pcsx_rearmed_multitap1')
        if val == '"auto"' or val == "" or val is None:
            coreSettings.save('pcsx_rearmed_multitap1', '"disabled"')
        val = coreSettings.load('pcsx_rearmed_multitap2')
        if val == '"auto"' or val == "" or val is None:
            coreSettings.save('pcsx_rearmed_multitap2', '"disabled"')

    # custom : allow the user to configure directly retroarchcore.cfg via batocera.conf via lines like : snes.retroarchcore.opt=val
    for user_config in system.config:
        if user_config[:14] == "retroarchcore.":
            coreSettings.save(user_config[14:], system.config[user_config])
Exemple #12
0
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
    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(
            "gfxbackend") and system.config["gfxbackend"] == "vulkan":
        retroarchConfig['video_driver'] = '"vulkan"'

    # 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'

    # 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'

    # 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"'

    ## 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'

    # 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'] = ''

    # 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'

    # 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'

    # 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) 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'
    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['aspect_ratio_index'] = '0'
        retroarchConfig['video_font_size'] = '12'
        retroarchConfig['menu_driver'] = 'rgui'
        retroarchConfig['menu_rgui_transparency'] = 'false'
        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'
        # 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
Exemple #13
0
    def generate(self, system, rom, playersControllers):
        dolphinControllers.generateControllerConfig(system, playersControllers,
                                                    rom)

        dolphinSettings = UnixSettings(recalboxFiles.dolphinIni, separator=' ')
        #Draw or not FPS
        if system.config['showFPS'] == 'true':
            dolphinSettings.save("ShowLag", "True")
            dolphinSettings.save("ShowFrameCount", "True")
        else:
            dolphinSettings.save("ShowLag", "False")
            dolphinSettings.save("ShowFrameCount", "False")

        # don't ask about statistics
        dolphinSettings.save("PermissionAsked", "True")

        # don't confirm at stop
        dolphinSettings.save("ConfirmStop", "False")

        # language (for gamecube at least)
        dolphinSettings.save("SelectedLanguage",
                             getDolphinLangFromEnvironment())

        # update SYSCONF
        try:
            dolphinSYSCONF.update(system.config, recalboxFiles.dolphinSYSCONF)
        except Exception:
            pass  # don't fail in case of SYSCONF update

        commandArray = [
            recalboxFiles.recalboxBins[system.config['emulator']], "-e", rom
        ]
        if 'args' in system.config and system.config['args'] is not None:
            commandArray.extend(system.config['args'])
        return Command.Command(videomode=system.config['videomode'],
                               array=commandArray,
                               env={
                                   "XDG_CONFIG_HOME": recalboxFiles.CONF,
                                   "XDG_DATA_HOME": recalboxFiles.SAVES
                               })
Exemple #14
0
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'] == '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')

    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'] == 'fba'):
        coreSettings.save('fba-diagnostics', 'disabled')
        coreSettings.save('fba-unibios', 'disabled')
        coreSettings.save('fba-controls', 'gamepad')

    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')
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=' ')

    # Path Retroarch
    retroarchSettings.save(
        'core_options_path',
        '"/userdata/system/configs/retroarch/cores/retroarch-core-options.cfg"'
    )
    retroarchSettings.save('assets_directory', '"/usr/share/libretro/assets"')
    retroarchSettings.save('screenshot_directory', '"/userdata/screenshots/"')
    retroarchSettings.save('recording_output_directory',
                           '"/userdata/screenshots/"')
    retroarchSettings.save('savestate_directory', '"/userdata/saves/"')
    retroarchSettings.save('savefile_directory', '"/userdata/saves/"')
    retroarchSettings.save('extraction_directory', '"/userdata/extractions/"')
    retroarchSettings.save('cheat_database_path',
                           '"/usr/share/batocera/datainit/cheats/cht/"')
    retroarchSettings.save('cheat_settings_path', '"/userdata/cheats/saves/"')
    retroarchSettings.save('system_directory', '"/userdata/bios/"')
    retroarchSettings.save('joypad_autoconfig_dir',
                           '"/userdata/system/configs/retroarch/inputs/"')
    retroarchSettings.save('video_shader_dir',
                           '"/usr/share/batocera/datainit/shaders/"')
    retroarchSettings.save('video_font_path',
                           '"/usr/share/fonts/dejavu/DejaVuSansMono.ttf"')
    retroarchSettings.save('video_filter_dir', '"/usr/share/video_filters"')
    retroarchSettings.save('audio_filter_dir', '"/usr/share/audio_filters"')

    # 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"')

    # Settings
    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', '"false"')

    # 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"')
    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)
            })
Exemple #17
0
    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]
        return Command.Command(array=commandArray, env={"XDG_CONFIG_HOME":recalboxFiles.CONF, "XDG_DATA_HOME":recalboxFiles.SAVES})
Exemple #18
0
    def generate(self, system, rom, playersControllers):
        if not system.config['configfile']:
            dolphinSettings = UnixSettings(rhgamestationFiles.dolphinIni,
                                           separator=' ')
            dolphinControllers.generateControllerConfig(
                system, playersControllers)
            dolphinGFX = UnixSettings(rhgamestationFiles.dolphinGFX,
                                      separator=' ')
            #Draw or not FPS
            showFPS = "True" if system.config['showFPS'] == 'true' else "False"
            dolphinGFX.save("ShowFPS", showFPS)

            # Disable analytics
            dolphinSettings.save("PermissionAsked", "True")
            dolphinSettings.save("Enabled", "True")
            dolphinSettings.save("AutoHideCursor", "True")
            dolphinSettings.save("WiimoteContinuousScanning", "True")
            dolphinSettings.save("ConfirmStop", "False")

        commandArray = [
            rhgamestationFiles.rhgamestationBins[system.config['emulator']],
            "-e", rom
        ]
        if 'args' in system.config and system.config['args'] is not None:
            commandArray.extend(system.config['args'])
        return Command.Command(videomode=system.config['videomode'],
                               array=commandArray,
                               env={
                                   "XDG_CONFIG_HOME": rhgamestationFiles.CONF,
                                   "XDG_DATA_HOME": rhgamestationFiles.SAVES
                               })
def generateMoonlightConfig(system):

    moonlightStagingConfigFile = batoceraFiles.moonlightStagingConfigFile
    if not os.path.exists(batoceraFiles.moonlightCustom + '/staging'):
        os.makedirs(batoceraFiles.moonlightCustom + '/staging')

    # If user made config file exists, copy to staging directory for use
    if os.path.exists(batoceraFiles.moonlightConfigFile):
        shutil.copy(batoceraFiles.moonlightConfigFile,
                    batoceraFiles.moonlightStagingConfigFile)
    else:
        # truncate existing config and create new one
        f = open(moonlightStagingConfigFile, "w").close()

        moonlightConfig = UnixSettings(moonlightStagingConfigFile,
                                       separator=' ')

        # resolution
        if system.isOptSet('moonlight_resolution'):
            if system.config["moonlight_resolution"] == "0":
                moonlightConfig.save('width', '1280')
                moonlightConfig.save('height', '720')
            elif system.config["moonlight_resolution"] == "1":
                moonlightConfig.save('width', '1920')
                moonlightConfig.save('height', '1080')
            elif system.config["moonlight_resolution"] == "2":
                moonlightConfig.save('width', '3840')
                moonlightConfig.save('height', '2160')
            else:
                moonlightConfig.save('width', '1280')
                moonlightConfig.save('height', '720')
        else:
            moonlightConfig.save('width', '1280')
            moonlightConfig.save('height', '720')

        # framerate
        if system.isOptSet('moonlight_framerate'):
            if system.config["moonlight_framerate"] == "0":
                moonlightConfig.save('fps', '30')
            elif system.config["moonlight_framerate"] == "1":
                moonlightConfig.save('fps', '60')
            elif system.config["moonlight_framerate"] == "2":
                moonlightConfig.save('fps', '120')
            else:
                moonlightConfig.save('fps', '30')
        else:
            moonlightConfig.save('fps', '30')

        # bitrate
        if system.isOptSet('moonlight_bitrate'):
            if system.config["moonlight_bitrate"] == "0":
                moonlightConfig.save('bitrate', '5000')
            elif system.config["moonlight_bitrate"] == "1":
                moonlightConfig.save('bitrate', '10000')
            elif system.config["moonlight_bitrate"] == "2":
                moonlightConfig.save('bitrate', '20000')
            elif system.config["moonlight_bitrate"] == "3":
                moonlightConfig.save('bitrate', '50000')
            else:
                moonlightConfig.save('bitrate',
                                     '-1')  #-1 sets Moonlight default
        else:
            moonlightConfig.save('bitrate', '-1')  #-1 sets Moonlight default

        # codec
        if system.isOptSet('moonlight_codec'):
            if system.config["moonlight_codec"] == "0":
                moonlightConfig.save('codec', 'h264')
            elif system.config["moonlight_codec"] == "1":
                moonlightConfig.save('codec', 'h265')
            else:
                moonlightConfig.save('codec', 'auto')
        else:
            moonlightConfig.save('codec', 'auto')

        # sops (Streaming Optimal Playable Settings)
        if system.isOptSet('moonlight_sops'):
            if system.config["moonlight_sops"] == "0":
                moonlightConfig.save('sops', 'true')
            elif system.config["moonlight_sops"] == "1":
                moonlightConfig.save('sops', 'false')
            else:
                moonlightConfig.save('sops', 'true')
        else:
            moonlightConfig.save('sops', 'true')

        # quit remote app on exit
        if system.isOptSet('moonlight_quitapp'):
            if system.config["moonlight_quitapp"] == "0":
                moonlightConfig.save('quitappafter', 'true')
            else:
                moonlightConfig.save('quitappafter', 'false')
        else:
            moonlightConfig.save('quitappafter', 'false')

        # av decoder
        if system.isOptSet('moonlight_avdecoder'):
            if system.config["moonlight_avdecoder"] == "sdl":
                moonlightConfig.save('platform', 'sdl')

        ## Directory to store encryption keys
        moonlightConfig.save('keydir',
                             batoceraFiles.moonlightCustom + '/keydir')

        moonlightConfig.write()
def generateLinappleConfig(rom, playersControllers):
    # conf file
    try:
        linappleConfig = UnixSettings(batoceraFiles.linappleConfigFile,
                                      separator=' ')
    except UnicodeError:
        # remove it and try again
        os.remove(batoceraFiles.linappleConfigFile)
        linappleConfig = UnixSettings(batoceraFiles.linappleConfigFile,
                                      separator=' ')

    # Rom
    linappleConfig.save('Disk Image 1', rom)

    # Joysticks, those sticks of joy! There may be 2 joysticks at the same time
    #
    # "Joystick 0" specifies the types of first first joystick.
    #
    # Possible values are:
    #  0 - joystick disabled
    #  1 - use PC joystick #1 or #2, for corresponding joystick
    #  2 - Keyboard standard
    #  3 - Keyboard centered
    #  4 - Use mouse as a joystick. Rather interesting thing, try it. Useful in Fantavision(tm)by Broderbund Software
    #
    # When joysticks used as a keyboard, they are stuck to Numpad keys (1-9 - axis movement, 0 - button1, . - button2)
    # When centered used, axis of joystick will be centered after releasing any cursor (Numpad 1..9) key.
    # Otherwise it assumed to be pressed always.
    #
    # Default is 1.
    #
    # "Joystick 1" specifies the types of the second joystick.
    # Possible values are the same as "Joystick 0".
    # Default is 0.
    linappleConfig.save('Joystick 0', '0')
    linappleConfig.save('Joystick 1', '0')

    # For Joysticks you can define which Joystick index number, axis number, and buttons.
    #
    # Default for Joystick 1 is index 0, axis 0 and 1, buttons 0 and 1.
    # Default for Joystick 2 is index 1, axis 0 and 1, button 0.
    for indexController in playersControllers:
        controller = playersControllers[indexController]

        # Enabling control
        linappleConfig.save('Joy{}Index'.format(controller.index),
                            controller.index)
        linappleConfig.save('Joystick {}'.format(controller.index), '1')

        # Button
        linappleConfig.save('Joy{}Button1'.format(controller.index),
                            controller.inputs["a"].id)
        linappleConfig.save('Joy{}Button2'.format(controller.index),
                            controller.inputs["b"].id)

        # Axis
        linappleConfig.save('Joy{}Axis0'.format(controller.index),
                            controller.inputs["joystick1left"].id)
        linappleConfig.save('Joy{}Axis1'.format(controller.index),
                            controller.inputs["joystick1up"].id)

        # Enable Quitting the program with by pressing two joystick buttons at the same time
        if (controller.index == 0):
            linappleConfig.save('JoyExitEnable', '1')
            linappleConfig.save('JoyExitButton0',
                                controller.inputs["hotkey"].id)
            linappleConfig.save('JoyExitButton1',
                                controller.inputs["start"].id)

    # Possible values are:
    #   0 - old Apple][, right out of the hands of Steve Wozniak and Steve Jobs in far 1977? year.
    #   1 - Apple][+	- same as Apple][ with somewhat enbettered functionality
    #   2 - Apple//e	- Enhanced Apple][ with 80-column mode and other useful additions
    #   3 - Apple//e enhanced	- currently same as Apple//e? Please, ask Tom Charlesworth about it.
    #
    # Default is 3.
    linappleConfig.save('Computer Emulation', '3')

    # "Sound Emulation" enables audio.
    #
    # Possible values are:
    #  0 - none
    #  1 - use SDL Audio for sounds
    #
    # Default is 1.
    linappleConfig.save('Sound Emulation', '1')

    # "Soundcard Type" specifies the type of sound card to use.
    #
    # Possible values are:
    #   1 - none (disables audio)
    #   2 - use Mockingboard in Slot 4 (Mockingboard is like SoundBlaster for PC, if you hear about it)
    #   3 - use Phasor in Slot 4. Phasor is also a sort of ancient sound cards. Ahhh, what sounds they have!!!
    #
    # Default is 2.
    linappleConfig.save('Soundcard Type', '2')

    # "Serial Port" joins your Apple][ machine to any device through serial ports.
    #
    # Possible values are:
    #   0        - disabled
    #   1 to 100 - which means device /dev/ttyS0 .. /dev/ttyS99 relatively
    #
    # Default is 0. Needs testing.
    linappleConfig.save('Serial Port', '0')

    # "Emulation Speed" controls the speed of the emulator.
    #
    # Possible values range from 0 to 40 where:
    #    0 - slowest
    #   10 - normal (about 1 MHz)
    #   40 - fastest
    #
    # Default is 10.
    linappleConfig.save('Emulation Speed', '10')

    # "Enhance Disk Speed" disables disk throttling.
    #
    # Possible values are:
    #   0 - disabled, disk spinning speed is like that of a real Apple][
    #   1 - use enhanced disk speed.
    #
    # Default is 1.
    linappleConfig.save('Enhance Disk Speed', '1')

    # "Parallel Printer Filename" specifies the path to use as for printer output.
    # Parallel printer allows you to print any DOS3.3 or Applesoft Basic(tm) output
    # to specified file (after PR#1 at DOS3.3 prompt)
    #
    # Possible values are any valid path.
    #
    # Default is "Printer.txt".
    linappleConfig.save('Parallel Printer Filename', 'Printer.txt')

    # "Slot 6 Autoload" enables automatic insertion of floppy disk images.
    # This is analogous to inserting floppies into an Apple][ before turning it on.
    #
    # Possible values are:
    #   0 - disabled
    #   1 - enabled
    #
    # Default is 0.
    linappleConfig.save('Slot 6 Autoload', '1')

    # Save State Filename - file name for saving/loading state with keys F11 and F12 in emulator.
    # Default is none. Note: you can choose it at runtime by pressing F11 (for saving)  or F12 (for loading)
    linappleConfig.save('Save State Filename', '')

    # SaveSate Directory is a directory where current states will be saved by using F11,F12 (or ALT+F11, ALT+F12 keys, or Ctrl+0..9, Ctrl+Shift+0..9)
    #Default is none, which means your home directory
    linappleConfig.save('Save State Directory', batoceraFiles.linapplaSaves)

    # "Save State On Exit" enables automatic saving of the emulator on exit.
    #
    # Possible values are:
    #   0 - disabled
    #   1 - enabled
    #
    # Default value is 0.
    linappleConfig.save('Save State On Exit', '0')

    # "Show Leds" enables displaying LEDs indicating disk access.
    #
    # Possible values are:
    #   0 - disabled
    #   1 - enabled
    #
    # Default is 1.
    linappleConfig.save('Show Leds', '1')

    # Screen properties
    #
    # Note: not all screen sizes can work in full screen mode, so be careful
    # Also if you are using not default mode, the speed of emulator can fall,
    # which can be spotted on old machines
    #
    # "Screen factor" specifies a multipler for the screen size.
    #
    # Any positive value is possible, but the suggested range is 0.3 to 3.0.
    # The value is a multiplier for "Screen Width" and "Screen Height".
    #   < 1.0 will make the screen smaller
    #   > 1.0 will make the screen larger
    #   = 1.0 will keep the screen at 560x384
    #   < 0.1 will be ignored.
    #
    # Default is 0.
    linappleConfig.save('Screen factor', '0')

    # "Screen Width" specifies the horizontal size of the display.
    # Possible values are any positive integer.
    # Value is ignored if "Screen factor" is set to anything >= 0.1.
    # Default is 560.
    #
    # "Screen Height" specifies the vertical size of the display.
    #
    # Possible values are any positive integer.
    # Value is ignored if "Screen factor" is set to anything >= 0.1.
    #
    # For best results, use a height divisible by 192 to avoid moire artifacts when
    # using scanline video effects.
    #
    # Default is 384.
    linappleConfig.save('Screen Width', '560')
    linappleConfig.save('Screen Height', '384')
Exemple #21
0
def generateCoreSettings(retroarchCore, system):
    # retroarch-core-options.cfg
    if not os.path.exists(os.path.dirname(retroarchCore)):
        os.makedirs(os.path.dirname(retroarchCore))

    try:
        coreSettings = UnixSettings(retroarchCore, separator=' ')
    except UnicodeError:
        # invalid retroarch-core-options.cfg
        # remove it and try again
        os.remove(retroarchCore)
        coreSettings = UnixSettings(retroarchCore, separator=' ')

    # Atari 800 and 5200
    if (system.config['core'] == 'atari800'):
        if (system.name == 'atari800'):
            coreSettings.save('atari800_system',    '"130XE (128K)"')
            coreSettings.save('RAM_SIZE',           '"64"')
            coreSettings.save('STEREO_POKEY',       '"1"')
            coreSettings.save('BUILTIN_BASIC',      '"1"')
        else:
            coreSettings.save('atari800_system',    '"5200"')
            coreSettings.save('RAM_SIZE',           '"16"')
            coreSettings.save('STEREO_POKEY',       '"0"')
            coreSettings.save('BUILTIN_BASIC',      '"0"')

    # Colecovision and MSX
    if (system.config['core'] == 'bluemsx'):
        coreSettings.save('bluemsx_overscan', '"enabled"')
        if (system.name == 'colecovision'):
            coreSettings.save('bluemsx_msxtype', '"ColecoVision"')
        elif (system.name == 'msx1'):
            coreSettings.save('bluemsx_msxtype', '"MSX"')
        elif (system.name == 'msx2'):
            coreSettings.save('bluemsx_msxtype', '"MSX2"')
        elif (system.name == 'msx2+'):
            coreSettings.save('bluemsx_msxtype', '"MSX2+"')
        elif (system.name == 'msxturbor'):
            coreSettings.save('bluemsx_msxtype', '"MSXturboR"')

    if (system.config['core'] == 'citra'):
        if not os.path.exists(batoceraFiles.CONF + "/retroarch/3ds.cfg"):
            f = open(batoceraFiles.CONF + "/retroarch/3ds.cfg", "w")
            f.write("video_driver = \"glcore\"\n")
            f.close()

    if (system.config['core'] == 'tgbdual'):
        coreSettings.save('tgbdual_audio_output',       '"Game Boy #1"')
        coreSettings.save('tgbdual_gblink_enable',      '"enabled"')
        coreSettings.save('tgbdual_screen_placement',   '"left-right"')
        coreSettings.save('tgbdual_single_screen_mp',   '"both players"')
        coreSettings.save('tgbdual_switch_screens',     '"normal"')

    if (system.config['core'] == 'gambatte'):
        if 'colorization' in system.renderconfig and system.renderconfig['colorization'] != None:
            coreSettings.save('gambatte_gb_colorization',     '"internal"')
            coreSettings.save('gambatte_gb_internal_palette', '"' + system.renderconfig['colorization'] + '"')
        else:
            coreSettings.save('gambatte_gb_colorization',     '"disabled"')

    if (system.config['core'] == 'desmume'):
        coreSettings.save('desmume_pointer_device_r',   '"emulated"')
        # multisampling aa
        if system.isOptSet('multisampling'):
            coreSettings.save('desmume_gfx_multisampling', system.config['multisampling'])
        else:
            coreSettings.save('desmume_gfx_multisampling', '"disabled"')
        # texture smoothing
        if system.isOptSet('texture_smoothing'):
            coreSettings.save('desmume_gfx_texture_smoothing', system.config['texture_smoothing'])
        else:
            coreSettings.save('desmume_gfx_texture_smoothing', '"disabled"')
        # texture scaling (xBrz)
        if system.isOptSet('texture_scaling'):
            coreSettings.save('desmume_gfx_texture_scaling', system.config['texture_scaling'])
        else:
            coreSettings.save('desmume_gfx_texture_scaling', '"1"')

    if (system.config['core'] == 'mame078'):
        coreSettings.save('mame2003_skip_disclaimer',   '"enabled"')
        coreSettings.save('mame2003_skip_warnings',     '"enabled"')

    if (system.config['core'] == 'mame078plus'):
        coreSettings.save('mame2003-plus_skip_disclaimer',  '"enabled"')
        coreSettings.save('mame2003-plus_skip_warnings',    '"enabled"')
        coreSettings.save('mame2003-plus_analog',           '"digital"')

    if (system.config['core'] == 'puae'):
        coreSettings.save('puae_video_options_display ',    '"enabled"')
        # video resolution
        if system.isOptSet('video_resolution'):
            coreSettings.save('puae_video_resolution', system.config['video_resolution'])
        else:
            coreSettings.save('puae_video_resolution', '"auto"')
        # zoom mode	
        if system.isOptSet('zoom_mode'):
            coreSettings.save('puae_zoom_mode', system.config['zoom_mode'])
        else:
            coreSettings.save('puae_zoom_mode', '"auto"')
        # standard video	
        if system.isOptSet('video_standard'):
            coreSettings.save('puae_video_standard', system.config['video_standard'])
        else:
            coreSettings.save('puae_video_standard', '"PAL"')
        # keypad mapping 2p	
        if system.isOptSet('keyrah_mapping'):
            coreSettings.save('puae_keyrah_keypad_mappings', system.config['keyrah_mapping'])
        else:
            coreSettings.save('puae_keyrah_keypad_mappings', '"enabled"')
        # mouse speed	
        if system.isOptSet('mouse_speed'):
            coreSettings.save('puae_mouse_speed', system.config['mouse_speed'])
        else:
            coreSettings.save('puae_mouse_speed', '"200"')
        # whdload	
        if system.isOptSet('whdload'):
            coreSettings.save('puae_use_whdload_prefs', system.config['whdload'])
        else:
            coreSettings.save('puae_use_whdload_prefs', '"config"')
        # retropad options	
        if system.isOptSet('pad_options'):
            coreSettings.save('puae_retropad_options', system.config['pad_options'])
        else:
            coreSettings.save('puae_retropad_options', '"jump"')

    if (system.config['core'] == 'pce'):
        coreSettings.save('pce_keepaspect', '"enabled"')
        coreSettings.save('pce_nospritelimit', '"enabled"')

    if (system.config['core'] == 'pce_fast'):
        coreSettings.save('pce_keepaspect', '"enabled"')

    if (system.config['core'] == 'mupen64plus-next'):
        # BilinearMode
        if system.isOptSet('BilinearMode'):
            coreSettings.save('mupen64plus-BilinearMode', system.config['BilinearMode'])
        else:
            coreSettings.save('mupen64plus-BilinearMode', '"standard"')
        # multisampling aa
        if system.isOptSet('MultiSampling'):
            coreSettings.save('mupen64plus-MultiSampling', system.config['MultiSampling'])
        else:
            coreSettings.save('mupen64plus-MultiSampling', '"0"')
        # Texture filter
        if system.isOptSet('Texture_filter'):
            coreSettings.save('mupen64plus-txFilterMode', '"' + system.config['Texture_filter'] + '"')
        else:
            coreSettings.save('mupen64plus-txFilterMode', '"None"')
        # Texture Enhancement
        if system.isOptSet('Texture_Enhancement'):
            coreSettings.save('mupen64plus-txEnhancementMode', '"' + system.config['Texture_Enhancement'] + '"')
        else:
            coreSettings.save('mupen64plus-txEnhancementMode', '"None"')

    if (system.config['core'] == 'vb'):
        # 2D color mode
        if system.isOptSet('2d_color_mode'):
            coreSettings.save('vb_color_mode', '"' + system.config['2d_color_mode'] + '"')
        else:
            coreSettings.save('vb_color_mode', '"black & red"')
        # 3D color mode
        if system.isOptSet('3d_color_mode'):
            coreSettings.save('vb_anaglyph_preset', '"' + system.config['3d_color_mode'] + '"')
        else:
            coreSettings.save('vb_anaglyph_preset', '"disabled"')

    if (system.config['core'] == 'picodrive'):
        coreSettings.save('picodrive_input1',   '"6 button pad"')
        coreSettings.save('picodrive_input2',   '"6 button pad"')
        coreSettings.save('picodrive_sprlim',    '"enabled"')

    if (system.config['core'] == '81'):
        coreSettings.save('81_sound',   '"Zon X-81"')

    if (system.config['core'] == 'cap32'):
        if (system.name == 'gx4000'):
            coreSettings.save('cap32_model',    '"6128+"')
        else:
            coreSettings.save('cap32_model',    '"6128"')

    if (system.config['core'] == 'fuse'):
        coreSettings.save('fuse_machine',   '"Spectrum 128K"')

    if (system.config['core'] == 'opera'):
        coreSettings.save('opera_dsp_threaded',   '"enabled"')

    if (system.config['core'] == 'virtualjaguar'):
        coreSettings.save('virtualjaguar_usefastblitter',   '"enabled"')

    if (system.config['core'] == 'vice'):
        coreSettings.save('vice_Controller',    '"joystick"')
        coreSettings.save('vice_datasette_hotkeys',    '"enabled"')
        coreSettings.save('vice_read_vicerc',    '"disabled"')
        coreSettings.save('vice_retropad_options',    '"jump"')
        coreSettings.save('vice_JoyPort',       '"port_1"')
        # aspect ratio
        if system.isOptSet('aspect_ratio'):
            coreSettings.save('vice_aspect_ratio', system.config['aspect_ratio'])
        else:
            coreSettings.save('vice_aspect_ratio', '"pal"')
        # zoom mode
        if system.isOptSet('zoom_mode'):
            coreSettings.save('vice_zoom_mode', system.config['zoom_mode'])
        else:
            coreSettings.save('vice_zoom_mode', '"medium"')
        # external palette
        if system.isOptSet('external_palette'):
            coreSettings.save('vice_external_palette', system.config['external_palette'])
        else:
            coreSettings.save('vice_external_palette', '"colodore"')

    if (system.config['core'] == 'theodore'):
        coreSettings.save('theodore_autorun',   '"enabled"')

    if (system.config['core'] == 'genesisplusgx'):
        coreSettings.save('genesis_plus_gx_no_sprite_limit',    '"enabled"')

    if (system.config['core'] == 'snes9x_next'):
        coreSettings.save('snes9x_2010_reduce_sprite_flicker',       '"enabled"')
        # reduce slowdown
        if system.isOptSet('reduce_slowdown'):
            coreSettings.save('snes9x_2010_overclock_cycles', system.config['reduce_slowdown'])
        else:
            coreSettings.save('snes9x_2010_overclock_cycles', '"compatible"')

    if (system.config['core'] == 'yabasanshiro'):
        # resolution mode
        if system.isOptSet('resolution_mode'):
            coreSettings.save('yabasanshiro_resolution_mode', system.config['resolution_mode'])
        else:
            coreSettings.save('yabasanshiro_resolution_mode', '"original"')

    if (system.config['core'] == 'nestopia'):
        coreSettings.save('nestopia_nospritelimit',    '"enabled"')
        coreSettings.save('nestopia_overscan_h',    '"enabled"')
        coreSettings.save('nestopia_overscan_v',    '"enabled"')
        # palette
        if system.isOptSet('palette'):
            coreSettings.save('nestopia_palette', system.config['palette'])
        else:
            coreSettings.save('nestopia_palette', '"consumer"')

    if (system.config['core'] == 'fceumm'):
        coreSettings.save('fceumm_nospritelimit',    '"enabled"')

    if (system.config['core'] == 'flycast'):
        coreSettings.save('reicast_threaded_rendering',   '"enabled"')
        coreSettings.save('reicast_mipmapping',   '"disabled"')
        # widescreen hack
        if system.isOptSet('widescreen_hack'):
            coreSettings.save('reicast_widescreen_hack', system.config['widescreen_hack'])
        else:
            coreSettings.save('reicast_widescreen_hack', '"disabled"')
        # anisotropic filtering
        if system.isOptSet('anisotropic_filtering'):
            coreSettings.save('reicast_anisotropic_filtering', system.config['anisotropic_filtering'])
        else:
            coreSettings.save('reicast_anisotropic_filtering', '"off"')
        # texture upscaling (xBRZ)
        if system.isOptSet('texture_upscaling'):
            coreSettings.save('reicast_texupscale', system.config['texture_upscaling'])
        else:
            coreSettings.save('reicast_texupscale', '"off"')
        # render to texture upscaling
        if system.isOptSet('render_to_texture_upscaling'):
            coreSettings.save('reicast_render_to_texture_upscaling', system.config['render_to_texture_upscaling'])
        else:
            coreSettings.save('reicast_render_to_texture_upscaling', '"1x"')

    if (system.config['core'] == 'dosbox'):
        coreSettings.save('dosbox_svn_pcspeaker', '"true"')

    if (system.config['core'] == 'px68k'):
        coreSettings.save('px68k_disk_path', '"disabled"')

    if (system.config['core'] == 'mednafen_psx'):
        coreSettings.save('beetle_psx_hw_cpu_freq_scale',   '"110%"')
        # internal resolution
        if system.isOptSet('internal_resolution'):
            coreSettings.save('beetle_psx_hw_internal_resolution', system.config['internal_resolution'])
        else:
            coreSettings.save('beetle_psx_hw_internal_resolution', '"1x(native)"')
        # texture filtering
        if system.isOptSet('texture_filtering'):
            coreSettings.save('beetle_psx_hw_filter', system.config['texture_filtering'])
        else:
            coreSettings.save('beetle_psx_hw_filter', '"nearest"')
        # widescreen hack
        if system.isOptSet('widescreen_hack'):
            coreSettings.save('beetle_psx_hw_widescreen_hack', system.config['widescreen_hack'])
        else:
            coreSettings.save('beetle_psx_hw_widescreen_hack', '"disabled"')

    if (system.config['core'] == 'duckstation'):
        # resolution scale (default 1)
        if system.isOptSet('resolution_scale'):
            coreSettings.save('duckstation_GPU.ResolutionScale', system.config['resolution_scale'])
        else:
            coreSettings.save('duckstation_GPU.ResolutionScale', '"1"')
        # multisampling antialiasing (default 1x)
        if system.isOptSet('antialiasing'):
            coreSettings.save('duckstation_GPU.MSAA', system.config['antialiasing'])
        else:
            coreSettings.save('duckstation_GPU.MSAA', '"1"')
        # texture filtering (default nearest)
        if system.isOptSet('texture_filtering'):
            coreSettings.save('duckstation_GPU.TextureFilter', system.config['texture_filtering'])
        else:
            coreSettings.save('duckstation_GPU.TextureFilter', '"Nearest"')
        # widescreen hack (default off)
        if system.isOptSet('widescreen_hack'):
            coreSettings.save('duckstation_GPU.WidescreenHack', system.config['widescreen_hack'])
        else:
            coreSettings.save('duckstation_GPU.WidescreenHack', '"false"')

    if (system.config['core'] == 'pcsx_rearmed'):
        for n in range(1, 8+1):
            val = coreSettings.load('pcsx_rearmed_pad{}type'.format(n))
            if val == '"none"' or val == "" or val is None:
                coreSettings.save('pcsx_rearmed_pad{}type'.format(n), '"standard"')
        # force multitap no value / auto to disable
        # only let enabled when it is forced while previous values enable it
        val = coreSettings.load('pcsx_rearmed_multitap1')
        if val == '"auto"' or val == "" or val is None:
            coreSettings.save('pcsx_rearmed_multitap1', '"disabled"')
        val = coreSettings.load('pcsx_rearmed_multitap2')
        if val == '"auto"' or val == "" or val is None:
            coreSettings.save('pcsx_rearmed_multitap2', '"disabled"')

    # custom : allow the user to configure directly retroarchcore.cfg via batocera.conf via lines like : snes.retroarchcore.opt=val
    for user_config in system.config:
        if user_config[:14] == "retroarchcore.":
            coreSettings.save(user_config[14:], system.config[user_config])

    coreSettings.write()
def 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')