all repos — mgba @ 5fa1638b1df3e16984bc356653fe405de6e944c7

mGBA Game Boy Advance Emulator

Qt: Separate fast forward volume control (fixes #846, #1143)
Vicki Pfau vi@endrift.com
Fri, 28 Sep 2018 10:58:24 -0700
commit

5fa1638b1df3e16984bc356653fe405de6e944c7

parent

40d2b0f77ad3503b99019589441b639748e38214

M CHANGESCHANGES

@@ -101,6 +101,7 @@ - mGUI: Add fast forward toggle

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
M src/platform/qt/CoreController.cppsrc/platform/qt/CoreController.cpp

@@ -245,6 +245,8 @@ m_fpsTarget = config->getOption("fpsTarget").toFloat();

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::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)
M src/platform/qt/CoreController.hsrc/platform/qt/CoreController.h

@@ -204,6 +204,8 @@ int m_autosaveCounter;

int m_fastForward = false; int m_fastForwardForced = false; + int m_fastForwardVolume = -1; + int m_fastForwardMute = -1; float m_fastForwardRatio = -1.f; float m_fpsTarget;
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -43,6 +43,18 @@ #endif

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 @@ saveSetting("lockAspectRatio", m_ui.lockAspectRatio);

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 @@ loadSetting("fpsTarget", m_ui.fpsTarget);

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 @@ QString option = loadSetting(key);

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) {
M src/platform/qt/SettingsView.hsrc/platform/qt/SettingsView.h

@@ -72,7 +72,7 @@ void loadSetting(const char* key, QAbstractButton*, bool defaultVal = false);

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); };
M src/platform/qt/SettingsView.uisrc/platform/qt/SettingsView.ui

@@ -263,21 +263,61 @@ </widget>

</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 @@ </sizepolicy>

</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 @@ </widget>

</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 @@ </widget>

</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 @@ </widget>

</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>
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -1610,6 +1610,16 @@ volume->connect([this](const QVariant& value) {

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();