Merge pull request #7868 from jordan-woyak/shutdown-crash-fix

WiimoteEmu: Fix a config change callback causing a crash on exit.
This commit is contained in:
Connor McLaughlin 2019-03-10 11:13:02 +10:00 committed by GitHub
commit 08b95c3fde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 13 deletions

View File

@ -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{

View File

@ -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;

View File

@ -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 =

View File

@ -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;