Merge pull request #9142 from jordan-woyak/expose-fov
WiimoteEmu: Expose IR camera FOV to adjust IMU pointing sensitivity.
This commit is contained in:
commit
f653bd7559
|
@ -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);
|
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.
|
// IR data is read from offset 0x37 on real hardware.
|
||||||
auto& data = m_reg_data.camera_data;
|
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},
|
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto camera_view = Matrix44::Perspective(CAMERA_FOV_Y, CAMERA_AR, 0.001f, 1000) *
|
const auto camera_view =
|
||||||
Matrix44::FromMatrix33(Matrix33::RotateX(float(MathUtil::TAU / 4))) *
|
Matrix44::Perspective(field_of_view.y, field_of_view.x / field_of_view.y, 0.001f, 1000) *
|
||||||
transform;
|
Matrix44::FromMatrix33(Matrix33::RotateX(float(MathUtil::TAU / 4))) * transform;
|
||||||
|
|
||||||
struct CameraPoint
|
struct CameraPoint
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void DoState(PointerWrap& p);
|
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);
|
void SetEnabled(bool is_enabled);
|
||||||
|
|
||||||
static constexpr u8 I2C_ADDR = 0x58;
|
static constexpr u8 I2C_ADDR = 0x58;
|
||||||
|
|
|
@ -217,6 +217,27 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
|
||||||
new ControllerEmu::IMUGyroscope("IMUGyroscope", _trans("Gyroscope")));
|
new ControllerEmu::IMUGyroscope("IMUGyroscope", _trans("Gyroscope")));
|
||||||
groups.emplace_back(m_imu_ir = new ControllerEmu::IMUCursor("IMUIR", _trans("Point")));
|
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
|
// Extension
|
||||||
groups.emplace_back(m_attachments = new ControllerEmu::Attachments(_trans("Extension")));
|
groups.emplace_back(m_attachments = new ControllerEmu::Attachments(_trans("Extension")));
|
||||||
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::None>());
|
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.
|
// 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();
|
// 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:
|
// The real wiimote reads camera data from the i2c bus starting at offset 0x37:
|
||||||
const u8 camera_data_offset =
|
const u8 camera_data_offset =
|
||||||
|
|
|
@ -262,6 +262,8 @@ private:
|
||||||
ControllerEmu::SettingValue<bool> m_upright_setting;
|
ControllerEmu::SettingValue<bool> m_upright_setting;
|
||||||
ControllerEmu::SettingValue<double> m_battery_setting;
|
ControllerEmu::SettingValue<double> m_battery_setting;
|
||||||
ControllerEmu::SettingValue<bool> m_motion_plus_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;
|
SpeakerLogic m_speaker_logic;
|
||||||
MotionPlus m_motion_plus;
|
MotionPlus m_motion_plus;
|
||||||
|
|
|
@ -37,7 +37,7 @@ IMUCursor::IMUCursor(std::string name_, std::string ui_name_)
|
||||||
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
||||||
_trans("°"),
|
_trans("°"),
|
||||||
// i18n: Refers to emulated wii remote movements.
|
// 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);
|
25, 0, 360);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue