From e49dcc0cb27a44ab5e1b5a6c86b941896b7009f3 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 16 Jun 2018 17:31:41 -0500 Subject: [PATCH] GTK+, Unix: Preserve current joypad state when rewinding. --- gtk/src/gtk_s9x.cpp | 9 +++++++++ unix/unix.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/gtk/src/gtk_s9x.cpp b/gtk/src/gtk_s9x.cpp index 2dc26e90..2c752bb5 100644 --- a/gtk/src/gtk_s9x.cpp +++ b/gtk/src/gtk_s9x.cpp @@ -352,7 +352,16 @@ S9xIdleFunc (gpointer data) #endif if(Settings.Rewinding) + { + uint16 joypads[8]; + for (int i = 0; i < 8; i++) + joypads[i] = MovieGetJoypad(i); + Settings.Rewinding = stateMan.pop(); + + for (int i = 0; i < 8; i++) + MovieSetJoypad (i, joypads[i]); + } else if(IPPU.TotalEmulatedFrames % gui_config->rewind_granularity == 0) stateMan.push(); diff --git a/unix/unix.cpp b/unix/unix.cpp index c0c79596..676b8f6c 100644 --- a/unix/unix.cpp +++ b/unix/unix.cpp @@ -1952,7 +1952,16 @@ int main (int argc, char **argv) #endif { if(rewinding) + { + uint16 joypads[8]; + for (int i = 0; i < 8; i++) + joypads[i] = MovieGetJoypad(i); + rewinding = stateMan.pop(); + + for (int i = 0; i < 8; i++) + MovieSetJoypad (i, joypads[i]); + } else if(IPPU.TotalEmulatedFrames % unixSettings.rewindGranularity == 0) stateMan.push();