mirror of https://github.com/PCSX2/pcsx2.git
recording: Update controller interrupt to handle both the VirtualPad and the movie
vs: solution updates for new folders / filters / files
This commit is contained in:
parent
0728acaf55
commit
ed829d427c
|
@ -51,9 +51,22 @@ void SaveStateBase::InputRecordingFreeze()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef DISABLE_RECORDING
|
||||
InputRecording g_InputRecording;
|
||||
|
||||
InputRecording::InputRecording()
|
||||
{
|
||||
// NOTE - No multi-tap support, only two controllers
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
padData[i] = new PadData();
|
||||
}
|
||||
}
|
||||
|
||||
void InputRecording::setVirtualPadPtr(VirtualPad *ptr, int port)
|
||||
{
|
||||
virtualPads[port] = ptr;
|
||||
}
|
||||
|
||||
void InputRecording::RecordingReset()
|
||||
{
|
||||
// Booting is an asynchronous task. If we are playing a recording
|
||||
|
@ -98,6 +111,9 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
|
|||
// We do not want to record or save the first two bytes in the data returned from the PAD plugin
|
||||
else if (fInterruptFrame && bufCount >= 3 && frameCounter >= 0 && frameCounter < INT_MAX)
|
||||
{
|
||||
u8 &bufVal = buf[bufCount];
|
||||
const u16 bufIndex = bufCount - 3;
|
||||
|
||||
// Read or Write
|
||||
if (state == InputRecordingMode::Recording)
|
||||
{
|
||||
|
@ -106,14 +122,53 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
|
|||
inputRecordingData.IncrementUndoCount();
|
||||
incrementUndo = false;
|
||||
}
|
||||
inputRecordingData.WriteKeyBuffer(frameCounter, port, bufCount - 3, buf[bufCount]);
|
||||
inputRecordingData.WriteKeyBuffer(frameCounter, port, bufIndex, buf[bufCount]);
|
||||
}
|
||||
else if (state == InputRecordingMode::Replaying)
|
||||
{
|
||||
u8 tmp = 0;
|
||||
if (inputRecordingData.ReadKeyBuffer(tmp, frameCounter, port, bufCount - 3))
|
||||
buf[bufCount] = tmp;
|
||||
if (inputRecordingData.ReadKeyBuffer(tmp, frameCounter, port, bufIndex))
|
||||
{
|
||||
// Overwrite value originally provided by the PAD plugin
|
||||
bufVal = tmp;
|
||||
// Update controller data state for future VirtualPad / logging usage.
|
||||
padData[port]->UpdateControllerData(bufIndex, bufVal);
|
||||
if (virtualPads[port] != NULL && virtualPads[port]->IsShown())
|
||||
{
|
||||
virtualPads[port]->UpdateControllerData(bufIndex, padData[port]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Update controller data state for future VirtualPad / logging usage.
|
||||
padData[port]->UpdateControllerData(bufIndex, bufVal);
|
||||
|
||||
if (virtualPads[port] != NULL && virtualPads[port]->IsShown())
|
||||
{
|
||||
// If the VirtualPad updated the PadData, we have to update the buffer
|
||||
// before committing it to the recording / sending it to the game
|
||||
if (virtualPads[port]->UpdateControllerData(bufIndex, padData[port]))
|
||||
{
|
||||
bufVal = padData[port]->PollControllerData(bufIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// If we have reached the end of the pad data, log it out
|
||||
if (bufIndex == 17) { // TODO constant for end
|
||||
padData[port]->LogPadData();
|
||||
if (virtualPads[port] != NULL && virtualPads[port]->IsShown())
|
||||
{
|
||||
virtualPads[port]->Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, commit the byte to the movie file if we are recording
|
||||
if (state == INPUT_RECORDING_MODE_RECORD)
|
||||
{
|
||||
InputRecordingData.UpdateFrameMax(g_FrameCount);
|
||||
InputRecordingData.WriteKeyBuf(g_FrameCount, port, bufIndex, bufVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,5 +395,3 @@ wxString InputRecording::resolveGameName()
|
|||
}
|
||||
return !gameName.IsEmpty() ? gameName : Path::GetFilename(g_Conf->CurrentIso);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
class InputRecording
|
||||
{
|
||||
public:
|
||||
InputRecording();
|
||||
|
||||
// Save or load PCSX2's global frame counter (g_FrameCount) along with each full/fast boot
|
||||
//
|
||||
// This is to prevent any inaccuracy issues caused by having a different
|
||||
|
@ -85,6 +87,8 @@ public:
|
|||
// Stop the active input recording
|
||||
void Stop();
|
||||
|
||||
void setVirtualPadPtr(VirtualPad *ptr, int port);
|
||||
|
||||
private:
|
||||
enum class InputRecordingMode
|
||||
{
|
||||
|
@ -101,8 +105,13 @@ private:
|
|||
s32 frameCounter = 0;
|
||||
bool incrementUndo = false;
|
||||
InputRecordingMode state = InputRecording::InputRecordingMode::NotActive;
|
||||
|
||||
|
||||
// Controller Data
|
||||
PadData *padData[2];
|
||||
|
||||
// VirtualPad
|
||||
VirtualPad *virtualPads[2];
|
||||
|
||||
// Resolve the name and region of the game currently loaded using the GameDB
|
||||
// If the game cannot be found in the DB, the fallback is the ISO filename
|
||||
wxString resolveGameName();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
|
@ -206,14 +206,15 @@
|
|||
<ClCompile Include="..\..\ps2\LegacyDmac.cpp" />
|
||||
<ClCompile Include="..\..\ps2\pgif.cpp" />
|
||||
<ClCompile Include="..\..\Recording\InputRecordingControls.cpp" />
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPad.cpp" />
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPadData.cpp" />
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPadResources.cpp" />
|
||||
<ClCompile Include="..\..\ShiftJisToUnicode.cpp" />
|
||||
<ClCompile Include="..\..\sif2.cpp" />
|
||||
<ClCompile Include="..\..\Recording\InputRecording.cpp" />
|
||||
<ClCompile Include="..\..\Recording\NewRecordingFrame.cpp" />
|
||||
<ClCompile Include="..\..\Recording\InputRecordingFile.cpp" />
|
||||
<ClCompile Include="..\..\Recording\PadData.cpp" />
|
||||
<ClCompile Include="..\..\Recording\RecordingInputManager.cpp" />
|
||||
<ClCompile Include="..\..\Recording\VirtualPad.cpp" />
|
||||
<ClCompile Include="..\..\Utilities\FileUtils.cpp" />
|
||||
<ClCompile Include="..\..\Dump.cpp" />
|
||||
<ClCompile Include="..\..\x86\iMisc.cpp" />
|
||||
|
@ -451,8 +452,9 @@
|
|||
<ClInclude Include="..\..\Recording\NewRecordingFrame.h" />
|
||||
<ClInclude Include="..\..\Recording\InputRecordingFile.h" />
|
||||
<ClInclude Include="..\..\Recording\PadData.h" />
|
||||
<ClInclude Include="..\..\Recording\RecordingInputManager.h" />
|
||||
<ClInclude Include="..\..\Recording\VirtualPad.h" />
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPad.h" />
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadData.h" />
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadResources.h" />
|
||||
<ClInclude Include="..\..\Utilities\AsciiFile.h" />
|
||||
<ClInclude Include="..\..\Elfheader.h" />
|
||||
<ClInclude Include="..\..\CDVD\IsoFileFormats.h" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Misc">
|
||||
|
@ -148,6 +148,9 @@
|
|||
<Filter Include="Recording\gui">
|
||||
<UniqueIdentifier>{93e36831-627f-4529-b709-1f4bad398512}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Recording\VirtualPad">
|
||||
<UniqueIdentifier>{ae88cd9a-f9f2-4196-979c-7a16ed5e455e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="System\Ps2\Iop\CDVD\Windows">
|
||||
<UniqueIdentifier>{be861049-a142-4650-85a5-a2fdd4eef011}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -856,14 +859,11 @@
|
|||
<ClCompile Include="..\..\Recording\PadData.cpp">
|
||||
<Filter>Recording</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Recording\RecordingInputManager.cpp">
|
||||
<Filter>Recording</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Recording\NewRecordingFrame.cpp">
|
||||
<Filter>Recording\gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Recording\VirtualPad.cpp">
|
||||
<Filter>Recording\gui</Filter>
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPad.cpp">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\IPU\IPUdither.cpp">
|
||||
<Filter>System\Ps2\IPU</Filter>
|
||||
|
@ -871,6 +871,12 @@
|
|||
<ClCompile Include="..\..\Recording\InputRecordingControls.cpp">
|
||||
<Filter>Recording</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPadData.cpp">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Recording\VirtualPad\VirtualPadResources.cpp">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CDVD\CDVDdiscReader.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1335,18 +1341,21 @@
|
|||
<ClInclude Include="..\..\Recording\PadData.h">
|
||||
<Filter>Recording</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\RecordingInputManager.h">
|
||||
<Filter>Recording</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\NewRecordingFrame.h">
|
||||
<Filter>Recording\gui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\VirtualPad.h">
|
||||
<Filter>Recording\gui</Filter>
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPad.h">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\InputRecordingControls.h">
|
||||
<Filter>Recording</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadData.h">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadResources.h">
|
||||
<Filter>Recording\VirtualPad</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\CDVD\CDVDdiscReader.h">
|
||||
<Filter>System\Ps2\Iop\CDVD</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue