From b78f47b214c6134f9217774592682579bda190e6 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Wed, 28 Apr 2021 18:06:00 +0200 Subject: [PATCH] mGUI: Add fast forward mute --- src/feature/gui/gui-config.c | 10 ++++++++++ src/feature/gui/gui-runner.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/feature/gui/gui-config.c b/src/feature/gui/gui-config.c index 6d43c0480..cba83166b 100644 --- a/src/feature/gui/gui-config.c +++ b/src/feature/gui/gui-config.c @@ -103,6 +103,16 @@ void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t }, .nStates = 2 }; + *GUIMenuItemListAppend(&menu.items) = (struct GUIMenuItem) { + .title = "Fast forward mute", + .data = "fastForwardMute", + .submenu = 0, + .state = false, + .validStates = (const char*[]) { + "Off", "On" + }, + .nStates = 2 + }; *GUIMenuItemListAppend(&menu.items) = (struct GUIMenuItem) { .title = "Use BIOS if found", .data = "useBios", diff --git a/src/feature/gui/gui-runner.c b/src/feature/gui/gui-runner.c index 2f296ee1b..3a7046b82 100644 --- a/src/feature/gui/gui-runner.c +++ b/src/feature/gui/gui-runner.c @@ -455,6 +455,12 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) { int drawFps = false; mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps); + int mute = false; + mCoreConfigGetIntValue(&runner->config, "mute", &mute); + + int fastForwardMute = false; + mCoreConfigGetIntValue(&runner->config, "fastForwardMute", &fastForwardMute); + bool running = true; #ifndef DISABLE_THREADING @@ -506,21 +512,33 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) { if (guiKeys & (1 << mGUI_INPUT_SCREENSHOT)) { mCoreTakeScreenshot(runner->core); } + bool muteTogglePressed = guiKeys & (1 << mGUI_INPUT_MUTE_TOGGLE); + if (muteTogglePressed) { + mute = !mute; + mCoreConfigSetUIntValue(&runner->config, "mute", mute); + runner->core->reloadConfigOption(runner->core, "mute", &runner->config); + } if (runner->setFrameLimiter) { if (guiKeys & (1 << mGUI_INPUT_FAST_FORWARD_TOGGLE)) { fastForward = !fastForward; } - if (fastForward || (heldKeys & (1 << mGUI_INPUT_FAST_FORWARD_HELD))) { + bool fastForwarding = fastForward || (heldKeys & (1 << mGUI_INPUT_FAST_FORWARD_HELD)); + if (fastForwarding) { + if (fastForwardMute && !mute && !muteTogglePressed) { + mCoreConfigSetUIntValue(&runner->core->config, "mute", fastForwardMute); + runner->core->reloadConfigOption(runner->core, "mute", NULL); + } + runner->setFrameLimiter(runner, false); } else { runner->setFrameLimiter(runner, true); + + if (fastForwardMute && !mute && !muteTogglePressed) { + mCoreConfigSetUIntValue(&runner->core->config, "mute", !fastForwardMute); + runner->core->reloadConfigOption(runner->core, "mute", NULL); + } } } - if (guiKeys & (1 << mGUI_INPUT_MUTE_TOGGLE)) { - int mute = !runner->core->opts.mute; - mCoreConfigSetUIntValue(&runner->config, "mute", mute); - runner->core->reloadConfigOption(runner->core, "mute", &runner->config); - } uint16_t keys = runner->pollGameInput(runner); if (runner->prepareForFrame) { runner->prepareForFrame(runner); @@ -651,6 +669,8 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) { } mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps); mCoreConfigGetIntValue(&runner->config, "showOSD", &showOSD); + mCoreConfigGetIntValue(&runner->config, "mute", &mute); + mCoreConfigGetIntValue(&runner->config, "fastForwardMute", &fastForwardMute); #ifdef M_CORE_GB if (runner->core->platform(runner->core) == mPLATFORM_GB) { runner->core->reloadConfigOption(runner->core, "gb.pal", &runner->config);