diff --git a/.gitignore b/.gitignore index e391987ab129..89dd7f9292b7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ assets/flash0 UWP/icph UWP/.vs .vs +.vscode # For Mac .DS_Store diff --git a/Core/Config.cpp b/Core/Config.cpp index fc2026c9bc4c..9ae911e268f3 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1109,7 +1109,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } } -void Config::Save() { +void Config::Save(const char *saveReason) { if (jitForcedOff) { // if JIT has been forced off, we don't want to screw up the user's ppsspp.ini g_Config.iCpuCore = (int)CPUCore::JIT; @@ -1162,11 +1162,11 @@ void Config::Save() { LogManager::GetInstance()->SaveConfig(log); if (!iniFile.Save(iniFilename_.c_str())) { - ERROR_LOG(LOADER, "Error saving config - can't write ini '%s'", iniFilename_.c_str()); + ERROR_LOG(LOADER, "Error saving config (%s)- can't write ini '%s'", saveReason, iniFilename_.c_str()); System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device."); return; } - INFO_LOG(LOADER, "Config saved: '%s'", iniFilename_.c_str()); + INFO_LOG(LOADER, "Config saved (%s): '%s'", saveReason, iniFilename_.c_str()); if (!bGameSpecific) //otherwise we already did this in saveGameConfig() { @@ -1353,7 +1353,7 @@ bool Config::hasGameConfig(const std::string &pGameId) { } void Config::changeGameSpecific(const std::string &pGameId) { - Save(); + Save("changeGameSpecific"); gameId_ = pGameId; bGameSpecific = !pGameId.empty(); } diff --git a/Core/Config.h b/Core/Config.h index ce8ad1458890..a45080ff0e74 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -410,7 +410,7 @@ struct Config { std::string dismissedVersion; void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr); - void Save(); + void Save(const char *saveReason); void RestoreDefaults(); //per game config managment, should maybe be in it's own class diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 32129d42ddf1..e6e311f0e0f1 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -119,6 +119,9 @@ void System_SendMessage(const char *command, const char *parameter) { QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFileEvent)); } else if (!strcmp(command, "browse_folder")) { QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFolderEvent)); + } else if (!strcmp(command, "graphics_restart")) { + // Should find a way to properly restart the app. + qApp->exit(0); } } @@ -402,7 +405,7 @@ bool MainUI::event(QEvent *e) { if (QFile::exists(fileName)) { QDir newPath; g_Config.currentDirectory = newPath.filePath(fileName).toStdString(); - g_Config.Save(); + g_Config.Save("browseFileEvent"); NativeMessageReceived("boot", fileName.toStdString().c_str()); } diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 3f07c9fb6a13..ae654d4a96bb 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -116,6 +116,9 @@ void System_SendMessage(const char *command, const char *parameter) { } else if (!strcmp(command, "finish")) { // Do a clean exit g_QuitRequested = true; + } else if (!strcmp(command, "graphics_restart")) { + // Not sure how we best do this, but do a clean exit, better than being stuck in a bad state. + g_QuitRequested = true; } } diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index a32d480f7637..7860a49710e7 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -44,7 +44,7 @@ void Combo_keyScreen::CreateViews() { static const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5, }; - + comboselect = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(10, 10, NONE, NONE)); comboselect->SetSpacing(10); for (int i = 0; i < 5; i++) { @@ -169,7 +169,7 @@ void Combo_keyScreen::onFinish(DialogResult result) { g_Config.iCombokey4 = arrayToInt(array); break; } - g_Config.Save(); + g_Config.Save("Combo_keyScreen::onFInish"); } UI::EventReturn Combo_keyScreen::ChoiceEventHandler::onChoiceClick(UI::EventParams &e){ diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 0612cad5409f..67cbca1775c3 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -431,8 +431,8 @@ class JoystickHistoryView : public UI::InertView { public: JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams), - xAxis_(xAxis), xDevice_(xDevice), xDir_(xDir), - yAxis_(yAxis), yDevice_(yDevice), yDir_(yDir), + xAxis_(xAxis), xDir_(xDir), + yAxis_(yAxis), yDir_(yDir), curX_(0.0f), curY_(0.0f), maxCount_(500) {} void Draw(UIContext &dc) override; @@ -455,10 +455,8 @@ class JoystickHistoryView : public UI::InertView { }; int xAxis_; - int xDevice_; int xDir_; int yAxis_; - int yDevice_; int yDir_; float curX_; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 0ba1901811f3..3f5f14ef1325 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -173,7 +173,7 @@ void DisplayLayoutScreen::resized() { } void DisplayLayoutScreen::onFinish(DialogResult reason) { - g_Config.Save(); + g_Config.Save("DisplayLayoutScreen::onFinish"); } UI::EventReturn DisplayLayoutScreen::OnCenter(UI::EventParams &e) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c04cc88602a5..cb1c80fdc107 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1065,7 +1065,7 @@ void GameSettingsScreen::onFinish(DialogResult result) { Reporting::Enable(enableReports_, "report.ppsspp.org"); Reporting::UpdateConfig(); - g_Config.Save(); + g_Config.Save("GameSettingsScreen::onFinish"); if (editThenRestore_) { g_Config.unloadGameConfig(); } @@ -1137,7 +1137,7 @@ void GameSettingsScreen::CallbackMemstickFolder(bool yes) { writeDataToFile(true, pendingMemstickFolder_.c_str(), pendingMemstickFolder_.size(), memstickDirFile.c_str()); // Save so the settings, at least, are transferred. g_Config.memStickDirectory = pendingMemstickFolder_ + "/"; - g_Config.Save(); + g_Config.Save("MemstickPathChanged"); screenManager()->RecreateAllViews(); } } @@ -1149,7 +1149,7 @@ void GameSettingsScreen::CallbackRenderingBackend(bool yes) { if (yes) { // Extra save here to make sure the choice really gets saved even if there are shutdown bugs in // the GPU backend code. - g_Config.Save(); + g_Config.Save("GameSettingsScreen::RenderingBackendYes"); System_SendMessage("graphics_restart", ""); } else { g_Config.iGPUBackend = (int)GetGPUBackend(); @@ -1162,7 +1162,7 @@ void GameSettingsScreen::CallbackRenderingDevice(bool yes) { if (yes) { // Extra save here to make sure the choice really gets saved even if there are shutdown bugs in // the GPU backend code. - g_Config.Save(); + g_Config.Save("GameSettingsScreen::RenderingDeviceYes"); System_SendMessage("graphics_restart", ""); } else { std::string *deviceNameSetting = GPUDeviceNameSetting(); @@ -1397,7 +1397,7 @@ void DeveloperToolsScreen::CreateViews() { } void DeveloperToolsScreen::onFinish(DialogResult result) { - g_Config.Save(); + g_Config.Save("DeveloperToolsScreen::onFinish"); } void GameSettingsScreen::CallbackRestoreDefaults(bool yes) { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 8f1fb0044de5..46b80d64be4b 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1199,7 +1199,7 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { System_SendMessage("finish", ""); // However, let's make sure the config was saved, since it may not have been. - g_Config.Save(); + g_Config.Save("MainScreen::OnExit"); #ifdef __ANDROID__ #ifdef ANDROID_NDK_PROFILER diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 8d7891c08a0b..e132d4464991 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -507,7 +507,7 @@ void LogoScreen::render() { int ppsspp_org_y = yres / 2 + 130; dc.DrawText("www.ppsspp.org", bounds.centerX(), ppsspp_org_y, textColor, ALIGN_CENTER); -#if (defined(_WIN32) && !PPSSPP_PLATFORM(UWP)) || PPSSPP_PLATFORM(ANDROID) +#if (defined(_WIN32) && !PPSSPP_PLATFORM(UWP)) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(LINUX) // Draw the graphics API, except on UWP where it's always D3D11 std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME); dc.DrawText(gr->T(apiName), bounds.centerX(), ppsspp_org_y + 50, textColor, ALIGN_CENTER); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index baa72bb9eb25..38e94664e6fc 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -401,7 +401,7 @@ static void CheckFailedGPUBackends() { writeStringToFile(true, g_Config.sFailedGPUBackends, cache.c_str()); } else { // Just save immediately, since we have storage. - g_Config.Save(); + g_Config.Save("got storage permission"); } } @@ -415,7 +415,7 @@ static void ClearFailedGPUBackends() { if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { File::Delete(GetSysDirectory(DIRECTORY_APP_CACHE) + "/FailedGraphicsBackends.txt"); } else { - g_Config.Save(); + g_Config.Save("clearFailedGPUBackends"); } } @@ -1292,7 +1292,7 @@ void NativeShutdown() { delete host; host = nullptr; #endif - g_Config.Save(); + g_Config.Save("NativeShutdown"); // Avoid shutting this down when restarting core. if (!restarting) diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index ae10ed16608a..7901e92a4416 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -330,7 +330,7 @@ EventReturn ReportScreen::HandleSubmit(EventParams &e) { if (Reporting::Enable(enableReporting_, "report.ppsspp.org")) { Reporting::UpdateConfig(); - g_Config.Save(); + g_Config.Save("ReportScreen::HandleSubmit"); } std::string filename = includeScreenshot_ ? screenshotFilename_ : ""; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 77ca20d95697..f75332be819a 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -286,7 +286,7 @@ void TouchControlLayoutScreen::resized() { } void TouchControlLayoutScreen::onFinish(DialogResult reason) { - g_Config.Save(); + g_Config.Save("TouchControlLayoutScreen::onFinish"); } UI::EventReturn TouchControlLayoutScreen::OnVisibility(UI::EventParams &e) { diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 4e67d1cc5c4f..20c0407c8bfb 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -106,14 +106,14 @@ void TouchControlVisibilityScreen::CreateViews() { } choice->SetCentered(true); - + row->Add(choice); grid->Add(row); } } void TouchControlVisibilityScreen::onFinish(DialogResult result) { - g_Config.Save(); + g_Config.Save("TouchControlVisibilityScreen::onFinish"); } UI::EventReturn TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) { diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 5a81b5ceb89b..3e310bf7cb55 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -159,7 +159,7 @@ void MainThreadFunc() { if (performingRestart) { // Okay, switching graphics didn't work out. Probably a driver bug - fallback to restart. // This happens on NVIDIA when switching OpenGL -> Vulkan. - g_Config.Save(); + g_Config.Save("switch_graphics_failed"); W32Util::ExitAndRestart(); } @@ -196,7 +196,7 @@ void MainThreadFunc() { g_Config.iGPUBackend = (int)nextBackend; // Clear this to ensure we try their selection. g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_graphics_fallback"); W32Util::ExitAndRestart(); } else { diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 183a3d052980..2841c003879a 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -145,10 +145,10 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { std::wstring title = ConvertUTF8ToWString(err->T("D3D11InitializationError", "Direct3D 11 initialization error")); bool yes = IDYES == MessageBox(hWnd_, error.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO); if (yes) { - // Change the config to D3D and restart. + // Change the config to D3D9 and restart. g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9; g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_d3d9_fallback"); W32Util::ExitAndRestart(); } diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 0701ffa4aac4..e4851e632990 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -271,7 +271,7 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) { bool d3d9 = IDYES == MessageBox(hWnd_, whichD3D9.c_str(), title.c_str(), MB_YESNO); g_Config.iGPUBackend = d3d9 ? (int)GPUBackend::DIRECT3D9 : (int)GPUBackend::DIRECT3D11; g_Config.sFailedGPUBackends.clear(); - g_Config.Save(); + g_Config.Save("save_d3d11_fallback"); W32Util::ExitAndRestart(); } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index b0a87829a70b..b6ff2d0eac0b 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -759,25 +759,25 @@ namespace MainWindow { case ID_OPTIONS_DIRECT3D9: g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D9; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_DIRECT3D11: g_Config.iGPUBackend = (int)GPUBackend::DIRECT3D11; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_OPENGL: g_Config.iGPUBackend = (int)GPUBackend::OPENGL; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break; case ID_OPTIONS_VULKAN: g_Config.iGPUBackend = (int)GPUBackend::VULKAN; - g_Config.Save(); + g_Config.Save("gpu_choice"); RestartApp(); break;