input-rec: remove frame-advance and adjust folder structure

This commit is contained in:
Tyler Wilding 2022-04-04 17:35:08 -04:00 committed by Tyler Wilding
parent 4f0c880e3e
commit 2aec91d8c0
13 changed files with 36 additions and 46 deletions

View File

@ -101,9 +101,9 @@ target_sources(pcsx2-qt PRIVATE
Settings/SystemSettingsWidget.cpp Settings/SystemSettingsWidget.cpp
Settings/SystemSettingsWidget.h Settings/SystemSettingsWidget.h
Settings/SystemSettingsWidget.ui Settings/SystemSettingsWidget.ui
input-rec/NewInputRecordingDlg.cpp Tools/InputRecording/NewInputRecordingDlg.cpp
input-rec/NewInputRecordingDlg.h Tools/InputRecording/NewInputRecordingDlg.h
input-rec/NewInputRecordingDlg.ui Tools/InputRecording/NewInputRecordingDlg.ui
resources/resources.qrc resources/resources.qrc
) )

View File

@ -976,13 +976,4 @@ DEFINE_HOTKEY("InputRecToggleMode", "Input Recording", "Toggle Recording Mode",
g_InputRecordingControls.RecordModeToggle(); g_InputRecordingControls.RecordModeToggle();
} }
}) })
// TODO - Vaser - the way the pause/resuming used to work is broken on Qt, needs a rewrite.
// - Currently if you frame advance you can't get out of frame advancing!
DEFINE_HOTKEY("InputRecFrameAdvance", "Input Recording", "Frame Advance", [](bool pressed) {
if (!pressed) // ?? - not pressed so it is on key up?
{
g_InputRecordingControls.FrameAdvance();
g_InputRecordingControls.ResumeCoreThreadIfStarted();
}
})
END_HOTKEY_LIST() END_HOTKEY_LIST()

View File

