vs/recording: Remove the committed header files, generate them at build-time

recording: General cleanup, remove obvious code duplication

recording: Improved function arg names in VirtualPad


format: Clang-format all new files
This commit is contained in:
Tyler Wilding 2020-09-19 20:18:34 -04:00 committed by refractionpcsx2
parent 8a968a0c11
commit 4519e32586
37 changed files with 812 additions and 713 deletions

View File

@ -364,7 +364,7 @@ set(pcsx2GuiHeaders
)
# Warning: the declaration of the .h are mandatory in case of resources files. It will ensure the creation
# from the bin2cpp tools at the good moment (ie .h must be created before the pcsx2 compilation)
# from the bin2cpp tools at right good moment (ie .h must be created before the pcsx2 compilation)
# Gui resources headers
set(res_bin "${CMAKE_BINARY_DIR}/pcsx2/gui/Resources")
set(res_src "${CMAKE_SOURCE_DIR}/pcsx2/gui/Resources")
@ -502,7 +502,7 @@ set(pcsx2RecordingHeaders
)
# Warning: the declaration of the .h are mandatory in case of resources files. It will ensure the creation
# from the bin2cpp tools at the good moment (ie .h must be created before the pcsx2 compilation)
# from the bin2cpp tools at the right moment (ie .h must be created before the pcsx2 compilation)
# Recording - VirtualPad resources headers
set(res_rec_vp_bin "${CMAKE_BINARY_DIR}/pcsx2/Recording/VirtualPad/img")
set(res_rec_vp_src "${CMAKE_SOURCE_DIR}/pcsx2/Recording/VirtualPad/img")

View File

@ -51,6 +51,8 @@ void SaveStateBase::InputRecordingFreeze()
#endif
}
#ifndef DISABLE_RECORDING
InputRecording g_InputRecording;
InputRecording::InputRecording()
@ -60,7 +62,7 @@ InputRecording::InputRecording()
padData[CONTROLLER_PORT_TWO] = new PadData();
}
void InputRecording::SetVirtualPadPtr(VirtualPad *ptr, int const port)
void InputRecording::setVirtualPadPtr(VirtualPad *ptr, int const port)
{
virtualPads[port] = ptr;
}
@ -85,25 +87,11 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
{
// TODO - Multi-Tap Support
/*
This appears to try to ensure that we are only paying attention
to the frames that matter, the ones that are reading from
the controller.
See - Lilypad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1193
0x42 is the magic number for the default read query
*/
if (bufCount == 1)
fInterruptFrame = data == 0x42;
fInterruptFrame = data == READ_DATA_AND_VIBRATE_FIRST_BYTE;
else if (bufCount == 2)
{
/*
See - LilyPad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1194
0x5A is always the second byte in the buffer
when the normal READ_DATA_AND_VIBRRATE (0x42)
query is executed, this looks like a sanity check
*/
if (buf[bufCount] != 0x5A)
if (buf[bufCount] != READ_DATA_AND_VIBRATE_SECOND_BYTE)
fInterruptFrame = false;
}
// We do not want to record or save the first two bytes in the data returned from the PAD plugin
@ -112,17 +100,7 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
u8 &bufVal = buf[bufCount];
const u16 bufIndex = bufCount - 3;
// Read or Write
if (state == InputRecordingMode::Recording)
{
if (incrementUndo)
{
inputRecordingData.IncrementUndoCount();
incrementUndo = false;
}
inputRecordingData.WriteKeyBuffer(frameCounter, port, bufIndex, buf[bufCount]);
}
else if (state == InputRecordingMode::Replaying)
if (state == InputRecordingMode::Replaying)
{
u8 tmp = 0;
if (inputRecordingData.ReadKeyBuffer(tmp, frameCounter, port, bufIndex))
@ -137,8 +115,6 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
}
}
}
return;
}
// Update controller data state for future VirtualPad / logging usage.
padData[port]->UpdateControllerData(bufIndex, bufVal);
@ -148,7 +124,7 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
// If the VirtualPad updated the PadData, we have to update the buffer
// before committing it to the recording / sending it to the game
// - Do not do this if we are in replay mode!
if (virtualPads[port]->UpdateControllerData(bufIndex, padData[port]) && state != INPUT_RECORDING_MODE_REPLAY)
if (virtualPads[port]->UpdateControllerData(bufIndex, padData[port]) && state != InputRecordingMode::Replaying)
{
bufVal = padData[port]->PollControllerData(bufIndex);
}
@ -166,10 +142,15 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
}
// Finally, commit the byte to the movie file if we are recording
if (state == INPUT_RECORDING_MODE_RECORD)
if (state == InputRecordingMode::Recording)
{
InputRecordingData.UpdateFrameMax(g_FrameCount);
InputRecordingData.WriteKeyBuf(g_FrameCount, port, bufIndex, bufVal);
if (incrementUndo)
{
inputRecordingData.IncrementUndoCount();
incrementUndo = false;
}
inputRecordingData.WriteKeyBuffer(frameCounter, port, bufIndex, bufVal);
}
}
}
@ -396,3 +377,5 @@ wxString InputRecording::resolveGameName()
}
return !gameName.IsEmpty() ? gameName : Path::GetFilename(g_Conf->CurrentIso);
}
#endif

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
#include "Recording/InputRecordingFile.h"
@ -86,7 +88,7 @@ public:
// Stop the active input recording
void Stop();
void SetVirtualPadPtr(VirtualPad *ptr, int const port);
void setVirtualPadPtr(VirtualPad *ptr, int const port);
private:
enum class InputRecordingMode
@ -96,6 +98,16 @@ private:
Replaying,
};
static const int CONTROLLER_PORT_ONE = 0;
static const int CONTROLLER_PORT_TWO = 1;
// 0x42 is the magic number to indicate the default controller read query
// See - Lilypad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1193
static const u8 READ_DATA_AND_VIBRATE_FIRST_BYTE = 0x42;
// 0x5A is always the second byte in the buffer when the normal READ_DATA_AND_VIBRATE (0x42) query is executed.
// See - LilyPad.cpp::PADpoll - https://github.com/PCSX2/pcsx2/blob/v1.5.0-dev/plugins/LilyPad/LilyPad.cpp#L1194
static const u8 READ_DATA_AND_VIBRATE_SECOND_BYTE = 0x5A;
// DEPRECATED: Slated for removal
bool fInterruptFrame = false;
InputRecordingFile inputRecordingData;
@ -117,3 +129,5 @@ private:
};
extern InputRecording g_InputRecording;
#endif

