@@ -60,11 +60,11 @@ InputRecording g_InputRecording;
60
60
InputRecording::InputRecording ()
61
61
{
62
62
// NOTE - No multi-tap support, only two controllers
63
- padData[CONTROLLER_PORT_ONE] = new PadData ();
64
- padData[CONTROLLER_PORT_TWO] = new PadData ();
63
+ padData[CONTROLLER_PORT_ONE] = new PadData ();
64
+ padData[CONTROLLER_PORT_TWO] = new PadData ();
65
65
}
66
66
67
- void InputRecording::setVirtualPadPtr (VirtualPad * ptr, int const port)
67
+ void InputRecording::setVirtualPadPtr (VirtualPad* ptr, int const port)
68
68
{
69
69
virtualPads[port] = ptr;
70
70
}
@@ -85,62 +85,53 @@ void InputRecording::RecordingReset()
85
85
g_InputRecordingControls.Resume ();
86
86
}
87
87
88
- void InputRecording::ControllerInterrupt (u8 & data, u8 & port, u16 & bufCount, u8 buf[])
88
+ void InputRecording::ControllerInterrupt (u8& data, u8& port, u16& bufCount, u8 buf[])
89
89
{
90
90
// TODO - Multi-Tap Support
91
91
92
92
if (bufCount == 1 )
93
93
fInterruptFrame = data == READ_DATA_AND_VIBRATE_FIRST_BYTE;
94
- else if (bufCount == 2 )
95
- {
96
- if (buf[bufCount] != READ_DATA_AND_VIBRATE_SECOND_BYTE)
97
- fInterruptFrame = false ;
98
- }
94
+ else if (bufCount == 2 && buf[bufCount] != READ_DATA_AND_VIBRATE_SECOND_BYTE)
95
+ fInterruptFrame = false ;
96
+
99
97
// We do not want to record or save the first two bytes in the data returned from the PAD plugin
100
98
else if (fInterruptFrame && bufCount >= 3 && frameCounter >= 0 && frameCounter < INT_MAX)
101
99
{
102
- u8 & bufVal = buf[bufCount];
103
- const u16 bufIndex = bufCount - 3 ;
100
+ u8& bufVal = buf[bufCount];
101
+ const u16 bufIndex = bufCount - 3 ;
104
102
105
103
if (state == InputRecordingMode::Replaying)
106
104
{
107
105
u8 tmp = 0 ;
108
106
if (inputRecordingData.ReadKeyBuffer (tmp, frameCounter, port, bufIndex))
109
- {
110
- // Overwrite value originally provided by the PAD plugin
111
- bufVal = tmp;
112
- // Update controller data state for future VirtualPad / logging usage.
113
- padData[port]->UpdateControllerData (bufIndex, bufVal);
114
- if (virtualPads[port] && virtualPads[port]->IsShown ())
115
- {
116
- virtualPads[port]->UpdateControllerData (bufIndex, padData[port]);
117
- }
118
- }
107
+ {
108
+ // Overwrite value originally provided by the PAD plugin
109
+ bufVal = tmp;
110
+ }
119
111
}
120
112
121
113
// Update controller data state for future VirtualPad / logging usage.
122
114
padData[port]->UpdateControllerData (bufIndex, bufVal);
123
115
124
- if (virtualPads[port] && virtualPads[port]->IsShown ())
116
+ if (virtualPads[port] &&
117
+ virtualPads[port]->IsShown () &&
118
+ virtualPads[port]->UpdateControllerData (bufIndex, padData[port]) &&
119
+ state != InputRecordingMode::Replaying)
125
120
{
126
121
// If the VirtualPad updated the PadData, we have to update the buffer
127
122
// before committing it to the recording / sending it to the game
128
123
// - Do not do this if we are in replay mode!
129
- if (virtualPads[port]->UpdateControllerData (bufIndex, padData[port]) && state != InputRecordingMode::Replaying)
130
- {
131
- bufVal = padData[port]->PollControllerData (bufIndex);
132
- }
124
+ bufVal = padData[port]->PollControllerData (bufIndex);
133
125
}
134
126
135
127
// If we have reached the end of the pad data, log it out
136
- if (bufIndex == PadData::END_INDEX_CONTROLLER_BUFFER) {
128
+ if (bufIndex == PadData::END_INDEX_CONTROLLER_BUFFER)
129
+ {
137
130
padData[port]->LogPadData (port);
138
131
// As well as re-render the virtual pad UI, if applicable
139
132
// - Don't render if it's minimized
140
133
if (virtualPads[port] && virtualPads[port]->IsShown () && !virtualPads[port]->IsIconized ())
141
- {
142
134
virtualPads[port]->Redraw ();
143
- }
144
135
}
145
136
146
137
// Finally, commit the byte to the movie file if we are recording
@@ -161,7 +152,7 @@ s32 InputRecording::GetFrameCounter()
161
152
return frameCounter;
162
153
}
163
154
164
- InputRecordingFile & InputRecording::GetInputRecordingData ()
155
+ InputRecordingFile& InputRecording::GetInputRecordingData ()
165
156
{
166
157
return inputRecordingData;
167
158
}
@@ -223,17 +214,21 @@ wxString InputRecording::RecordingModeTitleSegment()
223
214
void InputRecording::SetToRecordMode ()
224
215
{
225
216
state = InputRecordingMode::Recording;
217
+ virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode (false );
218
+ virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode (false );
226
219
recordingConLog (" [REC]: Record mode ON.\n " );
227
220
}
228
221
229
222
void InputRecording::SetToReplayMode ()
230
223
{
231
224
state = InputRecordingMode::Replaying;
225
+ virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode (true );
226
+ virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode (true );
232
227
recordingConLog (" [REC]: Replay mode ON.\n " );
233
228
}
234
229
235
230
void InputRecording::SetFrameCounter (u32 newGFrameCount)
236
- {
231
+ {
237
232
if (newGFrameCount > startingFrame + (u32)g_InputRecording.GetInputRecordingData ().GetTotalFrames ())
238
233
{
239
234
recordingConLog (L" [REC]: Warning, you've loaded PCSX2 emulation to a point after the end of the original recording. This should be avoided.\n " );
@@ -272,6 +267,8 @@ void InputRecording::SetStartingFrame(u32 newStartingFrame)
272
267
void InputRecording::Stop ()
273
268
{
274
269
state = InputRecordingMode::NotActive;
270
+ virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode (false );
271
+ virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode (false );
275
272
incrementUndo = false ;
276
273
if (inputRecordingData.Close ())
277
274
recordingConLog (L" [REC]: InputRecording Recording Stopped.\n " );
@@ -303,7 +300,7 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
303
300
inputRecordingData.GetHeader ().SetGameName (resolveGameName ());
304
301
// Write header contents
305
302
inputRecordingData.WriteHeader ();
306
- state = InputRecordingMode::Recording ;
303
+ SetToRecordMode () ;
307
304
g_InputRecordingControls.DisableFrameAdvance ();
308
305
recordingConLog (wxString::Format (L" [REC]: Started new recording - [%s]\n " , FileName));
309
306
return true ;
@@ -328,8 +325,8 @@ bool InputRecording::Play(wxString fileName)
328
325
}
329
326
if (!wxFileExists (inputRecordingData.GetFilename () + " _SaveState.p2s" ))
330
327
{
331
- recordingConLog (wxString::Format (" [REC]: Could not locate savestate file at location - %s_SaveState.p2s\n " ,
332
- inputRecordingData.GetFilename ()));
328
+ recordingConLog (wxString::Format (" [REC]: Could not locate savestate file at location - %s_SaveState.p2s\n " ,
329
+ inputRecordingData.GetFilename ()));
333
330
inputRecordingData.Close ();
334
331
return false ;
335
332
}
@@ -348,7 +345,7 @@ bool InputRecording::Play(wxString fileName)
348
345
recordingConLog (L" [REC]: Recording was possibly constructed for a different game.\n " );
349
346
350
347
incrementUndo = true ;
351
- state = InputRecordingMode::Replaying ;
348
+ SetToReplayMode () ;
352
349
g_InputRecordingControls.DisableFrameAdvance ();
353
350
recordingConLog (wxString::Format (L" [REC]: Replaying input recording - [%s]\n " , inputRecordingData.GetFilename ()));
354
351
recordingConLog (wxString::Format (L" [REC]: PCSX2 Version Used: %s\n " , inputRecordingData.GetHeader ().emu ));
@@ -380,4 +377,4 @@ wxString InputRecording::resolveGameName()
380
377
return !gameName.IsEmpty () ? gameName : Path::GetFilename (g_Conf->CurrentIso );
381
378
}
382
379
383
- #endif
380
+ #endif
0 commit comments