Wiimote: Separate the Wiimote index in the Input system from the index of the Wiimote in the emulated system.
This commit is contained in:
parent
b67ffb9ab5
commit
bb5943ae77
|
@ -30,6 +30,9 @@ public:
|
|||
virtual void EventLinked() = 0;
|
||||
virtual void EventUnlinked() = 0;
|
||||
|
||||
virtual u8 GetWiimoteDeviceIndex() const = 0;
|
||||
virtual void SetWiimoteDeviceIndex(u8 index) = 0;
|
||||
|
||||
// Called every ~200hz after HID channels are established.
|
||||
virtual void Update() = 0;
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ void Wiimote::Reset()
|
|||
m_imu_cursor_state = {};
|
||||
}
|
||||
|
||||
Wiimote::Wiimote(const unsigned int index) : m_index(index)
|
||||
Wiimote::Wiimote(const unsigned int index) : m_index(index), m_bt_device_index(index)
|
||||
{
|
||||
// Buttons
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
|
||||
|
@ -489,6 +489,16 @@ DesiredWiimoteState Wiimote::BuildDesiredWiimoteState()
|
|||
return wiimote_state;
|
||||
}
|
||||
|
||||
u8 Wiimote::GetWiimoteDeviceIndex() const
|
||||
{
|
||||
return m_bt_device_index;
|
||||
}
|
||||
|
||||
void Wiimote::SetWiimoteDeviceIndex(u8 index)
|
||||
{
|
||||
m_bt_device_index = index;
|
||||
}
|
||||
|
||||
// This is called every ::Wiimote::UPDATE_FREQ (200hz)
|
||||
void Wiimote::Update()
|
||||
{
|
||||
|
@ -551,7 +561,8 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
|||
DataReportBuilder rpt_builder(m_reporting_mode);
|
||||
|
||||
if (Movie::IsPlayingInput() &&
|
||||
Movie::PlayWiimote(m_index, rpt_builder, m_active_extension, GetExtensionEncryptionKey()))
|
||||
Movie::PlayWiimote(m_bt_device_index, rpt_builder, m_active_extension,
|
||||
GetExtensionEncryptionKey()))
|
||||
{
|
||||
// Update buttons in status struct from movie:
|
||||
rpt_builder.GetCoreData(&m_status.buttons);
|
||||
|
@ -619,7 +630,8 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
|||
}
|
||||
}
|
||||
|
||||
Movie::CallWiiInputManip(rpt_builder, m_index, m_active_extension, GetExtensionEncryptionKey());
|
||||
Movie::CallWiiInputManip(rpt_builder, m_bt_device_index, m_active_extension,
|
||||
GetExtensionEncryptionKey());
|
||||
}
|
||||
|
||||
if (NetPlay::IsNetPlayRunning())
|
||||
|
@ -631,7 +643,8 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
|||
rpt_builder.GetCoreData(&m_status.buttons);
|
||||
}
|
||||
|
||||
Movie::CheckWiimoteStatus(m_index, rpt_builder, m_active_extension, GetExtensionEncryptionKey());
|
||||
Movie::CheckWiimoteStatus(m_bt_device_index, rpt_builder, m_active_extension,
|
||||
GetExtensionEncryptionKey());
|
||||
|
||||
// Send the report:
|
||||
InterruptDataInputCallback(rpt_builder.GetDataPtr(), rpt_builder.GetDataSize());
|
||||
|
|
|
@ -129,6 +129,9 @@ public:
|
|||
ControllerEmu::ControlGroup* GetTaTaConGroup(TaTaConGroup group) const;
|
||||
ControllerEmu::ControlGroup* GetShinkansenGroup(ShinkansenGroup group) const;
|
||||
|
||||
u8 GetWiimoteDeviceIndex() const override;
|
||||
void SetWiimoteDeviceIndex(u8 index) override;
|
||||
|
||||
void Update() override;
|
||||
void EventLinked() override;
|
||||
void EventUnlinked() override;
|
||||
|
@ -281,9 +284,15 @@ private:
|
|||
|
||||
ExtensionPort m_extension_port{&m_i2c_bus};
|
||||
|
||||
// Wiimote index, 0-3
|
||||
// Wiimote index, 0-3.
|
||||
// Can also be 4 for Balance Board.
|
||||
// This is used to look up the user button config.
|
||||
const u8 m_index;
|
||||
|
||||
// The Bluetooth 'slot' this device is connected to.
|
||||
// This is usually the same as m_index, but can differ during Netplay.
|
||||
u8 m_bt_device_index;
|
||||
|
||||
WiimoteCommon::InputReportID m_reporting_mode;
|
||||
bool m_reporting_continuous;
|
||||
|
||||
|
|
|
@ -450,6 +450,16 @@ Report& Wiimote::ProcessReadQueue(bool repeat_last_data_report)
|
|||
return m_last_input_report;
|
||||
}
|
||||
|
||||
u8 Wiimote::GetWiimoteDeviceIndex() const
|
||||
{
|
||||
return m_bt_device_index;
|
||||
}
|
||||
|
||||
void Wiimote::SetWiimoteDeviceIndex(u8 index)
|
||||
{
|
||||
m_bt_device_index = index;
|
||||
}
|
||||
|
||||
void Wiimote::Update()
|
||||
{
|
||||
// Wii remotes send input at 200hz once a Wii enables "sniff mode" on the connection.
|
||||
|
|
|
@ -62,6 +62,10 @@ public:
|
|||
bool IsBalanceBoard();
|
||||
|
||||
void InterruptDataOutput(const u8* data, const u32 size) override;
|
||||
|
||||
u8 GetWiimoteDeviceIndex() const override;
|
||||
void SetWiimoteDeviceIndex(u8 index) override;
|
||||
|
||||
void Update() override;
|
||||
void EventLinked() override;
|
||||
void EventUnlinked() override;
|
||||
|
@ -98,6 +102,8 @@ protected:
|
|||
// This is not enabled on all platforms as connecting a Wiimote can be a pain on some platforms.
|
||||
bool m_really_disconnect = false;
|
||||
|
||||
u8 m_bt_device_index = 0;
|
||||
|
||||
private:
|
||||
void Read();
|
||||
bool Write();
|
||||
|
|
|
@ -58,7 +58,7 @@ BluetoothEmuDevice::BluetoothEmuDevice(Kernel& ios, const std::string& device_na
|
|||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Wii Remote {} BT ID {:x},{:x},{:x},{:x},{:x},{:x}", i, tmp_bd[0],
|
||||
tmp_bd[1], tmp_bd[2], tmp_bd[3], tmp_bd[4], tmp_bd[5]);
|
||||
|
||||
m_wiimotes.emplace_back(std::make_unique<WiimoteDevice>(this, i, tmp_bd));
|
||||
m_wiimotes.emplace_back(std::make_unique<WiimoteDevice>(this, tmp_bd, i));
|
||||
}
|
||||
|
||||
bt_dinf.num_registered = MAX_BBMOTES;
|
||||
|
|
|
@ -54,24 +54,28 @@ private:
|
|||
|
||||
constexpr int CONNECTION_MESSAGE_TIME = 3000;
|
||||
|
||||
WiimoteDevice::WiimoteDevice(BluetoothEmuDevice* host, int number, bdaddr_t bd)
|
||||
WiimoteDevice::WiimoteDevice(BluetoothEmuDevice* host, bdaddr_t bd, unsigned int hid_source_number)
|
||||
: m_host(host), m_bd(bd),
|
||||
m_name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01")
|
||||
m_name(GetNumber() == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01")
|
||||
|
||||
{
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Wiimote: #{} Constructed", number);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Wiimote: #{} Constructed", GetNumber());
|
||||
|
||||
m_link_key.fill(0xa0 + number);
|
||||
m_link_key.fill(0xa0 + GetNumber());
|
||||
m_class = {0x00, 0x04, 0x48};
|
||||
m_features = {0xBC, 0x02, 0x04, 0x38, 0x08, 0x00, 0x00, 0x00};
|
||||
m_lmp_version = 0x2;
|
||||
m_lmp_subversion = 0x229;
|
||||
|
||||
const auto hid_source = WiimoteCommon::GetHIDWiimoteSource(GetNumber());
|
||||
const auto hid_source = WiimoteCommon::GetHIDWiimoteSource(hid_source_number);
|
||||
|
||||
// UGLY: This prevents an OSD message in SetSource -> Activate.
|
||||
if (hid_source)
|
||||
{
|
||||
hid_source->SetWiimoteDeviceIndex(GetNumber());
|
||||
|
||||
// UGLY: This prevents an OSD message in SetSource -> Activate.
|
||||
SetBasebandState(BasebandState::RequestConnection);
|
||||
}
|
||||
|
||||
SetSource(hid_source);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
using FeaturesType = std::array<u8, HCI_FEATURES_SIZE>;
|
||||
using LinkKeyType = std::array<u8, HCI_KEY_SIZE>;
|
||||
|
||||
WiimoteDevice(BluetoothEmuDevice* host, int number, bdaddr_t bd);
|
||||
WiimoteDevice(BluetoothEmuDevice* host, bdaddr_t bd, unsigned int hid_source_number);
|
||||
~WiimoteDevice();
|
||||
|
||||
WiimoteDevice(const WiimoteDevice&) = delete;
|
||||
|
|
Loading…
Reference in New Issue