diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 4cced8be4d..d280272e6b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -154,9 +154,9 @@ void Nunchuk::GetState(u8* const data) s16 accel_y = (s16)(4 * (accel.y * ACCEL_RANGE + ACCEL_ZERO_G)); s16 accel_z = (s16)(4 * (accel.z * ACCEL_RANGE + ACCEL_ZERO_G)); - accel_x = MathUtil::Clamp(accel_x, 0, 1024); - accel_y = MathUtil::Clamp(accel_y, 0, 1024); - accel_z = MathUtil::Clamp(accel_z, 0, 1024); + accel_x = MathUtil::Clamp(accel_x, 0, 0x3ff); + accel_y = MathUtil::Clamp(accel_y, 0, 0x3ff); + accel_z = MathUtil::Clamp(accel_z, 0, 0x3ff); nc_data.ax = (accel_x >> 2) & 0xFF; nc_data.ay = (accel_y >> 2) & 0xFF; diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 95896dcbb6..e6c5fdcc2f 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -108,12 +108,14 @@ static const ReportFeatures reporting_mode_features[] = { }; // Used for extension calibration data: -// Last two bytes are the sum of the previous bytes plus 0x55 and 0xaa void UpdateCalibrationDataChecksum(std::array& data) { - const u8 ck1 = std::accumulate(std::begin(data), std::end(data) - 2, (u8)0x55); - data[0xe] = ck1; - data[0xf] = ck1 + 0x55; + // Last two bytes are the sum of the previous bytes plus 0x55 and 0xaa (0x55 + 0x55) + const u8 checksum1 = std::accumulate(std::begin(data), std::end(data) - 2, u8(0x55)); + const u8 checksum2 = checksum1 + 0x55; + + data[0xe] = checksum1; + data[0xf] = checksum2; } void EmulateShake(AccelData* const accel, ControllerEmu::Buttons* const buttons_group, @@ -128,7 +130,7 @@ void EmulateShake(AccelData* const accel, ControllerEmu::Buttons* const buttons_ { if (shake & (1 << i)) { - (&(accel->x))[i] = std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * intensity; + (&(accel->x))[i] += std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * intensity; shake_step[i] = (shake_step[i] + 1) % SHAKE_STEP_MAX; } else @@ -153,7 +155,8 @@ void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data, } else if (dynamic_data.executing_frames_left[i] > 0) { - (&(accel->x))[i] = std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * dynamic_data.intensity[i]; + (&(accel->x))[i] += + std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * dynamic_data.intensity[i]; shake_step[i] = (shake_step[i] + 1) % SHAKE_STEP_MAX; dynamic_data.executing_frames_left[i]--; } @@ -658,9 +661,9 @@ void Wiimote::GetAccelData(u8* const data, const ReportFeatures& rptf) s16 y = (s16)(4 * (m_accel.y * ACCEL_RANGE + ACCEL_ZERO_G)); s16 z = (s16)(4 * (m_accel.z * ACCEL_RANGE + ACCEL_ZERO_G)); - x = MathUtil::Clamp(x, 0, 1024); - y = MathUtil::Clamp(y, 0, 1024); - z = MathUtil::Clamp(z, 0, 1024); + x = MathUtil::Clamp(x, 0, 0x3ff); + y = MathUtil::Clamp(y, 0, 0x3ff); + z = MathUtil::Clamp(z, 0, 0x3ff); accel.x = (x >> 2) & 0xFF; accel.y = (y >> 2) & 0xFF;