Esempio n. 1
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0;
	iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini");

	const bool useControllerIniFilename = controllerIniFilename != nullptr && strlen(controllerIniFilename) > 0;
	controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : "controls.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	bShowFrameProfiler = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
		IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
		for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
			setting->Get(section);
		}
	}

	iRunCount++;
	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	// -1 is okay, though. We'll just ignore recent stuff if it is.
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	if (iMaxRecent > 0) {
		recentIsos.clear();
		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			std::string fileName;

			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
				recentIsos.push_back(fileName);
			}
		}
	}

	auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
	vPinnedPaths.clear();
	for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
		vPinnedPaths.push_back(it->second);
	}

	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}

	// Check for an old dpad setting
	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	float f;
	control->Get("DPadRadius", &f, 0.0f);
	if (f > 0.0f) {
		ResetControlLayout();
	}

	// MIGRATION: For users who had the old static touch layout, aren't I nice?
	// We can probably kill this in 0.9.8 or something.
	if (fDpadX > 1.0 || fDpadY > 1.0) { // Likely the rest are too!
		float screen_width = dp_xres;
		float screen_height = dp_yres;

		fActionButtonCenterX /= screen_width;
		fActionButtonCenterY /= screen_height;
		fDpadX /= screen_width;
		fDpadY /= screen_height;
		fStartKeyX /= screen_width;
		fStartKeyY /= screen_height;
		fSelectKeyX /= screen_width;
		fSelectKeyY /= screen_height;
		fUnthrottleKeyX /= screen_width;
		fUnthrottleKeyY /= screen_height;
		fLKeyX /= screen_width;
		fLKeyY /= screen_height;
		fRKeyX /= screen_width;
		fRKeyY /= screen_height;
		fAnalogStickX /= screen_width;
		fAnalogStickY /= screen_height;
	}
	
	const char *gitVer = PPSSPP_GIT_VERSION;
	Version installed(gitVer);
	Version upgrade(upgradeVersion);
	const bool versionsValid = installed.IsValid() && upgrade.IsValid();

	// Do this regardless of iRunCount to prevent a silly bug where one might use an older
	// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
	// even if said newer version is >= the upgrade found online.
	if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
		upgradeMessage = "";
	}

	// Check for new version on every 10 runs.
	// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
	// splash screen quickly), but then we'll just show the notification next time instead, we store the
	// upgrade number in the ini.
#if !defined(ARMEABI)
	if (iRunCount % 10 == 0 && bCheckForNewVersion) {
		std::shared_ptr<http::Download> dl = g_DownloadManager.StartDownloadWithCallback(
			"http://www.ppsspp.org/version.json", "", &DownloadCompletedCallback);
		dl->SetHidden(true);
	}
#endif

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}
	
	//so this is all the way down here to overwrite the controller settings
	//sadly it won't benefit from all the "version conversion" going on up-above
	//but these configs shouldn't contain older versions anyhow
	if (bGameSpecific)
	{
		loadGameConfig(gameId_);
	}

	CleanRecent();

#ifdef _WIN32
	iTempGPUBackend = iGPUBackend;
#endif

	// Fix Wrong MAC address by old version by "Change MAC address"
	if (sMACAddress.length() != 17)
		sMACAddress = CreateRandMAC();

	if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
		g_Config.iRenderingMode = FB_BUFFERED_MODE;
	}
}
Esempio n. 2
0
void Config::Save() {
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		
		saveGameConfig(gameId_);

		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		// Need to do this somewhere...
		bFirstRun = false;

		for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
			IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
			for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
				if (!bGameSpecific || !setting->perGame_){
					setting->Set(section);
				}
			}
		}

		IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
		recent->Set("MaxRecent", iMaxRecent);

		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (i < (int)recentIsos.size()) {
				recent->Set(keyName, recentIsos[i]);
			} else {
				recent->Delete(keyName); // delete the nonexisting FileName
			}
		}

		IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
		pinnedPaths->Clear();
		for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
			pinnedPaths->Set(keyName, vPinnedPaths[i]);
		}

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Delete("DPadRadius");

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());

		if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
		{
			IniFile controllerIniFile;
			if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
			}
			KeyMap::SaveToIni(controllerIniFile);
			if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
				return;
			}
			INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
		}
	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
}
Esempio n. 3
0
void Config::Save() {
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		IniFile::Section *general = iniFile.GetOrCreateSection("General");

		// Need to do this somewhere...
		bFirstRun = false;
		general->Set("FirstRun", bFirstRun);
		general->Set("RunCount", iRunCount);
		general->Set("Enable Logging", bEnableLogging);
		general->Set("AutoRun", bAutoRun);
		general->Set("Browse", bBrowse);
		general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
		general->Set("CurrentDirectory", currentDirectory);
		general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
		general->Set("ReportingHost", sReportHost);
		general->Set("AutoSaveSymbolMap", bAutoSaveSymbolMap);
#ifdef _WIN32
		general->Set("TopMost", bTopMost);
		general->Set("WindowX", iWindowX);
		general->Set("WindowY", iWindowY);
		general->Set("WindowWidth", iWindowWidth);
		general->Set("WindowHeight", iWindowHeight);
		general->Set("PauseOnLostFocus", bPauseOnLostFocus);
#endif
		general->Set("Language", sLanguageIni);
		general->Set("NumWorkerThreads", iNumWorkerThreads);
		general->Set("EnableAutoLoad", bEnableAutoLoad);
		general->Set("EnableCheats", bEnableCheats);
		general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG);
		general->Set("StateSlot", iCurrentStateSlot);
		general->Set("RewindFlipFrequency", iRewindFlipFrequency);
		general->Set("GridView1", bGridView1);
		general->Set("GridView2", bGridView2);
		general->Set("GridView3", bGridView3);

		IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
		recent->Set("MaxRecent", iMaxRecent);

		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			sprintf(keyName,"FileName%d",i);
			if (i < (int)recentIsos.size()) {
				recent->Set(keyName, recentIsos[i]);
			} else {
				recent->Delete(keyName); // delete the nonexisting FileName
			}
		}

		IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
		cpu->Set("Jit", bJit);
		cpu->Set("SeparateCPUThread", bSeparateCPUThread);
		cpu->Set("AtomicAudioLocks", bAtomicAudioLocks);
		cpu->Set("SeparateIOThread", bSeparateIOThread);
		cpu->Set("FastMemoryAccess", bFastMemory);
		cpu->Set("CPUSpeed", iLockedCPUSpeed);

		IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
		graphics->Set("ShowFPSCounter", iShowFPSCounter);
		graphics->Set("RenderingMode", iRenderingMode);
		graphics->Set("SoftwareRendering", bSoftwareRendering);
		graphics->Set("HardwareTransform", bHardwareTransform);
		graphics->Set("SoftwareSkinning", bSoftwareSkinning);
		graphics->Set("TextureFiltering", iTexFiltering);
		graphics->Set("InternalResolution", iInternalResolution);
		graphics->Set("FrameSkip", iFrameSkip);
		graphics->Set("FrameRate", iFpsLimit);
		graphics->Set("FrameSkipUnthrottle", bFrameSkipUnthrottle);
		graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS);
		graphics->Set("AnisotropyLevel", iAnisotropyLevel);
		graphics->Set("VertexCache", bVertexCache);
#ifdef _WIN32
		graphics->Set("FullScreen", bFullScreen);
#endif
		graphics->Set("PartialStretch", bPartialStretch);
		graphics->Set("StretchToDisplay", bStretchToDisplay);
		graphics->Set("TrueColor", bTrueColor);
		graphics->Set("MipMap", bMipMap);
		graphics->Set("TexScalingLevel", iTexScalingLevel);
		graphics->Set("TexScalingType", iTexScalingType);
		graphics->Set("TexDeposterize", bTexDeposterize);
		graphics->Set("VSyncInterval", bVSync);
		graphics->Set("DisableStencilTest", bDisableStencilTest);
		graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite);
		graphics->Set("TimerHack", bTimerHack);
		graphics->Set("LowQualitySplineBezier", bLowQualitySplineBezier);
		graphics->Set("PostShader", sPostShaderName);

		IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
		sound->Set("Enable", bEnableSound);
		sound->Set("VolumeBGM", iBGMVolume);
		sound->Set("VolumeSFX", iSFXVolume);
		sound->Set("LowLatency", bLowLatencyAudio);

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Set("HapticFeedback", bHapticFeedback);
		control->Set("ShowTouchControls", bShowTouchControls);
		control->Set("ShowTouchCross", bShowTouchCross);
		control->Set("ShowTouchCircle", bShowTouchCircle);
		control->Set("ShowTouchSquare", bShowTouchSquare);
		control->Set("ShowTouchTriangle", bShowTouchTriangle);
		control->Set("ShowTouchStart", bShowTouchStart);
		control->Set("ShowTouchSelect", bShowTouchSelect);
		control->Set("ShowTouchLTrigger", bShowTouchLTrigger);
		control->Set("ShowTouchRTrigger", bShowTouchRTrigger);
		control->Set("ShowAnalogStick", bShowTouchAnalogStick);
		control->Set("ShowTouchUnthrottle", bShowTouchUnthrottle);
		control->Set("ShowTouchDpad", bShowTouchDpad);

