@@ -78,6 +78,7 @@ int minimizeOnStart = 0;
7878// General
7979int resChangeDelayMs = 3000 ;
8080int dataAverageSamples = 128 ;
81+ bool externalResChangeCompatibility = false ;
8182std::string blacklistApps = " steam.app.620980 steam.app.658920 steam.app.2177750 steam.app.2177760" ; // Beat Saber and HL2VR
8283std::set<std::string> blacklistAppsSet = {" steam.app.620980" , " steam.app.658920" , " steam.app.2177750" , " steam.app.2177760" };
8384bool whitelistEnabled = false ;
@@ -154,6 +155,7 @@ bool loadSettings()
154155 // General
155156 resChangeDelayMs = std::stoi (ini.GetValue (" General" , " resChangeDelayMs" , std::to_string (resChangeDelayMs).c_str ()));
156157 dataAverageSamples = std::stoi (ini.GetValue (" General" , " dataAverageSamples" , std::to_string (dataAverageSamples).c_str ()));
158+ externalResChangeCompatibility = std::stoi (ini.GetValue (" General" , " externalResChangeCompatibility" , std::to_string (externalResChangeCompatibility).c_str ()));
157159 if (dataAverageSamples > 128 )
158160 dataAverageSamples = 128 ; // Max stored by OpenVR
159161 // blacklist
@@ -210,6 +212,7 @@ void saveSettings()
210212 // General
211213 ini.SetValue (" General" , " resChangeDelayMs" , std::to_string (resChangeDelayMs).c_str ());
212214 ini.SetValue (" General" , " dataAverageSamples" , std::to_string (dataAverageSamples).c_str ());
215+ ini.SetValue (" General" , " externalResChangeCompatibility" , std::to_string (externalResChangeCompatibility).c_str ());
213216 ini.SetValue (" General" , " disabledApps" , setToConfigString (blacklistAppsSet).c_str ());
214217 ini.SetValue (" General" , " whitelistEnabled" , std::to_string (whitelistEnabled).c_str ());
215218 ini.SetValue (" General" , " whitelistApps" , setToConfigString (whitelistAppsSet).c_str ());
@@ -446,7 +449,7 @@ int main(int argc, char *argv[])
446449 glfwWindowHint (GLFW_RESIZABLE, false );
447450
448451 // Create window with graphics context
449- glfwWindow = glfwCreateWindow (mainWindowWidth, mainWindowHeight, fmt::format ( " OVR Dynamic Resolution {} " , version). c_str () , nullptr , nullptr );
452+ glfwWindow = glfwCreateWindow (mainWindowWidth, mainWindowHeight, " OVR Dynamic Resolution" , nullptr , nullptr );
450453 if (glfwWindow == nullptr )
451454 return 1 ;
452455 glfwMakeContextCurrent (glfwWindow);
@@ -497,9 +500,10 @@ int main(int argc, char *argv[])
497500#pragma endregion
498501
499502 // Load settings from ini file
500- if (!loadSettings ()) {
503+ if (!loadSettings ())
504+ {
501505 std::replace (blacklistApps.begin (), blacklistApps.end (), ' ' , ' \n ' ); // Set blacklist newlines
502- saveSettings (); // Restore settings
506+ saveSettings (); // Restore settings
503507 }
504508
505509 // Set auto-start
@@ -621,7 +625,7 @@ int main(int argc, char *argv[])
621625 float averageGpuTime = 0 ;
622626 float averageCpuTime = 0 ;
623627 float averageFrameShown = 0 ;
624- int newRes = 0 ;
628+ float newRes = initialRes ;
625629 int targetFps = 0 ;
626630 float targetFrametime = 0 ;
627631 int hmdHz = 0 ;
@@ -645,8 +649,14 @@ int main(int argc, char *argv[])
645649 lastChangeTime = currentTime;
646650
647651#pragma region Getting data
652+ float currentRes = vr::VRSettings ()->GetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float) * 100 .0f ;
653+
654+ // Check for external resolution change compatibility
655+ if (externalResChangeCompatibility && std::fabs (newRes - currentRes) > 0 .001f && !manualRes)
656+ manualRes = true ;
657+
648658 // Fetch resolution and target fps
649- newRes = vr::VRSettings ()-> GetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float) * 100 ;
659+ newRes = currentRes ;
650660 float lastRes = newRes;
651661 targetFps = std::round (vr::VRSystem ()->GetFloatTrackedDeviceProperty (0 , Prop_DisplayFrequency_Float));
652662 targetFrametime = 1000 .0f / targetFps;
@@ -759,11 +769,11 @@ int main(int argc, char *argv[])
759769 else if (vramOnlyMode && newRes < initialRes && vramUsed < vramTarget / 100 .0f )
760770 {
761771 // When in VRAM-only mode, make sure the res goes back up when possible.
762- newRes = std::min (initialRes, newRes + resIncreaseMin);
772+ newRes = std::min (initialRes, ( int ) std::round ( newRes) + resIncreaseMin);
763773 }
764774
765775 // Clamp the new resolution
766- newRes = std::clamp (newRes, minRes, maxRes);
776+ newRes = std::clamp (( int ) std::round ( newRes) , minRes, maxRes);
767777 }
768778 }
769779 else if ((appKey == " " || (resetOnThreshold && averageCpuTime < minCpuTimeThreshold)) && !manualRes)
@@ -803,7 +813,7 @@ int main(int argc, char *argv[])
803813 ImGui::SetWindowSize (ImVec2 (mainWindowWidth, mainWindowHeight));
804814
805815 // Title
806- ImGui::Text (" OVR Dynamic Resolution" );
816+ ImGui::Text (fmt::format ( " OVR Dynamic Resolution {} " , version). c_str () );
807817
808818 ImGui::Separator ();
809819 ImGui::NewLine ();
@@ -858,7 +868,7 @@ int main(int argc, char *argv[])
858868 }
859869 else
860870 {
861- ImGui::Text (" %s" , fmt::format (" Resolution = {}" , newRes).c_str ());
871+ ImGui::Text (" %s" , fmt::format (" Resolution = {:.0f }" , newRes).c_str ());
862872 }
863873
864874 // Resolution adjustment status
@@ -869,7 +879,7 @@ int main(int argc, char *argv[])
869879 {
870880 ImGui::PushItemWidth (192 );
871881 ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, ImVec2 (0 , 0 ));
872- if (ImGui::SliderInt (" " , &newRes, 20 , 500 , " %d " , ImGuiSliderFlags_AlwaysClamp))
882+ if (ImGui::SliderFloat (" " , &newRes, 20 . 0f , 500 . 0f , " %.0f " , ImGuiSliderFlags_AlwaysClamp))
873883 {
874884 vr::VRSettings ()->SetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float, newRes / 100 .0f );
875885 }
@@ -954,6 +964,9 @@ int main(int argc, char *argv[])
954964 }
955965 addTooltip (" Number of frames' frametimes to average out." );
956966
967+ ImGui::Checkbox (" External res change compatibility" , &externalResChangeCompatibility);
968+ addTooltip (" Automatically switch to manual resolution adjustment within the app when VR resolution is changed from an external source (SteamVR setting, Oyasumi, etc.) as to let the external source control the resolution. Does not automatically switch back to dynamic resolution adjustment." );
969+
957970 ImGui::Text (" Blacklist" );
958971 addTooltip (" Don't allow resolution changes in blacklisted applications." );
959972 if (ImGui::InputTextMultiline (" Blacklisted apps" , &blacklistApps, ImVec2 (130 , 60 ), ImGuiInputTextFlags_CharsNoBlank))
@@ -965,7 +978,8 @@ int main(int argc, char *argv[])
965978 if (!isApplicationBlacklisted (appKey))
966979 {
967980 blacklistAppsSet.insert (appKey);
968- if (blacklistApps != " " ) blacklistApps += " \n " ;
981+ if (blacklistApps != " " )
982+ blacklistApps += " \n " ;
969983 blacklistApps += appKey;
970984 }
971985 }
@@ -982,7 +996,8 @@ int main(int argc, char *argv[])
982996 if (!isApplicationWhitelisted (appKey))
983997 {
984998 whitelistAppsSet.insert (appKey);
985- if (whitelistApps != " " ) whitelistApps += " \n " ;
999+ if (whitelistApps != " " )
1000+ whitelistApps += " \n " ;
9861001 whitelistApps += appKey;
9871002 }
9881003 }
0 commit comments