core, citra_qt: add frame advancing to framelimiter

Frame advancing is a commonly used TAS feature which basically means running the game frame by frame. TASers use this feature to press exact buttons at the exact frames. This commit added frame advancing to the framelimiter and two actions to the Movie menu. The default hotkey is `\` for advancing frames, and `Ctrl+A` for toggling frame advancing. The `Advance Frame` hotkey would automatically enable frame advancing if not already enabled.
This commit is contained in:
zhupengfei 2018-10-01 23:39:22 +08:00
parent 41688b2f2a
commit cb775eb1ba
No known key found for this signature in database
GPG key ID: DD129E108BD09378
4 changed files with 90 additions and 0 deletions

View file

@ -74,6 +74,13 @@ double PerfStats::GetLastFrameTimeScale() {
}
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
if (frame_advancing_enabled) {
// Frame advancing is enabled: wait on event instead of doing framelimiting
frame_advance_event.Wait();
frame_advance_event.Reset();
return;
}
if (!Settings::values.use_frame_limit) {
return;
}
@ -104,4 +111,20 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
previous_walltime = now;
}
void FrameLimiter::SetFrameAdvancing(bool value) {
const bool was_enabled = frame_advancing_enabled.exchange(value);
if (was_enabled && !value) {
// Set the event to let emulation continue
frame_advance_event.Set();
}
}
void FrameLimiter::AdvanceFrame() {
if (!frame_advancing_enabled) {
// Start frame advancing
frame_advancing_enabled = true;
}
frame_advance_event.Set();
}
} // namespace Core