#ifdef USING_GLES2
		control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz);
		control->Set("TiltBaseX", fTiltBaseX);
		control->Set("TiltBaseY", fTiltBaseY);
		control->Set("InvertTiltX", bInvertTiltX);
		control->Set("InvertTiltY", bInvertTiltY);
		control->Set("TiltSensitivityX", iTiltSensitivityX);
		control->Set("TiltSensitivityY", iTiltSensitivityY);
		control->Set("DeadzoneRadius", fDeadzoneRadius);
#endif
		control->Set("DisableDpadDiagonals", bDisableDpadDiagonals);

		control->Set("TouchButtonOpacity", iTouchButtonOpacity);
		control->Set("ActionButtonScale", fActionButtonScale);
		control->Set("ActionButtonSpacing2", fActionButtonSpacing);
		control->Set("ActionButtonCenterX", fActionButtonCenterX);
		control->Set("ActionButtonCenterY", fActionButtonCenterY);
		control->Set("DPadX", fDpadX);
		control->Set("DPadY", fDpadY);
		control->Set("DPadScale", fDpadScale);
		control->Set("DPadSpacing", fDpadSpacing);
		control->Set("StartKeyX", fStartKeyX);
		control->Set("StartKeyY", fStartKeyY);
		control->Set("StartKeyScale", fStartKeyScale);
		control->Set("SelectKeyX", fSelectKeyX);
		control->Set("SelectKeyY", fSelectKeyY);
		control->Set("SelectKeyScale", fSelectKeyScale);
		control->Set("UnthrottleKeyX", fUnthrottleKeyX);
		control->Set("UnthrottleKeyY", fUnthrottleKeyY);
		control->Set("UnthrottleKeyScale", fUnthrottleKeyScale);
		control->Set("LKeyX", fLKeyX);
		control->Set("LKeyY", fLKeyY);
		control->Set("LKeyScale", fLKeyScale);
		control->Set("RKeyX", fRKeyX);
		control->Set("RKeyY", fRKeyY);
		control->Set("RKeyScale", fRKeyScale);
		control->Set("AnalogStickX", fAnalogStickX);
		control->Set("AnalogStickY", fAnalogStickY);
		control->Set("AnalogStickScale", fAnalogStickScale);

		IniFile::Section *network = iniFile.GetOrCreateSection("Network");
		network->Set("EnableWlan", bEnableWlan);

		IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
		pspConfig->Set("PSPModel", iPSPModel);
		pspConfig->Set("NickName", sNickName.c_str());
		pspConfig->Set("proAdhocServer", proAdhocServer.c_str());
		pspConfig->Set("MacAddress", localMacAddress.c_str());
		pspConfig->Set("Language", iLanguage);
		pspConfig->Set("TimeFormat", iTimeFormat);
		pspConfig->Set("DateFormat", iDateFormat);
		pspConfig->Set("TimeZone", iTimeZone);
		pspConfig->Set("DayLightSavings", bDayLightSavings);
		pspConfig->Set("ButtonPreference", iButtonPreference);
		pspConfig->Set("LockParentalLevel", iLockParentalLevel);
		pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel);
		pspConfig->Set("WlanPowerSave", bWlanPowerSave);
		pspConfig->Set("EncryptSave", bEncryptSave);
#ifdef _WIN32
		pspConfig->Set("BypassOSKWithKeyboard", bBypassOSKWithKeyboard);
#endif

		IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
		debugConfig->Set("DisasmWindowX", iDisasmWindowX);
		debugConfig->Set("DisasmWindowY", iDisasmWindowY);
		debugConfig->Set("DisasmWindowW", iDisasmWindowW);
		debugConfig->Set("DisasmWindowH", iDisasmWindowH);
		debugConfig->Set("GEWindowX", iGEWindowX);
		debugConfig->Set("GEWindowY", iGEWindowY);
		debugConfig->Set("GEWindowW", iGEWindowW);
		debugConfig->Set("GEWindowH", iGEWindowH);
		debugConfig->Set("ConsoleWindowX", iConsoleWindowX);
		debugConfig->Set("ConsoleWindowY", iConsoleWindowY);
		debugConfig->Set("FontWidth", iFontWidth);
		debugConfig->Set("FontHeight", iFontHeight);
		debugConfig->Set("DisplayStatusBar", bDisplayStatusBar);
		debugConfig->Set("ShowBottomTabTitles",bShowBottomTabTitles);
		debugConfig->Set("ShowDeveloperMenu", bShowDeveloperMenu);
		debugConfig->Set("SkipDeadbeefFilling", bSkipDeadbeefFilling);

		IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks");
		speedhacks->Set("PrescaleUV", bPrescaleUV);
		speedhacks->Set("DisableAlphaTest", bDisableAlphaTest);

		// Save upgrade check state
		IniFile::Section *upgrade = iniFile.GetOrCreateSection("Upgrade");
		upgrade->Set("UpgradeMessage", upgradeMessage);
		upgrade->Set("UpgradeVersion", upgradeVersion);
		upgrade->Set("DismissedVersion", dismissedVersion);

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());


		IniFile controllerIniFile;
		if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
		}
		KeyMap::SaveToIni(controllerIniFile);
		if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());

	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
}
Esempio n. 4
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	iniFilename_ = FindConfigFile(iniFileName != NULL ? iniFileName : "ppsspp.ini");
	controllerIniFilename_ = FindConfigFile(controllerIniFilename != NULL ? controllerIniFilename : "controls.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	IniFile::Section *general = iniFile.GetOrCreateSection("General");

	general->Get("FirstRun", &bFirstRun, true);
	general->Get("RunCount", &iRunCount, 0);
	iRunCount++;
	general->Get("Enable Logging", &bEnableLogging, true);
	general->Get("AutoRun", &bAutoRun, true);
	general->Get("Browse", &bBrowse, false);
	general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
	general->Get("CurrentDirectory", &currentDirectory, "");
	general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
	general->Get("HomebrewStore", &bHomebrewStore, false);

	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	std::string defaultLangRegion = "en_US";
	if (bFirstRun) {
		std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
		if (i18nrepo.IniExists(langRegion))
			defaultLangRegion = langRegion;
		// TODO: Be smart about same language, different country
	}

	general->Get("Language", &sLanguageIni, defaultLangRegion.c_str());
	general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
	general->Get("EnableAutoLoad", &bEnableAutoLoad, false);
	general->Get("EnableCheats", &bEnableCheats, false);
	general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
	general->Get("StateSlot", &iCurrentStateSlot, 0);
	general->Get("RewindFlipFrequency", &iRewindFlipFrequency, 0);
	general->Get("GridView1", &bGridView1, true);
	general->Get("GridView2", &bGridView2, true);
	general->Get("GridView3", &bGridView3, false);

	// "default" means let emulator decide, "" means disable.
	general->Get("ReportingHost", &sReportHost, "default");
	general->Get("Recent", recentIsos);
	general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);
#ifdef _WIN32
	general->Get("TopMost", &bTopMost);
	general->Get("WindowX", &iWindowX, -1); // -1 tells us to center the window.
	general->Get("WindowY", &iWindowY, -1);
	general->Get("WindowWidth", &iWindowWidth, 0);   // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
	general->Get("WindowHeight", &iWindowHeight, 0);
	general->Get("PauseOnLostFocus", &bPauseOnLostFocus, false);
#endif

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	recentIsos.clear();
	for (int i = 0; i < iMaxRecent; i++)
	{
		char keyName[64];
		std::string fileName;

		sprintf(keyName,"FileName%d",i);
		if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) {
			// just skip it to get the next key
		}
		else {
			recentIsos.push_back(fileName);
		}
	}

	IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
#ifdef IOS
	cpu->Get("Jit", &bJit, iosCanUseJit);
