diff --git a/pcsx2/Recording/PadData.cpp b/pcsx2/Recording/PadData.cpp index 46706ee26a..89364e1266 100644 --- a/pcsx2/Recording/PadData.cpp +++ b/pcsx2/Recording/PadData.cpp @@ -97,24 +97,24 @@ void PadData::OverrideActualController() const PadBase* pad = Pad::GetPad(m_ext_port); pad->SetRawAnalogs(m_leftAnalog, m_rightAnalog); - pad->Set(PadDualshock2::Inputs::PAD_RIGHT, std::get<1>(m_right)); - pad->Set(PadDualshock2::Inputs::PAD_LEFT, std::get<1>(m_left)); - pad->Set(PadDualshock2::Inputs::PAD_UP, std::get<1>(m_up)); - pad->Set(PadDualshock2::Inputs::PAD_DOWN, std::get<1>(m_down)); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_RIGHT, m_right); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_LEFT, m_left); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_UP, m_up); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_DOWN, m_down); pad->Set(PadDualshock2::Inputs::PAD_START, m_start); pad->Set(PadDualshock2::Inputs::PAD_SELECT, m_select); pad->Set(PadDualshock2::Inputs::PAD_R3, m_r3); pad->Set(PadDualshock2::Inputs::PAD_L3, m_l3); - pad->Set(PadDualshock2::Inputs::PAD_SQUARE, std::get<1>(m_square)); - pad->Set(PadDualshock2::Inputs::PAD_CROSS, std::get<1>(m_cross)); - pad->Set(PadDualshock2::Inputs::PAD_CIRCLE, std::get<1>(m_circle)); - pad->Set(PadDualshock2::Inputs::PAD_TRIANGLE, std::get<1>(m_triangle)); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_SQUARE, m_square); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_CROSS, m_cross); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_CIRCLE, m_circle); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_TRIANGLE, m_triangle); - pad->Set(PadDualshock2::Inputs::PAD_R1, std::get<1>(m_r1)); - pad->Set(PadDualshock2::Inputs::PAD_L1, std::get<1>(m_l1)); - pad->Set(PadDualshock2::Inputs::PAD_R2, std::get<1>(m_r2)); - pad->Set(PadDualshock2::Inputs::PAD_L2, std::get<1>(m_l2)); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_R1, m_r1); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_L1, m_l1); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_R2, m_r2); + pad->SetRawPressureButton(PadDualshock2::Inputs::PAD_L2, m_l2); } void addButtonInfoToString(std::string label, std::string& str, std::tuple buttonInfo) diff --git a/pcsx2/SIO/Pad/PadBase.h b/pcsx2/SIO/Pad/PadBase.h index acfb2af514..98a7d6602f 100644 --- a/pcsx2/SIO/Pad/PadBase.h +++ b/pcsx2/SIO/Pad/PadBase.h @@ -39,6 +39,7 @@ public: // Public members virtual void Set(u32 index, float value) = 0; virtual void SetRawAnalogs(const std::tuple left, const std::tuple right) = 0; + virtual void SetRawPressureButton(u32 index, const std::tuple value) = 0; virtual void SetAxisScale(float deadzone, float scale) = 0; virtual float GetVibrationScale(u32 motor) const = 0; virtual void SetVibrationScale(u32 motor, float scale) = 0; diff --git a/pcsx2/SIO/Pad/PadDualshock2.cpp b/pcsx2/SIO/Pad/PadDualshock2.cpp index cb2e2fbeaf..dd19000b2e 100644 --- a/pcsx2/SIO/Pad/PadDualshock2.cpp +++ b/pcsx2/SIO/Pad/PadDualshock2.cpp @@ -560,29 +560,6 @@ void PadDualshock2::Set(u32 index, float value) return; } - // Since we reordered the buttons for better UI, we need to remap them here. - static constexpr std::array bitmaskMapping = {{ - 12, // PAD_UP - 13, // PAD_RIGHT - 14, // PAD_DOWN - 15, // PAD_LEFT - 4, // PAD_TRIANGLE - 5, // PAD_CIRCLE - 6, // PAD_CROSS - 7, // PAD_SQUARE - 8, // PAD_SELECT - 11, // PAD_START - 2, // PAD_L1 - 0, // PAD_L2 - 3, // PAD_R1 - 1, // PAD_R2 - 9, // PAD_L3 - 10, // PAD_R3 - 16, // PAD_ANALOG - 17, // PAD_PRESSURE - // remainder are analogs and not used here - }}; - if (IsAnalogKey(index)) { this->rawInputs[index] = static_cast(std::clamp(value * this->axisScale * 255.0f, 0.0f, 255.0f)); @@ -742,6 +719,20 @@ void PadDualshock2::SetRawAnalogs(const std::tuple left, const std::tupl this->analogs.ry = std::get<1>(right); } +void PadDualshock2::SetRawPressureButton(u32 index, const std::tuple value) +{ + this->rawInputs[index] = std::get<1>(value); + + if (std::get<0>(value)) + { + this->buttons &= ~(1u << bitmaskMapping[index]); + } + else + { + this->buttons |= (1u << bitmaskMapping[index]); + } +} + void PadDualshock2::SetAxisScale(float deadzone, float scale) { this->axisDeadzone = deadzone; diff --git a/pcsx2/SIO/Pad/PadDualshock2.h b/pcsx2/SIO/Pad/PadDualshock2.h index 83e8597490..c1c51d45aa 100644 --- a/pcsx2/SIO/Pad/PadDualshock2.h +++ b/pcsx2/SIO/Pad/PadDualshock2.h @@ -85,6 +85,29 @@ private: // Used to store the last vibration mapping request the PS2 made for the large motor. u8 largeMotorLastConfig = 0xff; + // Since we reordered the buttons for better UI, we need to remap them here. + static constexpr std::array bitmaskMapping = {{ + 12, // PAD_UP + 13, // PAD_RIGHT + 14, // PAD_DOWN + 15, // PAD_LEFT + 4, // PAD_TRIANGLE + 5, // PAD_CIRCLE + 6, // PAD_CROSS + 7, // PAD_SQUARE + 8, // PAD_SELECT + 11, // PAD_START + 2, // PAD_L1 + 0, // PAD_L2 + 3, // PAD_R1 + 1, // PAD_R2 + 9, // PAD_L3 + 10, // PAD_R3 + 16, // PAD_ANALOG + 17, // PAD_PRESSURE + // remainder are analogs and not used here + }}; + void ConfigLog(); u8 Mystery(u8 commandByte); @@ -117,6 +140,7 @@ public: const Pad::ControllerInfo& GetInfo() const override; void Set(u32 index, float value) override; void SetRawAnalogs(const std::tuple left, const std::tuple right) override; + void SetRawPressureButton(u32 index, const std::tuple value) override; void SetAxisScale(float deadzone, float scale) override; float GetVibrationScale(u32 motor) const override; void SetVibrationScale(u32 motor, float scale) override; diff --git a/pcsx2/SIO/Pad/PadGuitar.cpp b/pcsx2/SIO/Pad/PadGuitar.cpp index 76caf4450e..ec8d190869 100644 --- a/pcsx2/SIO/Pad/PadGuitar.cpp +++ b/pcsx2/SIO/Pad/PadGuitar.cpp @@ -318,6 +318,20 @@ void PadGuitar::SetRawAnalogs(const std::tuple left, const std::tuple value) +{ + this->rawInputs[index] = std::get<1>(value); + + if (std::get<0>(value)) + { + this->buttons &= ~(1u << bitmaskMapping[index]); + } + else + { + this->buttons |= (1u << bitmaskMapping[index]); + } +} + void PadGuitar::SetAxisScale(float deadzone, float scale) { this->whammyDeadzone = deadzone; diff --git a/pcsx2/SIO/Pad/PadGuitar.h b/pcsx2/SIO/Pad/PadGuitar.h index 88a07ba4e5..30c29516ec 100644 --- a/pcsx2/SIO/Pad/PadGuitar.h +++ b/pcsx2/SIO/Pad/PadGuitar.h @@ -37,6 +37,20 @@ private: float whammyDeadzone = 0.0f; float buttonDeadzone = 0.0f; // Button deadzone is still a good idea, in case a host analog stick is bound to a guitar button + // Since we reordered the buttons for better UI, we need to remap them here. + static constexpr std::array bitmaskMapping = {{ + 12, // STRUM_UP + 14, // STRUM_DOWN + 8, // SELECT + 11, // START + 1, // GREEN + 5, // RED + 4, // YELLOW + 6, // BLUE + 7, // ORANGE + 0 // TILT + }}; + void ConfigLog(); u8 Mystery(u8 commandByte); @@ -58,6 +72,7 @@ public: const Pad::ControllerInfo& GetInfo() const override; void Set(u32 index, float value) override; void SetRawAnalogs(const std::tuple left, const std::tuple right) override; + void SetRawPressureButton(u32 index, const std::tuple value) override; void SetAxisScale(float deadzone, float scale) override; float GetVibrationScale(u32 motor) const override; void SetVibrationScale(u32 motor, float scale) override; diff --git a/pcsx2/SIO/Pad/PadNotConnected.cpp b/pcsx2/SIO/Pad/PadNotConnected.cpp index f233a722f7..c1168b7566 100644 --- a/pcsx2/SIO/Pad/PadNotConnected.cpp +++ b/pcsx2/SIO/Pad/PadNotConnected.cpp @@ -36,6 +36,11 @@ void PadNotConnected::SetRawAnalogs(const std::tuple left, const std::tu } +void PadNotConnected::SetRawPressureButton(u32 index, const std::tuple value) +{ + +} + void PadNotConnected::SetAxisScale(float deadzone, float scale) { diff --git a/pcsx2/SIO/Pad/PadNotConnected.h b/pcsx2/SIO/Pad/PadNotConnected.h index 06d812244f..6abd9999d0 100644 --- a/pcsx2/SIO/Pad/PadNotConnected.h +++ b/pcsx2/SIO/Pad/PadNotConnected.h @@ -15,6 +15,7 @@ public: const Pad::ControllerInfo& GetInfo() const override; void Set(u32 index, float value) override; void SetRawAnalogs(const std::tuple left, const std::tuple right) override; + void SetRawPressureButton(u32 index, const std::tuple value) override; void SetAxisScale(float deadzone, float scale) override; float GetVibrationScale(u32 motor) const override; void SetVibrationScale(u32 motor, float scale) override; diff --git a/pcsx2/SIO/Pad/PadPopn.cpp b/pcsx2/SIO/Pad/PadPopn.cpp index 9de81e8219..16099b80bb 100644 --- a/pcsx2/SIO/Pad/PadPopn.cpp +++ b/pcsx2/SIO/Pad/PadPopn.cpp @@ -376,21 +376,6 @@ void PadPopn::Set(u32 index, float value) return; } - // Since we reordered the buttons for better UI, we need to remap them here. - static constexpr std::array bitmaskMapping = {{ - 5, // PAD_YELLOW_LEFT - 12, // PAD_YELLOW_RIGHT - 6, // PAD_BLUE_LEFT - 7, // PAD_BLUE_RIGHT - 4, // PAD_WHITE_LEFT - 0, // PAD_WHITE_RIGHT - 3, // PAD_GREEN_LEFT - 1, // PAD_GREEN_RIGHT - 2, // PAD_RED - 11, // PAD_START - 8, // PAD_SELECT - }}; - this->rawInputs[index] = static_cast(std::clamp(value * 255.0f, 0.0f, 255.0f)); if (value) @@ -407,6 +392,20 @@ void PadPopn::SetRawAnalogs(const std::tuple left, const std::tuple value) +{ + this->rawInputs[index] = std::get<1>(value); + + if (std::get<0>(value)) + { + this->buttons &= ~(1u << bitmaskMapping[index]); + } + else + { + this->buttons |= (1u << bitmaskMapping[index]); + } +} + void PadPopn::SetAxisScale(float deadzone, float scale) { } diff --git a/pcsx2/SIO/Pad/PadPopn.h b/pcsx2/SIO/Pad/PadPopn.h index 98b60f197b..b2ac9f3862 100644 --- a/pcsx2/SIO/Pad/PadPopn.h +++ b/pcsx2/SIO/Pad/PadPopn.h @@ -59,6 +59,21 @@ private: bool commandStage = false; u32 responseBytes = 0; + // Since we reordered the buttons for better UI, we need to remap them here. + static constexpr std::array bitmaskMapping = {{ + 5, // PAD_YELLOW_LEFT + 12, // PAD_YELLOW_RIGHT + 6, // PAD_BLUE_LEFT + 7, // PAD_BLUE_RIGHT + 4, // PAD_WHITE_LEFT + 0, // PAD_WHITE_RIGHT + 3, // PAD_GREEN_LEFT + 1, // PAD_GREEN_RIGHT + 2, // PAD_RED + 11, // PAD_START + 8, // PAD_SELECT + }}; + void ConfigLog(); u8 Mystery(u8 commandByte); @@ -81,6 +96,7 @@ public: const Pad::ControllerInfo& GetInfo() const override; void Set(u32 index, float value) override; void SetRawAnalogs(const std::tuple left, const std::tuple right) override; + void SetRawPressureButton(u32 index, const std::tuple value) override; void SetAxisScale(float deadzone, float scale) override; float GetVibrationScale(u32 motor) const override; void SetVibrationScale(u32 motor, float scale) override;