all repos — mgba @ 7e411fda30145b4d72bda9777356cac994c5acfa

mGBA Game Boy Advance Emulator

Qt: Holdable shortcut for rewinding one frame at a time
Jeffrey Pfau jeffrey@endrift.com
Tue, 26 May 2015 20:38:33 -0700
commit

7e411fda30145b4d72bda9777356cac994c5acfa

parent

4c5cdcaa4e4e9951edaf8f0bb791f32c29dbcf6a

M CHANGESCHANGES

@@ -19,6 +19,7 @@ - Load/save the most recent savestate slot

- Support varible speed (PWM) rumble - Ability to cap fast forward speed - Finer control over FPS target + - Holdable shortcut for rewinding one frame at a time Bugfixes: - ARM7: Fix SWI and IRQ timings - GBA Audio: Force audio FIFOs to 32-bit
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -150,6 +150,13 @@ }

controller->postLog(level, message); }; + connect(&m_rewindTimer, &QTimer::timeout, [this]() { + GBARewind(&m_threadContext, 1); + emit rewound(&m_threadContext); + emit frameAvailable(m_drawContext); + }); + m_rewindTimer.setInterval(100); + m_audioThread->start(QThread::TimeCriticalPriority); m_audioProcessor->moveToThread(m_audioThread); connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start()));

@@ -441,6 +448,16 @@ }

threadContinue(); emit rewound(&m_threadContext); emit frameAvailable(m_drawContext); +} + +void GameController::startRewinding() { + threadInterrupt(); + m_rewindTimer.start(); +} + +void GameController::stopRewinding() { + m_rewindTimer.stop(); + threadContinue(); } void GameController::keyPressed(int key) {
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -11,6 +11,7 @@ #include <QImage>

#include <QObject> #include <QMutex> #include <QString> +#include <QTimer> #include <memory>

@@ -108,6 +109,8 @@ void reset();

void frameAdvance(); void setRewind(bool enable, int capacity, int interval); void rewind(int states = 0); + void startRewinding(); + void stopRewinding(); void keyPressed(int key); void keyReleased(int key); void clearKeys();

@@ -183,6 +186,7 @@ float m_fpsTarget;

bool m_turbo; bool m_turboForced; float m_turboSpeed; + QTimer m_rewindTimer; int m_stateSlot;
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -800,6 +800,12 @@ ffspeed->addValue(tr("%0x").arg(i), i, ffspeedMenu);

} m_config->updateOption("fastForwardRatio"); + m_shortcutController->addFunctions(emulationMenu, [this]() { + m_controller->startRewinding(); + }, [this]() { + m_controller->stopRewinding(); + }, QKeySequence("~"), tr("Rewind (held)"), "holdRewind"); + QAction* rewind = new QAction(tr("Re&wind"), emulationMenu); rewind->setShortcut(tr("`")); connect(rewind, SIGNAL(triggered()), m_controller, SLOT(rewind()));