#else
	cpu->Get("Jit", &bJit, true);
#endif
	cpu->Get("SeparateCPUThread", &bSeparateCPUThread, false);
	cpu->Get("AtomicAudioLocks", &bAtomicAudioLocks, false);

	cpu->Get("SeparateIOThread", &bSeparateIOThread, true);
	cpu->Get("FastMemoryAccess", &bFastMemory, true);
	cpu->Get("CPUSpeed", &iLockedCPUSpeed, 0);

	IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
	graphics->Get("ShowFPSCounter", &iShowFPSCounter, false);

	int renderingModeDefault = 1;  // Buffered
	if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
		renderingModeDefault = 0;  // Non-buffered
	}

	graphics->Get("RenderingMode", &iRenderingMode, renderingModeDefault);
	graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
	graphics->Get("HardwareTransform", &bHardwareTransform, true);
	graphics->Get("SoftwareSkinning", &bSoftwareSkinning, true);
	graphics->Get("TextureFiltering", &iTexFiltering, 1);
	// Auto on Windows, 2x on large screens, 1x elsewhere.
#if defined(_WIN32) && !defined(USING_QT_UI)
	graphics->Get("InternalResolution", &iInternalResolution, 0);
#else
	graphics->Get("InternalResolution", &iInternalResolution, pixel_xres >= 1024 ? 2 : 1);
#endif

	graphics->Get("FrameSkip", &iFrameSkip, 0);
	graphics->Get("FrameRate", &iFpsLimit, 0);
#ifdef _WIN32
	graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, false);
#else
	graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, true);
#endif
	graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 60);
#ifdef USING_GLES2
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
#endif
	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}
	graphics->Get("VertexCache", &bVertexCache, true);
#ifdef IOS
	graphics->Get("VertexDecJit", &bVertexDecoderJit, iosCanUseJit);
#else
	graphics->Get("VertexDecJit", &bVertexDecoderJit, true);
#endif

#ifdef _WIN32
	graphics->Get("FullScreen", &bFullScreen, false);
#endif
	bool partialStretchDefault = false;
#ifdef BLACKBERRY
	partialStretchDefault = pixel_xres < 1.3 * pixel_yres;
#endif
	graphics->Get("PartialStretch", &bPartialStretch, partialStretchDefault);
	graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
	graphics->Get("TrueColor", &bTrueColor, true);

	graphics->Get("MipMap", &bMipMap, false);

	graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
	graphics->Get("TexScalingType", &iTexScalingType, 0);
	graphics->Get("TexDeposterize", &bTexDeposterize, false);
	graphics->Get("VSyncInterval", &bVSync, false);
	graphics->Get("DisableStencilTest", &bDisableStencilTest, false);
	graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false);
// Has been in use on Symbian since v0.7. Preferred option.
#ifdef __SYMBIAN32__
	graphics->Get("TimerHack", &bTimerHack, true);
#else
	graphics->Get("TimerHack", &bTimerHack, false);
#endif
	graphics->Get("LowQualitySplineBezier", &bLowQualitySplineBezier, false);
	graphics->Get("PostShader", &sPostShaderName, "Off");

	IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
	sound->Get("Enable", &bEnableSound, true);
	sound->Get("VolumeBGM", &iBGMVolume, 7);
	sound->Get("VolumeSFX", &iSFXVolume, 7);
	sound->Get("LowLatency", &bLowLatencyAudio, false);

	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	control->Get("HapticFeedback", &bHapticFeedback, true);
	control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
	control->Get("ShowTouchCross", &bShowTouchCross, true);
	control->Get("ShowTouchCircle", &bShowTouchCircle, true);
	control->Get("ShowTouchSquare", &bShowTouchSquare, true);
	control->Get("ShowTouchTriangle", &bShowTouchTriangle, true);
	control->Get("ShowTouchStart", &bShowTouchStart, true);
	control->Get("ShowTouchSelect", &bShowTouchSelect, true);
	control->Get("ShowTouchLTrigger", &bShowTouchLTrigger, true);
	control->Get("ShowTouchRTrigger", &bShowTouchRTrigger, true);
	control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
	control->Get("ShowTouchDpad", &bShowTouchDpad, true);
	control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle, true);

#if defined(USING_GLES2)
	std::string name = System_GetProperty(SYSPROP_NAME);
	if (KeyMap::HasBuiltinController(name)) {
		control->Get("ShowTouchControls", &bShowTouchControls, false);
	} else {
		control->Get("ShowTouchControls", &bShowTouchControls, true);
	}
#else
	control->Get("ShowTouchControls", &bShowTouchControls, false);
#endif
	// control->Get("KeyMapping",iMappingMap);
#ifdef USING_GLES2
	control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);

	control->Get("TiltBaseX", &fTiltBaseX, 0);
	control->Get("TiltBaseY", &fTiltBaseY, 0);
	control->Get("InvertTiltX", &bInvertTiltX, false);
	control->Get("InvertTiltY", &bInvertTiltY, true);
	control->Get("TiltSensitivityX", &iTiltSensitivityX, 100);
	control->Get("TiltSensitivityY", &iTiltSensitivityY, 100);
	control->Get("DeadzoneRadius", &fDeadzoneRadius, 0.35);

#endif
	control->Get("DisableDpadDiagonals", &bDisableDpadDiagonals, false);
	control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
	//set these to -1 if not initialized. initializing these
	//requires pixel coordinates which is not known right now.
	//will be initialized in GamepadEmu::CreatePadLayout
	float defaultScale = 1.15f;
	control->Get("ActionButtonSpacing2", &fActionButtonSpacing, 1.0f);
	control->Get("ActionButtonCenterX", &fActionButtonCenterX, -1.0);
	control->Get("ActionButtonCenterY", &fActionButtonCenterY, -1.0);
	control->Get("ActionButtonScale", &fActionButtonScale, defaultScale);
	control->Get("DPadX", &fDpadX, -1.0);
	control->Get("DPadY", &fDpadY, -1.0);
	control->Get("DPadScale", &fDpadScale, defaultScale);
	control->Get("DPadSpacing", &fDpadSpacing, 1.0f);
	control->Get("StartKeyX", &fStartKeyX, -1.0);
	control->Get("StartKeyY", &fStartKeyY, -1.0);
	control->Get("StartKeyScale", &fStartKeyScale, defaultScale);
	control->Get("SelectKeyX", &fSelectKeyX, -1.0);
	control->Get("SelectKeyY", &fSelectKeyY, -1.0);
	control->Get("SelectKeyScale", &fSelectKeyScale, defaultScale);
	control->Get("UnthrottleKeyX", &fUnthrottleKeyX, -1.0);
	control->Get("UnthrottleKeyY", &fUnthrottleKeyY, -1.0);
	control->Get("UnthrottleKeyScale", &fUnthrottleKeyScale, defaultScale);
	control->Get("LKeyX", &fLKeyX, -1.0);
	control->Get("LKeyY", &fLKeyY, -1.0);
	control->Get("LKeyScale", &fLKeyScale, defaultScale);
	control->Get("RKeyX", &fRKeyX, -1.0);
	control->Get("RKeyY", &fRKeyY, -1.0);
	control->Get("RKeyScale", &fRKeyScale, defaultScale);
	control->Get("AnalogStickX", &fAnalogStickX, -1.0);
	control->Get("AnalogStickY", &fAnalogStickY, -1.0);
	control->Get("AnalogStickScale", &fAnalogStickScale, defaultScale);

	// MIGRATION: For users who had the old static touch layout, aren't I nice?
	if (fDpadX > 1.0 || fDpadY > 1.0) // Likely the rest are too!
	{
		fActionButtonCenterX /= dp_xres;
		fActionButtonCenterY /= dp_yres;
		fDpadX /= dp_xres;
		fDpadY /= dp_yres;
		fStartKeyX /= dp_xres;
		fStartKeyY /= dp_yres;
		fSelectKeyX /= dp_xres;
		fSelectKeyY /= dp_yres;
		fUnthrottleKeyX /= dp_xres;
		fUnthrottleKeyY /= dp_yres;
		fLKeyX /= dp_xres;
		fLKeyY /= dp_yres;
		fRKeyX /= dp_xres;
		fRKeyY /= dp_yres;
		fAnalogStickX /= dp_xres;
		fAnalogStickY /= dp_yres;
	}

	IniFile::Section *network = iniFile.GetOrCreateSection("Network");
	network->Get("EnableWlan", &bEnableWlan, false);
	
	IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
