Пример #1
0
    def reset_config(self):
        p_bCheck = False
        self.m_sTemp = generate_random_temp_filename(RASP_BOOTCFG_FILE)
        touch_file(self.m_sTemp)
        p_lBaseCfg = {
            'pi4': [['dtoverlay', 'vc4-fkms-v3d'], ['max_framebuffers', '2']],
            'all': [['gpu_mem_256', '128'], ['gpu_mem_512', '256'],
                    ['gpu_mem_1024', '256']]
        }

        timings = " ".join(ini_getlist(RASP_BOOTCFG_FILE, 'hdmi_timings'))
        if not timings:
            res = ini_get(CRT_UTILITY_FILE, 'default') + '_timings'
            timings = " ".join(ini_getlist(CRT_UTILITY_FILE, res))
        line = 'hdmi_timings=' + timings
        add_line(self.m_sTemp, line)

        section_order = ['pi4', 'all']  # pi4 section must be before of all
        for section in section_order:
            list = p_lBaseCfg[section]
            for key, value in list:
                ini_sect_add_key(self.m_sTemp, section, key, value)

        self.set_cable(self.m_sTemp, 0)  # create cable config ID0 (default)
        ini_sect_create_section(self.m_sTemp, "CUSTOM-USER")

        os.system('sudo cp %s %s' % (self.m_sTemp, RASP_BOOTCFG_FILE))
        if md5_file(self.m_sTemp) == md5_file(RASP_BOOTCFG_FILE):
            p_bCheck = True
        self.__clean()
        return p_bCheck
Пример #2
0
 def _add_ra_version_to_db(self):
     # update file if not found
     self.m_sRAVersion = self.get_ra_version()
     add_line(CRT_RA_HASHDB_FILE, "RetroArch %s %s" % \
             (self.m_sRAHash, self.m_sRAVersion))
     logging.info("INFO: added new retroarch hash to db: " + \
                  "{%s} {%s}" % (self.m_sRAHash, self.m_sRAVersion))
Пример #3
0
 def _add_ra_version_to_db(self):
     # update file if not found
     output = commands.getoutput("%s --version" % RA_BIN_FILE)
     for line in output.splitlines():
         lValues = line.strip().split(' ')
         if 'RetroArch' in lValues[0]:
             self.m_sRAVersion = lValues[5]
             add_line(CRT_RA_HASHDB_FILE, "RetroArch %s %s" % \
                     (self.m_sRAHash, self.m_sRAVersion))
             logging.info("INFO: added new retroach hash to db: " + \
                          "{%s} {%s}" % (self.m_sRAHash, self.m_sRAVersion))
Пример #4
0
    def create_daphne_config(self):
        """ custom commands for resolution """
        COMMAND_FILE = os.path.join(self.m_sFilePath,
                                    "%s.commands" % self.m_sGameName)
        sOptions = ""
        # first value is flag, second if has any value
        lOptions = (["-ignore_aspect_ratio",
                     False], ["-x", str(self.m_oCRT.m_dData["H_Res"])],
                    ["-y", str(self.m_oCRT.m_dData["V_Res"])])
        # create full command string
        for option in lOptions:
            sOptions += option[0] + " "
            if option[1]:
                sOptions += option[1] + " "

        if os.path.exists(COMMAND_FILE):
            with open(COMMAND_FILE, "r+") as f:
                new_file = f.readlines()
                if not new_file:
                    new_file.append("")
                f.seek(0)  # rewind
                bSaveFile = False
                for line in new_file:
                    bSaveLine = False
                    lValues = line.strip().replace('=', ' ').split(' ')
                    for option in lOptions:
                        if not option[0] in lValues:
                            lValues.append(option[0])
                            if option[1]:
                                lValues.append(option[1])
                            bSaveLine = True
                        else:
                            if option[1]:
                                pos = lValues.index(option[0]) + 1
                                if lValues[pos] != option[1]:
                                    lValues[pos] = option[1]
                                    bSaveLine = True
                    line = " ".join(lValues) + "\n"
                    if bSaveLine:
                        f.write(line)  # new line
                        bSaveFile = True
                if bSaveFile:
                    f.truncate()  # remove everything after the last write
        else:
            logging.info("INFO: creating daphne commandline " + \
                         "file: %s" % COMMAND_FILE)
            touch_file(COMMAND_FILE)
            add_line(COMMAND_FILE, sOptions)
            logging.info("INFO: daphne launch parameters " + \
                         "{%s}" % sOptions)
