diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2019-03-13 19:47:52 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2019-04-13 08:45:19 -0500 |
| commit | be897b41a746b2c9e427a3411681f1571dea7003 (patch) | |
| tree | 1bf1c01b31c57527180ce6270d2d9d553e7deb71 /Source/Core/InputCommon/ControllerInterface/Device.cpp | |
| parent | 241166a1a5becb0a6a2af209e7f5ea2962d6a2dd (diff) | |
ControllerInterface: Rename full surface analog inputs to be more visually dissimilar from their underlying inputs. e.g. "Full Axis X+".
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Device.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Device.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.cpp b/Source/Core/InputCommon/ControllerInterface/Device.cpp index 4cd50fa08e..7624b359d1 100644 --- a/Source/Core/InputCommon/ControllerInterface/Device.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Device.cpp @@ -55,7 +55,7 @@ Device::Input* Device::FindInput(const std::string& name) const { for (Input* input : m_inputs) { - if (input->GetName() == name) + if (input->IsMatchingName(name)) return input; } @@ -66,18 +66,42 @@ Device::Output* Device::FindOutput(const std::string& name) const { for (Output* output : m_outputs) { - if (output->GetName() == name) + if (output->IsMatchingName(name)) return output; } return nullptr; } +bool Device::Control::IsMatchingName(const std::string& name) const +{ + return GetName() == name; +} + ControlState Device::FullAnalogSurface::GetState() const { return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2; } +std::string Device::FullAnalogSurface::GetName() const +{ + // E.g. "Full Axis X+" + return "Full " + m_high.GetName(); +} + +bool Device::FullAnalogSurface::IsMatchingName(const std::string& name) const +{ + 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; +} + // // DeviceQualifier :: ToString // |
