mirror of https://github.com/mgba-emu/mgba.git
Qt: Holdable shortcut for rewinding one frame at a time
This commit is contained in:
parent
4c5cdcaa4e
commit
7e411fda30
1
CHANGES
1
CHANGES
|
@ -19,6 +19,7 @@ Features:
|
||||||
- Support varible speed (PWM) rumble
|
- Support varible speed (PWM) rumble
|
||||||
- Ability to cap fast forward speed
|
- Ability to cap fast forward speed
|
||||||
- Finer control over FPS target
|
- Finer control over FPS target
|
||||||
|
- Holdable shortcut for rewinding one frame at a time
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- ARM7: Fix SWI and IRQ timings
|
- ARM7: Fix SWI and IRQ timings
|
||||||
- GBA Audio: Force audio FIFOs to 32-bit
|
- GBA Audio: Force audio FIFOs to 32-bit
|
||||||
|
|
|
@ -150,6 +150,13 @@ GameController::GameController(QObject* parent)
|
||||||
controller->postLog(level, message);
|
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_audioThread->start(QThread::TimeCriticalPriority);
|
||||||
m_audioProcessor->moveToThread(m_audioThread);
|
m_audioProcessor->moveToThread(m_audioThread);
|
||||||
connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start()));
|
connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start()));
|
||||||
|
@ -443,6 +450,16 @@ void GameController::rewind(int states) {
|
||||||
emit frameAvailable(m_drawContext);
|
emit frameAvailable(m_drawContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::startRewinding() {
|
||||||
|
threadInterrupt();
|
||||||
|
m_rewindTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::stopRewinding() {
|
||||||
|
m_rewindTimer.stop();
|
||||||
|
threadContinue();
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::keyPressed(int key) {
|
void GameController::keyPressed(int key) {
|
||||||
int mappedKey = 1 << key;
|
int mappedKey = 1 << key;
|
||||||
m_activeKeys |= mappedKey;
|
m_activeKeys |= mappedKey;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -108,6 +109,8 @@ public slots:
|
||||||
void frameAdvance();
|
void frameAdvance();
|
||||||
void setRewind(bool enable, int capacity, int interval);
|
void setRewind(bool enable, int capacity, int interval);
|
||||||
void rewind(int states = 0);
|
void rewind(int states = 0);
|
||||||
|
void startRewinding();
|
||||||
|
void stopRewinding();
|
||||||
void keyPressed(int key);
|
void keyPressed(int key);
|
||||||
void keyReleased(int key);
|
void keyReleased(int key);
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
|
@ -183,6 +186,7 @@ private:
|
||||||
bool m_turbo;
|
bool m_turbo;
|
||||||
bool m_turboForced;
|
bool m_turboForced;
|
||||||
float m_turboSpeed;
|
float m_turboSpeed;
|
||||||
|
QTimer m_rewindTimer;
|
||||||
|
|
||||||
int m_stateSlot;
|
int m_stateSlot;
|
||||||
|
|
||||||
|
|
|
@ -800,6 +800,12 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
}
|
}
|
||||||
m_config->updateOption("fastForwardRatio");
|
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);
|
QAction* rewind = new QAction(tr("Re&wind"), emulationMenu);
|
||||||
rewind->setShortcut(tr("`"));
|
rewind->setShortcut(tr("`"));
|
||||||
connect(rewind, SIGNAL(triggered()), m_controller, SLOT(rewind()));
|
connect(rewind, SIGNAL(triggered()), m_controller, SLOT(rewind()));
|
||||||
|
|
Loading…
Reference in New Issue