From c5695c987b75628315f2189085e10eddb3442ff4 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Fri, 27 Dec 2013 16:00:59 -0600 Subject: [PATCH] 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 4dad640d5f58c226c0e6fd757edd13fe23099856. Fixed issue 6702. --- .../Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 4 ++-- Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp | 10 +++------- Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 7f330ecc78..5f466fd897 100644 --- a/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -107,7 +107,6 @@ void Nunchuk::GetState(u8* const data, const bool focus) } AccelData accel; - accel_cal* calib = (accel_cal*)®.calibration[0]; // tilt EmulateTilt(&accel, m_tilt, focus); @@ -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); } @@ -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*)®.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)); diff --git a/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp index 4c80b1adda..f4ddd4a1db 100644 --- a/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp @@ -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 ) { @@ -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 }; @@ -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; } @@ -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); @@ -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); diff --git a/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h index f2afda4aa3..45cacb390e 100644 --- a/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h @@ -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);