diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2024-11-04 11:04:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-04 11:04:50 +0100 |
| commit | b8823457c14248b61ffb400c6af080db2aa799b0 (patch) | |
| tree | 444be031ade83f8ef00c719f3dc1b813d780bafb /Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp | |
| parent | 6a59e83bbba2a1495a89a844e636f67aa87a32a8 (diff) | |
| parent | 346a9e0f97d4e17abb237a638896ef43db30488f (diff) | |
Merge pull request #13165 from jordan-woyak/FullAnalogSurface-rename
InputCommon: Rename AddAnalogInputs to AddFullAnalogSurfaceInputs.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp index 8cf3e763e8..377ea4444f 100644 --- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp +++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp @@ -130,38 +130,50 @@ bool Device::Control::IsHidden() const 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 -{ - // E.g. "Full Axis X+" - return "Full " + m_high.GetName(); -} + ControlState GetState() const override + { + return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2; + } -bool Device::FullAnalogSurface::IsDetectable() const -{ - return m_low.IsDetectable() && m_high.IsDetectable(); -} + std::string GetName() const override + { + // E.g. "Full Axis X+" + return "Full " + m_high.GetName(); + } -bool Device::FullAnalogSurface::IsHidden() const -{ - return m_low.IsHidden() && m_high.IsHidden(); -} + bool IsDetectable() const override { return m_low.IsDetectable() && m_high.IsDetectable(); } -bool Device::FullAnalogSurface::IsMatchingName(std::string_view name) const -{ - if (Control::IsMatchingName(name)) - return true; + bool IsHidden() const override { return m_low.IsHidden() && m_high.IsHidden(); } - // 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(); + bool IsMatchingName(std::string_view name) const override + { + if (Control::IsMatchingName(name)) + return true; + + // 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; + return old_name == name; + } + +private: + Input& m_low; + Input& m_high; +}; + +void Device::AddFullAnalogSurfaceInputs(Input* low, Input* high) +{ + AddInput(low); + AddInput(high); + AddInput(new FullAnalogSurface(low, high)); + AddInput(new FullAnalogSurface(high, low)); } void Device::AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs) |
