Skip to content

Commit 400ed82

Browse files
xTVaserrefractionpcsx2
authored andcommitted
recording: Many adjustments on VirtualPad from review feedback
recording: Factor in DPIScaling when scaling VirtualPad window recording: Add a reset button, hopefully better quality backgrounds for lower resolutions recording: Improved VPad analog alignment Co-authored-by: sonicfind recording: Some final VirtualPad coordinate adjustments
1 parent 28a4d03 commit 400ed82

18 files changed

+266
-221
lines changed

.gitattributes

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@
66
*.props text eol=crlf
77
*.vcxproj text eol=crlf
88
*.vcxproj.filters text eol=crlf
9-
10-
# Hide generated files for easier pull-request reviewing
11-
pcsx2/Recording/VirtualPad/img/*.h linguist-generated

.github/workflows/linux-workflow.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ jobs:
7878
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
7979
message("::set-output name=timestamp::${current_date}")
8080
81-
# - name: ccache cache files
82-
# uses: actions/cache@v2
83-
# with:
84-
# path: .ccache
85-
# key: ${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
86-
# restore-keys: |
87-
# ${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-ccache-
81+
- name: ccache cache files
82+
uses: actions/cache@v2
83+
with:
84+
path: .ccache
85+
key: ${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
86+
restore-keys: |
87+
${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-ccache-
8888
8989
- name: Install Packages
9090
env:
@@ -102,4 +102,3 @@ jobs:
102102
chmod +x .github/workflows/scripts/build-linux.sh
103103
./.github/workflows/scripts/build-linux.sh generate_cmake
104104
./.github/workflows/scripts/build-linux.sh compile
105-
ls ./pcsx2/Recording/VirtualPad/img

pcsx2/CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,9 @@ set(pcsx2RecordingHeaders
507507
set(res_rec_vp_src "${CMAKE_SOURCE_DIR}/pcsx2/Recording/VirtualPad/img")
508508
set(pcsx2RecordingVirtualPadResources
509509
${res_rec_vp_src}/circlePressed.h
510-
${res_rec_vp_src}/controller.h
510+
${res_rec_vp_src}/controllerFull.h
511+
${res_rec_vp_src}/controllerHalf.h
512+
${res_rec_vp_src}/controllerThreeQuarters.h
511513
${res_rec_vp_src}/crossPressed.h
512514
${res_rec_vp_src}/downPressed.h
513515
${res_rec_vp_src}/l1Pressed.h
@@ -760,7 +762,7 @@ endforeach()
760762
### Generate Recording resource files
761763
### Drop them into the folder alongside the png files
762764
foreach(res_file IN ITEMS
763-
circlePressed controller crossPressed downPressed l1Pressed l2Pressed l3Pressed leftPressed
765+
circlePressed controllerFull controllerHalf controllerThreeQuarters crossPressed downPressed l1Pressed l2Pressed l3Pressed leftPressed
764766
r1Pressed r2Pressed r3Pressed rightPressed selectPressed squarePressed startPressed trianglePressed upPressed)
765767
add_custom_command(OUTPUT "${res_rec_vp_src}/${res_file}.h" COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${res_rec_vp_src}/${res_file}.png" "${res_rec_vp_src}/${res_file}" )
766768
endforeach()

pcsx2/Recording/InputRecording.cpp

+33-36
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ InputRecording g_InputRecording;
6060
InputRecording::InputRecording()
6161
{
6262
// 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();
6565
}
6666

67-
void InputRecording::setVirtualPadPtr(VirtualPad *ptr, int const port)
67+
void InputRecording::setVirtualPadPtr(VirtualPad* ptr, int const port)
6868
{
6969
virtualPads[port] = ptr;
7070
}
@@ -85,62 +85,53 @@ void InputRecording::RecordingReset()
8585
g_InputRecordingControls.Resume();
8686
}
8787

88-
void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 buf[])
88+
void InputRecording::ControllerInterrupt(u8& data, u8& port, u16& bufCount, u8 buf[])
8989
{
9090
// TODO - Multi-Tap Support
9191

9292
if (bufCount == 1)
9393
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+
9997
// We do not want to record or save the first two bytes in the data returned from the PAD plugin
10098
else if (fInterruptFrame && bufCount >= 3 && frameCounter >= 0 && frameCounter < INT_MAX)
10199
{
102-
u8 &bufVal = buf[bufCount];
103-
const u16 bufIndex = bufCount - 3;
100+
u8& bufVal = buf[bufCount];
101+
const u16 bufIndex = bufCount - 3;
104102

105103
if (state == InputRecordingMode::Replaying)
106104
{
107105
u8 tmp = 0;
108106
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+
}
119111
}
120112

121113
// Update controller data state for future VirtualPad / logging usage.
122114
padData[port]->UpdateControllerData(bufIndex, bufVal);
123115

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)
125120
{
126121
// If the VirtualPad updated the PadData, we have to update the buffer
127122
// before committing it to the recording / sending it to the game
128123
// - 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);
133125
}
134126

135127
// 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+
{
137130
padData[port]->LogPadData(port);
138131
// As well as re-render the virtual pad UI, if applicable
139132
// - Don't render if it's minimized
140133
if (virtualPads[port] && virtualPads[port]->IsShown() && !virtualPads[port]->IsIconized())
141-
{
142134
virtualPads[port]->Redraw();
143-
}
144135
}
145136

146137
// Finally, commit the byte to the movie file if we are recording
@@ -161,7 +152,7 @@ s32 InputRecording::GetFrameCounter()
161152
return frameCounter;
162153
}
163154

164-
InputRecordingFile &InputRecording::GetInputRecordingData()
155+
InputRecordingFile& InputRecording::GetInputRecordingData()
165156
{
166157
return inputRecordingData;
167158
}
@@ -223,17 +214,21 @@ wxString InputRecording::RecordingModeTitleSegment()
223214
void InputRecording::SetToRecordMode()
224215
{
225216
state = InputRecordingMode::Recording;
217+
virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode(false);
218+
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(false);
226219
recordingConLog("[REC]: Record mode ON.\n");
227220
}
228221

229222
void InputRecording::SetToReplayMode()
230223
{
231224
state = InputRecordingMode::Replaying;
225+
virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode(true);
226+
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(true);
232227
recordingConLog("[REC]: Replay mode ON.\n");
233228
}
234229

235230
void InputRecording::SetFrameCounter(u32 newGFrameCount)
236-
{
231+
{
237232
if (newGFrameCount > startingFrame + (u32)g_InputRecording.GetInputRecordingData().GetTotalFrames())
238233
{
239234
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)
272267
void InputRecording::Stop()
273268
{
274269
state = InputRecordingMode::NotActive;
270+
virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode(false);
271+
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(false);
275272
incrementUndo = false;
276273
if (inputRecordingData.Close())
277274
recordingConLog(L"[REC]: InputRecording Recording Stopped.\n");
@@ -303,7 +300,7 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
303300
inputRecordingData.GetHeader().SetGameName(resolveGameName());
304301
// Write header contents
305302
inputRecordingData.WriteHeader();
306-
state = InputRecordingMode::Recording;
303+
SetToRecordMode();
307304
g_InputRecordingControls.DisableFrameAdvance();
308305
recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName));
309306
return true;
@@ -328,8 +325,8 @@ bool InputRecording::Play(wxString fileName)
328325
}
329326
if (!wxFileExists(inputRecordingData.GetFilename() + "_SaveState.p2s"))
330327
{
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()));
333330
inputRecordingData.Close();
334331
return false;
335332
}
@@ -348,7 +345,7 @@ bool InputRecording::Play(wxString fileName)
348345
recordingConLog(L"[REC]: Recording was possibly constructed for a different game.\n");
349346

350347
incrementUndo = true;
351-
state = InputRecordingMode::Replaying;
348+
SetToReplayMode();
352349
g_InputRecordingControls.DisableFrameAdvance();
353350
recordingConLog(wxString::Format(L"[REC]: Replaying input recording - [%s]\n", inputRecordingData.GetFilename()));
354351
recordingConLog(wxString::Format(L"[REC]: PCSX2 Version Used: %s\n", inputRecordingData.GetHeader().emu));
@@ -380,4 +377,4 @@ wxString InputRecording::resolveGameName()
380377
return !gameName.IsEmpty() ? gameName : Path::GetFilename(g_Conf->CurrentIso);
381378
}
382379

383-
#endif
380+
#endif

pcsx2/Recording/InputRecording.h

+16-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InputRecording
2424
{
2525
public:
2626
InputRecording();
27-
27+
2828
// Save or load PCSX2's global frame counter (g_FrameCount) along with each full/fast boot
2929
//
3030
// This is to prevent any inaccuracy issues caused by having a different
@@ -34,26 +34,26 @@ class InputRecording
3434

3535
// Main handler for ingesting input data and either saving it to the recording file (recording)
3636
// or mutating it to the contents of the recording file (replaying)
37-
void ControllerInterrupt(u8 &data, u8 &port, u16 &BufCount, u8 buf[]);
37+
void ControllerInterrupt(u8& data, u8& port, u16& BufCount, u8 buf[]);
3838

3939
// The running frame counter for the input recording
4040
s32 GetFrameCounter();
4141

42-
InputRecordingFile &GetInputRecordingData();
42+
InputRecordingFile& GetInputRecordingData();
4343

4444
// The internal PCSX2 g_FrameCount value on the first frame of the recording
4545
u32 GetStartingFrame();
4646

4747
void IncrementFrameCounter();
4848

49-
// DEPRECATED: Slated for removal
49+
// DEPRECATED: Slated for removal
5050
// If the current frame contains controller / input data
5151
bool IsInterruptFrame();
5252

5353
// If there is currently an input recording being played back or actively being recorded
5454
bool IsActive();
5555

56-
// Whether or not the recording's initial state has yet to be loaded or saved and
56+
// Whether or not the recording's initial state has yet to be loaded or saved and
5757
// the rest of the recording can be initialized
5858
// This is not applicable to recordings from a "power-on" state
5959
bool IsInitialLoad();
@@ -78,7 +78,7 @@ class InputRecording
7878

7979
// Store the starting internal PCSX2 g_FrameCount value
8080
void SetStartingFrame(u32 newStartingFrame);
81-
81+
8282
/// Functions called from GUI
8383

8484
// Create a new input recording file
@@ -87,8 +87,8 @@ class InputRecording
8787
bool Play(wxString filename);
8888
// Stop the active input recording
8989
void Stop();
90-
91-
void setVirtualPadPtr(VirtualPad *ptr, int const port);
90+
// Initialze VirtualPad window
91+
void setVirtualPadPtr(VirtualPad* ptr, int const port);
9292

9393
private:
9494
enum class InputRecordingMode
@@ -99,35 +99,35 @@ class InputRecording
9999
};
100100

101101
static const int CONTROLLER_PORT_ONE = 0;
102-
static const int CONTROLLER_PORT_TWO = 1;
102+
static const int CONTROLLER_PORT_TWO = 1;
103103

104104
// 0x42 is the magic number to indicate the default controller read query
105105
// See - Lilypad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1193
106106
static const u8 READ_DATA_AND_VIBRATE_FIRST_BYTE = 0x42;
107107
// 0x5A is always the second byte in the buffer when the normal READ_DATA_AND_VIBRATE (0x42) query is executed.
108108
// See - LilyPad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1194
109-
static const u8 READ_DATA_AND_VIBRATE_SECOND_BYTE = 0x5A;
109+
static const u8 READ_DATA_AND_VIBRATE_SECOND_BYTE = 0x5A;
110110

111-
// DEPRECATED: Slated for removal
111+
// DEPRECATED: Slated for removal
112112
bool fInterruptFrame = false;
113113
InputRecordingFile inputRecordingData;
114114
bool initialLoad = false;
115115
u32 startingFrame = 0;
116116
s32 frameCounter = 0;
117117
bool incrementUndo = false;
118118
InputRecordingMode state = InputRecording::InputRecordingMode::NotActive;
119-
119+
120120
// Controller Data
121-
PadData *padData[2];
121+
PadData* padData[2];
122122

123123
// VirtualPads
124-
VirtualPad *virtualPads[2];
125-
124+
VirtualPad* virtualPads[2];
125+
126126
// Resolve the name and region of the game currently loaded using the GameDB
127127
// If the game cannot be found in the DB, the fallback is the ISO filename
128128
wxString resolveGameName();
129129
};
130130

131131
extern InputRecording g_InputRecording;
132132

133-
#endif
133+
#endif

pcsx2/Recording/NewRecordingFrame.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020

2121
#ifndef DISABLE_RECORDING
22-
NewRecordingFrame::NewRecordingFrame(wxWindow *parent)
22+
NewRecordingFrame::NewRecordingFrame(wxWindow* parent)
2323
: wxDialog(parent, wxID_ANY, "New Input Recording", wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP | wxCAPTION)
2424
{
25-
wxPanel *panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("panel"));
25+
wxPanel* panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("panel"));
2626

27-
wxFlexGridSizer *fgs = new wxFlexGridSizer(4, 2, 20, 20);
28-
wxBoxSizer *container = new wxBoxSizer(wxVERTICAL);
27+
wxFlexGridSizer* fgs = new wxFlexGridSizer(4, 2, 20, 20);
28+
wxBoxSizer* container = new wxBoxSizer(wxVERTICAL);
2929

3030
m_fileLabel = new wxStaticText(panel, wxID_ANY, _("File Path"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
3131
m_authorLabel = new wxStaticText(panel, wxID_ANY, _("Author"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
@@ -65,7 +65,8 @@ wxString NewRecordingFrame::GetFile() const
6565
wxString path = m_filePicker->GetPath();
6666
// wxWidget's removes the extension if it contains wildcards
6767
// on wxGTK https://trac.wxwidgets.org/ticket/15285
68-
if (!path.EndsWith(".p2m2")) {
68+
if (!path.EndsWith(".p2m2"))
69+
{
6970
return wxString::Format("%s.p2m2", path);
7071
}
7172
return path;

pcsx2/Recording/NewRecordingFrame.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ enum MenuIds_New_Recording_Frame
3131
class NewRecordingFrame : public wxDialog
3232
{
3333
public:
34-
NewRecordingFrame(wxWindow *parent);
34+
NewRecordingFrame(wxWindow* parent);
3535

3636
wxString GetFile() const;
3737
wxString GetAuthor() const;
3838
int GetFrom() const;
3939

4040
private:
41-
wxStaticText *m_fileLabel;
42-
wxFilePickerCtrl *m_filePicker;
43-
wxStaticText *m_authorLabel;
44-
wxTextCtrl *m_authorInput;
45-
wxStaticText *m_fromLabel;
46-
wxChoice *m_fromChoice;
47-
wxButton *m_startRecording;
48-
wxButton *m_cancelRecording;
41+
wxStaticText* m_fileLabel;
42+
wxFilePickerCtrl* m_filePicker;
43+
wxStaticText* m_authorLabel;
44+
wxTextCtrl* m_authorInput;
45+
wxStaticText* m_fromLabel;
46+
wxChoice* m_fromChoice;
47+
wxButton* m_startRecording;
48+
wxButton* m_cancelRecording;
4949
};
5050
#endif

pcsx2/Recording/PadData.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ wxString PadData::RawPadBytesToString(int start, int end)
184184
{
185185
str += wxString::Format("%d", PollControllerData(i));
186186
if (i != end - 1)
187-
{
188187
str += ", ";
189-
}
190188
}
191189
return str;
192190
}

0 commit comments

Comments
 (0)