From 6b2eebf1f9d5715a3d898c824bf309750ac3df53 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sat, 10 Oct 2020 14:53:07 -0500 Subject: [PATCH 1/2] WiimoteEmu: Expose IR camera FOV to adjust IMU pointing sensitivity. --- Source/Core/Core/HW/WiimoteEmu/Camera.cpp | 8 +++--- Source/Core/Core/HW/WiimoteEmu/Camera.h | 2 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 25 ++++++++++++++++++- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h | 2 ++ 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()); @@ -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 m_upright_setting; ControllerEmu::SettingValue m_battery_setting; ControllerEmu::SettingValue m_motion_plus_setting; + ControllerEmu::SettingValue m_fov_x_setting; + ControllerEmu::SettingValue m_fov_y_setting; SpeakerLogic m_speaker_logic; MotionPlus m_motion_plus; From 1dae834c62c01fe0476f1aa9acd737989bbe83ee Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sat, 10 Oct 2020 14:58:43 -0500 Subject: [PATCH 2/2] WiimoteEmu: Tweak IMUCursor total yaw setting tool-tip. --- .../Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp index 429cd18880..beda11a29d 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp @@ -37,7 +37,7 @@ IMUCursor::IMUCursor(std::string name_, std::string ui_name_) // i18n: The symbol/abbreviation for degrees (unit of angular measure). _trans("°"), // i18n: Refers to emulated wii remote movements. - _trans("Total rotation about the yaw axis.")}, + _trans("Clamping of rotation about the yaw axis.")}, 25, 0, 360); }