Nunchuk: Use the accel_cal struct directly in nu_cal

This commit is contained in:
Jasper St. Pierre 2014-09-04 19:22:31 -07:00
parent cd95002356
commit 64014d1dcd
2 changed files with 4 additions and 5 deletions

View File

@ -112,7 +112,7 @@ void Nunchuk::GetState(u8* const data)
// flip the button bits :/
ncdata->bt.hex ^= 0x03;
accel_cal& calib = *(accel_cal*)&reg.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);

View File

@ -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];