View File

@ -15,6 +15,8 @@
#include "PrecompiledHeader.h"
#ifndef DISABLE_RECORDING
#include "App.h"
#include "Counters.h"
#include "DebugTools/Debug.h"
@ -25,11 +27,8 @@
#include "InputRecordingControls.h"
#ifndef DISABLE_RECORDING
InputRecordingControls g_InputRecordingControls;
void InputRecordingControls::HandleFrameAdvanceAndPausing()
{
// This function can be called multiple times per frame via Counters::rcntUpdate_vSync,

View File

@ -16,6 +16,7 @@
#pragma once
#ifndef DISABLE_RECORDING
class InputRecordingControls
{
public:
@ -82,4 +83,5 @@ private:
};
extern InputRecordingControls g_InputRecordingControls;
#endif

View File

@ -15,14 +15,14 @@
#include "PrecompiledHeader.h"
#ifndef DISABLE_RECORDING
#include "DebugTools/Debug.h"
#include "MainFrame.h"
#include "MemoryTypes.h"
#include "Recording/InputRecordingFile.h"
#ifndef DISABLE_RECORDING
void InputRecordingFileHeader::Init()
{
memset(author, 0, ArraySize(author));

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
#include "System.h"
#include "PadData.h"
@ -22,7 +24,6 @@
// NOTE / TODOs for Version 2
// - Move fromSavestate, undoCount, and total frames into the header
#ifndef DISABLE_RECORDING
struct InputRecordingFileHeader
{
u8 version = 1;
@ -109,4 +110,5 @@ private:
bool open(const wxString path, bool newRecording);
bool verifyRecordingFileHeader();
};
#endif

View File

@ -180,16 +180,19 @@ u8 PadData::BitmaskOrZero(bool pressed, ButtonResolver buttonInfo)
wxString PadData::RawPadBytesToString(int start, int end)
{
wxString str;
for (int i = start; i < end; i++) {
for (int i = start; i < end; i++)
{
str += wxString::Format("%d", PollControllerData(i));
if (i != end-1) {
if (i != end - 1)
{
str += ", ";
}
}
return str;
}
void PadData::LogPadData(u8 const &port) {
void PadData::LogPadData(u8 const& port)
{
wxString pressedBytes = RawPadBytesToString(0, 2);
wxString rightAnalogBytes = RawPadBytesToString(2, 4);
wxString leftAnalogBytes = RawPadBytesToString(4, 6);
@ -201,3 +204,5 @@ void PadData::LogPadData(u8 const &port) {
wxString::Format("[PAD %d] Raw Bytes: Pressure = [%s]\n", port + 1, pressureBytes);
controlLog(fullLog);
}
#endif

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
class PadData
{
public:
@ -123,4 +125,5 @@ private:
wxString RawPadBytesToString(int start, int end);
};
#endif

View File

@ -47,9 +47,8 @@
#include "Recording/VirtualPad/img/upPressed.h"
// TODO - Store position of frame in an (possibly the main) .ini file
VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, int controllerPort, const wxPoint& pos, const wxSize& size, long style) :
wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, int controllerPort, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
{
// Images at 1.00 scale are designed to work well on HiDPI (4k) at 150% scaling (default recommended setting on windows)
// Therefore, on a 1080p monitor we halve the scaling, on 1440p we reduce it by 25%, which from some quick tests looks comparable
@ -73,28 +72,30 @@ VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, i
// Use the background image's size to define the window size
SetClientSize(virtualPadData.background.width, virtualPadData.background.height);
InitPressureButtonGuiElements(virtualPadData.cross, NewBitmap(EmbeddedImage<res_crossPressed>().Get(), wxPoint(968, 498)), this, wxPoint(1062, 660));
InitPressureButtonGuiElements(virtualPadData.circle, NewBitmap(EmbeddedImage<res_circlePressed>().Get(), wxPoint(1057, 413)), this, wxPoint(1062, 700));
InitPressureButtonGuiElements(virtualPadData.triangle, NewBitmap(EmbeddedImage<res_trianglePressed>().Get(), wxPoint(968, 325)), this, wxPoint(1062, 740));
InitPressureButtonGuiElements(virtualPadData.square, NewBitmap(EmbeddedImage<res_squarePressed>().Get(), wxPoint(879, 413)), this, wxPoint(1062, 780));
InitPressureButtonGuiElements(virtualPadData.down, NewBitmap(EmbeddedImage<res_downPressed>().Get(), wxPoint(191, 488)), this, wxPoint(199, 660), true);
InitPressureButtonGuiElements(virtualPadData.right, NewBitmap(EmbeddedImage<res_rightPressed>().Get(), wxPoint(255, 429)), this, wxPoint(199, 700), true);
InitPressureButtonGuiElements(virtualPadData.up, NewBitmap(EmbeddedImage<res_upPressed>().Get(), wxPoint(191, 354)), this, wxPoint(199, 740), true);
InitPressureButtonGuiElements(virtualPadData.left, NewBitmap(EmbeddedImage<res_leftPressed>().Get(), wxPoint(115, 429)), this, wxPoint(199, 780), true);
InitPressureButtonGuiElements(virtualPadData.l1, NewBitmap(EmbeddedImage<res_l1Pressed>().Get(), wxPoint(166, 8)), this, wxPoint(294, 20));
InitPressureButtonGuiElements(virtualPadData.l2, NewBitmap(EmbeddedImage<res_l2Pressed>().Get(), wxPoint(166, 81)), this, wxPoint(294, 100));
InitPressureButtonGuiElements(virtualPadData.r1, NewBitmap(EmbeddedImage<res_r1Pressed>().Get(), wxPoint(958, 7)), this, wxPoint(940, 20), true);
InitPressureButtonGuiElements(virtualPadData.r2, NewBitmap(EmbeddedImage<res_r2Pressed>().Get(), wxPoint(958, 81)), this, wxPoint(940, 100), true);
InitPressureButtonGuiElements(virtualPadData.cross, NewBitmap(EmbeddedImage<res_crossPressed>().Get(), wxPoint(938, 369)), this, wxPoint(1055, 525));
InitPressureButtonGuiElements(virtualPadData.circle, NewBitmap(EmbeddedImage<res_circlePressed>().Get(), wxPoint(1024, 286)), this, wxPoint(1055, 565));
InitPressureButtonGuiElements(virtualPadData.triangle, NewBitmap(EmbeddedImage<res_trianglePressed>().Get(), wxPoint(938, 201)), this, wxPoint(1055, 605));
InitPressureButtonGuiElements(virtualPadData.square, NewBitmap(EmbeddedImage<res_squarePressed>().Get(), wxPoint(852, 287)), this, wxPoint(1055, 645));
InitNormalButtonGuiElements(virtualPadData.select, NewBitmap(EmbeddedImage<res_selectPressed>().Get(), wxPoint(473, 441)), this, wxPoint(545, 448));
InitNormalButtonGuiElements(virtualPadData.start, NewBitmap(EmbeddedImage<res_startPressed>().Get(), wxPoint(710, 440)), this, wxPoint(675, 448));
InitNormalButtonGuiElements(virtualPadData.l3, NewBitmap(EmbeddedImage<res_r3Pressed>().Get(), wxPoint(347, 585)), this, wxPoint(440, 835));
InitNormalButtonGuiElements(virtualPadData.r3, NewBitmap(EmbeddedImage<res_l3Pressed>().Get(), wxPoint(750, 585)), this, wxPoint(844, 835));
InitPressureButtonGuiElements(virtualPadData.down, NewBitmap(EmbeddedImage<res_downPressed>().Get(), wxPoint(186, 359)), this, wxPoint(175, 525), true);
InitPressureButtonGuiElements(virtualPadData.right, NewBitmap(EmbeddedImage<res_rightPressed>().Get(), wxPoint(248, 302)), this, wxPoint(175, 565), true);
InitPressureButtonGuiElements(virtualPadData.up, NewBitmap(EmbeddedImage<res_upPressed>().Get(), wxPoint(186, 227)), this, wxPoint(175, 605), true);
InitPressureButtonGuiElements(virtualPadData.left, NewBitmap(EmbeddedImage<res_leftPressed>().Get(), wxPoint(110, 302)), this, wxPoint(175, 645), true);
InitAnalogStickGuiElements(virtualPadData.leftAnalog, this, wxPoint(418, 656), 105, wxPoint(326, 782), wxPoint(545, 568), false, wxPoint(522, 800), wxPoint(522, 760));
InitAnalogStickGuiElements(virtualPadData.rightAnalog, this, wxPoint(821, 656), 105, wxPoint(730, 782), wxPoint(672, 568), true, wxPoint(720, 800), wxPoint(720, 760), true);
InitPressureButtonGuiElements(virtualPadData.l1, NewBitmap(EmbeddedImage<res_l1Pressed>().Get(), wxPoint(156, 98)), this, wxPoint(170, 135));
InitPressureButtonGuiElements(virtualPadData.l2, NewBitmap(EmbeddedImage<res_l2Pressed>().Get(), wxPoint(156, 57)), this, wxPoint(170, 18));
InitPressureButtonGuiElements(virtualPadData.r1, NewBitmap(EmbeddedImage<res_r1Pressed>().Get(), wxPoint(921, 98)), this, wxPoint(1035, 135), true);
InitPressureButtonGuiElements(virtualPadData.r2, NewBitmap(EmbeddedImage<res_r2Pressed>().Get(), wxPoint(921, 57)), this, wxPoint(1035, 18), true);
ignoreRealControllerBox = new wxCheckBox(this, wxID_ANY, wxEmptyString, ScaledPoint(605, 256), wxDefaultSize);
InitNormalButtonGuiElements(virtualPadData.select, NewBitmap(EmbeddedImage<res_selectPressed>().Get(), wxPoint(457, 313)), this, wxPoint(530, 320));
InitNormalButtonGuiElements(virtualPadData.start, NewBitmap(EmbeddedImage<res_startPressed>().Get(), wxPoint(688, 311)), this, wxPoint(650, 320));
InitNormalButtonGuiElements(virtualPadData.l3, NewBitmap(EmbeddedImage<res_r3Pressed>().Get(), wxPoint(726, 453)), this, wxPoint(440, 835)); // TODO - text for L3 / R3
InitNormalButtonGuiElements(virtualPadData.r3, NewBitmap(EmbeddedImage<res_l3Pressed>().Get(), wxPoint(336, 453)), this, wxPoint(844, 835)); // TODO - text for L3 / R3
InitAnalogStickGuiElements(virtualPadData.leftAnalog, this, wxPoint(405, 522), 101, wxPoint(312, 642), wxPoint(525, 431), false, wxPoint(507, 662), wxPoint(507, 622));
InitAnalogStickGuiElements(virtualPadData.rightAnalog, this, wxPoint(795, 522), 101, wxPoint(703, 642), wxPoint(648, 431), true, wxPoint(695, 662), wxPoint(695, 622), true);
ignoreRealControllerBox = new wxCheckBox(this, wxID_ANY, wxEmptyString, ScaledPoint(575, 135), wxDefaultSize);
Bind(wxEVT_CHECKBOX, &VirtualPad::OnIgnoreRealController, this, ignoreRealControllerBox->GetId());
// Bind Window Events
@ -158,26 +159,10 @@ void VirtualPad::Redraw()
void VirtualPad::Render(wxDC& dc)
{
// Update GUI Elements and figure out what needs to be rendered
virtualPadData.circle.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.cross.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.square.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.triangle.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.down.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.left.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.right.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.up.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.l1.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.l2.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.r1.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.r2.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.select.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.start.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.l3.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.r3.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.leftAnalog.UpdateGuiElement(renderQueue, clearScreenRequired);
virtualPadData.rightAnalog.UpdateGuiElement(renderQueue, clearScreenRequired);
for (VirtualPadElement* virtualPadElement : virtualPadElements)
{
virtualPadElement->UpdateGuiElement(renderQueue, clearScreenRequired);
}
// Update Graphic Elements off render stack
// Before we start rendering (if we have to) clear and re-draw the background
@ -191,7 +176,8 @@ void VirtualPad::Render(wxDC &dc)
clearScreenRequired = false;
// Switch to Manual Rendering once the first user action on the VirtualPad is taken
if (!manualRedrawMode && !renderQueue.empty()) {
if (!manualRedrawMode && !renderQueue.empty())
{
// DevCon.WriteLn("Paint Event Unbound");
Unbind(wxEVT_PAINT, &VirtualPad::OnPaint, this);
manualRedrawMode = true;
@ -201,10 +187,11 @@ void VirtualPad::Render(wxDC &dc)
// It can be assumed that if the element has already been drawn to the screen (and not cleared) that we can skip rendering it
//
// For example - you hold a single button for several frames, it will currently draw that every frame
// despite the screen never being cleared, this is not strictly necessary.
// despite the screen never being cleared - so this is not strictly necessary.
//
// After some tests, the performance impact is well within reason, and on the hardware renderer modes, is almost non-existant.
while (!renderQueue.empty()) {
// Though after some tests, the performance impact is well within reason, and on the hardware renderer modes, is almost non-existant.
while (!renderQueue.empty())
{
VirtualPadElement* element = renderQueue.front();
if (element)
{
@ -222,26 +209,10 @@ bool VirtualPad::UpdateControllerData(u16 const bufIndex, PadData *padData)
void VirtualPad::enablePadElements(bool enable)
{
virtualPadData.circle.EnableWidgets(enable);
virtualPadData.cross.EnableWidgets(enable);
virtualPadData.square.EnableWidgets(enable);
virtualPadData.triangle.EnableWidgets(enable);
virtualPadData.down.EnableWidgets(enable);
virtualPadData.left.EnableWidgets(enable);
virtualPadData.right.EnableWidgets(enable);
virtualPadData.up.EnableWidgets(enable);
virtualPadData.l1.EnableWidgets(enable);
virtualPadData.l2.EnableWidgets(enable);
virtualPadData.r1.EnableWidgets(enable);
virtualPadData.r2.EnableWidgets(enable);
virtualPadData.select.EnableWidgets(enable);
virtualPadData.start.EnableWidgets(enable);
virtualPadData.l3.EnableWidgets(enable);
virtualPadData.r3.EnableWidgets(enable);
virtualPadData.leftAnalog.EnableWidgets(enable);
virtualPadData.rightAnalog.EnableWidgets(enable);
for (VirtualPadElement* virtualPadElement : virtualPadElements)
{
virtualPadElement->EnableWidgets(enable);
}
}
void VirtualPad::SetReadOnlyMode()
@ -275,7 +246,8 @@ void VirtualPad::OnNormalButtonPress(wxCommandEvent &event)
eventBtn->pressed = pressedButton->GetValue();
}
if (!eventBtn->isControllerPressBypassed) {
if (!eventBtn->isControllerPressBypassed)
{
eventBtn->isControllerPressBypassed = true;
}
}
@ -291,7 +263,8 @@ void VirtualPad::OnPressureButtonPressureChange(wxCommandEvent &event)
}
eventBtn->pressed = eventBtn->pressure > 0;
if (!eventBtn->isControllerPressureBypassed || !eventBtn->isControllerPressBypassed) {
if (!eventBtn->isControllerPressureBypassed || !eventBtn->isControllerPressBypassed)
{
eventBtn->isControllerPressureBypassed = true;
eventBtn->isControllerPressBypassed = true;
}
@ -308,7 +281,8 @@ void VirtualPad::OnAnalogSpinnerChange(wxCommandEvent &event)
}
eventVector->slider->SetValue(eventVector->val);
if (!eventVector->isControllerBypassed) {
if (!eventVector->isControllerBypassed)
{
eventVector->isControllerBypassed = true;
}
}
@ -324,7 +298,8 @@ void VirtualPad::OnAnalogSliderChange(wxCommandEvent &event)
}
eventVector->spinner->SetValue(eventVector->val);
if (!eventVector->isControllerBypassed) {
if (!eventVector->isControllerBypassed)
{
eventVector->isControllerBypassed = true;
}
}
@ -339,7 +314,8 @@ wxPoint VirtualPad::ScaledPoint(wxPoint point, int widgetWidth, bool rightAligne
wxPoint VirtualPad::ScaledPoint(int x, int y, int widgetWidth, bool rightAligned)
{
wxPoint scaledPoint = wxPoint(x * scalingFactor, y * scalingFactor);
if (rightAligned) {
if (rightAligned)
{
scaledPoint.x -= widgetWidth * scalingFactor;
if (scaledPoint.x < 0)
{
@ -354,12 +330,12 @@ wxSize VirtualPad::ScaledSize(int x, int y)
return wxSize(x * scalingFactor, y * scalingFactor);
}
ImageFile VirtualPad::NewBitmap(wxImage resource, wxPoint point)
ImageFile VirtualPad::NewBitmap(wxImage resource, wxPoint imgCoord)
{
return NewBitmap(scalingFactor, resource, point);
return NewBitmap(scalingFactor, resource, imgCoord);
}
ImageFile VirtualPad::NewBitmap(float scalingFactor, wxImage resource, wxPoint point)
ImageFile VirtualPad::NewBitmap(float scalingFactor, wxImage resource, wxPoint imgCoord)
{
wxBitmap bitmap = wxBitmap(resource.Rescale(resource.GetWidth() * scalingFactor, resource.GetHeight() * scalingFactor, wxIMAGE_QUALITY_HIGH));
@ -367,28 +343,30 @@ ImageFile VirtualPad::NewBitmap(float scalingFactor, wxImage resource, wxPoint p
image.image = bitmap;
image.width = bitmap.GetWidth();
image.height = bitmap.GetHeight();
image.coords = ScaledPoint(point);
image.coords = ScaledPoint(imgCoord);
return image;
}
void VirtualPad::InitNormalButtonGuiElements(ControllerNormalButton &button, ImageFile image, wxWindow *parentWindow, wxPoint point)
void VirtualPad::InitNormalButtonGuiElements(ControllerNormalButton& button, ImageFile image, wxWindow* parentWindow, wxPoint checkboxCoord)
{
button.icon = image;
button.pressedBox = new wxCheckBox(parentWindow, wxID_ANY, wxEmptyString, ScaledPoint(point), wxDefaultSize);
button.pressedBox = new wxCheckBox(parentWindow, wxID_ANY, wxEmptyString, ScaledPoint(checkboxCoord), wxDefaultSize);
Bind(wxEVT_CHECKBOX, &VirtualPad::OnNormalButtonPress, this, button.pressedBox->GetId());
buttonElements[button.pressedBox->GetId()] = &button;
virtualPadElements.push_back(&button);
}
void VirtualPad::InitPressureButtonGuiElements(ControllerPressureButton &button, ImageFile image, wxWindow *parentWindow, wxPoint point, bool rightAlignedPoint)
void VirtualPad::InitPressureButtonGuiElements(ControllerPressureButton& button, ImageFile image, wxWindow* parentWindow, wxPoint pressureSpinnerCoord, bool rightAlignedCoord)
{
const int spinnerWidth = 100;
const wxPoint scaledPoint = ScaledPoint(point.x, point.y, spinnerWidth, rightAlignedPoint);
const wxPoint scaledPoint = ScaledPoint(pressureSpinnerCoord.x, pressureSpinnerCoord.y, spinnerWidth, rightAlignedCoord);
wxSpinCtrl* spinner = new wxSpinCtrl(parentWindow, wxID_ANY, wxEmptyString, scaledPoint, ScaledSize(spinnerWidth, wxDefaultSize.GetHeight()), wxSP_ARROW_KEYS, 0, 255, 0);
button.icon = image;
button.pressureSpinner = spinner;
Bind(wxEVT_SPINCTRL, &VirtualPad::OnPressureButtonPressureChange, this, button.pressureSpinner->GetId());
pressureElements[button.pressureSpinner->GetId()] = &button;
virtualPadElements.push_back(&button);
}
void VirtualPad::InitAnalogStickGuiElements(AnalogStick& analog, wxWindow* parentWindow, wxPoint centerPoint, int radius, wxPoint xSliderPoint, wxPoint ySliderPoint, bool flipYSlider, wxPoint xSpinnerPoint, wxPoint ySpinnerPoint, bool rightAlignedSpinners)
@ -421,4 +399,7 @@ void VirtualPad::InitAnalogStickGuiElements(AnalogStick &analog, wxWindow *paren
analogElements[ySlider->GetId()] = &analog.yVector;
analogElements[xSpinner->GetId()] = &analog.xVector;
analogElements[ySpinner->GetId()] = &analog.yVector;
virtualPadElements.push_back(&analog);
}
#endif

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
#include <map>
#include <queue>
@ -57,6 +59,7 @@ private:
VirtualPadData virtualPadData;
std::vector<VirtualPadElement*> virtualPadElements;
std::queue<VirtualPadElement*> renderQueue;
void enablePadElements(bool enable);
@ -88,11 +91,13 @@ private:
wxPoint ScaledPoint(wxPoint point, int widgetWidth = 0, bool rightAligned = false);
wxPoint ScaledPoint(int x, int y, int widgetWidth = 0, bool rightAligned = false);
ImageFile NewBitmap(wxImage resource, wxPoint point);
ImageFile NewBitmap(float scalingFactor, wxImage resource, wxPoint point);
ImageFile NewBitmap(wxImage resource, wxPoint imgCoord);
ImageFile NewBitmap(float scalingFactor, wxImage resource, wxPoint imgCoord);
void InitPressureButtonGuiElements(ControllerPressureButton &button, ImageFile image, wxWindow *parentWindow, wxPoint point, bool rightAlignedPoint = false);
void InitNormalButtonGuiElements(ControllerNormalButton &btn, ImageFile image, wxWindow *parentWindow, wxPoint point);
void InitPressureButtonGuiElements(ControllerPressureButton& button, ImageFile image, wxWindow* parentWindow, wxPoint pressureSpinnerCoord, bool rightAlignedCoord = false);
void InitNormalButtonGuiElements(ControllerNormalButton& btn, ImageFile image, wxWindow* parentWindow, wxPoint checkboxCoord);
void InitAnalogStickGuiElements(AnalogStick& analog, wxWindow* parentWindow, wxPoint centerPoint, int radius, wxPoint xSliderPoint,
wxPoint ySliderPoint, bool flipYSlider, wxPoint xSpinnerPoint, wxPoint ySpinnerPoint, bool rightAlignedSpinners = false);
};
#endif

View File

@ -80,3 +80,5 @@ bool VirtualPadData::UpdateVirtualPadData(u16 bufIndex, PadData *padData, bool i
}
return changeDetected;
}
#endif

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
#include "Pcsx2Types.h"
#include "Recording/PadData.h"
@ -57,3 +59,5 @@ public:
// returns a boolean to indicate if it has updated the PadData
bool UpdateVirtualPadData(u16 bufIndex, PadData* padData, bool ignoreRealController = false, bool readOnly = false);
};
#endif

View File

@ -86,7 +86,8 @@ void AnalogStick::UpdateGuiElement(std::queue<VirtualPadElement *> &renderQueue,
{
renderQueue.push(this);
}
else if (analogStick.currentlyRendered) {
else if (analogStick.currentlyRendered)
{
analogStick.currentlyRendered = false;
clearScreenRequired = true;
}
@ -108,9 +109,12 @@ void ControllerNormalButton::EnableWidgets(bool enable)
void ControllerPressureButton::EnableWidgets(bool enable)
{
ControllerPressureButton& button = *this;
if (enable) {
if (enable)
{
button.pressureSpinner->Enable();
} else {
}
else
{
button.pressureSpinner->Disable();
}
}
@ -118,12 +122,15 @@ void ControllerPressureButton::EnableWidgets(bool enable)
void AnalogStick::EnableWidgets(bool enable)
{
AnalogStick& analog = *this;
if (enable) {
if (enable)
{
analog.xVector.slider->Enable();
analog.yVector.slider->Enable();
analog.xVector.spinner->Enable();
analog.yVector.spinner->Enable();
} else {
}
else
{
analog.xVector.slider->Disable();
analog.yVector.slider->Disable();
analog.xVector.spinner->Disable();
@ -159,7 +166,8 @@ void AnalogStick::Render(wxDC &dc)
// NOTE - The conventional way to do this is using arctan2, but the analog values that come out
// of the Pad plugins in pcsx2 do not permit this, the coordinates returned do not define a circle.
const float lengthOfLine = sqrt(pow(newXCoord - analogPos.centerCoords.x, 2) + pow(newYCoord - analogPos.centerCoords.y, 2));
if (lengthOfLine > analogPos.radius) {
if (lengthOfLine > analogPos.radius)
{
newXCoord = ((1 - analogPos.radius / lengthOfLine) * analogPos.centerCoords.x) + analogPos.radius / lengthOfLine * newXCoord;
newYCoord = ((1 - analogPos.radius / lengthOfLine) * analogPos.centerCoords.y) + analogPos.radius / lengthOfLine * newYCoord;
}
@ -186,15 +194,18 @@ bool ControllerPressureButton::UpdateData(bool &padDataVal, bool ignoreRealContr
bool ControllerButton::UpdateButtonData(bool& padDataVal, bool ignoreRealController, bool readOnly)
{
ControllerButton& button = *this;
if (!ignoreRealController || readOnly) {
if (!ignoreRealController || readOnly)
{
// If controller is being bypassed and controller's state has changed
const bool bypassedWithChangedState = button.isControllerPressBypassed && padDataVal != button.prevPressedVal;
if (bypassedWithChangedState) {
if (bypassedWithChangedState)
{
button.prevPressedVal = padDataVal;
button.isControllerPressBypassed = false;
}
// If we aren't bypassing the controller OR the previous condition was met
if (bypassedWithChangedState || !button.isControllerPressBypassed || readOnly) {
if (bypassedWithChangedState || !button.isControllerPressBypassed || readOnly)
{
button.widgetUpdateRequired = button.pressed != padDataVal;
button.pressed = padDataVal;
return false;
@ -209,13 +220,16 @@ bool ControllerButton::UpdateButtonData(bool &padDataVal, bool ignoreRealControl
bool ControllerPressureButton::UpdateData(u8& padDataVal, bool ignoreRealController, bool readOnly)
{
ControllerPressureButton& button = *this;
if (!ignoreRealController || readOnly) {
if (!ignoreRealController || readOnly)
{
const bool bypassedWithChangedState = button.isControllerPressureBypassed && padDataVal != button.prevPressureVal;
if (bypassedWithChangedState) {
if (bypassedWithChangedState)
{
button.prevPressureVal = padDataVal;
button.isControllerPressureBypassed = false;
}
if (bypassedWithChangedState || !button.isControllerPressureBypassed || readOnly) {
if (bypassedWithChangedState || !button.isControllerPressureBypassed || readOnly)
{
button.widgetUpdateRequired = button.pressure != padDataVal;
button.pressure = padDataVal;
return false;
@ -229,13 +243,16 @@ bool ControllerPressureButton::UpdateData(u8 &padDataVal, bool ignoreRealControl
bool AnalogVector::UpdateData(u8& padDataVal, bool ignoreRealController, bool readOnly)
{
AnalogVector& vector = *this;
if (!ignoreRealController || readOnly) {
if (!ignoreRealController || readOnly)
{
const bool bypassedWithChangedState = vector.isControllerBypassed && padDataVal != vector.prevVal;
if (bypassedWithChangedState) {
if (bypassedWithChangedState)
{
vector.prevVal = padDataVal;
vector.isControllerBypassed = false;
}
if (bypassedWithChangedState || !vector.isControllerBypassed || readOnly) {
if (bypassedWithChangedState || !vector.isControllerBypassed || readOnly)
{
vector.widgetUpdateRequired = vector.val != padDataVal;
vector.val = padDataVal;
return false;
@ -245,3 +262,5 @@ bool AnalogVector::UpdateData(u8 &padDataVal, bool ignoreRealController, bool re
padDataVal = vector.val;
return vector.prevVal != vector.val;
}
#endif

View File

@ -15,6 +15,8 @@
#pragma once
#ifndef DISABLE_RECORDING
#include <queue>
#include "Pcsx2Types.h"
@ -119,3 +121,5 @@ public:
void Render(wxDC& dc) override;
void UpdateGuiElement(std::queue<VirtualPadElement*>& renderQueue, bool& clearScreenRequired) override;
};
#endif

View File

@ -0,0 +1 @@
*.h

View File

@ -0,0 +1,18 @@
:: Probably self-explanatory: This batch file compiles a single souce image into a
:: CPP header file for use by pcsx2.
::
:: bin2cpp.cmd SrcImage
::
:: Parameters
:: SrcImage - Complete filename with extension.
::
@echo off
SETLOCAL ENABLEEXTENSIONS
cd "%~0\..\"
"..\..\..\..\tools\bin\bin2cpp.exe" %1
ENDLOCAL

View File

@ -1,12 +0,0 @@
# ----
# Runs all *.png files in the current directory
# through tools/bin/bin2cpp.exe
# which creates a header file with the image data to be used
# with wxWidgets (wxBitmap / wxImage specifically)
# ----
$files = Get-ChildItem -Path $PSScriptRoot -Filter *.png
foreach ($f in $files ) {
..\..\..\..\tools\bin\bin2cpp.exe $f.Name
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 699 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 854 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -79,11 +79,11 @@ void Pcsx2App::OpenMainFrame()
#ifndef DISABLE_RECORDING
VirtualPad* virtualPad0 = new VirtualPad(mainFrame, wxID_ANY, wxEmptyString, 0);
g_inputRecording.setVirtualPadPtr(virtualPad0, 0);
g_InputRecording.setVirtualPadPtr(virtualPad0, 0);
m_id_VirtualPad[0] = virtualPad0->GetId();
VirtualPad *virtualPad1 = new VirtualPad(mainFrame, wxID_ANY, wxEmptyString, 1);
g_inputRecording.setVirtualPadPtr(virtualPad1, 1);
g_InputRecording.setVirtualPadPtr(virtualPad1, 1);
m_id_VirtualPad[1] = virtualPad1->GetId();
NewRecordingFrame* newRecordingFrame = new NewRecordingFrame(mainFrame);

View File

@ -144,6 +144,75 @@
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<!-- Generate Recording GUI Image Headers -->
<CustomBuild Include="..\..\Recording\VirtualPad\img\controller.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\circlePressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\crossPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\downPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\l1Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\l2Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\l3Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\leftPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\r1Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\r2Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\r3Pressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\rightPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\selectPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\squarePressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\startPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\trianglePressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\Recording\VirtualPad\img\upPressed.png">
<Command>cmd.exe /c %(RelativeDir)bin2cpp.cmd %(Filename)%(Extension)</Command>
<Outputs>%(RelativeDir)%(Filename).h</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\CDVD\BlockdumpFileReader.cpp" />