Пример #5
0
 def _add_miss_ini(self, p_sIni):
     p_bCheck = False
     with open(CRT_NETPLAY_FILE, "r") as f:
         for line in f:
             lValues = line.strip()
             lValues = lValues.replace('"', '')
             lValues = lValues.replace('=', ' ')
             lValues = re.sub(r' +', " ", lValues).split(' ')
             if p_sIni == lValues[0]:
                 p_bCheck = True
                 break
     if not p_bCheck:
         for ini in self.NETPLAY_CFG:
             if p_sIni == ini.split("=")[0]:
                 add_line(CRT_NETPLAY_FILE, ini)
                 break
Пример #6
0
 def check_cfg_file(self):
     CFG = [
         "default = \"system60\"",
         "system60_timings = \"320 1 10 30 40 240 1 6 5 12 0 0 0 60 0 6400000 1\"",
         "system60_offsetX = \"0\"",
         "system60_offsetY = \"0\"",
         "system60_width = \"0\"",
         "system60_height = \"0\"",
         "test60_timings = \"1920 240 60.00 -4 -10 3 48 192 240 5 15734\"",
         "test60_offsetX = \"0\"",
         "test60_offsetY = \"0\"",
         "test60_width = \"0\"",
         "test60_height = \"0\"",
         "keyb_ipac = \"false\"",
         "netplay = \"false\"",
         "netplay_stateless = \"false\"",
         "netplay_lframes = \"2\"",
         "netplay_spectator = \"false\"",
         "netplay_lobby = \"true\"",
         "netplay_ask = \"true\"",
         "wifi_country = \"ES\"",
         "music_volume = \"50\"",
         "music_folder = \"root\"",
         "audio_presets = \"flat\"",
         "autosel_info = \"True\"",
         "handheld_bezel = \"false\"",
         "fast_boot = \"False\"",
         "freq_selector = \"manual\"",
         "integer_scale = \"false\"",
         "scummvm_arc = \"false\"",
         "daphne_remap = \"true\"",
         "version = \"EVO v3.3\"",
         "v_theme = \"VCRT-UniFlyered-Dark\"",
         "h_theme = \"CRT-UniFlyered-Color\"",
     ]
     if not os.path.exists(CRT_UTILITY_FILE):
         logging.info("INFO: config file not found")
         touch_file(CRT_UTILITY_FILE)
         for line in CFG:
             add_line(CRT_UTILITY_FILE, line)
         logging.info("INFO: created base config file")
Пример #7
0
 def get_config(self):
     if not os.path.exists(CRT_OLED_FILE): touch_file(CRT_OLED_FILE)
     p_sHash = md5_file(CRT_OLED_FILE)
     if p_sHash != self.m_sHash_Prev:
         logging.info("INFO: getting configuration from file")
         for screen in self.m_lOLEDScrns:
             for item in screen:
                 if 'scr_' in item:
                     value = ini_get(CRT_OLED_FILE, item)
                     if value == False:
                         value = 0
                         remove_line(CRT_OLED_FILE, item)
                         add_line(CRT_OLED_FILE, "%s = 0" % item)
                     else: value = int(value)
                     if value > 0: 
                         screen[item] = True
                         screen['time'] = value * 60
                     elif value <= 0: 
                         screen[item] = False
                         screen['time'] = 0
         self.m_sHash_Prev = md5_file(CRT_OLED_FILE)
Пример #8
0
 def host(self, p_sHost):
     if not self.check_ip_format(p_sHost): return False
     line1 = self.ini_host + '=' + '"%s"' % p_sHost
     line2 = self.ini_host_cfile + '=' + '"%s"' % p_sHost
     line3 = self.ini_host_cfile + '=' + '""'
     # remove both config lines for host: __netplayhostipXXX
     remove_line(CRT_NETPLAY_FILE, self.ini_host)
     remove_line(CRT_NETPLAY_FILE, self.ini_host_cfile)
     add_line(CRT_NETPLAY_FILE, line1)
     if self.get_mode() == "client":
         add_line(CRT_NETPLAY_FILE, line2)
     else:
         add_line(CRT_NETPLAY_FILE, line3)
     new = self.get_host()
     if new == p_sHost: return new
     logging.info("INFO: %s wrong edited" % self.ini_host)
     return False
Пример #9
0
 def _scummvm_create_cfg(self):
     """ create base ini file if not exist """
     if not os.path.isfile(SCUMMVMCFG_FILE):
         touch_file(SCUMMVMCFG_FILE)
         add_line(SCUMMVMCFG_FILE, "[scummvm]")
