diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 5259d85bff..14b619bef0 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -39,10 +39,6 @@ static const u8 eeprom_data_0[] = { // assuming last 2 bytes are checksum 0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, /*0x74, 0xD3,*/ 0x00, 0x00, // messing up the checksum on purpose 0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, 0xA7, /*0x74, 0xD3,*/ 0x00, 0x00, - // Accelerometer - // 0g x,y,z, 1g x,y,z, idk, last byte is a checksum - 0x80, 0x80, 0x80, 0x00, 0x9A, 0x9A, 0x9A, 0x00, 0x40, 0xE3, - 0x80, 0x80, 0x80, 0x00, 0x9A, 0x9A, 0x9A, 0x00, 0x40, 0xE3, }; static const u8 motion_plus_id[] = { 0x00, 0x00, 0xA6, 0x20, 0x00, 0x05 }; @@ -395,11 +391,10 @@ void Wiimote::GetAccelData(u8* const data, const ReportFeatures& rptf) wm_accel& accel = *(wm_accel*)(data + rptf.accel); wm_buttons& core = *(wm_buttons*)(data + rptf.core); - accel_cal& calib = *(accel_cal*)&m_eeprom[0x16]; - u16 x = (u16)(m_accel.x * (calib.one_g.x - calib.zero_g.x) + calib.zero_g.x); - u16 y = (u16)(m_accel.y * (calib.one_g.y - calib.zero_g.y) + calib.zero_g.y); - u16 z = (u16)(m_accel.z * (calib.one_g.z - calib.zero_g.z) + calib.zero_g.z); + u16 x = (u16)(m_accel.x * ACCEL_RANGE + ACCEL_ZERO_G); + u16 y = (u16)(m_accel.y * ACCEL_RANGE + ACCEL_ZERO_G); + u16 z = (u16)(m_accel.z * ACCEL_RANGE + ACCEL_ZERO_G); if (x > 1024) x = 1024; diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h index d0494d7579..0695f62aa9 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h @@ -106,6 +106,13 @@ public: BUTTON_HOME = 0x8000, }; + enum + { + ACCEL_ZERO_G = 0x80, + ACCEL_ONE_G = 0x9A, + ACCEL_RANGE = (ACCEL_ONE_G - ACCEL_ZERO_G), + }; + Wiimote(const unsigned int index); std::string GetName() const override; diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h index 22105dce43..095e2be053 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteHid.h @@ -495,29 +495,4 @@ struct wm_speaker_data // Custom structs -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -struct accel_cal -{ - struct - { - u8 x, y, z; - u8 xlo : 2; - u8 ylo : 2; - u8 zlo : 2; - } zero_g; - - struct - { - u8 x, y, z; - u8 xlo : 2; - u8 ylo : 2; - u8 zlo : 2; - } one_g; -}; - -static_assert(sizeof(accel_cal) == 8, "acceleration data needs needs to be 8 bytes"); - #pragma pack(pop)