summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-01-29 14:39:14 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2019-03-03 12:43:25 -0600
commit4db4840d7c6ca42dd33c4bfc1e46568622e3a96b (patch)
treea26ca3d48ad1b1181a88ac0c06fdb54fc969b416 /Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
parent902e407ae5eb39e03b127e9fd58f4a8193cd2ab8 (diff)
WiimoteEmu: Reimplement tilt/swing/camera/orientation data using matrix math.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp35
1 files changed, 2 insertions, 33 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
index bacf158be0..8407aa646f 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
@@ -4,13 +4,9 @@
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
-#include <algorithm>
-#include <cmath>
-#include <memory>
#include <string>
#include "Common/Common.h"
-#include "Common/MathUtil.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
@@ -19,8 +15,7 @@
namespace ControllerEmu
{
-Tilt::Tilt(const std::string& name_)
- : ReshapableInput(name_, name_, GroupType::Tilt), m_last_update(Clock::now())
+Tilt::Tilt(const std::string& name_) : ReshapableInput(name_, name_, GroupType::Tilt)
{
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
@@ -43,33 +38,7 @@ Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted)
const ControlState modifier = controls[4]->control_ref->State();
- // Compute desired tilt:
- StateData target = Reshape(x, y, modifier);
-
- // Step the simulation. This is somewhat ugly being here.
- // We should be able to GetState without changing state.
- // State should be stored outside of this object inside the wiimote,
- // and separately inside the UI.
-
- // We're using system time rather than ticks to step this.
- // I don't think that's too horrible as we can consider this part of user input.
- // And at least the Mapping UI will behave sanely this way.
- // TODO: when state is moved outside of this class have a separate Step()
- // function that takes a ms_passed argument
- const auto now = Clock::now();
- const auto ms_since_update =
- std::chrono::duration_cast<std::chrono::milliseconds>(now - m_last_update).count();
- m_last_update = now;
-
- const double max_step = MAX_DEG_PER_SEC / 180.0 * ms_since_update / 1000;
-
- // TODO: Allow wrap around from 1.0 to -1.0
- // (take the fastest route to target)
-
- m_tilt.x += MathUtil::Clamp(target.x - m_tilt.x, -max_step, max_step);
- m_tilt.y += MathUtil::Clamp(target.y - m_tilt.y, -max_step, max_step);
-
- return m_tilt;
+ return Reshape(x, y, modifier);
}
Tilt::StateData Tilt::GetState()