#ifndef ANDROID
	pspConfig->Get("PSPModel", &iPSPModel, PSP_MODEL_SLIM);
#else
	pspConfig->Get("PSPModel", &iPSPModel, PSP_MODEL_FAT);
#endif
	pspConfig->Get("NickName", &sNickName, "PPSSPP");
	pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost");
	pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06");
	pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
	pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
	pspConfig->Get("TimeZone", &iTimeZone, 0);
	pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
	pspConfig->Get("ButtonPreference", &iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
	pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
	pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
#ifdef _WIN32
	pspConfig->Get("BypassOSKWithKeyboard", &bBypassOSKWithKeyboard, false);
#endif
	pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
	pspConfig->Get("EncryptSave", &bEncryptSave, true);

	IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
	debugConfig->Get("DisasmWindowX", &iDisasmWindowX, -1);
	debugConfig->Get("DisasmWindowY", &iDisasmWindowY, -1);
	debugConfig->Get("DisasmWindowW", &iDisasmWindowW, -1);
	debugConfig->Get("DisasmWindowH", &iDisasmWindowH, -1);
	debugConfig->Get("GEWindowX", &iGEWindowX, -1);
	debugConfig->Get("GEWindowY", &iGEWindowY, -1);
	debugConfig->Get("GEWindowW", &iGEWindowW, -1);
	debugConfig->Get("GEWindowH", &iGEWindowH, -1);
	debugConfig->Get("ConsoleWindowX", &iConsoleWindowX, -1);
	debugConfig->Get("ConsoleWindowY", &iConsoleWindowY, -1);
	debugConfig->Get("FontWidth", &iFontWidth, 8);
	debugConfig->Get("FontHeight", &iFontHeight, 12);
	debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true);
	debugConfig->Get("ShowBottomTabTitles",&bShowBottomTabTitles,true);
	debugConfig->Get("ShowDeveloperMenu", &bShowDeveloperMenu, false);
	debugConfig->Get("SkipDeadbeefFilling", &bSkipDeadbeefFilling, false);

	IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks");
	speedhacks->Get("PrescaleUV", &bPrescaleUV, false);
	speedhacks->Get("DisableAlphaTest", &bDisableAlphaTest, false);

	IniFile::Section *jitConfig = iniFile.GetOrCreateSection("JIT");
	jitConfig->Get("DiscardRegsOnJRRA", &bDiscardRegsOnJRRA, false);

	IniFile::Section *upgrade = iniFile.GetOrCreateSection("Upgrade");
	upgrade->Get("UpgradeMessage", &upgradeMessage, "");
	upgrade->Get("UpgradeVersion", &upgradeVersion, "");
	upgrade->Get("DismissedVersion", &dismissedVersion, "");
	
	if (dismissedVersion == upgradeVersion) {
		upgradeMessage = "";
	}

	// Check for new version on every 5 runs.
	// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
	// splash screen quickly), but then we'll just show the notification next time instead, we store the
	// upgrade number in the ini.
	if (iRunCount % 5 == 0) {
		g_DownloadManager.StartDownloadWithCallback(
			"http://www.ppsspp.org/version.json", "", &DownloadCompletedCallback);
	}

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}

	CleanRecent();
}
Esempio n. 5
0
void Config::Save() {
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		IniFile::Section *general = iniFile.GetOrCreateSection("General");
		
		// Need to do this somewhere...
		bFirstRun = false;
		general->Set("FirstRun", bFirstRun);
		general->Set("Enable Logging", bEnableLogging);
		general->Set("AutoRun", bAutoRun);
		general->Set("Browse", bBrowse);
		general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
		general->Set("CurrentDirectory", currentDirectory);
		general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
		general->Set("ReportingHost", sReportHost);
		general->Set("Recent", recentIsos);
		general->Set("AutoSaveSymbolMap", bAutoSaveSymbolMap);
#ifdef _WIN32
		general->Set("TopMost", bTopMost);
		general->Set("WindowX", iWindowX);
		general->Set("WindowY", iWindowY);
#endif
		general->Set("Language", languageIni);
		general->Set("NumWorkerThreads", iNumWorkerThreads);
		general->Set("EnableCheats", bEnableCheats);
		general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG);
		general->Set("StateSlot", iCurrentStateSlot);
		general->Set("GridView1", bGridView1);
		general->Set("GridView2", bGridView2);
		general->Set("GridView3", bGridView3);

		IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
		cpu->Set("Jit", bJit);
		cpu->Set("SeparateCPUThread", bSeparateCPUThread);
		cpu->Set("SeparateIOThread", bSeparateIOThread);
		cpu->Set("FastMemory", bFastMemory);
		cpu->Set("CPUSpeed", iLockedCPUSpeed);

		IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
		graphics->Set("ShowFPSCounter", iShowFPSCounter);
		graphics->Set("ResolutionScale", iWindowZoom);
		graphics->Set("RenderingMode", iRenderingMode);
		graphics->Set("SoftwareRendering", bSoftwareRendering);
		graphics->Set("HardwareTransform", bHardwareTransform);
		graphics->Set("TextureFiltering", iTexFiltering);
		graphics->Set("SSAA", bAntiAliasing);
		graphics->Set("FrameSkip", iFrameSkip);
		graphics->Set("FrameRate", iFpsLimit);
		graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS);
		graphics->Set("AnisotropyLevel", iAnisotropyLevel);
		graphics->Set("VertexCache", bVertexCache);
#ifdef _WIN32
		graphics->Set("FullScreen", bFullScreen);
		graphics->Set("FullScreenOnLaunch", bFullScreenOnLaunch);
#endif		
#ifdef BLACKBERRY
		graphics->Set("PartialStretch", bPartialStretch);
#endif
		graphics->Set("StretchToDisplay", bStretchToDisplay);
		graphics->Set("TrueColor", bTrueColor);
		graphics->Set("MipMap", bMipMap);
		graphics->Set("TexScalingLevel", iTexScalingLevel);
		graphics->Set("TexScalingType", iTexScalingType);
		graphics->Set("TexDeposterize", bTexDeposterize);
		graphics->Set("VSyncInterval", bVSync);

		IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
		sound->Set("Enable", bEnableSound);
		sound->Set("EnableAtrac3plus", bEnableAtrac3plus);
		sound->Set("VolumeBGM", iBGMVolume);
		sound->Set("VolumeSFX", iSFXVolume);
		sound->Set("LowLatency", bLowLatencyAudio);

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Set("ShowAnalogStick", bShowAnalogStick);
		control->Set("ShowTouchControls", bShowTouchControls);
		// control->Set("KeyMapping",iMappingMap);
		control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz);
		control->Set("TouchButtonOpacity", iTouchButtonOpacity);
		control->Set("ButtonScale", fButtonScale);

		IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
		pspConfig->Set("NickName", sNickName.c_str());
		pspConfig->Set("Language", ilanguage);
		pspConfig->Set("TimeFormat", iTimeFormat);
		pspConfig->Set("DateFormat", iDateFormat);
		pspConfig->Set("TimeZone", iTimeZone);
		pspConfig->Set("DayLightSavings", bDayLightSavings);
		pspConfig->Set("ButtonPreference", iButtonPreference);
		pspConfig->Set("LockParentalLevel", iLockParentalLevel);
		pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel);
		pspConfig->Set("WlanPowerSave", bWlanPowerSave);
		pspConfig->Set("EncryptSave", bEncryptSave);
#ifdef _WIN32
		pspConfig->Set("BypassOSKWithKeyboard", bBypassOSKWithKeyboard);
