InputCommon: Move FullAnalogSurface class definition out of header file.
This commit is contained in:
parent
2f1390e9f9
commit
346a9e0f97
|
@ -130,39 +130,43 @@ bool Device::Control::IsHidden() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Device::FullAnalogSurface::GetState() const
|
class FullAnalogSurface final : public Device::Input
|
||||||
{
|
{
|
||||||
return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2;
|
public:
|
||||||
}
|
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
|
||||||
|
|
||||||
std::string Device::FullAnalogSurface::GetName() const
|
ControlState GetState() const override
|
||||||
{
|
{
|
||||||
// E.g. "Full Axis X+"
|
return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2;
|
||||||
return "Full " + m_high.GetName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool Device::FullAnalogSurface::IsDetectable() const
|
std::string GetName() const override
|
||||||
{
|
{
|
||||||
return m_low.IsDetectable() && m_high.IsDetectable();
|
// E.g. "Full Axis X+"
|
||||||
}
|
return "Full " + m_high.GetName();
|
||||||
|
}
|
||||||
|
|
||||||
bool Device::FullAnalogSurface::IsHidden() const
|
bool IsDetectable() const override { return m_low.IsDetectable() && m_high.IsDetectable(); }
|
||||||
{
|
|
||||||
return m_low.IsHidden() && m_high.IsHidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Device::FullAnalogSurface::IsMatchingName(std::string_view name) const
|
bool IsHidden() const override { return m_low.IsHidden() && m_high.IsHidden(); }
|
||||||
{
|
|
||||||
if (Control::IsMatchingName(name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Old naming scheme was "Axis X-+" which is too visually similar to "Axis X+".
|
bool IsMatchingName(std::string_view name) const override
|
||||||
// This has caused countless problems for users with mysterious misconfigurations.
|
{
|
||||||
// We match this old name to support old configurations.
|
if (Control::IsMatchingName(name))
|
||||||
const auto old_name = m_low.GetName() + *m_high.GetName().rbegin();
|
return true;
|
||||||
|
|
||||||
return old_name == name;
|
// Old naming scheme was "Axis X-+" which is too visually similar to "Axis X+".
|
||||||
}
|
// This has caused countless problems for users with mysterious misconfigurations.
|
||||||
|
// We match this old name to support old configurations.
|
||||||
|
const auto old_name = m_low.GetName() + *m_high.GetName().rbegin();
|
||||||
|
|
||||||
|
return old_name == name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Input& m_low;
|
||||||
|
Input& m_high;
|
||||||
|
};
|
||||||
|
|
||||||
void Device::AddFullAnalogSurfaceInputs(Input* low, Input* high)
|
void Device::AddFullAnalogSurfaceInputs(Input* low, Input* high)
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,21 +163,6 @@ protected:
|
||||||
void AddInput(Input* const i);
|
void AddInput(Input* const i);
|
||||||
void AddOutput(Output* const o);
|
void AddOutput(Output* const o);
|
||||||
|
|
||||||
class FullAnalogSurface final : public Input
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
|
|
||||||
ControlState GetState() const override;
|
|
||||||
std::string GetName() const override;
|
|
||||||
bool IsDetectable() const override;
|
|
||||||
bool IsHidden() const override;
|
|
||||||
bool IsMatchingName(std::string_view name) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Input& m_low;
|
|
||||||
Input& m_high;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pass Inputs for center-neutral (- and +) directions of some axis.
|
// Pass Inputs for center-neutral (- and +) directions of some axis.
|
||||||
// This function adds those Inputs and also a FullAnalogSurface Input for each direction.
|
// This function adds those Inputs and also a FullAnalogSurface Input for each direction.
|
||||||
// This is only needed when it's not known if the particular axis is neutral in the center
|
// This is only needed when it's not known if the particular axis is neutral in the center
|
||||||
|
|
Loading…
Reference in New Issue