summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLC <mathew1800@gmail.com>2020-07-12 12:38:49 -0400
committerGitHub <noreply@github.com>2020-07-12 12:38:49 -0400
commitecc6af7f7f2dd91fd3318ff25c9d50d70176be2e (patch)
treea897c1f1e75c4d61e64dc2f2ebcb73caa2798bd3 /Source/Core
parented32a2a1fe1d63f3ac1d9380b2328ebff39668e8 (diff)
parentd9e7d0514c9cbe161ba93401f40ea20e5e701da3 (diff)
Merge pull request #8948 from jordan-woyak/speaker-data-writes
WiimoteEmu: Allow writes of the i2c bus to play speaker data.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp7
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Speaker.cpp2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Speaker.h11
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h1
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h4
6 files changed, 17 insertions, 10 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
index 5100ae74fc..bd25279867 100644
--- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
@@ -389,10 +389,9 @@ void Wiimote::HandleSpeakerData(const WiimoteCommon::OutputReportSpeakerData& rp
}
else
{
- // Speaker Pan
- const auto pan = m_speaker_pan_setting.GetValue() / 100;
-
- m_speaker_logic.SpeakerData(rpt.data, rpt.length, pan);
+ // Speaker data reports result in a write to the speaker hardware at offset 0x00.
+ m_i2c_bus.BusWrite(SpeakerLogic::I2C_ADDR, SpeakerLogic::SPEAKER_DATA_OFFSET, rpt.length,
+ rpt.data);
}
}
diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
index 6fcd8c10a9..c3131cc6f2 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
@@ -197,7 +197,7 @@ int SpeakerLogic::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
if (0x00 == addr)
{
- ERROR_LOG(WIIMOTE, "Writing of speaker data to address 0x00 is unimplemented!");
+ SpeakerData(data_in, count, m_speaker_pan_setting.GetValue() / 100);
return count;
}
else
diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.h b/Source/Core/Core/HW/WiimoteEmu/Speaker.h
index 6f30566842..d746dc2498 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Speaker.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.h
@@ -7,6 +7,7 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Core/HW/WiimoteEmu/I2CBus.h"
+#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
namespace WiimoteEmu
{
@@ -15,18 +16,24 @@ struct ADPCMState
s32 predictor, step;
};
+class Wiimote;
+
class SpeakerLogic : public I2CSlave
{
+ friend class Wiimote;
+
public:
static const u8 I2C_ADDR = 0x51;
+ static constexpr u8 SPEAKER_DATA_OFFSET = 0x00;
+
void Reset();
void DoState(PointerWrap& p);
+private:
// Pan is -1.0 to +1.0
void SpeakerData(const u8* data, int length, float speaker_pan);
-private:
// TODO: enum class
static const u8 DATA_FORMAT_ADPCM = 0x00;
static const u8 DATA_FORMAT_PCM = 0x40;
@@ -63,6 +70,8 @@ private:
// TODO: What actions reset this state?
// Is this actually in the register somewhere?
ADPCMState adpcm_state;
+
+ ControllerEmu::SettingValue<double> m_speaker_pan_setting;
};
} // namespace WiimoteEmu
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
index 8909b140c0..8191c231ec 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -246,7 +246,7 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
// Options
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
- m_options->AddSetting(&m_speaker_pan_setting,
+ m_options->AddSetting(&m_speaker_logic.m_speaker_pan_setting,
{_trans("Speaker Pan"),
// i18n: The percent symbol.
_trans("%")},
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
index c8149353c2..cfb1205941 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
@@ -263,7 +263,6 @@ private:
ControllerEmu::SettingValue<bool> m_sideways_setting;
ControllerEmu::SettingValue<bool> m_upright_setting;
ControllerEmu::SettingValue<double> m_battery_setting;
- ControllerEmu::SettingValue<double> m_speaker_pan_setting;
ControllerEmu::SettingValue<bool> m_motion_plus_setting;
SpeakerLogic m_speaker_logic;
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
index 8f98401dcd..46b8172d14 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
@@ -75,11 +75,11 @@ public:
template <typename T>
void AddSetting(SettingValue<T>* value, const NumericSettingDetails& details,
- std::common_type_t<T> default_value, std::common_type_t<T> min_value = {},
+ std::common_type_t<T> default_value_, std::common_type_t<T> min_value = {},
std::common_type_t<T> max_value = T(100))
{
numeric_settings.emplace_back(
- std::make_unique<NumericSetting<T>>(value, details, default_value, min_value, max_value));
+ std::make_unique<NumericSetting<T>>(value, details, default_value_, min_value, max_value));
}
void AddDeadzoneSetting(SettingValue<double>* value, double maximum_deadzone);