@ -39,7 +39,6 @@
#include "EmuThread.h" #include "EmuThread.h"
#include "GameList/GameListRefreshThread.h" #include "GameList/GameListRefreshThread.h"
#include "GameList/GameListWidget.h" #include "GameList/GameListWidget.h"
#include "input-rec/NewInputRecordingDlg.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "QtHost.h" #include "QtHost.h"
#include "QtUtils.h" #include "QtUtils.h"
@ -48,6 +47,7 @@
#include "Settings/InterfaceSettingsWidget.h" #include "Settings/InterfaceSettingsWidget.h"
#include "SettingWidgetBinder.h" #include "SettingWidgetBinder.h"
#include "svnrev.h" #include "svnrev.h"
#include "Tools/InputRecording/NewInputRecordingDlg.h"
static constexpr char DISC_IMAGE_FILTER[] = static constexpr char DISC_IMAGE_FILTER[] =
@ -1194,8 +1194,8 @@ void MainWindow::onLoggingOptionChanged()
void MainWindow::onInputRecNewActionTriggered() void MainWindow::onInputRecNewActionTriggered()
{ {
const bool wasPaused = VMManager::GetState() == VMState::Paused; const bool wasPaused = m_vm_paused;
const bool wasRunning = VMManager::GetState() == VMState::Running; const bool wasRunning = m_vm_valid;
if (wasRunning && !wasPaused) if (wasRunning && !wasPaused)
{ {
VMManager::SetPaused(true); VMManager::SetPaused(true);
@ -1225,7 +1225,7 @@ void MainWindow::onInputRecNewActionTriggered()
void MainWindow::onInputRecPlayActionTriggered() void MainWindow::onInputRecPlayActionTriggered()
{ {
const bool wasPaused = VMManager::GetState() == VMState::Paused; const bool wasPaused = m_vm_paused;
if (!wasPaused) if (!wasPaused)
g_InputRecordingControls.PauseImmediately(); g_InputRecordingControls.PauseImmediately();
@ -1246,7 +1246,7 @@ void MainWindow::onInputRecPlayActionTriggered()
{ {
g_InputRecording.Stop(); g_InputRecording.Stop();
} }
if (g_InputRecording.Play(fs::path(fileNames.first().toStdString()))) if (g_InputRecording.Play(fileNames.first().toStdString()))
{ {
return; return;
} }

View File

@ -45,7 +45,7 @@
<AdditionalIncludeDirectories>$(SolutionDir)3rdparty\lzma\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\lzma\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)pcsx2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)pcsx2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<!-- Needed for moc pch --> <!-- Needed for moc pch -->
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(ProjectDir)\Settings;$(ProjectDir)\GameList;$(ProjectDir)\input-rec</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(ProjectDir)\Settings;$(ProjectDir)\GameList;$(ProjectDir)\Tools\InputRecording</AdditionalIncludeDirectories>
<ExceptionHandling>Async</ExceptionHandling> <ExceptionHandling>Async</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>PrecompiledHeader.h</PrecompiledHeaderFile>
@ -134,7 +134,7 @@
<Manifest Include="..\pcsx2\windows\PCSX2.manifest" /> <Manifest Include="..\pcsx2\windows\PCSX2.manifest" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="input-rec\NewInputRecordingDlg.cpp" /> <ClCompile Include="Tools\InputRecording\NewInputRecordingDlg.cpp" />
<ClCompile Include="Settings\BIOSSettingsWidget.cpp" /> <ClCompile Include="Settings\BIOSSettingsWidget.cpp" />
<ClCompile Include="Settings\ControllerBindingWidgets.cpp" /> <ClCompile Include="Settings\ControllerBindingWidgets.cpp" />
<ClCompile Include="Settings\ControllerGlobalSettingsWidget.cpp" /> <ClCompile Include="Settings\ControllerGlobalSettingsWidget.cpp" />
@ -195,7 +195,7 @@
<QtMoc Include="GameList\GameListModel.h" /> <QtMoc Include="GameList\GameListModel.h" />
<QtMoc Include="GameList\GameListWidget.h" /> <QtMoc Include="GameList\GameListWidget.h" />
<QtMoc Include="GameList\GameListRefreshThread.h" /> <QtMoc Include="GameList\GameListRefreshThread.h" />
<QtMoc Include="input-rec\NewInputRecordingDlg.h" /> <QtMoc Include="Tools\InputRecording\NewInputRecordingDlg.h" />
<ClInclude Include="QtUtils.h" /> <ClInclude Include="QtUtils.h" />
<QtMoc Include="Settings\ControllerBindingWidgets.h" /> <QtMoc Include="Settings\ControllerBindingWidgets.h" />
<QtMoc Include="Settings\ControllerGlobalSettingsWidget.h" /> <QtMoc Include="Settings\ControllerGlobalSettingsWidget.h" />
@ -242,7 +242,7 @@
<ClCompile Include="$(IntDir)moc_DisplayWidget.cpp" /> <ClCompile Include="$(IntDir)moc_DisplayWidget.cpp" />
<ClCompile Include="$(IntDir)moc_EmuThread.cpp" /> <ClCompile Include="$(IntDir)moc_EmuThread.cpp" />
<ClCompile Include="$(IntDir)moc_MainWindow.cpp" /> <ClCompile Include="$(IntDir)moc_MainWindow.cpp" />
<ClCompile Include="$(IntDir)input-rec\moc_NewInputRecordingDlg.cpp" /> <ClCompile Include="$(IntDir)Tools\InputRecording\moc_NewInputRecordingDlg.cpp" />
<ClCompile Include="$(IntDir)qrc_resources.cpp"> <ClCompile Include="$(IntDir)qrc_resources.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>
@ -314,7 +314,7 @@
<QtUi Include="AutoUpdaterDialog.ui"> <QtUi Include="AutoUpdaterDialog.ui">
<FileType>Document</FileType> <FileType>Document</FileType>
</QtUi> </QtUi>
<QtUi Include="input-rec\NewInputRecordingDlg.ui"> <QtUi Include="Tools\InputRecording\NewInputRecordingDlg.ui">
<FileType>Document</FileType> <FileType>Document</FileType>
</QtUi> </QtUi>
</ItemGroup> </ItemGroup>

View File

@ -198,10 +198,10 @@
<ClCompile Include="$(IntDir)moc_AutoUpdaterDialog.cpp"> <ClCompile Include="$(IntDir)moc_AutoUpdaterDialog.cpp">
<Filter>moc</Filter> <Filter>moc</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(IntDir)input-rec\moc_NewInputRecordingDlg.cpp"> <ClCompile Include="$(IntDir)Tools\InputRecording\moc_NewInputRecordingDlg.cpp">
<Filter>moc</Filter> <Filter>moc</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="input-rec\NewInputRecordingDlg.cpp"> <ClCompile Include="Tools\InputRecording\NewInputRecordingDlg.cpp">
<Filter>Tools\Input Recording</Filter> <Filter>Tools\Input Recording</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -294,7 +294,7 @@
<Filter>Settings</Filter> <Filter>Settings</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="AutoUpdaterDialog.h" /> <QtMoc Include="AutoUpdaterDialog.h" />
<QtMoc Include="input-rec\NewInputRecordingDlg.h"> <QtMoc Include="Tools\InputRecording\NewInputRecordingDlg.h">
<Filter>Tools\Input Recording</Filter> <Filter>Tools\Input Recording</Filter>
</QtMoc> </QtMoc>
</ItemGroup> </ItemGroup>
@ -366,7 +366,7 @@
<Filter>GameList</Filter> <Filter>GameList</Filter>
</QtUi> </QtUi>
<QtUi Include="AutoUpdaterDialog.ui" /> <QtUi Include="AutoUpdaterDialog.ui" />
<QtUi Include="input-rec\NewInputRecordingDlg.ui"> <QtUi Include="Tools\InputRecording\NewInputRecordingDlg.ui">
<Filter>Tools\Input Recording</Filter> <Filter>Tools\Input Recording</Filter>
</QtUi> </QtUi>
</ItemGroup> </ItemGroup>

View File

@ -465,6 +465,7 @@ wxString InputRecording::resolveGameName()
#else #else
#include "common/FileSystem.h"
#include "common/StringUtil.h" #include "common/StringUtil.h"
#include "SaveState.h" #include "SaveState.h"
#include "Counters.h" #include "Counters.h"
@ -742,9 +743,9 @@ bool InputRecording::Create(const std::string_view& fileName, const bool fromSav
if (fromSaveState) if (fromSaveState)
{ {
savestate = fmt::format("{}_SaveState.p2s", fileName); savestate = fmt::format("{}_SaveState.p2s", fileName);
if (fs::exists(savestate)) if (FileSystem::FileExists(savestate.c_str()))
{ {
fs::copy_file(savestate, fmt::format("{}.bak", savestate)); FileSystem::CopyFilePath(savestate.c_str(), fmt::format("{}.bak", savestate).c_str(), true);
} }
VMManager::SaveState(savestate.c_str()); VMManager::SaveState(savestate.c_str());
} }
@ -768,7 +769,7 @@ bool InputRecording::Create(const std::string_view& fileName, const bool fromSav
return true; return true;
} }
bool InputRecording::Play(const fs::path& filename) bool InputRecording::Play(const std::string_view& filename)
{ {
if (!inputRecordingData.OpenExisting(filename)) if (!inputRecordingData.OpenExisting(filename))
return false; return false;
@ -785,7 +786,7 @@ bool InputRecording::Play(const fs::path& filename)
} }
savestate = fmt::format("{}_SaveState.p2s", inputRecordingData.GetFilename()); savestate = fmt::format("{}_SaveState.p2s", inputRecordingData.GetFilename());
if (!fs::exists(savestate)) if (!FileSystem::FileExists(savestate.c_str()))
{ {
inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestate)); inputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestate));
inputRec::log("Savestate load failed"); inputRec::log("Savestate load failed");
@ -809,8 +810,7 @@ bool InputRecording::Play(const fs::path& filename)
std::string InputRecording::resolveGameName() std::string InputRecording::resolveGameName()
{ {
std::string gameName; std::string gameName;
// TODO - Vaser - there is probably a way to get rid of the wx usage here i imagine const std::string gameKey = SysGetDiscID();
const std::string gameKey(StringUtil::wxStringToUTF8String(SysGetDiscID()));
if (!gameKey.empty()) if (!gameKey.empty())
{ {
auto game = GameDatabase::findGame(gameKey); auto game = GameDatabase::findGame(gameKey);
@ -820,7 +820,6 @@ std::string InputRecording::resolveGameName()
gameName += " (" + game->region + ")"; gameName += " (" + game->region + ")";
} }
} }
// TODO - Vaser - there is probably a way to get rid of the wx usage here i imagine
return !gameName.empty() ? gameName : VMManager::GetGameName(); return !gameName.empty() ? gameName : VMManager::GetGameName();
} }

