Skip to content

Commit

Permalink
StickGate: add custom clamp value
Browse files Browse the repository at this point in the history
Works exactly as before by default.
It will be used by my upcoming input PRs.
  • Loading branch information
Filoppi committed May 12, 2021
1 parent 5f74d0e commit 26f6648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Source/Core/InputCommon/ControllerEmu/StickGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ void ReshapableInput::SaveConfig(IniFile::Section* section, const std::string& d
}

ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlState y,
ControlState modifier) const
ControlState modifier,
ControlState clamp) const
{
x -= m_center.x;
y -= m_center.y;
Expand Down Expand Up @@ -326,8 +327,8 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
// Scale to the gate shape/radius:
dist *= gate_max_dist;

return {std::clamp(std::cos(angle) * dist, -1.0, 1.0),
std::clamp(std::sin(angle) * dist, -1.0, 1.0)};
return {std::clamp(std::cos(angle) * dist, -clamp, clamp),
std::clamp(std::sin(angle) * dist, -clamp, clamp)};
}

} // namespace ControllerEmu
3 changes: 2 additions & 1 deletion Source/Core/InputCommon/ControllerEmu/StickGate.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class ReshapableInput : public ControlGroup
void SetCenter(ReshapeData center);

protected:
ReshapeData Reshape(ControlState x, ControlState y, ControlState modifier = 0.0) const;
ReshapeData Reshape(ControlState x, ControlState y, ControlState modifier = 0.0,
ControlState clamp = 1.0) const;

private:
void LoadConfig(IniFile::Section*, const std::string&, const std::string&) override;
Expand Down

0 comments on commit 26f6648

Please sign in to comment.