citra-qt: Add customizable speed limit target (#3353)

citra-qt: Add customizable speed limit target

* Update SDL config for the new frame_limit option
* Made max lag time a function of target speed percent.
* Added a checkbox to enable/disable frame limiter
* UI: Prevent frame_limit from under/overflowing
* UI: Hide target speed percent when frame limiter is off
* Disable frame limit spin box when framelimit isn't enabled
This commit is contained in:
James Rowe 2018-01-25 22:24:40 -07:00 committed by GitHub
parent 33b0b5163f
commit b002511df0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 155 additions and 96 deletions

View file

@ -77,7 +77,8 @@ void Config::ReadValues() {
Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool();
Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat();
Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool();
Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool();
Settings::values.use_frame_limit = qt_config->value("use_frame_limit", true).toBool();
Settings::values.frame_limit = qt_config->value("frame_limit", 100).toInt();
Settings::values.bg_red = qt_config->value("bg_red", 0.0).toFloat();
Settings::values.bg_green = qt_config->value("bg_green", 0.0).toFloat();
@ -241,7 +242,8 @@ void Config::SaveValues() {
qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit);
qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor);
qt_config->setValue("use_vsync", Settings::values.use_vsync);
qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit);
qt_config->setValue("use_frame_limit", Settings::values.use_frame_limit);
qt_config->setValue("frame_limit", Settings::values.frame_limit);
// Cast to double because Qt's written float values are not human-readable
qt_config->setValue("bg_red", (double)Settings::values.bg_red);

View file

@ -14,6 +14,8 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
this->setConfiguration();
ui->toggle_vsync->setEnabled(!Core::System::GetInstance().IsPoweredOn());
ui->frame_limit->setEnabled(Settings::values.use_frame_limit);
connect(ui->toggle_frame_limit, &QCheckBox::stateChanged, ui->frame_limit, &QSpinBox::setEnabled);
ui->layoutBox->setEnabled(!Settings::values.custom_layout);
}
@ -96,7 +98,8 @@ void ConfigureGraphics::setConfiguration() {
ui->resolution_factor_combobox->setCurrentIndex(
static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor)));
ui->toggle_vsync->setChecked(Settings::values.use_vsync);
ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit);
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
ui->frame_limit->setValue(Settings::values.frame_limit);
ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option));
ui->swap_screen->setChecked(Settings::values.swap_screen);
}
@ -107,7 +110,8 @@ void ConfigureGraphics::applyConfiguration() {
Settings::values.resolution_factor =
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
Settings::values.use_vsync = ui->toggle_vsync->isChecked();
Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked();
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
Settings::values.frame_limit = ui->frame_limit->value();
Settings::values.layout_option =
static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());
Settings::values.swap_screen = ui->swap_screen->isChecked();

View file

@ -44,81 +44,101 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_framelimit">
<property name="text">
<string>Limit framerate</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="toggle_frame_limit">
<property name="text">
<string>Limit Speed Percent</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="frame_limit">
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Internal Resolution:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="resolution_factor_combobox">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Internal Resolution:</string>
</property>
</widget>
<property name="text">
<string>Auto (Window Size)</string>
</property>
</item>
<item>
<widget class="QComboBox" name="resolution_factor_combobox">
<item>
<property name="text">
<string>Auto (Window Size)</string>
</property>
</item>
<item>
<property name="text">
<string>Native (400x240)</string>
</property>
</item>
<item>
<property name="text">
<string>2x Native (800x480)</string>
</property>
</item>
<item>
<property name="text">
<string>3x Native (1200x720)</string>
</property>
</item>
<item>
<property name="text">
<string>4x Native (1600x960)</string>
</property>
</item>
<item>
<property name="text">
<string>5x Native (2000x1200)</string>
</property>
</item>
<item>
<property name="text">
<string>6x Native (2400x1440)</string>
</property>
</item>
<item>
<property name="text">
<string>7x Native (2800x1680)</string>
</property>
</item>
<item>
<property name="text">
<string>8x Native (3200x1920)</string>
</property>
</item>
<item>
<property name="text">
<string>9x Native (3600x2160)</string>
</property>
</item>
<item>
<property name="text">
<string>10x Native (4000x2400)</string>
</property>
</item>
</widget>
<property name="text">
<string>Native (400x240)</string>
</property>
</item>
</layout>
<item>
<property name="text">
<string>2x Native (800x480)</string>
</property>
</item>
<item>
<property name="text">
<string>3x Native (1200x720)</string>
</property>
</item>
<item>
<property name="text">
<string>4x Native (1600x960)</string>
</property>
</item>
<item>
<property name="text">
<string>5x Native (2000x1200)</string>
</property>
</item>
<item>
<property name="text">
<string>6x Native (2400x1440)</string>
</property>
</item>
<item>
<property name="text">
<string>7x Native (2800x1680)</string>
</property>
</item>
<item>
<property name="text">
<string>8x Native (3200x1920)</string>
</property>
</item>
<item>
<property name="text">
<string>9x Native (3600x2160)</string>
</property>
</item>
<item>
<property name="text">
<string>10x Native (4000x2400)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View file

@ -269,6 +269,10 @@ void GMainWindow::InitializeHotkeys() {
RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape),
Qt::ApplicationShortcut);
RegisterHotkey("Main Window", "Increase Speed Limit", QKeySequence("+"),
Qt::ApplicationShortcut);
RegisterHotkey("Main Window", "Decrease Speed Limit", QKeySequence("-"),
Qt::ApplicationShortcut);
LoadHotkeys();
connect(GetHotkey("Main Window", "Load File", this), &QShortcut::activated, this,
@ -287,6 +291,21 @@ void GMainWindow::InitializeHotkeys() {
ToggleFullscreen();
}
});
constexpr u16 SPEED_LIMIT_STEP = 5;
connect(GetHotkey("Main Window", "Increase Speed Limit", this), &QShortcut::activated, this,
[&] {
if (Settings::values.frame_limit < 9999 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit += SPEED_LIMIT_STEP;
UpdateStatusBar();
}
});
connect(GetHotkey("Main Window", "Decrease Speed Limit", this), &QShortcut::activated, this,
[&] {
if (Settings::values.frame_limit > SPEED_LIMIT_STEP) {
Settings::values.frame_limit -= SPEED_LIMIT_STEP;
UpdateStatusBar();
}
});
}
void GMainWindow::ShowUpdaterWidgets() {
@ -912,7 +931,14 @@ void GMainWindow::UpdateStatusBar() {
auto results = Core::System::GetInstance().GetAndResetPerfStats();
emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
if (Settings::values.use_frame_limit) {
emu_speed_label->setText(tr("Speed: %1% / %2%")
.arg(results.emulation_speed * 100.0, 0, 'f', 0)
.arg(Settings::values.frame_limit));
} else {
emu_speed_label->setText(tr("Speed: %1%")
.arg(results.emulation_speed * 100.0, 0, 'f', 0));
}
game_fps_label->setText(tr("Game: %1 FPS").arg(results.game_fps, 0, 'f', 0));
emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2));