View File

@ -216,7 +216,7 @@ public:
bool Create(const std::string_view& filename, const bool fromSaveState, const std::string_view& authorName); bool Create(const std::string_view& filename, const bool fromSaveState, const std::string_view& authorName);
// Play an existing input recording from a file // Play an existing input recording from a file
// TODO - Vaser - Calls a file dialog if it fails to locate the default base savestate // TODO - Vaser - Calls a file dialog if it fails to locate the default base savestate
bool Play(const fs::path& path); bool Play(const std::string_view& path);
// Stop the active input recording // Stop the active input recording
void Stop(); void Stop();
// Logs the padData and redraws the virtualPad windows of active pads // Logs the padData and redraws the virtualPad windows of active pads

View File

@ -318,24 +318,24 @@ void InputRecordingFile::IncrementUndoCount()
fwrite(&undoCount, 4, 1, recordingFile); fwrite(&undoCount, 4, 1, recordingFile);
} }
bool InputRecordingFile::open(const fs::path& path, bool newRecording) bool InputRecordingFile::open(const std::string_view& path, bool newRecording)
{ {
if (newRecording) if (newRecording)
{ {
if ((recordingFile = FileSystem::OpenCFile(path.string().c_str(), "wb+")) != nullptr) if ((recordingFile = FileSystem::OpenCFile(path.data(), "wb+")) != nullptr)
{ {
filename = path.string(); filename = path;
totalFrames = 0; totalFrames = 0;
undoCount = 0; undoCount = 0;
header.Init(); header.Init();
return true; return true;
} }
} }
else if ((recordingFile = FileSystem::OpenCFile(path.string().c_str(), "rb+")) != nullptr) else if ((recordingFile = FileSystem::OpenCFile(path.data(), "rb+")) != nullptr)
{ {
if (verifyRecordingFileHeader()) if (verifyRecordingFileHeader())
{ {
filename = path.string(); filename = path;
return true; return true;
} }
Close(); Close();
@ -346,7 +346,7 @@ bool InputRecordingFile::open(const fs::path& path, bool newRecording)
return false; return false;
} }
bool InputRecordingFile::OpenNew(const fs::path& path, bool fromSavestate) bool InputRecordingFile::OpenNew(const std::string_view& path, bool fromSavestate)
{ {
if (!open(path, true)) if (!open(path, true))
return false; return false;
@ -354,7 +354,7 @@ bool InputRecordingFile::OpenNew(const fs::path& path, bool fromSavestate)
return true; return true;
} }
bool InputRecordingFile::OpenExisting(const fs::path& path) bool InputRecordingFile::OpenExisting(const std::string_view& path)
{ {
return open(path, false); return open(path, false);
} }

View File

@ -164,10 +164,10 @@ public:
// Increment the number of undo actions and commit it to the recording file // Increment the number of undo actions and commit it to the recording file
void IncrementUndoCount(); void IncrementUndoCount();
// Open an existing recording file // Open an existing recording file
bool OpenExisting(const fs::path& path); bool OpenExisting(const std::string_view& path);
// Create and open a brand new input recording, either starting from a save-state or from // Create and open a brand new input recording, either starting from a save-state or from
// booting the game // booting the game
bool OpenNew(const fs::path& path, bool fromSaveState); bool OpenNew(const std::string_view& path, bool fromSaveState);
// Reads the current frame's input data from the file in order to intercept and overwrite // Reads the current frame's input data from the file in order to intercept and overwrite
// the current frame's value from the emulator // the current frame's value from the emulator
bool ReadKeyBuffer(u8& result, const uint& frame, const uint port, const uint bufIndex); bool ReadKeyBuffer(u8& result, const uint& frame, const uint port, const uint bufIndex);
@ -202,7 +202,7 @@ private:
// Calculates the position of the current frame in the input recording // Calculates the position of the current frame in the input recording
long getRecordingBlockSeekPoint(const long& frame); long getRecordingBlockSeekPoint(const long& frame);
bool open(const fs::path& path, bool newRecording); bool open(const std::string_view& path, bool newRecording);
bool verifyRecordingFileHeader(); bool verifyRecordingFileHeader();
}; };

View File

@ -106,7 +106,7 @@ static const TraceLogDescriptor
TLD_sysoutConsole = {"SYSout", "System Out", "Shows strings printed to the system output stream."}, TLD_sysoutConsole = {"SYSout", "System Out", "Shows strings printed to the system output stream."},
TLD_Pgif = {"PGIFout", "&PGIF Console", "Shows output from pgif the emulated ps1 gpu"} TLD_Pgif = {"PGIFout", "&PGIF Console", "Shows output from pgif the emulated ps1 gpu"},
TLD_recordingConsole = {"Input Recording", "Input Recording Console", "Shows recording related logs and information."}, TLD_recordingConsole = {"Input Recording", "Input Recording Console", "Shows recording related logs and information."},