Qt: Separate fast forward volume control (fixes #846, #1143)

This commit is contained in:
Vicki Pfau 2018-09-28 10:58:24 -07:00
parent 40d2b0f77a
commit 5fa1638b1d
7 changed files with 101 additions and 16 deletions

View File

@ -101,6 +101,7 @@ Misc:
Changes from beta 1:
Features:
- Libretro: Add Game Boy cheat support
- Qt: Separate fast forward volume control (fixes mgba.io/i/846, mgba.io/i/1143)
Bugfixes:
- PSP2: Fix audio crackling after fast forward
- PSP2: Fix audio crackling when buffer is full

View File

@ -245,6 +245,8 @@ void CoreController::loadConfig(ConfigController* config) {
m_autosave = config->getOption("autosave", false).toInt();
m_autoload = config->getOption("autoload", true).toInt();
m_autofireThreshold = config->getOption("autofireThreshold", m_autofireThreshold).toInt();
m_fastForwardVolume = config->getOption("fastForwardVolume", -1).toInt();
m_fastForwardMute = config->getOption("fastForwardMute", -1).toInt();
mCoreLoadForeignConfig(m_threadContext.core, config->config());
if (hasStarted()) {
updateFastForward();
@ -810,15 +812,29 @@ void CoreController::finishFrame() {
void CoreController::updateFastForward() {
if (m_fastForward || m_fastForwardForced) {
if (m_fastForwardVolume >= 0) {
m_threadContext.core->opts.volume = m_fastForwardVolume;
}
if (m_fastForwardMute >= 0) {
m_threadContext.core->opts.mute = m_fastForwardMute;
}
if (m_fastForwardRatio > 0) {
m_threadContext.impl->sync.fpsTarget = m_fpsTarget * m_fastForwardRatio;
} else {
setSync(false);
}
} else {
if (!mCoreConfigGetIntValue(&m_threadContext.core->config, "volume", &m_threadContext.core->opts.volume)) {
m_threadContext.core->opts.volume = 0x100;
}
int fakeBool = 0;
mCoreConfigGetIntValue(&m_threadContext.core->config, "mute", &fakeBool);
m_threadContext.core->opts.mute = fakeBool;
m_threadContext.impl->sync.fpsTarget = m_fpsTarget;
setSync(true);
}
// XXX: Have a way of just updating opts
m_threadContext.core->loadConfig(m_threadContext.core, &m_threadContext.core->config);
}
CoreController::Interrupter::Interrupter(CoreController* parent, bool fromThread)

View File

@ -204,6 +204,8 @@ private:
int m_fastForward = false;
int m_fastForwardForced = false;
int m_fastForwardVolume = -1;
int m_fastForwardMute = -1;
float m_fastForwardRatio = -1.f;
float m_fpsTarget;

View File

@ -43,6 +43,18 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
reloadConfig();
connect(m_ui.volume, static_cast<void (QSlider::*)(int)>(&QSlider::valueChanged), [this](int v) {
if (v < m_ui.volumeFf->value()) {
m_ui.volumeFf->setValue(v);
}
});
connect(m_ui.mute, &QAbstractButton::toggled, [this](bool e) {
if (e) {
m_ui.muteFf->setChecked(e);
}
});
if (m_ui.savegamePath->text().isEmpty()) {
m_ui.savegameSameDir->setChecked(true);
}
@ -339,6 +351,8 @@ void SettingsView::updateConfig() {
saveSetting("lockIntegerScaling", m_ui.lockIntegerScaling);
saveSetting("volume", m_ui.volume);
saveSetting("mute", m_ui.mute);
saveSetting("fastForwardVolume", m_ui.volumeFf);
saveSetting("fastForwardMute", m_ui.muteFf);
saveSetting("rewindEnable", m_ui.rewind);
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
saveSetting("resampleVideo", m_ui.resampleVideo);
@ -460,8 +474,10 @@ void SettingsView::reloadConfig() {
loadSetting("autofireThreshold", m_ui.autofireThreshold);
loadSetting("lockAspectRatio", m_ui.lockAspectRatio);
loadSetting("lockIntegerScaling", m_ui.lockIntegerScaling);
loadSetting("volume", m_ui.volume);
loadSetting("mute", m_ui.mute);
loadSetting("volume", m_ui.volume, 0x100);
loadSetting("mute", m_ui.mute, false);
loadSetting("fastForwardVolume", m_ui.volumeFf, m_ui.volume->value());
loadSetting("fastForwardMute", m_ui.muteFf, m_ui.mute->isChecked());
loadSetting("rewindEnable", m_ui.rewind);
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
loadSetting("resampleVideo", m_ui.resampleVideo);
@ -592,9 +608,9 @@ void SettingsView::loadSetting(const char* key, QLineEdit* field) {
field->setText(option);
}
void SettingsView::loadSetting(const char* key, QSlider* field) {
void SettingsView::loadSetting(const char* key, QSlider* field, int defaultVal) {
QString option = loadSetting(key);
field->setValue(option.toInt());
field->setValue(option.isNull() ? defaultVal : option.toInt());
}
void SettingsView::loadSetting(const char* key, QSpinBox* field) {

View File

@ -72,7 +72,7 @@ private:
void loadSetting(const char* key, QComboBox*);
void loadSetting(const char* key, QDoubleSpinBox*);
void loadSetting(const char* key, QLineEdit*);
void loadSetting(const char* key, QSlider*);
void loadSetting(const char* key, QSlider*, int defaultVal = 0);
void loadSetting(const char* key, QSpinBox*);
QString loadSetting(const char* key);
};

View File

@ -263,21 +263,61 @@
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QLabel" name="label_34">
<property name="text">
<string>Fast forward volume:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QSlider" name="volumeFf">
<property name="minimumSize">
<size>
<width>128</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>256</number>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="value">
<number>256</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="muteFf">
<property name="text">
<string>Mute</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Display driver:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="displayDriver">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -287,14 +327,14 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Frameskip:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="label_12">
@ -315,14 +355,14 @@
</item>
</layout>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>FPS target:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QDoubleSpinBox" name="fpsTarget">
@ -349,21 +389,21 @@
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Sync:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QCheckBox" name="videoSync">
@ -381,7 +421,7 @@
</item>
</layout>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QCheckBox" name="lockAspectRatio">
<property name="text">
<string>Lock aspect ratio</string>

View File

@ -1610,6 +1610,16 @@ void Window::setupMenu(QMenuBar* menubar) {
reloadConfig();
}, this);
ConfigOption* volumeFf = m_config->addOption("fastForwardVolume");
volumeFf->connect([this](const QVariant& value) {
reloadConfig();
}, this);
ConfigOption* muteFf = m_config->addOption("fastForwardMute");
muteFf->connect([this](const QVariant& value) {
reloadConfig();
}, this);
ConfigOption* rewindEnable = m_config->addOption("rewindEnable");
rewindEnable->connect([this](const QVariant& value) {
reloadConfig();