mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
WiimoteEmu: Hardcode acceleration calibration values
Now we don't have any runtime calibration at all.
This commit is contained in:
parent
5f6cfd67b7
commit
1cee3b8cc6
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user