From f8cca9fe5dc93b051fbb63247edad99533f19bfc Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 24 Feb 2020 16:55:44 -0600 Subject: InputCommon: RoundStickGate's ideal sample count can be 1. --- Source/Core/InputCommon/ControllerEmu/StickGate.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp') diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index 0b16103773..3346b874a2 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -54,7 +54,7 @@ constexpr int ReshapableInput::CALIBRATION_SAMPLE_COUNT; std::optional StickGate::GetIdealCalibrationSampleCount() const { - return {}; + return std::nullopt; } OctagonStickGate::OctagonStickGate(ControlState radius) : m_radius(radius) @@ -86,6 +86,12 @@ ControlState RoundStickGate::GetRadiusAtAngle(double) const return m_radius; } +std::optional RoundStickGate::GetIdealCalibrationSampleCount() const +{ + // The "radius" is the same at every angle so a single sample is enough. + return 1; +} + SquareStickGate::SquareStickGate(ControlState half_width) : m_half_width(half_width) { } -- cgit v1.2.3 From bd43e084f4e911d5eeec2f237559f382cd89f795 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 24 Feb 2020 16:58:25 -0600 Subject: InputCommon: Clamp calibration values within square shape. --- Source/Core/InputCommon/ControllerEmu/StickGate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp') diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index 3346b874a2..30c9acdcbd 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -183,7 +183,8 @@ void ReshapableInput::UpdateCalibrationData(CalibrationData& data, Common::DVec2 auto& calibration_sample = data[calibration_index]; // Update closest sample from provided x,y. - calibration_sample = std::max(calibration_sample, point.Length()); + calibration_sample = std::clamp(point.Length(), calibration_sample, + SquareStickGate(1).GetRadiusAtAngle(calibration_angle)); // Here we update all other samples in our calibration vector to maintain // a convex polygon containing our new calibration point. -- cgit v1.2.3 From ed24f32c5bf31bbb249f2748e38d6066bb7f72d1 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 24 Feb 2020 16:59:23 -0600 Subject: InputCommon: Specify ini value default when saving calibration "center". --- Source/Core/InputCommon/ControllerEmu/StickGate.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp') diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index 30c9acdcbd..5e2acb3f5b 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -282,10 +282,11 @@ void ReshapableInput::SaveConfig(IniFile::Section* section, const std::string& d [](ControlState val) { return fmt::format("{:.2f}", val * CALIBRATION_CONFIG_SCALE); }); section->Set(group + CALIBRATION_CONFIG_NAME, JoinStrings(save_data, " "), ""); - const auto center_data = fmt::format("{:.2f} {:.2f}", m_center.x * CENTER_CONFIG_SCALE, + // Save center value. + static constexpr char center_format[] = "{:.2f} {:.2f}"; + const auto center_data = fmt::format(center_format, m_center.x * CENTER_CONFIG_SCALE, m_center.y * CENTER_CONFIG_SCALE); - - section->Set(group + CENTER_CONFIG_NAME, center_data, ""); + section->Set(group + CENTER_CONFIG_NAME, center_data, fmt::format(center_format, 0.0, 0.0)); } ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlState y, -- cgit v1.2.3