From 70ac9ad2e6faf120c8ef4859141675c33e5f33c7 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 12 Feb 2020 19:32:39 -0600 Subject: [PATCH] InputCommon: Remove Wii Remote real-time calibration of M+ in favor of functionality provided by ControllerEmu. --- .../ControllerInterface/Wiimote/Wiimote.cpp | 41 +------------------ .../ControllerInterface/Wiimote/Wiimote.h | 6 --- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp index c5d756fb15..34a169aa83 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp @@ -1323,46 +1323,7 @@ void Device::MotionPlusState::ProcessData(const WiimoteEmu::MotionPlus::DataForm if (!calibration.has_value()) return; - // Unfortunately M+ calibration zero values are very poor. - // We calibrate when we receive a few seconds of stable data. - const auto unadjusted_gyro_data = data.GetData().GetAngularVelocity(*calibration); - - // Use zero-data calibration until acquired. - const auto adjusted_gyro_data = - unadjusted_gyro_data - m_dynamic_calibration.value_or(Common::Vec3{}); - - // We want quick calibration when remote is set down but not when held in the hand. - // This magic value seems to work well enough. - static constexpr auto UNSTABLE_ROTATION = float(MathUtil::TAU / 120); - - const bool is_stable = (adjusted_gyro_data - gyro_data).Length() < UNSTABLE_ROTATION; - - gyro_data = adjusted_gyro_data; - - // If we've yet to achieve calibration acquire one more quickly. - // This lessens the extreme drift on initial M+ activation. - const auto required_stable_frames = m_dynamic_calibration.has_value() ? 100u : 5u; - - if (is_stable) - { - if (++m_new_calibration_frames < required_stable_frames) - { - m_new_dynamic_calibration += unadjusted_gyro_data; - } - else - { - m_dynamic_calibration = m_new_dynamic_calibration / m_new_calibration_frames; - m_new_dynamic_calibration = {}; - m_new_calibration_frames = 0; - - DEBUG_LOG(WIIMOTE, "WiiRemote: M+ applied dynamic calibration."); - } - } - else - { - m_new_dynamic_calibration = {}; - m_new_calibration_frames = 0; - } + gyro_data = data.GetData().GetAngularVelocity(*calibration); } bool Device::IsWaitingForMotionPlus() const diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.h b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.h index e70ad0f293..75296c65b1 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.h +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.h @@ -64,12 +64,6 @@ private: Common::Vec3 gyro_data = {}; std::optional calibration; - - private: - // Used to perform realtime calibration. - std::optional m_dynamic_calibration = {}; - Common::Vec3 m_new_dynamic_calibration = {}; - u32 m_new_calibration_frames = 0; }; struct NunchukState