mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
WiimoteEmu: Update accelerometer status from DesiredWiimoteState.
This commit is contained in:
parent
a39f82cb1f
commit
9669722dfc
@ -4,11 +4,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
||||||
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||||
|
|
||||||
namespace WiimoteEmu
|
namespace WiimoteEmu
|
||||||
{
|
{
|
||||||
struct DesiredWiimoteState
|
struct DesiredWiimoteState
|
||||||
{
|
{
|
||||||
|
// 1g in Z direction, which is the default returned by an unmoving emulated Wiimote.
|
||||||
|
static constexpr WiimoteCommon::AccelData DEFAULT_ACCELERATION = WiimoteCommon::AccelData(
|
||||||
|
{Wiimote::ACCEL_ZERO_G << 2, Wiimote::ACCEL_ZERO_G << 2, Wiimote::ACCEL_ONE_G << 2});
|
||||||
|
|
||||||
WiimoteCommon::ButtonData buttons{}; // non-button state in this is ignored
|
WiimoteCommon::ButtonData buttons{}; // non-button state in this is ignored
|
||||||
|
WiimoteCommon::AccelData acceleration = DEFAULT_ACCELERATION;
|
||||||
};
|
};
|
||||||
} // namespace WiimoteEmu
|
} // namespace WiimoteEmu
|
||||||
|
@ -449,6 +449,11 @@ DesiredWiimoteState Wiimote::BuildDesiredWiimoteState()
|
|||||||
m_dpad->GetState(&wiimote_state.buttons.hex,
|
m_dpad->GetState(&wiimote_state.buttons.hex,
|
||||||
IsSideways() ? dpad_sideways_bitmasks : dpad_bitmasks);
|
IsSideways() ? dpad_sideways_bitmasks : dpad_bitmasks);
|
||||||
|
|
||||||
|
// Calculate accelerometer state.
|
||||||
|
// Calibration values are 8-bit but we want 10-bit precision, so << 2.
|
||||||
|
wiimote_state.acceleration =
|
||||||
|
ConvertAccelData(GetTotalAcceleration(), ACCEL_ZERO_G << 2, ACCEL_ONE_G << 2);
|
||||||
|
|
||||||
return wiimote_state;
|
return wiimote_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,10 +498,10 @@ void Wiimote::Update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDataReport();
|
SendDataReport(target_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::SendDataReport()
|
void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
||||||
{
|
{
|
||||||
Movie::SetPolledDevice();
|
Movie::SetPolledDevice();
|
||||||
|
|
||||||
@ -532,10 +537,7 @@ void Wiimote::SendDataReport()
|
|||||||
// Acceleration:
|
// Acceleration:
|
||||||
if (rpt_builder.HasAccel())
|
if (rpt_builder.HasAccel())
|
||||||
{
|
{
|
||||||
// Calibration values are 8-bit but we want 10-bit precision, so << 2.
|
rpt_builder.SetAccelData(target_state.acceleration);
|
||||||
AccelData accel =
|
|
||||||
ConvertAccelData(GetTotalAcceleration(), ACCEL_ZERO_G << 2, ACCEL_ONE_G << 2);
|
|
||||||
rpt_builder.SetAccelData(accel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IR Camera:
|
// IR Camera:
|
||||||
|
@ -192,7 +192,7 @@ private:
|
|||||||
|
|
||||||
void HandleExtensionSwap();
|
void HandleExtensionSwap();
|
||||||
bool ProcessExtensionPortEvent();
|
bool ProcessExtensionPortEvent();
|
||||||
void SendDataReport();
|
void SendDataReport(const DesiredWiimoteState& target_state);
|
||||||
bool ProcessReadDataRequest();
|
bool ProcessReadDataRequest();
|
||||||
|
|
||||||
void SetRumble(bool on);
|
void SetRumble(bool on);
|
||||||
|
Loading…
Reference in New Issue
Block a user