mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Core/HW/WiimoteEmu: Allow storing and reporting up to 4 camera objects, like a real Wiimote.
This commit is contained in:
parent
5c656a2b6f
commit
eced34f3f3
@ -59,7 +59,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
|
||||
using Common::Vec3;
|
||||
using Common::Vec4;
|
||||
|
||||
const std::array<Vec3, NUM_POINTS> leds{
|
||||
const std::array<Vec3, 2> leds{
|
||||
Vec3{-SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
|
||||
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
|
||||
};
|
||||
@ -68,7 +68,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
|
||||
Matrix44::Perspective(field_of_view.y, field_of_view.x / field_of_view.y, 0.001f, 1000) *
|
||||
Matrix44::FromMatrix33(Matrix33::RotateX(float(MathUtil::TAU / 4))) * transform;
|
||||
|
||||
std::array<CameraPoint, leds.size()> camera_points;
|
||||
std::array<CameraPoint, CameraLogic::NUM_POINTS> camera_points;
|
||||
|
||||
std::transform(leds.begin(), leds.end(), camera_points.begin(), [&](const Vec3& v) {
|
||||
const auto point = camera_view * Vec4(v, 1.0);
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
|
||||
// FYI: A real wiimote normally only returns 1 point for each LED cluster (2 total).
|
||||
// Sending all 4 points can actually cause some stuttering issues.
|
||||
static constexpr int NUM_POINTS = 2;
|
||||
static constexpr int NUM_POINTS = 4;
|
||||
|
||||
// Range from 0-15. Small values (2-4) seem to be very typical.
|
||||
// This is reduced based on distance from sensor bar.
|
||||
|
@ -82,7 +82,7 @@ SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state)
|
||||
|
||||
if (has_camera)
|
||||
{
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
for (size_t i = 0; i < state.camera_points.size(); ++i)
|
||||
{
|
||||
const u16 camera_x = state.camera_points[i].position.x; // 10 bits
|
||||
const u16 camera_y = state.camera_points[i].position.y; // 10 bits
|
||||
@ -178,7 +178,7 @@ bool DeserializeDesiredState(DesiredWiimoteState* state, const SerializedWiimote
|
||||
else if (has_accel)
|
||||
s += 4;
|
||||
if (has_camera)
|
||||
s += 6;
|
||||
s += 12;
|
||||
if (has_motion_plus)
|
||||
s += 6;
|
||||
switch (extension)
|
||||
@ -260,7 +260,7 @@ bool DeserializeDesiredState(DesiredWiimoteState* state, const SerializedWiimote
|
||||
|
||||
if (has_camera)
|
||||
{
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
for (size_t i = 0; i < state->camera_points.size(); ++i)
|
||||
{
|
||||
const u8 camera_misc = d[pos];
|
||||
const u8 camera_x_high = d[pos + 1];
|
||||
|
@ -21,11 +21,12 @@ struct DesiredWiimoteState
|
||||
{Wiimote::ACCEL_ZERO_G << 2, Wiimote::ACCEL_ZERO_G << 2, Wiimote::ACCEL_ONE_G << 2});
|
||||
|
||||
// No light detected by the IR camera.
|
||||
static constexpr std::array<CameraPoint, 2> DEFAULT_CAMERA = {CameraPoint(), CameraPoint()};
|
||||
static constexpr std::array<CameraPoint, 4> DEFAULT_CAMERA = {CameraPoint(), CameraPoint(),
|
||||
CameraPoint(), CameraPoint()};
|
||||
|
||||
WiimoteCommon::ButtonData buttons{}; // non-button state in this is ignored
|
||||
WiimoteCommon::AccelData acceleration = DEFAULT_ACCELERATION;
|
||||
std::array<CameraPoint, 2> camera_points = DEFAULT_CAMERA;
|
||||
std::array<CameraPoint, 4> camera_points = DEFAULT_CAMERA;
|
||||
std::optional<MotionPlus::DataFormat::Data> motion_plus = std::nullopt;
|
||||
DesiredExtensionState extension;
|
||||
};
|
||||
@ -34,7 +35,7 @@ struct DesiredWiimoteState
|
||||
struct SerializedWiimoteState
|
||||
{
|
||||
u8 length;
|
||||
std::array<u8, 24> data; // 12 bytes Wiimote, 6 bytes MotionPlus, 6 bytes Extension
|
||||
std::array<u8, 30> data; // 18 bytes Wiimote, 6 bytes MotionPlus, 6 bytes Extension
|
||||
};
|
||||
|
||||
SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state);
|
||||
|
Loading…
Reference in New Issue
Block a user