#endif

		IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
		debugConfig->Set("DisasmWindowX", iDisasmWindowX);
		debugConfig->Set("DisasmWindowY", iDisasmWindowY);
		debugConfig->Set("DisasmWindowW", iDisasmWindowW);
		debugConfig->Set("DisasmWindowH", iDisasmWindowH);
		debugConfig->Set("ConsoleWindowX", iConsoleWindowX);
		debugConfig->Set("ConsoleWindowY", iConsoleWindowY);
		debugConfig->Set("FontWidth", iFontWidth);
		debugConfig->Set("FontHeight", iFontHeight);
		debugConfig->Set("DisplayStatusBar", bDisplayStatusBar);
		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());


		IniFile controllerIniFile;
		if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
		}
		KeyMap::SaveToIni(controllerIniFile);
		if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());

	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
}
Esempio n. 6
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename)
{
	iniFilename_ = iniFileName;
	controllerIniFilename_ = controllerIniFilename;
	INFO_LOG(LOADER, "Loading config: %s", iniFileName);
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFileName)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFileName);
		// Continue anyway to initialize the config.
	}

	IniFile::Section *general = iniFile.GetOrCreateSection("General");

	general->Get("FirstRun", &bFirstRun, true);
	general->Get("Enable Logging", &bEnableLogging, true);
	general->Get("AutoRun", &bAutoRun, true);
	general->Get("Browse", &bBrowse, false);
	general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
	general->Get("CurrentDirectory", &currentDirectory, "");
	general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
	general->Get("Language", &languageIni, "en_US");
	general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
	general->Get("EnableCheats", &bEnableCheats, false);
	general->Get("MaxRecent", &iMaxRecent, 30);
	general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
	general->Get("StateSlot", &iCurrentStateSlot, 0);
	general->Get("GridView1", &bGridView1, true);
	general->Get("GridView2", &bGridView2, true);
	general->Get("GridView3", &bGridView3, true);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	// "default" means let emulator decide, "" means disable.
	general->Get("ReportingHost", &sReportHost, "default");
	general->Get("Recent", recentIsos);
	general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);
#ifdef _WIN32
	general->Get("TopMost", &bTopMost);
	general->Get("WindowX", &iWindowX, 40);
	general->Get("WindowY", &iWindowY, 100);
#endif

	if ((int)recentIsos.size() > iMaxRecent)
		recentIsos.resize(iMaxRecent);

	IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
#ifdef IOS
	cpu->Get("Jit", &bJit, !isJailed);
#else
	cpu->Get("Jit", &bJit, true);
#endif
	cpu->Get("SeparateCPUThread", &bSeparateCPUThread, false);
#ifdef __SYMBIAN32__
	cpu->Get("SeparateIOThread", &bSeparateIOThread, false);
#else
	cpu->Get("SeparateIOThread", &bSeparateIOThread, true);
#endif
	cpu->Get("FastMemory", &bFastMemory, false);
	cpu->Get("CPUSpeed", &iLockedCPUSpeed, 0);

	IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
	graphics->Get("ShowFPSCounter", &iShowFPSCounter, false);
#ifdef _WIN32
	graphics->Get("ResolutionScale", &iWindowZoom, 2);
#else
	graphics->Get("ResolutionScale", &iWindowZoom, 1);
#endif
	graphics->Get("RenderingMode", &iRenderingMode, 
		// Many ARMv6 devices have serious problems with buffered rendering.
#if defined(ARM) && !defined(ARMV7)
		0
#else
		1
#endif
		); // default is buffered rendering mode
	graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
	graphics->Get("HardwareTransform", &bHardwareTransform, true);
	graphics->Get("TextureFiltering", &iTexFiltering, 1);
	graphics->Get("SSAA", &bAntiAliasing, 0);
	graphics->Get("FrameSkip", &iFrameSkip, 0);
	graphics->Get("FrameRate", &iFpsLimit, 0);
	graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 60);
#ifdef USING_GLES2
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
#endif
	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}
	graphics->Get("VertexCache", &bVertexCache, true);
#ifdef _WIN32
	graphics->Get("FullScreen", &bFullScreen, false);
	graphics->Get("FullScreenOnLaunch", &bFullScreenOnLaunch, false);
#endif
#ifdef BLACKBERRY
	graphics->Get("PartialStretch", &bPartialStretch, pixel_xres == pixel_yres);
#endif
	graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
	graphics->Get("TrueColor", &bTrueColor, true);
	graphics->Get("MipMap", &bMipMap, true);
	graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
	graphics->Get("TexScalingType", &iTexScalingType, 0);
	graphics->Get("TexDeposterize", &bTexDeposterize, false);
	graphics->Get("VSyncInterval", &bVSync, false);

	IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
	sound->Get("Enable", &bEnableSound, true);
	sound->Get("EnableAtrac3plus", &bEnableAtrac3plus, true);
	sound->Get("VolumeBGM", &iBGMVolume, 7);
	sound->Get("VolumeSFX", &iSFXVolume, 7);
	sound->Get("LowLatency", &bLowLatencyAudio, false);

	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	control->Get("ShowAnalogStick", &bShowAnalogStick, true);
#ifdef BLACKBERRY
	control->Get("ShowTouchControls", &bShowTouchControls, pixel_xres != pixel_yres);
#elif defined(USING_GLES2)
	std::string name = System_GetName();
	if (name == "NVIDIA:SHIELD" || name == "Sony Ericsson:R800i" || name == "Sony Ericsson:zeus") {
		control->Get("ShowTouchControls", &bShowTouchControls, false);
	} else {
		control->Get("ShowTouchControls", &bShowTouchControls, true);
	}
#else
	control->Get("ShowTouchControls", &bShowTouchControls, false);
#endif
	// control->Get("KeyMapping",iMappingMap);
	control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
	control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
	control->Get("ButtonScale", &fButtonScale, 1.15);

	IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
	pspConfig->Get("NickName", &sNickName, "PPSSPP");
	pspConfig->Get("Language", &ilanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
	pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
	pspConfig->Get("TimeZone", &iTimeZone, 0);
	pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
	pspConfig->Get("ButtonPreference", &iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
	pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
	pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
#ifdef _WIN32
	pspConfig->Get("BypassOSKWithKeyboard", &bBypassOSKWithKeyboard, false);
#endif
	pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
	pspConfig->Get("EncryptSave", &bEncryptSave, true);

	IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
	debugConfig->Get("DisasmWindowX", &iDisasmWindowX, -1);
	debugConfig->Get("DisasmWindowY", &iDisasmWindowY, -1);
	debugConfig->Get("DisasmWindowW", &iDisasmWindowW, -1);
	debugConfig->Get("DisasmWindowH", &iDisasmWindowH, -1);
	debugConfig->Get("ConsoleWindowX", &iConsoleWindowX, -1);
	debugConfig->Get("ConsoleWindowY", &iConsoleWindowY, -1);
	debugConfig->Get("FontWidth", &iFontWidth, 8);
	debugConfig->Get("FontHeight", &iFontHeight, 12);
	debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true);

	IniFile::Section *gleshacks = iniFile.GetOrCreateSection("GLESHacks");
	gleshacks->Get("PrescaleUV", &bPrescaleUV, false);

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename);
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename);
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}

	CleanRecent();
}
Esempio n. 7
0
void Config::Load(const char *iniFileName)
{
	iniFilename_ = iniFileName;
	INFO_LOG(LOADER, "Loading config: %s", iniFileName);
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFileName)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFileName);
		// Continue anyway to initialize the config.
	}

	IniFile::Section *general = iniFile.GetOrCreateSection("General");

	bSpeedLimit = false;
	general->Get("FirstRun", &bFirstRun, true);
	general->Get("AutoLoadLast", &bAutoLoadLast, false);
	general->Get("AutoRun", &bAutoRun, true);
	general->Get("Browse", &bBrowse, false);
	general->Get("ConfirmOnQuit", &bConfirmOnQuit, false);
	general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
	general->Get("CurrentDirectory", &currentDirectory, "");
	general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
	general->Get("Language", &languageIni, "en_US");
	general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
	general->Get("EnableCheats", &bEnableCheats, false);
	general->Get("MaxRecent", &iMaxRecent, 12);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	if (iMaxRecent == 0)
		iMaxRecent = 12;

	// "default" means let emulator decide, "" means disable.
	general->Get("ReportHost", &sReportHost, "default");
	general->Get("Recent", recentIsos);
	general->Get("WindowX", &iWindowX, 40);
	general->Get("WindowY", &iWindowY, 100);
	general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);
#ifdef _WIN32
	general->Get("TopMost", &bTopMost);
#endif

	if (recentIsos.size() > iMaxRecent)
		recentIsos.resize(iMaxRecent);

	IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
#ifdef IOS
	cpu->Get("Jit", &bJit, !isJailed);
#else
	cpu->Get("Jit", &bJit, true);
#endif
	//FastMemory Default set back to True when solve UNIMPL _sceAtracGetContextAddress making game crash
	cpu->Get("FastMemory", &bFastMemory, false);

	IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
	graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
	graphics->Get("DisplayFramebuffer", &bDisplayFramebuffer, false);
#ifdef _WIN32
	graphics->Get("ResolutionScale", &iWindowZoom, 2);
#else
	graphics->Get("ResolutionScale", &iWindowZoom, 1);
