Skip to content

Commit

Permalink
Nunchuk: Use the accel_cal struct directly in nu_cal
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Nov 28, 2014
1 parent cd95002 commit 64014d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,16 @@ 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;
};

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];
Expand Down

0 comments on commit 64014d1

Please sign in to comment.