mirror of https://github.com/PCSX2/pcsx2.git
Pad: Add GetEffectiveInput()
Returns the value, incorporating any deadzone.
This commit is contained in:
parent
c0d86c3852
commit
6f34b7ba99
|
@ -47,6 +47,7 @@ public: // Public members
|
|||
virtual void SetButtonDeadzone(float deadzone) = 0;
|
||||
virtual void SetAnalogInvertL(bool x, bool y) = 0;
|
||||
virtual void SetAnalogInvertR(bool x, bool y) = 0;
|
||||
virtual u8 GetEffectiveInput(u32 index) const = 0;
|
||||
virtual u8 GetRawInput(u32 index) const = 0;
|
||||
virtual std::tuple<u8, u8> GetRawLeftAnalog() const = 0;
|
||||
virtual std::tuple<u8, u8> GetRawRightAnalog() const = 0;
|
||||
|
|
|
@ -785,6 +785,42 @@ void PadDualshock2::SetAnalogInvertR(bool x, bool y)
|
|||
this->analogs.ryInvert = y;
|
||||
}
|
||||
|
||||
u8 PadDualshock2::GetEffectiveInput(u32 index) const
|
||||
{
|
||||
if (!IsAnalogKey(index))
|
||||
return GetRawInput(index);
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case Inputs::PAD_L_LEFT:
|
||||
return (analogs.lx > 0 && analogs.lx < 127) ? analogs.lx : 0;
|
||||
|
||||
case Inputs::PAD_L_RIGHT:
|
||||
return (analogs.lx >= 128) ? analogs.lx : 0;
|
||||
|
||||
case Inputs::PAD_L_UP:
|
||||
return (analogs.ly > 0 && analogs.ly < 127) ? analogs.ly : 0;
|
||||
|
||||
case Inputs::PAD_L_DOWN:
|
||||
return (analogs.ly >= 128) ? analogs.ly : 0;
|
||||
|
||||
case Inputs::PAD_R_LEFT:
|
||||
return (analogs.rx > 0 && analogs.rx < 127) ? analogs.rx : 0;
|
||||
|
||||
case Inputs::PAD_R_RIGHT:
|
||||
return (analogs.rx >= 128) ? analogs.rx : 0;
|
||||
|
||||
case Inputs::PAD_R_UP:
|
||||
return (analogs.ry > 0 && analogs.ry < 127) ? analogs.ry : 0;
|
||||
|
||||
case Inputs::PAD_R_DOWN:
|
||||
return (analogs.ry >= 128) ? analogs.ry : 0;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
u8 PadDualshock2::GetRawInput(u32 index) const
|
||||
{
|
||||
return rawInputs[index];
|
||||
|
|
|
@ -125,6 +125,7 @@ public:
|
|||
void SetButtonDeadzone(float deadzone) override;
|
||||
void SetAnalogInvertL(bool x, bool y) override;
|
||||
void SetAnalogInvertR(bool x, bool y) override;
|
||||
u8 GetEffectiveInput(u32 index) const override;
|
||||
u8 GetRawInput(u32 index) const override;
|
||||
std::tuple<u8, u8> GetRawLeftAnalog() const override;
|
||||
std::tuple<u8, u8> GetRawRightAnalog() const override;
|
||||
|
|
|
@ -355,6 +355,11 @@ void PadGuitar::SetAnalogInvertR(bool x, bool y)
|
|||
{
|
||||
}
|
||||
|
||||
u8 PadGuitar::GetEffectiveInput(u32 index) const
|
||||
{
|
||||
return GetRawInput(index);
|
||||
}
|
||||
|
||||
u8 PadGuitar::GetRawInput(u32 index) const
|
||||
{
|
||||
return rawInputs[index];
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
void SetButtonDeadzone(float deadzone) override;
|
||||
void SetAnalogInvertL(bool x, bool y) override;
|
||||
void SetAnalogInvertR(bool x, bool y) override;
|
||||
u8 GetEffectiveInput(u32 index) const override;
|
||||
u8 GetRawInput(u32 index) const override;
|
||||
std::tuple<u8, u8> GetRawLeftAnalog() const override;
|
||||
std::tuple<u8, u8> GetRawRightAnalog() const override;
|
||||
|
|
|
@ -76,6 +76,11 @@ void PadNotConnected::SetAnalogInvertR(bool x, bool y)
|
|||
|
||||
}
|
||||
|
||||
u8 PadNotConnected::GetEffectiveInput(u32 index) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 PadNotConnected::GetRawInput(u32 index) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
void SetButtonDeadzone(float deadzone) override;
|
||||
void SetAnalogInvertL(bool x, bool y) override;
|
||||
void SetAnalogInvertR(bool x, bool y) override;
|
||||
u8 GetEffectiveInput(u32 index) const override;
|
||||
u8 GetRawInput(u32 index) const override;
|
||||
std::tuple<u8, u8> GetRawLeftAnalog() const override;
|
||||
std::tuple<u8, u8> GetRawRightAnalog() const override;
|
||||
|
|
|
@ -441,6 +441,11 @@ void PadPopn::SetAnalogInvertR(bool x, bool y)
|
|||
{
|
||||
}
|
||||
|
||||
u8 PadPopn::GetEffectiveInput(u32 index) const
|
||||
{
|
||||
return GetRawInput(index);
|
||||
}
|
||||
|
||||
u8 PadPopn::GetRawInput(u32 index) const
|
||||
{
|
||||
return rawInputs[index];
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
void SetButtonDeadzone(float deadzone) override;
|
||||
void SetAnalogInvertL(bool x, bool y) override;
|
||||
void SetAnalogInvertR(bool x, bool y) override;
|
||||
u8 GetEffectiveInput(u32 index) const override;
|
||||
u8 GetRawInput(u32 index) const override;
|
||||
std::tuple<u8, u8> GetRawLeftAnalog() const override;
|
||||
std::tuple<u8, u8> GetRawRightAnalog() const override;
|
||||
|
|
Loading…
Reference in New Issue