#endif
	graphics->Get("BufferedRendering", &bBufferedRendering, true);
	graphics->Get("HardwareTransform", &bHardwareTransform, true);
	graphics->Get("LinearFiltering", &bLinearFiltering, false);
	graphics->Get("SSAA", &SSAntiAliasing, 0);
	graphics->Get("VBO", &bUseVBO, false);
	graphics->Get("FrameSkip", &iFrameSkip, 0);
	graphics->Get("FrameRate", &iFpsLimit, 60);
#ifdef USING_GLES2
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
#endif
	graphics->Get("VertexCache", &bVertexCache, true);
	graphics->Get("FullScreen", &bFullScreen, false);
#ifdef BLACKBERRY10
	graphics->Get("PartialStretch", &bPartialStretch, pixel_xres == pixel_yres);
#endif
	graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
	graphics->Get("TrueColor", &bTrueColor, true);
	graphics->Get("MipMap", &bMipMap, true);
	graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
	graphics->Get("TexScalingType", &iTexScalingType, 0);
	graphics->Get("TexDeposterize", &bTexDeposterize, false);
	graphics->Get("VSyncInterval", &iVSyncInterval, 0);

	IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
	sound->Get("Enable", &bEnableSound, true);
	sound->Get("EnableAtrac3plus", &bEnableAtrac3plus, true);
	
	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	control->Get("ShowStick", &bShowAnalogStick, false);
#ifdef BLACKBERRY10
	control->Get("ShowTouchControls", &bShowTouchControls, pixel_xres != pixel_yres);
#elif defined(USING_GLES2)
	control->Get("ShowTouchControls", &bShowTouchControls, true);
#else
	control->Get("ShowTouchControls", &bShowTouchControls,false);
#endif
	control->Get("LargeControls", &bLargeControls, false);
	control->Get("KeyMapping",iMappingMap);
	control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
	control->Get("ForceInputDevice", &iForceInputDevice, -1);
	control->Get("RightStickBind", &iRightStickBind, 0);
	control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
	control->Get("ButtonScale", &fButtonScale, 1.15);

	IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
	pspConfig->Get("NickName", &sNickName, "shadow");
	pspConfig->Get("Language", &ilanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
	pspConfig->Get("TimeFormat", &itimeformat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
	pspConfig->Get("TimeZone", &iTimeZone, 0);
	pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
	pspConfig->Get("ButtonPreference", &bButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
	pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
	pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
	pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
	pspConfig->Get("EncryptSave", &bEncryptSave, true);

	CleanRecent();
}
Esempio n. 8
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	iniFilename_ = FindConfigFile(iniFileName != NULL ? iniFileName : "ppsspp.ini");
	controllerIniFilename_ = FindConfigFile(controllerIniFilename != NULL ? controllerIniFilename : "controls.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
		IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
		for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
			setting->Get(section);
		}
	}

	iRunCount++;
	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	recentIsos.clear();
	for (int i = 0; i < iMaxRecent; i++) {
		char keyName[64];
		std::string fileName;

		sprintf(keyName, "FileName%d", i);
		if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
			recentIsos.push_back(fileName);
		}
	}

	auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
	vPinnedPaths.clear();
	for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
		vPinnedPaths.push_back(it->second);
	}

	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}

	// Check for an old dpad setting
	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	float f;
	control->Get("DPadRadius", &f, 0.0f);
	if (f > 0.0f) {
		ResetControlLayout();
	}

	// MIGRATION: For users who had the old static touch layout, aren't I nice?
	// We can probably kill this in 0.9.8 or something.
	if (fDpadX > 1.0 || fDpadY > 1.0) { // Likely the rest are too!
		float screen_width = dp_xres;
		float screen_height = dp_yres;

		fActionButtonCenterX /= screen_width;
		fActionButtonCenterY /= screen_height;
		fDpadX /= screen_width;
		fDpadY /= screen_height;
		fStartKeyX /= screen_width;
		fStartKeyY /= screen_height;
		fSelectKeyX /= screen_width;
		fSelectKeyY /= screen_height;
		fUnthrottleKeyX /= screen_width;
		fUnthrottleKeyY /= screen_height;
		fLKeyX /= screen_width;
		fLKeyY /= screen_height;
		fRKeyX /= screen_width;
		fRKeyY /= screen_height;
		fAnalogStickX /= screen_width;
		fAnalogStickY /= screen_height;
	}
	
	if (dismissedVersion == upgradeVersion) {
		upgradeMessage = "";
	}

	// Check for new version on every 10 runs.
	// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
	// splash screen quickly), but then we'll just show the notification next time instead, we store the
	// upgrade number in the ini.
	if (iRunCount % 10 == 0 && bCheckForNewVersion) {
		std::shared_ptr<http::Download> dl = g_DownloadManager.StartDownloadWithCallback(
			"http://www.ppsspp.org/version.json", "", &DownloadCompletedCallback);
		dl->SetHidden(true);
	}

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}

	CleanRecent();
}
Esempio n. 9
0
void Config::Save()
{
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		IniFile::Section *general = iniFile.GetOrCreateSection("General");
		
		// Need to do this somewhere...
		bFirstRun = false;
		general->Set("FirstRun", bFirstRun);

		general->Set("AutoLoadLast", bAutoLoadLast);
		general->Set("AutoRun", bAutoRun);
		general->Set("Browse", bBrowse);
		general->Set("ConfirmOnQuit", bConfirmOnQuit);
		general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
		general->Set("CurrentDirectory", currentDirectory);
		general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
		general->Set("ReportHost", sReportHost);
		general->Set("Recent", recentIsos);
		general->Set("WindowX", iWindowX);
		general->Set("WindowY", iWindowY);
		general->Set("AutoSaveSymbolMap", bAutoSaveSymbolMap);
#ifdef _WIN32
		general->Set("TopMost", bTopMost);
#endif
		general->Set("Language", languageIni);
		general->Set("NumWorkerThreads", iNumWorkerThreads);
		general->Set("MaxRecent", iMaxRecent);
		general->Set("EnableCheats", bEnableCheats);

		IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
		cpu->Set("Jit", bJit);
		cpu->Set("FastMemory", bFastMemory);

		IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
		graphics->Set("ShowFPSCounter", bShowFPSCounter);
		graphics->Set("DisplayFramebuffer", bDisplayFramebuffer);
		graphics->Set("ResolutionScale", iWindowZoom);
		graphics->Set("BufferedRendering", bBufferedRendering);
		graphics->Set("HardwareTransform", bHardwareTransform);
		graphics->Set("LinearFiltering", bLinearFiltering);
		graphics->Set("SSAA", SSAntiAliasing);
		graphics->Set("VBO", bUseVBO);
		graphics->Set("FrameSkip", iFrameSkip);
		graphics->Set("FrameRate", iFpsLimit);
		graphics->Set("AnisotropyLevel", iAnisotropyLevel);
		graphics->Set("VertexCache", bVertexCache);
		graphics->Set("FullScreen", bFullScreen);
#ifdef BLACKBERRY10
		graphics->Set("PartialStretch", bPartialStretch);
#endif
		graphics->Set("StretchToDisplay", bStretchToDisplay);
		graphics->Set("TrueColor", bTrueColor);
		graphics->Set("MipMap", bMipMap);
		graphics->Set("TexScalingLevel", iTexScalingLevel);
		graphics->Set("TexScalingType", iTexScalingType);
		graphics->Set("TexDeposterize", bTexDeposterize);
		graphics->Set("VSyncInterval", iVSyncInterval);

		IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
		sound->Set("Enable", bEnableSound);
		sound->Set("EnableAtrac3plus", bEnableAtrac3plus);
		
		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Set("ShowStick", bShowAnalogStick);
		control->Set("ShowTouchControls", bShowTouchControls);
		control->Set("LargeControls", bLargeControls);
		control->Set("KeyMapping",iMappingMap);
		control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz);
		control->Set("ForceInputDevice", iForceInputDevice);
		control->Set("RightStickBind", iRightStickBind);
		control->Set("TouchButtonOpacity", iTouchButtonOpacity);
		control->Set("ButtonScale", fButtonScale);

		IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
		pspConfig->Set("NickName", sNickName.c_str());
		pspConfig->Set("Language", ilanguage);
		pspConfig->Set("TimeFormat", itimeformat);
		pspConfig->Set("DateFormat", iDateFormat);
		pspConfig->Set("TimeZone", iTimeZone);
		pspConfig->Set("DayLightSavings", bDayLightSavings);
		pspConfig->Set("ButtonPreference", bButtonPreference);
		pspConfig->Set("LockParentalLevel", iLockParentalLevel);
		pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel);
		pspConfig->Set("WlanPowerSave", bWlanPowerSave);
		pspConfig->Set("EncryptSave", bEncryptSave);

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());
	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
}
Esempio n. 10
0
void Config::Save() {
	if (jitForcedOff) {
		// if JIT has been forced off, we don't want to screw up the user's ppsspp.ini
		g_Config.bJit = true;
	}
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		
		saveGameConfig(gameId_);

		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		// Need to do this somewhere...
		bFirstRun = false;

		IterateSettings(iniFile, [&](IniFile::Section *section, ConfigSetting *setting) {
			if (!bGameSpecific || !setting->perGame_) {
				setting->Set(section);
			}
		});

		IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
		recent->Set("MaxRecent", iMaxRecent);

		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (i < (int)recentIsos.size()) {
				recent->Set(keyName, recentIsos[i]);
			} else {
				recent->Delete(keyName); // delete the nonexisting FileName
			}
		}

		IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
		pinnedPaths->Clear();
		for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
			pinnedPaths->Set(keyName, vPinnedPaths[i]);
		}

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Delete("DPadRadius");

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());

		if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
		{
			IniFile controllerIniFile;
			if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
			}
			KeyMap::SaveToIni(controllerIniFile);
			if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
				return;
			}
			INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
		}
	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
	if (jitForcedOff) {
		// force JIT off again just in case Config::Save() is called without exiting PPSSPP
		g_Config.bJit = false;
	}
}
Esempio n. 11
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0;
	iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	bShowFrameProfiler = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
		IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
		for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
			setting->Get(section);
		}
	}

	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	// -1 is okay, though. We'll just ignore recent stuff if it is.
	 if (iMaxRecent == 0)
		iMaxRecent = 30;

	 if (iMaxRecent > 0) {
		 recentIsos.clear();
		 for (int i = 0; i < iMaxRecent; i++) {
			 char keyName[64];
			 std::string fileName;

			 snprintf(keyName, sizeof(keyName), "FileName%d", i);
			 if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
				 recentIsos.push_back(fileName);
			 }
		 }
	 }

	auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
	vPinnedPaths.clear();
	for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
		vPinnedPaths.push_back(it->second);
	}

	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}

	// Check for an old dpad setting
	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	float f;
	control->Get("DPadRadius", &f, 0.0f);
	if (f > 0.0f) {
		ResetControlLayout();
	}

	const char *gitVer = PPSSPP_GIT_VERSION;
	Version installed(gitVer);
	Version upgrade(upgradeVersion);
	const bool versionsValid = installed.IsValid() && upgrade.IsValid();

	// Do this regardless of iRunCount to prevent a silly bug where one might use an older
	// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
	// even if said newer version is >= the upgrade found online.
	if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
		upgradeMessage = "";
	}

	bSaveSettings = true;

	//so this is all the way down here to overwrite the controller settings
	//sadly it won't benefit from all the "version conversion" going on up-above
	//but these configs shouldn't contain older versions anyhow
	if (bGameSpecific)
	{
		loadGameConfig(gameId_);
	}

	CleanRecent();

