Skip to content

Commit

Permalink
WiimoteEmu: Apply orientation settings to accel/gyro override
Browse files Browse the repository at this point in the history
Needed for Android.
  • Loading branch information
JosJuice committed Apr 25, 2021
1 parent 6a1ae55 commit a593ecc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,19 +728,19 @@ void Wiimote::StepDynamics()

Common::Vec3 Wiimote::GetAcceleration(Common::Vec3 extra_acceleration) const
{
Common::Vec3 accel = GetOrientation() * GetTransformation().Transform(
m_swing_state.acceleration + extra_acceleration, 0);
Common::Vec3 accel =
GetTransformation().Transform(m_swing_state.acceleration + extra_acceleration, 0);

// Our shake effects have never been affected by orientation. Should they be?
accel += m_shake_state.acceleration;
accel += GetOrientation().Inverted() * m_shake_state.acceleration;

return accel;
}

Common::Vec3 Wiimote::GetAngularVelocity(Common::Vec3 extra_angular_velocity) const
{
return GetOrientation() * (m_tilt_state.angular_velocity + m_swing_state.angular_velocity +
m_point_state.angular_velocity + extra_angular_velocity);
return (m_tilt_state.angular_velocity + m_swing_state.angular_velocity +
m_point_state.angular_velocity + extra_angular_velocity);
}

Common::Matrix44 Wiimote::GetTransformation(const Common::Matrix33& extra_rotation) const
Expand Down Expand Up @@ -836,7 +836,7 @@ Common::Vec3 Wiimote::GetTotalAcceleration() const
if (const auto extra_accel = m_imu_accelerometer->GetState())
accel = *extra_accel;

return OverrideVec3(m_imu_accelerometer, GetAcceleration(accel));
return GetOrientation() * OverrideVec3(m_imu_accelerometer, GetAcceleration(accel));
}

Common::Vec3 Wiimote::GetTotalAngularVelocity() const
Expand All @@ -846,7 +846,7 @@ Common::Vec3 Wiimote::GetTotalAngularVelocity() const
if (const auto extra_ang_vel = m_imu_gyroscope->GetState())
ang_vel = *extra_ang_vel;

return OverrideVec3(m_imu_gyroscope, GetAngularVelocity(ang_vel));
return GetOrientation() * OverrideVec3(m_imu_gyroscope, GetAngularVelocity(ang_vel));
}

Common::Matrix44 Wiimote::GetTotalTransformation() const
Expand Down

0 comments on commit a593ecc

Please sign in to comment.