mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
WiimoteEmu: Update accelerometer status from DesiredWiimoteState.
This commit is contained in:
parent
a39f82cb1f
commit
9669722dfc
@ -4,11 +4,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
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::AccelData acceleration = DEFAULT_ACCELERATION;
|
||||
};
|
||||
} // namespace WiimoteEmu
|
||||
|
@ -449,6 +449,11 @@ DesiredWiimoteState Wiimote::BuildDesiredWiimoteState()
|
||||
m_dpad->GetState(&wiimote_state.buttons.hex,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -493,10 +498,10 @@ void Wiimote::Update()
|
||||
return;
|
||||
}
|
||||
|
||||
SendDataReport();
|
||||
SendDataReport(target_state);
|
||||
}
|
||||
|
||||
void Wiimote::SendDataReport()
|
||||
void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
||||
{
|
||||
Movie::SetPolledDevice();
|
||||
|
||||
@ -532,10 +537,7 @@ void Wiimote::SendDataReport()
|
||||
// Acceleration:
|
||||
if (rpt_builder.HasAccel())
|
||||
{
|
||||
// Calibration values are 8-bit but we want 10-bit precision, so << 2.
|
||||
AccelData accel =
|
||||
ConvertAccelData(GetTotalAcceleration(), ACCEL_ZERO_G << 2, ACCEL_ONE_G << 2);
|
||||
rpt_builder.SetAccelData(accel);
|
||||
rpt_builder.SetAccelData(target_state.acceleration);
|
||||
}
|
||||
|
||||
// IR Camera:
|
||||
|
@ -192,7 +192,7 @@ private:
|
||||
|
||||
void HandleExtensionSwap();
|
||||
bool ProcessExtensionPortEvent();
|
||||
void SendDataReport();
|
||||
void SendDataReport(const DesiredWiimoteState& target_state);
|
||||
bool ProcessReadDataRequest();
|
||||
|
||||
void SetRumble(bool on);
|
||||
|
Loading…
Reference in New Issue
Block a user