BTEmu: Add helper function for accessing WiimoteDevice instances by index
This makes it much more straightforward to access WiimoteDevice instances and also keeps the implementation details of accessing those instances in one spot. Given as all external accesses to the WiimoteDevice instances go through this function, we can make the other two private.
This commit is contained in:
1 parent
e4b6d7626b
commit
7eb86cdb67
8 files changed
+45
-29
No files matched your search
@@ -104,9 +104,9 @@ void Connect(unsigned int index, bool connect)
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
|
||||
if (bluetooth)
|
||||
bluetooth->AccessWiiMote(index | 0x100)->Activate(connect);
|
||||
bluetooth->AccessWiiMoteByIndex(index)->Activate(connect);
|
||||
|
||||
const char* message = connect ? "Wii Remote %i connected" : "Wii Remote %i disconnected";
|
||||
const char* message = connect ? "Wii Remote %u connected" : "Wii Remote %u disconnected";
|
||||
Core::DisplayMessage(StringFromFormat(message, index + 1), 3000);
|
||||
}
|
||||
|
||||
|
||||
@@ -1740,6 +1740,12 @@ void BluetoothEmu::CommandVendorSpecific_FC4C(const u8* input, u32 size)
|
||||
// --- helper
|
||||
//
|
||||
//
|
||||
WiimoteDevice* BluetoothEmu::AccessWiiMoteByIndex(std::size_t index)
|
||||
{
|
||||
const u16 connection_handle = static_cast<u16>(0x100 + index);
|
||||
return AccessWiiMote(connection_handle);
|
||||
}
|
||||
|
||||
WiimoteDevice* BluetoothEmu::AccessWiiMote(const bdaddr_t& address)
|
||||
{
|
||||
const auto iterator =
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -57,8 +56,7 @@ public:
|
||||
|
||||
bool RemoteDisconnect(u16 _connectionHandle);
|
||||
|
||||
WiimoteDevice* AccessWiiMote(const bdaddr_t& _rAddr);
|
||||
WiimoteDevice* AccessWiiMote(u16 _ConnectionHandle);
|
||||
WiimoteDevice* AccessWiiMoteByIndex(std::size_t index);
|
||||
|
||||
void DoState(PointerWrap& p) override;
|
||||
|
||||
@@ -102,6 +100,9 @@ private:
|
||||
u32 m_PacketCount[MAX_BBMOTES] = {};
|
||||
u64 m_last_ticks = 0;
|
||||
|
||||
WiimoteDevice* AccessWiiMote(const bdaddr_t& _rAddr);
|
||||
WiimoteDevice* AccessWiiMote(u16 _ConnectionHandle);
|
||||
|
||||
// Send ACL data to a device (wiimote)
|
||||
void IncDataPacket(u16 _ConnectionHandle);
|
||||
void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size);
|
||||
|
||||
@@ -926,6 +926,6 @@ void Callback_WiimoteInterruptChannel(int number, u16 channel_id, const u8* data
|
||||
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
|
||||
IOS::HLE::GetIOS()->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
if (bt)
|
||||
bt->AccessWiiMote(0x100 + number)->ReceiveL2capData(channel_id, data, size);
|
||||
bt->AccessWiiMoteByIndex(number)->ReceiveL2capData(channel_id, data, size);
|
||||
}
|
||||
}
|
||||
@@ -466,9 +466,11 @@ void ChangeWiiPads(bool instantly)
|
||||
nullptr;
|
||||
for (int i = 0; i < MAX_WIIMOTES; ++i)
|
||||
{
|
||||
g_wiimote_sources[i] = IsUsingWiimote(i) ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE;
|
||||
const bool is_using_wiimote = IsUsingWiimote(i);
|
||||
|
||||
g_wiimote_sources[i] = is_using_wiimote ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE;
|
||||
if (!SConfig::GetInstance().m_bt_passthrough_enabled && bt)
|
||||
bt->AccessWiiMote(i | 0x100)->Activate(IsUsingWiimote(i));
|
||||
bt->AccessWiiMoteByIndex(i)->Activate(is_using_wiimote);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user