From 64014d1dcd36b2b1a011ace7dd69ec6bf1203a0d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 4 Sep 2014 19:22:31 -0700 Subject: [PATCH] Nunchuk: Use the accel_cal struct directly in nu_cal --- Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 2 +- Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 7bf603b47d..a400e10f27 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -112,7 +112,7 @@ void Nunchuk::GetState(u8* const data) // flip the button bits :/ ncdata->bt.hex ^= 0x03; - accel_cal& calib = *(accel_cal*)®.calibration; + accel_cal& calib = cal.cal; u16 x = (u16)(accel.x * (calib.one_g.x - calib.zero_g.x) + calib.zero_g.x); u16 y = (u16)(accel.y * (calib.one_g.y - calib.zero_g.y) + calib.zero_g.y); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h index 78d430b8bb..dc8d268d6b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h @@ -518,6 +518,8 @@ struct accel_cal } one_g; }; +static_assert(sizeof(accel_cal) == 8, "acceleration data needs needs to be 8 bytes"); + struct nu_js { u8 max, min, center; @@ -525,10 +527,7 @@ struct nu_js struct nu_cal { - wm_accel cal_zero; // zero calibration - u8 pad1; - wm_accel cal_g; // g size - u8 pad2; + accel_cal cal; nu_js jx; nu_js jy; u8 sum[2];