Пример #10
0
    def ra_config_write(self, p_bSmooth):
        logging.info("result - w %s, h %s (%s/%s) - scale integer{%s} - %sHz - s[%s] smooth{%s}" % (
            self.cfg_hres,
            self.cfg_vres,
            self.cfg_offsetx,
            self.cfg_offsety,
            self.cfg_iscale,
            self.m_dVideo["R_Rate"],
            self.m_oCRT.m_sSide_Game,
            p_bSmooth
            ))
        # copy cfg base
        add_line(self.m_sCustomRACFG, 'custom_viewport_width = "%s"' % self.cfg_hres)
        add_line(self.m_sCustomRACFG, 'custom_viewport_height = "%s"' % self.cfg_vres)
        add_line(self.m_sCustomRACFG, 'custom_viewport_x = "%s"' % self.cfg_offsetx)
        add_line(self.m_sCustomRACFG, 'custom_viewport_y = "%s"' % self.cfg_offsety)
        add_line(self.m_sCustomRACFG, 'video_refresh_rate = "%s"' % self.m_dVideo["R_Rate"])

        # smooth vertical games on horizontal screens
        ini_set(self.m_sCustomRACFG, "video_smooth", str(p_bSmooth).lower())

        # Check orientation
        logging.info("m_sSide_Game %s" % (self.m_oCRT.m_sSide_Game))
        logging.info("System Side: %s" % (self.m_iSide))
        if self.m_oCRT.m_sSide_Game == "H":
            add_line(self.m_sCustomRACFG, 'video_rotation = "0"')
        elif self.m_oCRT.m_sSide_Game == "V3":
            add_line(self.m_sCustomRACFG, 'video_rotation = "1"')
        elif self.m_oCRT.m_sSide_Game == "V1":
            add_line(self.m_sCustomRACFG, 'video_rotation = "3"')

        # Video Scale Integer activation
        ini_set(self.m_sCustomRACFG, "video_scale_integer", self.cfg_iscale)

        # Change custom core config if applies, like neogeo
        if self.m_sCoreCFG:
            ini_set(self.m_sCustomRACFG, "core_options_path", self.m_sCoreCFG)

        # Check retroarch version
        ra_version_fixes(self.m_sCustomRACFG)
Пример #11
0
    def ra_config_write(self, p_bSmooth):
        logging.info(
            "result - w %s, h %s (%s/%s) - scale integer{%s} - %sHz - s[%s] smooth{%s}"
            % (self.cfg_hres, self.cfg_vres, self.cfg_offsetx,
               self.cfg_offsety, self.cfg_scaleint, self.m_dVideo["R_Rate"],
               self.m_oCRT.m_sSide_Game, p_bSmooth))
        # copy cfg base
        shutil.copy2(CFG_ARCADE_BASE, TMP_ARCADE_FILE)
        add_line(TMP_ARCADE_FILE,
                 'custom_viewport_width = "%s"' % self.cfg_hres)
        add_line(TMP_ARCADE_FILE,
                 'custom_viewport_height = "%s"' % self.cfg_vres)
        add_line(TMP_ARCADE_FILE,
                 'custom_viewport_x = "%s"' % self.cfg_offsetx)
        add_line(TMP_ARCADE_FILE,
                 'custom_viewport_y = "%s"' % self.cfg_offsety)
        add_line(TMP_ARCADE_FILE,
                 'video_refresh_rate = "%s"' % self.m_dVideo["R_Rate"])

        # smooth vertical games on horizontal screens
        modify_line(TMP_ARCADE_FILE, "video_smooth",
                    'video_smooth = "%s"' % str(p_bSmooth).lower())

        # Check orientation
        logging.info("m_sSide_Game %s" % (self.m_oCRT.m_sSide_Game))
        logging.info("m_iRSys %s" % (self.m_oCRT.m_iRSys))
        if self.m_oCRT.m_sSide_Game == "H":
            add_line(TMP_ARCADE_FILE, 'video_rotation = "0"')
        elif self.m_oCRT.m_sSide_Game == "V3":
            add_line(TMP_ARCADE_FILE, 'video_rotation = "1"')
        elif self.m_oCRT.m_sSide_Game == "V1":
            add_line(TMP_ARCADE_FILE, 'video_rotation = "3"')

        # Video Scale Integer activation
        modify_line(TMP_ARCADE_FILE, "video_scale_integer =",
                    'video_scale_integer = "%s"' % self.cfg_scaleint)

        # Change custom core config if applies, like neogeo
        if self.m_sCstCoreCFG:
            modify_line(TMP_ARCADE_FILE, "core_options_path",
                        'core_options_path = "%s"' % self.m_sCstCoreCFG)

        # Check retroarch version
        ra_version_fixes(TMP_ARCADE_FILE)
Пример #12
0
 def add(self, p_sName, p_sFreq):
     if not p_sName or not p_sFreq:
         return
     add_line(CRT_AUTOFREQ_FILE, "%s %s" % (p_sName, p_sFreq))
Пример #13
0
 def _check_netplay_cfg(self):
     if not os.path.exists(CRT_NETPLAY_FILE):
         touch_file(CRT_NETPLAY_FILE)
         for line in self.NETPLAY_CFG:
             add_line(CRT_NETPLAY_FILE, line)