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
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)
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")
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)
def emulatorcfg_per_game(self): """ Retropie allows to choice per game an specific emulator from available we check if emulator is valid or clean emulators.cfg Returns ------- False If emulator is wrong and it was cleaned True Emulator is ok or not specific emulator for this game was selected """ p_bNeedClean = False if not os.path.exists(RETROPIE_CUSTEMU_FILE): #create emulators.cfg if doesn't exists touch_file(RETROPIE_CUSTEMU_FILE) logging.info("Created emulators.cfg") sCleanName = re.sub('[^a-zA-Z0-9-_]+', '', self.m_sGameName).replace(" ", "") sGameSystemName = "%s_%s" % (self.m_sSystem, sCleanName) with open(RETROPIE_CUSTEMU_FILE, 'r') as oFile: for line in oFile: lValues = line.strip().split(' ') if lValues[0] == sGameSystemName: sBinaryName = lValues[2].replace('"', '') if self.set_binary(sBinaryName): logging.info("(%s) is " % self.m_sSelCore + \ "selected for this game, will " + \ "be the chosen core to launch") return True else: # not valid is just ignored p_bNeedClean = True # clean emulators.cfg if have an invalid binary if p_bNeedClean: logging.info("cleaning line %s from %s" % (sGameSystemName, RETROPIE_CUSTEMU_FILE)) remove_line(RETROPIE_CUSTEMU_FILE, sGameSystemName) return False return True
def _frontend_rotation(self): show_info("WAIT, PREPARING ROTATION...") # remove first all trigger files self.__clean() p_sFileTail = "_" + str(self.RES_Y) + "p" p_sTheme = None p_sIntro = None if self.iToMode == 0: p_sFileTail += "_0" p_sIntro = INTRO_VID0_FILE touch_file(ROTMODES_YOKO_FILE) os.system('sudo rm %s >> /dev/null 2>&1' % ESSYSTEMS_TEMP_FILE) os.system('sudo mv %s %s >> /dev/null 2>&1' % (ESTHEMES_DIS_PATH, ES_THEMES_PRI_PATH)) for theme in THEME_LIST: VTHEME270_DST_PATH = os.path.join(ES_CFG_PATH, theme) os.system('sudo rm -R %s >> /dev/null 2>&1' % VTHEME270_DST_PATH) else: if not os.path.exists(ES_THEMES_SEC_PATH): os.system('mkdir %s >> /dev/null 2>&1' % ES_THEMES_SEC_PATH) os.system('cp %s %s >> /dev/null 2>&1' % (ESSYSTEMS_VERT_FILE, ESSYSTEMS_TEMP_FILE)) os.system('sudo mv %s %s >> /dev/null 2>&1' % (ES_THEMES_PRI_PATH, ESTHEMES_DIS_PATH)) for theme in THEME_LIST: VTHEME270_SRC_PATH = os.path.join(CRT_ES_RES_PATH, theme) os.system('cp -R %s %s >> /dev/null 2>&1' % (VTHEME270_SRC_PATH, ES_THEMES_SEC_PATH)) if self.iToMode == 90: p_sFileTail += "_1" p_sIntro = INTRO_VID1_FILE touch_file(ROTMODES_TATE1_FILE) elif self.iToMode == -90: p_sFileTail += "_3" p_sIntro = INTRO_VID3_FILE touch_file(ROTMODES_TATE3_FILE) modify_line(CRT_UTILITY_FILE, 'frontend_rotation', 'frontend_rotation %s' % self.iToMode) os.system('sudo cp %s %s >> /dev/null 2>&1' % (p_sIntro, INTRO_VID_DEF_FILE)) self._fix_aspect_ratio_images(p_sFileTail) self._fix_icons_image()
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]")
def _check_ra_db(self): if not os.path.isfile(CRT_RA_HASHDB_FILE): touch_file(CRT_RA_HASHDB_FILE) logging.info("INFO: Created retroarch hash database")
def __init__(self): if not os.path.isfile(CRT_AUTOFREQ_FILE): touch_file(CRT_AUTOFREQ_FILE) logging.info("Created frequency database")
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)
def _set_side_mode(self, p_sTrMode): """ Clean all side file triggers and create new """ os.system('rm %s >> /dev/null 2>&1' % ROTMODES_TATE1_FILE) os.system('rm %s >> /dev/null 2>&1' % ROTMODES_TATE3_FILE) if p_sTrMode: touch_file(p_sTrMode)