summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2019-03-10 11:13:02 +1000
committerGitHub <noreply@github.com>2019-03-10 11:13:02 +1000
commit08b95c3fde475d50842a4f049f3faf22d2ace1ef (patch)
tree8a46fe5f93bd7ae93b91495b08b69a257983424e /Source/Core
parentc55db27194df21542e68a4169b083f8aca15f3fe (diff)
parent224e678cf8e8800cb6c709f7d144b82098b5583b (diff)
Merge pull request #7868 from jordan-woyak/shutdown-crash-fix
WiimoteEmu: Fix a config change callback causing a crash on exit.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Camera.cpp7
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Camera.h2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp9
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h3
4 files changed, 8 insertions, 13 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
index b208002467..8355c5d377 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp
@@ -11,6 +11,8 @@
#include "Common/ChunkFile.h"
#include "Common/MathUtil.h"
#include "Common/Matrix.h"
+
+#include "Core/Config/SYSCONFSettings.h"
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
namespace WiimoteEmu
@@ -51,7 +53,7 @@ int CameraLogic::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
return RawWrite(&reg_data, addr, count, data_in);
}
-void CameraLogic::Update(const Common::Matrix44& transform, bool sensor_bar_on_top)
+void CameraLogic::Update(const Common::Matrix44& transform)
{
using Common::Matrix33;
using Common::Matrix44;
@@ -81,6 +83,9 @@ void CameraLogic::Update(const Common::Matrix44& transform, bool sensor_bar_on_t
// Values are optimized for default settings in "Super Mario Galaxy 2"
// This seems to be acceptable for a good number of games.
constexpr float SENSOR_BAR_LED_SEPARATION = 0.2f;
+
+ // Emulate a sensor bar height that matches the config.
+ const bool sensor_bar_on_top = Config::Get(Config::SYSCONF_SENSOR_BAR_POSITION) != 0;
const float sensor_bar_height = sensor_bar_on_top ? 0.11 : -0.11;
const std::array<Vec3, NUM_POINTS> leds{
diff --git a/Source/Core/Core/HW/WiimoteEmu/Camera.h b/Source/Core/Core/HW/WiimoteEmu/Camera.h
index fbc7f6516f..7ad44022f8 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Camera.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Camera.h
@@ -71,7 +71,7 @@ public:
void Reset();
void DoState(PointerWrap& p);
- void Update(const Common::Matrix44& transform, bool sensor_bar_on_top);
+ void Update(const Common::Matrix44& transform);
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 0de1cc0b16..10f1326f6d 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -243,13 +243,6 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
m_hotkeys->AddInput(_trans("Sideways Hold"), false);
m_hotkeys->AddInput(_trans("Upright Hold"), false);
- auto config_change_callback = [this] {
- m_sensor_bar_on_top = Config::Get(Config::SYSCONF_SENSOR_BAR_POSITION) != 0;
- };
- Config::AddConfigChangedCallback(config_change_callback);
-
- config_change_callback();
-
Reset();
}
@@ -439,7 +432,7 @@ void Wiimote::SendDataReport()
// IR Camera:
if (rpt_builder.HasIR())
{
- m_camera_logic.Update(GetTransformation(), m_sensor_bar_on_top);
+ m_camera_logic.Update(GetTransformation());
// 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 f534548d65..863bb8a1e1 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
@@ -268,9 +268,6 @@ private:
bool m_speaker_mute;
- // This is just for the IR Camera to compensate for the sensor bar position.
- bool m_sensor_bar_on_top;
-
WiimoteCommon::InputReportStatus m_status;
ExtensionNumber m_active_extension;