Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Reading shake force from calibration rather than a constant"
It didn't make sense. The math was nonsensical. Calibration data was somehow applied twice. I don't even.

This reverts commit 4dad640.

Fixed issue 6702.
  • Loading branch information
jordan-woyak committed Dec 27, 2013
1 parent 4d1f113 commit c5695c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
Expand Up @@ -107,7 +107,6 @@ void Nunchuk::GetState(u8* const data, const bool focus)
}

AccelData accel;
accel_cal* calib = (accel_cal*)&reg.calibration[0];

// tilt
EmulateTilt(&accel, m_tilt, focus);
Expand All @@ -117,7 +116,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
// swing
EmulateSwing(&accel, m_swing);
// shake
EmulateShake(&accel, calib, m_shake, m_shake_step);
EmulateShake(&accel, m_shake, m_shake_step);
// buttons
m_buttons->GetState(&ncdata->bt, nunchuk_button_bitmasks);
}
Expand Down Expand Up @@ -155,6 +154,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
}

wm_accel* dt = (wm_accel*)&ncdata->ax;
accel_cal* calib = (accel_cal*)&reg.calibration;
dt->x = u8(trim(accel.x * (calib->one_g.x - calib->zero_g.x) + calib->zero_g.x));
dt->y = u8(trim(accel.y * (calib->one_g.y - calib->zero_g.y) + calib->zero_g.y));
dt->z = u8(trim(accel.z * (calib->one_g.z - calib->zero_g.z) + calib->zero_g.z));
Expand Down
10 changes: 3 additions & 7 deletions Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -87,7 +87,6 @@ const ReportFeatures reporting_mode_features[] =
};

void EmulateShake(AccelData* const accel
, accel_cal* const calib
, ControllerEmu::Buttons* const buttons_group
, u8* const shake_step )
{
Expand All @@ -96,7 +95,7 @@ void EmulateShake(AccelData* const accel
auto const shake_step_max = 15;

// peak G-force
double shake_intensity;
auto const shake_intensity = 3.f;

// shake is a bitfield of X,Y,Z shake button states
static const unsigned int btns[] = { 0x01, 0x02, 0x04 };
Expand All @@ -107,9 +106,6 @@ void EmulateShake(AccelData* const accel
{
if (shake & (1 << i))
{
double zero = double((&(calib->zero_g.x))[i]);
double one = double((&(calib->one_g.x))[i]);
shake_intensity = max(zero / (one - zero), (255.f - zero) / (one - zero));
(&(accel->x))[i] = std::sin(TAU * shake_step[i] / shake_step_max) * shake_intensity;
shake_step[i] = (shake_step[i] + 1) % shake_step_max;
}
Expand Down Expand Up @@ -411,7 +407,6 @@ void Wiimote::GetAccelData(u8* const data, u8* const buttons)
const bool has_focus = HAS_FOCUS;
const bool is_sideways = m_options->settings[1]->value != 0;
const bool is_upright = m_options->settings[2]->value != 0;
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];

// ----TILT----
EmulateTilt(&m_accel, m_tilt, has_focus, is_sideways, is_upright);
Expand All @@ -421,10 +416,11 @@ void Wiimote::GetAccelData(u8* const data, u8* const buttons)
if (has_focus)
{
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
EmulateShake(&m_accel, calib, m_shake, m_shake_step);
EmulateShake(&m_accel, m_shake, m_shake_step);
UDPTLayer::GetAcceleration(m_udp, &m_accel);
}
wm_accel* dt = (wm_accel*)data;
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];
double cx,cy,cz;
cx=trim(m_accel.x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
cy=trim(m_accel.y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
Expand Up @@ -74,7 +74,6 @@ struct ExtensionReg
extern const ReportFeatures reporting_mode_features[];

void EmulateShake(AccelData* const accel_data
, accel_cal* const calib
, ControllerEmu::Buttons* const buttons_group
, u8* const shake_step);

Expand Down

0 comments on commit c5695c9

Please sign in to comment.