Add a setting for minimum (automatic) refresh rate
This commit is contained in:
@@ -19,7 +19,9 @@
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/battery.h"
|
||||
#endif
|
||||
#include "application.h"
|
||||
#include "asset.h"
|
||||
#include "configuration.h"
|
||||
@@ -607,6 +609,24 @@ void scenes::lobby::gui_settings()
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
vibrate_on_hover();
|
||||
|
||||
if (config.preferred_refresh_rate == 0 and refresh_rates.size() > 2)
|
||||
{
|
||||
float min_rate = config.minimum_refresh_rate.value_or(refresh_rates.front());
|
||||
if (ImGui::BeginCombo(_S("Minimum refresh rate"), fmt::format("{}", min_rate).c_str()))
|
||||
{
|
||||
for (float rate: refresh_rates | std::views::take(refresh_rates.size() - 1))
|
||||
{
|
||||
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.minimum_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
config.minimum_refresh_rate = rate;
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
vibrate_on_hover();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,11 +184,18 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
if (self->instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
|
||||
{
|
||||
info.available_refresh_rates = self->session.get_refresh_rates();
|
||||
// I can't find anythin in specification the ensures it won't be empty
|
||||
// I can't find anything in specification the ensures it won't be empty
|
||||
if (not info.available_refresh_rates.empty())
|
||||
{
|
||||
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(info.available_refresh_rates, *config.preferred_refresh_rate)))
|
||||
{
|
||||
info.preferred_refresh_rate = *config.preferred_refresh_rate;
|
||||
if (info.preferred_refresh_rate == 0)
|
||||
info.available_refresh_rates = {
|
||||
std::ranges::lower_bound(info.available_refresh_rates, config.minimum_refresh_rate),
|
||||
info.available_refresh_rates.end(),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to highest refresh rate
|
||||
|
||||
Reference in New Issue
Block a user