Qt: Holdable shortcut for rewinding one frame at a time

This commit is contained in:
Jeffrey Pfau 2015-05-26 20:38:33 -07:00
parent 4c5cdcaa4e
commit 7e411fda30
4 changed files with 28 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Features:
- 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

View File

@ -150,6 +150,13 @@ GameController::GameController(QObject* parent)
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()));
@ -443,6 +450,16 @@ void GameController::rewind(int states) {
emit frameAvailable(m_drawContext);
}
void GameController::startRewinding() {
threadInterrupt();
m_rewindTimer.start();
}
void GameController::stopRewinding() {
m_rewindTimer.stop();
threadContinue();
}
void GameController::keyPressed(int key) {
int mappedKey = 1 << key;
m_activeKeys |= mappedKey;

View File

@ -11,6 +11,7 @@
#include <QObject>
#include <QMutex>
#include <QString>
#include <QTimer>
#include <memory>
@ -108,6 +109,8 @@ public slots:
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 @@ private:
bool m_turbo;
bool m_turboForced;
float m_turboSpeed;
QTimer m_rewindTimer;
int m_stateSlot;

View File

@ -800,6 +800,12 @@ void Window::setupMenu(QMenuBar* menubar) {
}
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()));