Add a setting for minimum (automatic) refresh rate
This commit is contained in:
@@ -182,6 +182,9 @@ configuration::configuration(xr::system & system)
|
||||
if (auto val = root["preferred_refresh_rate"]; val.is_double())
|
||||
preferred_refresh_rate = val.get_double();
|
||||
|
||||
if (auto val = root["minimum_refresh_rate"]; val.is_double())
|
||||
minimum_refresh_rate = val.get_double();
|
||||
|
||||
if (auto val = root["resolution_scale"]; val.is_double())
|
||||
resolution_scale = val.get_double();
|
||||
|
||||
@@ -210,6 +213,7 @@ configuration::configuration(xr::system & system)
|
||||
// Restore default configuration
|
||||
servers.clear();
|
||||
preferred_refresh_rate.reset();
|
||||
minimum_refresh_rate.reset();
|
||||
resolution_scale = 1.4;
|
||||
show_performance_metrics = false;
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
@@ -253,6 +257,8 @@ void configuration::save()
|
||||
<< "\"show_performance_metrics\":" << std::boolalpha << show_performance_metrics;
|
||||
if (preferred_refresh_rate)
|
||||
json << ",\"preferred_refresh_rate\":" << *preferred_refresh_rate;
|
||||
if (minimum_refresh_rate)
|
||||
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
|
||||
json << ",\"resolution_scale\":" << resolution_scale;
|
||||
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
|
||||
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
|
||||
std::map<std::string, server_data> servers;
|
||||
std::optional<float> preferred_refresh_rate;
|
||||
std::optional<float> minimum_refresh_rate;
|
||||
float resolution_scale = 1.4;
|
||||
bool show_performance_metrics = false;
|
||||
bool passthrough_enabled = false;
|
||||
|
||||
@@ -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