summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2020-10-10 14:53:07 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2020-10-19 17:08:02 -0500
commit6b2eebf1f9d5715a3d898c824bf309750ac3df53 (patch)
tree45a6153e21f69b59028f25e75a55df31199f269a /Source/Core
parent0f5bf90013cd1358b3ccb2f22c09748e40a552f4 (diff)
WiimoteEmu: Expose IR camera FOV to adjust IMU pointing sensitivity.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Camera.cpp8
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Camera.h2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp25
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h2
4 files changed, 31 insertions, 6 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
index 46ec87f672..61f1c88f80 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
@@ -53,7 +53,7 @@ int CameraLogic::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
return RawWrite(&m_reg_data, addr, count, data_in);
}
-void CameraLogic::Update(const Common::Matrix44& transform)
+void CameraLogic::Update(const Common::Matrix44& transform, Common::Vec2 field_of_view)
{
// IR data is read from offset 0x37 on real hardware.
auto& data = m_reg_data.camera_data;
@@ -88,9 +88,9 @@ void CameraLogic::Update(const Common::Matrix44& transform)
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
};
- const auto camera_view = Matrix44::Perspective(CAMERA_FOV_Y, CAMERA_AR, 0.001f, 1000) *
- Matrix44::FromMatrix33(Matrix33::RotateX(float(MathUtil::TAU / 4))) *
- transform;
+ const auto camera_view =
+ 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;
struct CameraPoint
{
diff --git a/Source/Core/Core/HW/WiimoteEmu/Camera.h b/Source/Core/Core/HW/WiimoteEmu/Camera.h
index 6d07d720da..d70422325c 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Camera.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Camera.h
@@ -112,7 +112,7 @@ public:
void Reset();
void DoState(PointerWrap& p);
- void Update(const Common::Matrix44& transform);
+ void Update(const Common::Matrix44& transform, Common::Vec2 field_of_view);
void SetEnabled(bool is_enabled);
static constexpr u8 I2C_ADDR = 0x58;
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
index 549251aed1..150bb9256a 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -217,6 +217,27 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
new ControllerEmu::IMUGyroscope("IMUGyroscope", _trans("Gyroscope")));
groups.emplace_back(m_imu_ir = new ControllerEmu::IMUCursor("IMUIR", _trans("Point")));
+ const auto fov_default =
+ Common::DVec2(CameraLogic::CAMERA_FOV_X, CameraLogic::CAMERA_FOV_Y) / MathUtil::TAU * 360;
+
+ m_imu_ir->AddSetting(&m_fov_x_setting,
+ // i18n: FOV stands for "Field of view".
+ {_trans("Horizontal FOV"),
+ // i18n: The symbol/abbreviation for degrees (unit of angular measure).
+ _trans("°"),
+ // i18n: Refers to emulated wii remote camera properties.
+ _trans("Camera field of view (affects sensitivity of pointing).")},
+ fov_default.x, 0.01, 180);
+
+ m_imu_ir->AddSetting(&m_fov_y_setting,
+ // i18n: FOV stands for "Field of view".
+ {_trans("Vertical FOV"),
+ // i18n: The symbol/abbreviation for degrees (unit of angular measure).
+ _trans("°"),
+ // i18n: Refers to emulated wii remote camera properties.
+ _trans("Camera field of view (affects sensitivity of pointing).")},
+ fov_default.y, 0.01, 180);
+
// Extension
groups.emplace_back(m_attachments = new ControllerEmu::Attachments(_trans("Extension")));
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::None>());
@@ -505,7 +526,9 @@ void Wiimote::SendDataReport()
{
// Note: Camera logic currently contains no changing state so we can just update it here.
// If that changes this should be moved to Wiimote::Update();
- m_camera_logic.Update(GetTotalTransformation());
+ m_camera_logic.Update(GetTotalTransformation(),
+ Common::Vec2(m_fov_x_setting.GetValue(), m_fov_y_setting.GetValue()) /
+ 360 * float(MathUtil::TAU));
// The real wiimote reads camera data from the i2c bus starting at offset 0x37:
const u8 camera_data_offset =
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
index a01d4c545f..13fd352617 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
@@ -262,6 +262,8 @@ private:
ControllerEmu::SettingValue<bool> m_upright_setting;
ControllerEmu::SettingValue<double> m_battery_setting;
ControllerEmu::SettingValue<bool> m_motion_plus_setting;
+ ControllerEmu::SettingValue<double> m_fov_x_setting;
+ ControllerEmu::SettingValue<double> m_fov_y_setting;
SpeakerLogic m_speaker_logic;
MotionPlus m_motion_plus;