DolphinQt: Adjust CPU Clock Override slider

CPU Clock Override slider now increments 1% in the UI, with the new lower limit
being 1% instead of 6%.

Prior implementation made it impossible to set exactly 150% in the GUI.
147% -> 152%. Now users can set exact clock % without needing to edit INIs.
This commit is contained in:
dreamsyntax 2024-06-18 18:36:04 -07:00
parent a0d8c1088d
commit 55ba014fed
1 changed files with 4 additions and 5 deletions

View File

@ -100,7 +100,7 @@ void AdvancedPane::CreateLayout()
clock_override_layout->addLayout(cpu_clock_override_slider_layout); clock_override_layout->addLayout(cpu_clock_override_slider_layout);
m_cpu_clock_override_slider = new QSlider(Qt::Horizontal); m_cpu_clock_override_slider = new QSlider(Qt::Horizontal);
m_cpu_clock_override_slider->setRange(0, 150); m_cpu_clock_override_slider->setRange(1, 400);
cpu_clock_override_slider_layout->addWidget(m_cpu_clock_override_slider); cpu_clock_override_slider_layout->addWidget(m_cpu_clock_override_slider);
m_cpu_clock_override_slider_label = new QLabel(); m_cpu_clock_override_slider_label = new QLabel();
@ -203,8 +203,7 @@ void AdvancedPane::ConnectLayout()
}); });
connect(m_cpu_clock_override_slider, &QSlider::valueChanged, [this](int oc_factor) { connect(m_cpu_clock_override_slider, &QSlider::valueChanged, [this](int oc_factor) {
// Vaguely exponential scaling? const float factor = m_cpu_clock_override_slider->value() / 100.f;
const float factor = std::exp2f((m_cpu_clock_override_slider->value() - 100.f) / 25.f);
Config::SetBaseOrCurrent(Config::MAIN_OVERCLOCK, factor); Config::SetBaseOrCurrent(Config::MAIN_OVERCLOCK, factor);
Update(); Update();
}); });
@ -271,8 +270,8 @@ void AdvancedPane::Update()
{ {
const QSignalBlocker blocker(m_cpu_clock_override_slider); const QSignalBlocker blocker(m_cpu_clock_override_slider);
m_cpu_clock_override_slider->setValue(static_cast<int>( m_cpu_clock_override_slider->setValue(
std::round(std::log2f(Config::Get(Config::MAIN_OVERCLOCK)) * 25.f + 100.f))); static_cast<int>(std::round(Config::Get(Config::MAIN_OVERCLOCK) * 100.f)));
} }
m_cpu_clock_override_slider_label->setText([] { m_cpu_clock_override_slider_label->setText([] {