def get_fix_user_raw(self): offsetX = int(ini_get(CRT_UTILITY_FILE, "system60_offsetX")) offsetY = int(ini_get(CRT_UTILITY_FILE, "system60_offsetY")) width = int(ini_get(CRT_UTILITY_FILE, "system60_width")) #Apply width to timings #self.timing_add("H_Res", (2*width)) #if width < 0: # self.timing_add("H_BP", abs(width)) # self.timing_add("H_FP", abs(width)) #else: # self.timing_add("H_BP", -width) # self.timing_add("H_FP", -width) #Apply offsetX to timings self.timing_add("H_BP", offsetX) if offsetX < 0: self.timing_add("H_FP", abs(offsetX)) else: self.timing_add("H_FP", -offsetX) #Apply offsetY to timings self.timing_add("V_BP", offsetY) if offsetY < 0: self.timing_add("V_FP", abs(offsetY)) else: self.timing_add("V_FP", -offsetY)
def get_config(): global opt # create configuration file if not exists if not os.path.exists(CRT_UTILITY_FILE): os.system('echo %s > %s' % \ (DEFAULT_CONFIG, CRT_UTILITY_FILE)) # get configuration values opt[0][2] = int(ini_get(CRT_UTILITY_FILE, "game_rotation")) opt[2][2] = int(ini_get(CRT_UTILITY_FILE, "handheld_bezel")) opt[3][2] = int(ini_get(CRT_UTILITY_FILE, "freq_selector")) opt[6][2] = int(ini_get(CRT_UTILITY_FILE, "integer_scale")) opt[7][2] = int(ini_get(CRT_UTILITY_FILE, "scummvm_arc")) # get current emulationstation side if os.path.exists(ROTMODES_TATE1_FILE): opt[1][2] = 90 opt[1][3] = 90 opt[0][2] = 0 elif os.path.exists(ROTMODES_TATE3_FILE): opt[1][2] = -90 opt[1][3] = -90 opt[0][2] = 0 else: opt[1][2] = 0 opt[1][3] = 0
def get_mode(self): value = ini_get(CRT_NETPLAY_FILE, self.ini_mode) if not value: self._add_miss_ini(self.ini_mode) value = ini_get(CRT_NETPLAY_FILE, self.ini_mode) if value == value: if value == "H": return "host" elif value == "C": return "client" return value
def get_host(self): value = ini_get(CRT_NETPLAY_FILE, self.ini_host) if not value: self._add_miss_ini(self.ini_host) value = ini_get(CRT_NETPLAY_FILE, self.ini_host) if not self.check_ip_format(value): line = self.ini_host + '=' + '"192.168.0.1"' modify_line(CRT_NETPLAY_FILE, self.ini_host, line) value = "192.168.0.1" return value
def _prepare_cfg(self): """ Take config from utility.cfg """ self.m_dConfigFile["offsetX"] = int( ini_get(CRT_UTILITY_FILE, self.m_sEnv + "_offsetX")) self.m_dConfigFile["offsetY"] = int( ini_get(CRT_UTILITY_FILE, self.m_sEnv + "_offsetY")) self.m_dConfigFile["width"] = int( ini_get(CRT_UTILITY_FILE, self.m_sEnv + "_width")) self.m_dConfigFile["height"] = int( ini_get(CRT_UTILITY_FILE, self.m_sEnv + "_height"))
def ingame_get_info(self): self.m_sNetplay = "NETPLAY: DISABLED" self.m_sPublic = "LOCAL PLAYING" self.m_sRate = "" p_iTime = 0 """ Get Retroarch Netplay info if launched by CRT scripts """ p_bNetplay = ini_get(CRT_UTILITY_FILE, "netplay") p_sNetMode = ini_get(CRT_NETPLAY_FILE, "__netplaymode") p_sNetRemo = ini_get(CRT_NETPLAY_FILE, "__netplayhostip") p_sNetPort = ini_get(CRT_NETPLAY_FILE, "__netplayport") if p_bNetplay and p_bNetplay.lower() == "true": p_bNetplay = True else: p_bNetplay = None while not STOP_SCREEN and not STOP_SERVICE: if p_iTime == 0 or time.time() - p_iTime >= 5: """ Get Retroarch Netplay info if launched by runcommand """ if p_bNetplay == None: if os.path.exists(RETROPIE_RUNCOMMAND_LOG): with open(RETROPIE_RUNCOMMAND_LOG, "r") as f: for line in f: if "-H" in line or "-C" in line: p_bNetplay = True """ Get current resolution """ cmd = "vcgencmd hdmi_timings" p_sOutput = subprocess.check_output(cmd, shell=True).decode("utf-8") p_lTimings = p_sOutput.strip().split("=")[1].split(' ') self.m_sTimings = p_lTimings[0] + "x" + p_lTimings[5] + "@" + p_lTimings[13] + "hz" text_width = self.m_oDraw.textsize(self.m_sTimings, font=self.m_oFont10)[0] self.m_iTimingPosX = 81 - int(text_width / 2) """ Get if NTSC or PAL and its screen position """ if int(p_lTimings[0]) == 320 and int(p_lTimings[5]) == 240: self.m_sRate = "240p" elif int(p_lTimings[5]) <= 240: self.m_sRate = "NTSC" elif int(p_lTimings[5]) > 240: self.m_sRate = "PAL" text_width = self.m_oDraw.textsize(self.m_sRate, font=self.m_oFont10)[0] self.m_iRatePosX = 15 - int(text_width / 2) """ Get IP and connection for Netplay""" if p_bNetplay: if p_sNetMode == "C" or p_sNetMode == "c": self.m_sNetplay = "NETPLAY: CLIENT MODE" self.m_sPublic = chr(8594) + " " + p_sNetRemo + ":" + p_sNetPort elif p_sNetMode == "H" or p_sNetMode == "h": p_sIP = self.get_ip_address("public") if not p_sIP: p_sIP = self.get_ip_address("eth0") if not p_sIP: p_sIP = self.get_ip_address("wlan0") if not p_sIP: p_sIP = "NOT CONNECTED" self.m_sNetplay = "NETPLAY: HOST MODE" if p_sIP == "NOT CONNECTED": self.m_sPublic = "NO NETWORK AVAILABLE" else: self.m_sPublic = p_sIP + ":" + p_sNetPort + " " + chr(8592) p_iTime = time.time() time.sleep(0.3) return
def opt11_datas(self): p_lLines = { 'text': "Runcommand Allow Config", 'color_val': "type_color_1" } if ini_get(CRT_UTILITY_FILE, "fast_boot").lower() == "true": value = "N/A" p_lLines.update({'color_val': "type_color_7"}) else: value = ini_get(RETROPIE_RUNCOMMAND_CFG_FILE, "disable_menu") if value == "0": value = True else: value = False p_lLines.update({'value': value}) return p_lLines
def get_lframes(self): value = ini_get(CRT_UTILITY_FILE, "netplay_lframes") try: frame = int(value) except: frame = 0 return frame
def validate_host(self): value1 = self.get_host() value2 = ini_get(CRT_NETPLAY_FILE, self.ini_host_cfile) if self.get_mode == "client": if value1 == value2: if self.check_ip_format(value1): return True self.host(value1)
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 _set_new_theme(self): """ Identify saved theme for next orientation in utility.cfg If theme not found, default ones will be applied. """ p_sTheme = None p_sTail = self.sTailSideH if self.iCurSide != 0: p_sTail = self.sTailSideV p_sIniTheme = str(self.iToRes) + p_sTail p_sTheme = ini_get(CRT_UTILITY_FILE, p_sIniTheme) """ If theme was not found then apply by default """ # by default vertical theme if self.iCurSide != 0 and not p_sTheme: if self.RES_Y == 270: p_sTheme = "V270P-CRT-BASE" elif self.RES_Y == 240: p_sTheme = "V270P-CRT-BASE" else: p_sTheme = "V270P-CRT-BASE" # by default horizontal theme elif self.iCurSide == 0 and not p_sTheme: if self.RES_Y == 270: p_sTheme = "270P-CRT-SNES-MINI" elif self.RES_Y == 240: p_sTheme = "240P-CRT-BUBBLEGUM" else: p_sTheme = "270P-CRT-BASE" # no change if current configuration is the same if p_sTheme != get_xml_value_esconfig("ThemeSet"): set_xml_value_esconfig("ThemeSet", p_sTheme)
def opt11_datas(self): p_lLines = {'text': "ScummVM ARC"} value = ini_get(CRT_UTILITY_FILE, "scummvm_arc") if value.lower() == "true": value = True else: value = False p_lLines.update({'value': value}) return p_lLines
def opt3_datas(self): p_lLines = {'text': "RA Handled Bezels"} value = ini_get(CRT_UTILITY_FILE, "handheld_bezel") if value.lower() == "true": value = True else: value = False p_lLines.update({'value': value}) return p_lLines
def _scummvm_change_aspect(self): """ If aspect ratio correction is enabled game will fit vertically the screen although we lost pixel perfect. If disabled, most of the games are 320x200 so will show two horizontal bars up and down on the screen. If auto will ask just before of game launching for an option """ p_sARValue = 'aspect_ratio' # get aspect ratio configuration from CRT config sAspect = None p_sScummARC = int(ini_get(CRT_UTILITY_FILE, "scummvm_arc")) if p_sScummARC == 0: """ If Aspect Ratio Correction is not enabled leave this config as it is, only change if forced required or asked. """ pass if p_sScummARC == 1: sAspect = "FIT" elif p_sScummARC == 2: sAspect = menu_options(self.m_lOptARC) if sAspect == "PIXEL": self._scummvm_change_ini(SCUMMVMCFG_FILE, p_sARValue, "false") elif sAspect == "FIT": self._scummvm_change_ini(SCUMMVMCFG_FILE, p_sARValue, "true")
def opt2_datas(self): p_lLines = {'text': "RA Integer Scale"} value = ini_get(CRT_UTILITY_FILE, "integer_scale") if value.lower() == "true": value = True else: value = False p_lLines.update({'value': value}) return p_lLines
def opt2_datas(self): p_lLines = {'text': "Selector Info", 'color_val': "type_color_1"} if ini_get(CRT_UTILITY_FILE, "fast_boot").lower() == "true": value = "N/A" p_lLines.update({'color_val': "type_color_7"}) else: mode = ini_get(CRT_UTILITY_FILE, "freq_selector") if mode.lower() == "manual": value = "--" p_lLines.update({'color_val': "type_color_7"}) else: value = ini_get(CRT_UTILITY_FILE, "autosel_info") if value.lower() == "true": value = True else: value = False p_lLines.update({'value': value}) return p_lLines
def get_country(self): if not self.m_sCountry: os.system('cp %s %s > /dev/null 2>&1' % (self.WPA_FILE, self.TMP_FILE)) ctry = ini_get(self.TMP_FILE, "country") os.system("sudo rm %s > /dev/null 2>&1" % self.TMP_FILE) if not ctry: ctry = ini_get(CRT_UTILITY_FILE, "wifi_country") if not ctry: ctry = "ES" for item in self.COUNTRY: if self.COUNTRY[item] == ctry: self.m_sCountry = item break if not self.m_sCountry: self.m_sCountry = "Spain" self.country(self.m_sCountry) return self.m_sCountry
def _get_boot_timing(self): """ Take current system base timings from utility.cfg""" self.m_sEnv = ini_get(CRT_UTILITY_FILE, "default") self.m_lBootTimings = ini_getlist(CRT_UTILITY_FILE, "%s_timings" % self.m_sEnv) self.m_lBootTimings = list(map(int, self.m_lBootTimings)) if not self._apply_fix_tv(): logging.info("INFO: not fix tv to apply") logging.info("INFO: default system resolution: %s" % self.m_sEnv)
def opt1_datas(self): p_lLines = {'text': "Daphne Controls Remap", 'color_val': "type_color_1", 'icon': None} value = False if ini_get(CRT_UTILITY_FILE, "daphne_remap") == "true": value = True p_lLines.update({'value': value}) return p_lLines
def get_frequency(self): # first i try to find an allowed freq self.m_sSelectFreq = ini_get(CRT_UTILITY_FILE, "freq_selector") if self.m_sSelectFreq in ALLOWED_FREQS: logging.info("Frequency selector always %sHz" % self.m_sSelectFreq) if self.m_sSelectFreq == "50": AutoSelection = "FORCED TO 50Hz / PAL" elif self.m_sSelectFreq == "60": AutoSelection = "FORCED TO 60Hz / NTSC" if ini_get(CRT_UTILITY_FILE, "autosel_info").lower() != "false": if not self.m_bFastBoot: show_info(AutoSelection) elif self.m_sSelectFreq == "auto": logging.info("Frequency selector mode auto") self.m_sSelectFreq = self.frecuency_auto() else: logging.info("Frequency selector mode manual") self.m_sSelectFreq = self.frequency_manual() return self.m_sSelectFreq
def __init__(self, p_sFileName=""): if not p_sFileName: logging.info("WARNING: NO filename passed, setting " % \ "60Hz by default") return "60" self.m_sFileName = p_sFileName self.m_sCompactedName = compact_rom_name(p_sFileName) self.m_oFreqDB = dbfreq() if ini_get(CRT_UTILITY_FILE, "fast_boot").lower() == "true": self.m_bFastBoot = True
def opt12_datas(self): p_lLines = { 'text': "Retroarch Allow Config", 'color_val': "type_color_1" } value = ini_get(RA_CFG_FILE, "menu_driver") if value == "Null": value = False else: value = True p_lLines.update({'value': value}) return p_lLines
def _save_current_theme(self): # identify element theme to find in CRT config p_sIni = "h_theme" if self.iCurSide != 0: p_sIni = "v_theme" # get current saved theme for current side p_sTheme = ini_get(CRT_UTILITY_FILE, p_sIni) p_sCurTheme = get_xml_value_esconfig("ThemeSet") if p_sTheme != p_sCurTheme: ini_set(CRT_UTILITY_FILE, p_sIni, p_sCurTheme)
def _joy_get_cfg(self, p_sCfgFile, p_sINI): temp = ini_get(p_sCfgFile, p_sINI) if temp: try: temp = temp.replace('"', '') logging.info("INFO: found %s = %s" % (p_sINI, temp)) except: logging.info("WARNING: value no found for %s in %s" % (p_sINI, p_sCfgFile)) return False return temp
def _save_current_theme(self): # identify element theme to find in CRT config p_sElement = str(self.RES_Y) + self.sTailSideH if self.iCurSide != 0: p_sElement = str(self.RES_Y) + self.sTailSideV # get current saved theme for current side p_sTheme = ini_get(CRT_UTILITY_FILE, p_sElement) self.sCurTheme = get_xml_value_esconfig("ThemeSet") if p_sTheme != self.sCurTheme: modify_line(CRT_UTILITY_FILE, p_sElement, "%s %s" % (p_sElement, self.sCurTheme))
def opt1_datas(self): p_lLines = { 'text': "TV Modes", 'es_restart': True, 'color_val': "type_color_1" } value = ini_get(CRT_FIXMODES_FILE, "mode_default") if value.lower() == "default": value = 'Default' p_lLines.update({'value': value}) p_lLines.update({'options': get_modes()}) return p_lLines
def opt4_datas(self): p_lLines = { 'text': "Game Launcher", 'options': ["Runcommand", "FastBoot"], 'color_val': "type_color_1" } value = ini_get(CRT_UTILITY_FILE, "fast_boot").lower() if value == "true": value = "FastBoot" else: value = "Runcommand" p_lLines.update({'value': value}) return p_lLines
def opt2_datas(self): try: self.m_oSYSVOLClass except: self.m_oSYSVOLClass = sys_volume() p_lLines = {'text': "EQ Preset", 'color_val': "type_color_1"} m_lOpt = self.m_oSYSVOLClass.get_presets() m_lOpt = list(map(lambda x:x.title(),m_lOpt)) p_lLines.update({'options': m_lOpt}) value = (ini_get(CRT_UTILITY_FILE, "audio_presets")).title() p_lLines.update({'value': value}) return p_lLines
def opt8_datas(self): p_lLines = {'color_val': "type_color_1"} p_lLines.update({'text': "Time Played"}) value = 0 if os.path.exists(CRT_STATS_FILE): value = int(ini_get(CRT_STATS_FILE, 'timer')) m, s = divmod(value, 60) h, m = divmod(m, 60) value = "%sh %sm" % (h, m) p_lLines.update({'value': value}) return p_lLines
def opt1(self, p_iJoy = None, p_iLine = None): p_lLines = {} if p_iJoy == None: return self.opt1_datas() if p_iJoy & CRT_OK: list = self.m_lLines[p_iLine]['options'] value = self.m_lLines[p_iLine]['value'] new = explore_list(p_iJoy, value, list) if new: ini_set(CRT_UTILITY_FILE, "daphne_remap", "true") else: ini_set(CRT_UTILITY_FILE, "daphne_remap", "false") value = ini_get(CRT_UTILITY_FILE, "daphne_remap") == "true" self.m_lLines[p_iLine]['value'] = value