Add "frame step" hotkey and function (#1119)

This commit is contained in:
cat 2021-06-05 15:10:37 -04:00 committed by GitHub
parent af36d10023
commit 2494058a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 1 deletions

View File

@ -52,6 +52,7 @@ const int hk_general[] =
{
HK_Pause,
HK_Reset,
HK_FrameStep,
HK_FastForward,
HK_FastForwardToggle,
HK_FullscreenToggle,
@ -64,6 +65,7 @@ const char* hk_general_labels[] =
{
"Pause/resume",
"Reset",
"Frame step",
"Fast forward",
"Toggle FPS limit",
"Toggle Fullscreen",

View File

@ -124,6 +124,7 @@ ConfigEntry PlatformConfigFile[] =
{"HKKey_SwapScreens", 0, &HKKeyMapping[HK_SwapScreens], -1, NULL, 0},
{"HKKey_SolarSensorDecrease", 0, &HKKeyMapping[HK_SolarSensorDecrease], -1, NULL, 0},
{"HKKey_SolarSensorIncrease", 0, &HKKeyMapping[HK_SolarSensorIncrease], -1, NULL, 0},
{"HKKey_FrameStep", 0, &HKKeyMapping[HK_FrameStep], -1, NULL, 0},
{"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
{"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
@ -135,6 +136,7 @@ ConfigEntry PlatformConfigFile[] =
{"HKJoy_SwapScreens", 0, &HKJoyMapping[HK_SwapScreens], -1, NULL, 0},
{"HKJoy_SolarSensorDecrease", 0, &HKJoyMapping[HK_SolarSensorDecrease], -1, NULL, 0},
{"HKJoy_SolarSensorIncrease", 0, &HKJoyMapping[HK_SolarSensorIncrease], -1, NULL, 0},
{"HKJoy_FrameStep", 0, &HKJoyMapping[HK_FrameStep], -1, NULL, 0},
{"JoystickID", 0, &JoystickID, 0, NULL, 0},

View File

@ -33,6 +33,7 @@ enum
HK_SwapScreens,
HK_SolarSensorDecrease,
HK_SolarSensorIncrease,
HK_FrameStep,
HK_MAX
};

View File

@ -281,6 +281,7 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent)
connect(this, SIGNAL(windowEmuStop()), mainWindow, SLOT(onEmuStop()));
connect(this, SIGNAL(windowEmuPause()), mainWindow->actPause, SLOT(trigger()));
connect(this, SIGNAL(windowEmuReset()), mainWindow->actReset, SLOT(trigger()));
connect(this, SIGNAL(windowEmuFrameStep()), mainWindow->actFrameStep, SLOT(trigger()));
connect(this, SIGNAL(windowLimitFPSChange()), mainWindow->actLimitFramerate, SLOT(trigger()));
connect(this, SIGNAL(screenLayoutChange()), mainWindow->panel, SLOT(onScreenLayoutChanged()));
connect(this, SIGNAL(windowFullscreenToggle()), mainWindow, SLOT(onFullscreenToggled()));
@ -377,6 +378,7 @@ void EmuThread::run()
if (Input::HotkeyPressed(HK_Pause)) emit windowEmuPause();
if (Input::HotkeyPressed(HK_Reset)) emit windowEmuReset();
if (Input::HotkeyPressed(HK_FrameStep)) emit windowEmuFrameStep();
if (Input::HotkeyPressed(HK_FullscreenToggle)) emit windowFullscreenToggle();
@ -403,9 +405,10 @@ void EmuThread::run()
}
}
if (EmuRunning == 1)
if (EmuRunning == 1 || EmuRunning == 3)
{
EmuStatus = 1;
if (EmuRunning == 3) EmuRunning = 2;
// update render settings if needed
if (videoSettingsDirty)
@ -655,6 +658,12 @@ void EmuThread::emuStop()
if (micDevice) SDL_PauseAudioDevice(micDevice, 1);
}
void EmuThread::emuFrameStep()
{
if (EmuPause < 1) emit windowEmuPause();
EmuRunning = 3;
}
bool EmuThread::emuIsRunning()
{
return (EmuRunning == 1);
@ -1306,6 +1315,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actStop = menu->addAction("Stop");
connect(actStop, &QAction::triggered, this, &MainWindow::onStop);
actFrameStep = menu->addAction("Frame step");
connect(actFrameStep, &QAction::triggered, this, &MainWindow::onFrameStep);
menu->addSeparator();
actEnableCheats = menu->addAction("Enable cheats");
@ -1509,6 +1521,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actPause->setEnabled(false);
actReset->setEnabled(false);
actStop->setEnabled(false);
actFrameStep->setEnabled(false);
actSetupCheats->setEnabled(false);
@ -2271,6 +2284,13 @@ void MainWindow::onStop()
NDS::Stop();
}
void MainWindow::onFrameStep()
{
if (!RunningSomething) return;
emuThread->emuFrameStep();
}
void MainWindow::onEnableCheats(bool checked)
{
Config::EnableCheats = checked?1:0;
@ -2540,6 +2560,7 @@ void MainWindow::onEmuStart()
actPause->setChecked(false);
actReset->setEnabled(true);
actStop->setEnabled(true);
actFrameStep->setEnabled(true);
actImportSavefile->setEnabled(true);
actSetupCheats->setEnabled(true);
@ -2560,6 +2581,7 @@ void MainWindow::onEmuStop()
actPause->setEnabled(false);
actReset->setEnabled(false);
actStop->setEnabled(false);
actFrameStep->setEnabled(false);
actSetupCheats->setEnabled(false);
}

View File

@ -55,6 +55,7 @@ public:
void emuPause();
void emuUnpause();
void emuStop();
void emuFrameStep();
bool emuIsRunning();
@ -72,6 +73,7 @@ signals:
void windowEmuStop();
void windowEmuPause();
void windowEmuReset();
void windowEmuFrameStep();
void windowLimitFPSChange();
@ -228,6 +230,7 @@ private slots:
void onPause(bool checked);
void onReset();
void onStop();
void onFrameStep();
void onEnableCheats(bool checked);
void onSetupCheats();
void onCheatsDialogFinished(int res);
@ -300,6 +303,7 @@ public:
QAction* actPause;
QAction* actReset;
QAction* actStop;
QAction* actFrameStep;
QAction* actEnableCheats;
QAction* actSetupCheats;