summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-09-04 19:11:11 -0700
committerJasper St. Pierre <jstpierre@mecheye.net>2014-11-28 10:51:30 -0800
commit5f6cfd67b76e4944a2f8dff308e5bb37d0e985aa (patch)
treeae016e81625c4ca12481e86c0883c03ba4063430 /Source/Core
parent211eafc13025687d624f435b0fa8e3e7fcf950c2 (diff)
Nunchuk: Hardcode Nunchuk accelerometre calibration values as well
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp19
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h7
2 files changed, 10 insertions, 16 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp
index 2bfa33b39d..a482055fa5 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp
@@ -8,14 +8,6 @@ namespace WiimoteEmu
{
static const u8 nunchuk_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 };
-/* Default calibration for the nunchuk. It should be written to 0x20 - 0x3f of the
- extension register. 0x80 is the neutral x and y accelerators and 0xb3 is the
- neutral z accelerometer that is adjusted for gravity. */
-static const u8 nunchuk_calibration[] =
-{
- 0x80, 0x80, 0x80, 0x00, // accelerometer x, y, z neutral
- 0xb3, 0xb3, 0xb3, 0x00, // x, y, z g-force values
-};
static const u8 nunchuk_button_bitmasks[] =
{
@@ -45,9 +37,6 @@ Nunchuk::Nunchuk(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Nunchuk"),
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
- // set up register
- // calibration
- memcpy(&calibration, nunchuk_calibration, sizeof(nunchuk_calibration));
// id
memcpy(&id, nunchuk_id, sizeof(nunchuk_id));
@@ -98,11 +87,9 @@ void Nunchuk::GetState(u8* const data)
// flip the button bits :/
ncdata->bt.hex ^= 0x03;
- accel_cal& calib = *(accel_cal*)&reg.calibration;
-
- u16 accel_x = (u16)(accel.x * (calib.one_g.x - calib.zero_g.x) + calib.zero_g.x);
- u16 accel_y = (u16)(accel.y * (calib.one_g.y - calib.zero_g.y) + calib.zero_g.y);
- u16 accel_z = (u16)(accel.z * (calib.one_g.z - calib.zero_g.z) + calib.zero_g.z);
+ u16 accel_x = (u16)(accel.x * ACCEL_RANGE + ACCEL_ZERO_G);
+ u16 accel_y = (u16)(accel.y * ACCEL_RANGE + ACCEL_ZERO_G);
+ u16 accel_z = (u16)(accel.z * ACCEL_RANGE + ACCEL_ZERO_G);
if (accel_x > 1024)
accel_x = 1024;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
index c38ed342f6..4c58c2454c 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
@@ -24,6 +24,13 @@ public:
enum
{
+ ACCEL_ZERO_G = 0x80,
+ ACCEL_ONE_G = 0xB3,
+ ACCEL_RANGE = (ACCEL_ONE_G - ACCEL_ZERO_G),
+ };
+
+ enum
+ {
STICK_CENTER = 0x80,
STICK_RADIUS = 0x7F,
};