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 4dad640d5f
.
Fixed issue 6702.
This commit is contained in:
parent
4d1f113ab1
commit
c5695c987b
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue