mGUI: Add fast forward mute

This commit is contained in:
Rik Smeets 2021-04-28 18:06:00 +02:00 committed by Vicki Pfau
parent 86ec2d4d22
commit b78f47b214
2 changed files with 36 additions and 6 deletions

View File

@ -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",

View File

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