#if defined (_WIN32) && !defined (__LIBRETRO__)
	iTempGPUBackend = iGPUBackend;
#endif

	// Fix Wrong MAC address by old version by "Change MAC address"
	if (sMACAddress.length() != 17)
		sMACAddress = CreateRandMAC();

	if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
		g_Config.iRenderingMode = FB_BUFFERED_MODE;
	}
}
Esempio n. 12
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	iniFilename_ = FindConfigFile(iniFileName != NULL ? iniFileName : "ppsspp.ini");
	controllerIniFilename_ = FindConfigFile(controllerIniFilename != NULL ? controllerIniFilename : "controls.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	IniFile::Section *general = iniFile.GetOrCreateSection("General");

	general->Get("FirstRun", &bFirstRun, true);
	general->Get("Enable Logging", &bEnableLogging, true);
	general->Get("AutoRun", &bAutoRun, true);
	general->Get("Browse", &bBrowse, false);
	general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
	general->Get("CurrentDirectory", &currentDirectory, "");
	general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);

	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	std::string defaultLangRegion = "en_US";
	if (bFirstRun) {
		std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
		if (i18nrepo.IniExists(langRegion))
			defaultLangRegion = langRegion;
		// TODO: Be smart about same language, different country
	}

	general->Get("Language", &sLanguageIni, defaultLangRegion.c_str());
	general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
	general->Get("EnableCheats", &bEnableCheats, false);
	general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
	general->Get("StateSlot", &iCurrentStateSlot, 0);
	general->Get("GridView1", &bGridView1, true);
	general->Get("GridView2", &bGridView2, true);
	general->Get("GridView3", &bGridView3, true);

	// "default" means let emulator decide, "" means disable.
	general->Get("ReportingHost", &sReportHost, "default");
	general->Get("Recent", recentIsos);
	general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);
#ifdef _WIN32
	general->Get("TopMost", &bTopMost);
	general->Get("WindowX", &iWindowX, -1); // -1 tells us to center the window.
	general->Get("WindowY", &iWindowY, -1);
	general->Get("WindowWidth", &iWindowWidth, 0);   // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
	general->Get("WindowHeight", &iWindowHeight, 0);
	general->Get("PauseOnLostFocus", &bPauseOnLostFocus, false);
#endif

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	recentIsos.clear();
	for (int i = 0; i < iMaxRecent; i++)
	{
		char keyName[64];
		std::string fileName;

		sprintf(keyName,"FileName%d",i);
		if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) {
			// just skip it to get the next key
		}
		else {
			recentIsos.push_back(fileName);
		}
	}

	IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
#ifdef IOS
	cpu->Get("Jit", &bJit, !isJailed);
#else
	cpu->Get("Jit", &bJit, true);
#endif
	cpu->Get("SeparateCPUThread", &bSeparateCPUThread, false);
	cpu->Get("AtomicAudioLocks", &bAtomicAudioLocks, false);

#ifdef __SYMBIAN32__
	cpu->Get("SeparateIOThread", &bSeparateIOThread, false);
#else
	cpu->Get("SeparateIOThread", &bSeparateIOThread, true);
#endif
	cpu->Get("FastMemory", &bFastMemory, false);
	cpu->Get("CPUSpeed", &iLockedCPUSpeed, 0);

	IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
	graphics->Get("ShowFPSCounter", &iShowFPSCounter, false);

	int renderingModeDefault = 1;  // Buffered
	if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
		renderingModeDefault = 0;  // Non-buffered
	}

	graphics->Get("RenderingMode", &iRenderingMode, renderingModeDefault);
	graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
	graphics->Get("HardwareTransform", &bHardwareTransform, true);
	graphics->Get("TextureFiltering", &iTexFiltering, 1);
	// Auto on Windows, 1x elsewhere. Maybe change to 2x on large screens?
#ifdef _WIN32
	graphics->Get("InternalResolution", &iInternalResolution, 0);
#else
	graphics->Get("InternalResolution", &iInternalResolution, 1);
#endif

	graphics->Get("FrameSkip", &iFrameSkip, 0);
	graphics->Get("FrameRate", &iFpsLimit, 0);
#ifdef _WIN32
	graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, false);
#else
	graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, true);
#endif
	graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 60);
#ifdef USING_GLES2
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
#endif
	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}
	graphics->Get("VertexCache", &bVertexCache, true);
#ifdef _WIN32
	graphics->Get("FullScreen", &bFullScreen, false);
#endif
#ifdef BLACKBERRY
	graphics->Get("PartialStretch", &bPartialStretch, pixel_xres == pixel_yres);
#endif
	graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
	graphics->Get("TrueColor", &bTrueColor, true);
	graphics->Get("MipMap", &bMipMap, true);
	graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
	graphics->Get("TexScalingType", &iTexScalingType, 0);
	graphics->Get("TexDeposterize", &bTexDeposterize, false);
	graphics->Get("VSyncInterval", &bVSync, false);
	graphics->Get("DisableStencilTest", &bDisableStencilTest, false);
	graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false);
	graphics->Get("LowQualitySplineBezier", &bLowQualitySplineBezier, false);
	graphics->Get("PostShader", &sPostShaderName, "Off");

	IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
	sound->Get("Enable", &bEnableSound, true);
	sound->Get("VolumeBGM", &iBGMVolume, 7);
	sound->Get("VolumeSFX", &iSFXVolume, 7);
	sound->Get("LowLatency", &bLowLatencyAudio, false);

	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	control->Get("HapticFeedback", &bHapticFeedback, true);
	control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
	control->Get("ShowTouchCross", &bShowTouchCross, true);
	control->Get("ShowTouchCircle", &bShowTouchCircle, true);
	control->Get("ShowTouchSquare", &bShowTouchSquare, true);
	control->Get("ShowTouchTriangle", &bShowTouchTriangle, true);
	control->Get("ShowTouchStart", &bShowTouchStart, true);
	control->Get("ShowTouchSelect", &bShowTouchSelect, true);
	control->Get("ShowTouchLTrigger", &bShowTouchLTrigger, true);
	control->Get("ShowTouchRTrigger", &bShowTouchRTrigger, true);
	control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
	control->Get("ShowTouchDpad", &bShowTouchDpad, true);
	control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle, true);

#if defined(USING_GLES2)
	std::string name = System_GetProperty(SYSPROP_NAME);
	if (KeyMap::HasBuiltinController(name)) {
		control->Get("ShowTouchControls", &bShowTouchControls, false);
	} else {
		control->Get("ShowTouchControls", &bShowTouchControls, true);
	}
#else
	control->Get("ShowTouchControls", &bShowTouchControls, false);
#endif
	// control->Get("KeyMapping",iMappingMap);
#ifdef USING_GLES2
	control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
	control->Get("TiltSensitivity", &iTiltSensitivity, 100);
#endif
	control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
	control->Get("ButtonScale", &fButtonScale, 1.15);
	//set these to -1 if not initialized. initializing these
	//requires pixel coordinates which is not known right now.
	//will be initialized in GamepadEmu::CreatePadLayout
	control->Get("ActionButtonSpacing", &iActionButtonSpacing, -1);
	control->Get("ActionButtonCenterX", &iActionButtonCenterX, -1);
	control->Get("ActionButtonCenterY", &iActionButtonCenterY, -1);
	control->Get("DPadRadius", &iDpadRadius, -1);
	control->Get("DPadX", &iDpadX, -1);
	control->Get("DPadY", &iDpadY, -1);
	control->Get("StartKeyX", &iStartKeyX, -1);
	control->Get("StartKeyY", &iStartKeyY, -1);
	control->Get("SelectKeyX", &iSelectKeyX, -1);
	control->Get("SelectKeyY", &iSelectKeyY, -1);
	control->Get("UnthrottleKeyX", &iUnthrottleKeyX, -1);
	control->Get("UnthrottleKeyY", &iUnthrottleKeyY, -1);
	control->Get("LKeyX", &iLKeyX, -1);
	control->Get("LKeyY", &iLKeyY, -1);
	control->Get("RKeyX", &iRKeyX, -1);
	control->Get("RKeyY", &iRKeyY, -1);
	control->Get("AnalogStickX", &iAnalogStickX, -1);
	control->Get("AnalogStickY", &iAnalogStickY, -1);
	
	IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
	pspConfig->Get("NickName", &sNickName, "PPSSPP");
	pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
	pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
	pspConfig->Get("TimeZone", &iTimeZone, 0);
	pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
	pspConfig->Get("ButtonPreference", &iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
	pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
	pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
#ifdef _WIN32
	pspConfig->Get("BypassOSKWithKeyboard", &bBypassOSKWithKeyboard, false);
#endif
	pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
	pspConfig->Get("EncryptSave", &bEncryptSave, true);

	IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
	debugConfig->Get("DisasmWindowX", &iDisasmWindowX, -1);
	debugConfig->Get("DisasmWindowY", &iDisasmWindowY, -1);
	debugConfig->Get("DisasmWindowW", &iDisasmWindowW, -1);
	debugConfig->Get("DisasmWindowH", &iDisasmWindowH, -1);
	debugConfig->Get("GEWindowX", &iGEWindowX, -1);
	debugConfig->Get("GEWindowY", &iGEWindowY, -1);
	debugConfig->Get("GEWindowW", &iGEWindowW, -1);
	debugConfig->Get("GEWindowH", &iGEWindowH, -1);
	debugConfig->Get("ConsoleWindowX", &iConsoleWindowX, -1);
	debugConfig->Get("ConsoleWindowY", &iConsoleWindowY, -1);
	debugConfig->Get("FontWidth", &iFontWidth, 8);
	debugConfig->Get("FontHeight", &iFontHeight, 12);
	debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true);
	debugConfig->Get("ShowBottomTabTitles",&bShowBottomTabTitles,true);
	debugConfig->Get("ShowDeveloperMenu", &bShowDeveloperMenu, false);

	IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks");
	speedhacks->Get("PrescaleUV", &bPrescaleUV, false);
	speedhacks->Get("DisableAlphaTest", &bDisableAlphaTest, false);

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}

	CleanRecent();
}
Esempio n. 13
0
void Config::Load(const char *iniFileName)
{
	iniFilename_ = iniFileName;
	INFO_LOG(LOADER, "Loading config: %s", iniFileName);
	bSaveSettings = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFileName)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFileName);
		// Continue anyway to initialize the config.
	}

	IniFile::Section *general = iniFile.GetOrCreateSection("General");

	bSpeedLimit = false;
	general->Get("FirstRun", &bFirstRun, true);
	general->Get("AutoLoadLast", &bAutoLoadLast, false);
	general->Get("AutoRun", &bAutoRun, true);
	general->Get("Browse", &bBrowse, false);
	general->Get("ConfirmOnQuit", &bConfirmOnQuit, false);
	general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
	general->Get("CurrentDirectory", &currentDirectory, "");
	general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
	general->Get("Language", &languageIni, "en_US");

	// "default" means let emulator decide, "" means disable.
	general->Get("ReportHost", &sReportHost, "default");
	general->Get("Recent", recentIsos);
	general->Get("WindowX", &iWindowX, 40);
	general->Get("WindowY", &iWindowY, 100);
	general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);

	if (recentIsos.size() > MAX_RECENT)
		recentIsos.resize(MAX_RECENT);

	IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
	cpu->Get("Jit", &bJit, true);
	//FastMemory Default set back to True when solve UNIMPL _sceAtracGetContextAddress making game crash
	cpu->Get("FastMemory", &bFastMemory, false);

	IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
	graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
	graphics->Get("DisplayFramebuffer", &bDisplayFramebuffer, false);
#ifdef _WIN32
	graphics->Get("WindowZoom", &iWindowZoom, 2);
#else
	graphics->Get("WindowZoom", &iWindowZoom, 1);
#endif
	graphics->Get("BufferedRendering", &bBufferedRendering, true);
	graphics->Get("HardwareTransform", &bHardwareTransform, true);
	graphics->Get("LinearFiltering", &bLinearFiltering, false);
	graphics->Get("SSAA", &SSAntiAliasing, 0);
	graphics->Get("VBO", &bUseVBO, false);
	graphics->Get("FrameSkip", &iFrameSkip, 0);
	graphics->Get("UseMediaEngine", &bUseMediaEngine, true);
#ifdef USING_GLES2
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
	graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
#endif
	graphics->Get("VertexCache", &bVertexCache, true);
	graphics->Get("FullScreen", &bFullScreen, false);	
	graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
	graphics->Get("TrueColor", &bTrueColor, true);
#ifdef USING_GLES2
	graphics->Get("MipMap", &bMipMap, true);
#else
	graphics->Get("MipMap", &bMipMap, false);
#endif
	IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
	sound->Get("Enable", &bEnableSound, true);

	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	control->Get("ShowStick", &bShowAnalogStick, false);
#ifdef USING_GLES2
	control->Get("ShowTouchControls", &bShowTouchControls, true);
#else
	control->Get("ShowTouchControls", &bShowTouchControls,false);
#endif
	control->Get("LargeControls", &bLargeControls, false);
	control->Get("KeyMapping",iMappingMap);
	control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
	control->Get("ForceInputDevice", &iForceInputDevice, -1);

	IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
	pspConfig->Get("NickName", &sNickName, "shadow");
	pspConfig->Get("Language", &ilanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
	pspConfig->Get("TimeFormat", &itimeformat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
	pspConfig->Get("TimeZone", &iTimeZone, 0);
	pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
	pspConfig->Get("ButtonPreference", &bButtonPreference, PSP_SYSTEMPARAM_BUTTON_CIRCLE);
	pspConfig->Get("LockParentalLevel", &bLockParentalLevel, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
	pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
	pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
	pspConfig->Get("EncryptSave", &bEncryptSave, true);

	CleanRecent();
	// Ephemeral settings
	bDrawWireframe = false;
}