Use bdaddr to compare L2CapWiimotes

This commit is contained in:
capitalistspz 2024-09-26 17:01:10 +01:00
parent 75b5d28540
commit 873b6285b9
2 changed files with 6 additions and 5 deletions

View File

@ -16,8 +16,8 @@ namespace {
}
}
L2CapWiimote::L2CapWiimote(int recvFd,int sendFd)
: m_recvFd(recvFd), m_sendFd(sendFd)
L2CapWiimote::L2CapWiimote(int recvFd,int sendFd, bdaddr_t addr)
: m_recvFd(recvFd), m_sendFd(sendFd), m_addr(addr)
{
}
@ -83,7 +83,7 @@ std::vector<WiimoteDevicePtr> L2CapWiimote::get_devices()
continue;
}
outDevices.emplace_back(std::make_shared<L2CapWiimote>(sendFd, recvFd));
outDevices.emplace_back(std::make_shared<L2CapWiimote>(sendFd, recvFd, addr));
}
return outDevices;
}
@ -117,5 +117,5 @@ bool L2CapWiimote::operator==(const WiimoteDevice& rhs) const
auto mote = dynamic_cast<const L2CapWiimote*>(&rhs);
if (!mote)
return false;
return m_recvFd == mote->m_recvFd || m_recvFd == mote->m_sendFd;
return bacmp(&m_addr, &mote->m_addr) == 0;
}

View File

@ -5,7 +5,7 @@
class L2CapWiimote : public WiimoteDevice
{
public:
L2CapWiimote(int recvFd, int sendFd);
L2CapWiimote(int recvFd, int sendFd, bdaddr_t addr);
~L2CapWiimote() override;
bool write_data(const std::vector<uint8>& data) override;
@ -17,5 +17,6 @@ class L2CapWiimote : public WiimoteDevice
private:
int m_recvFd;
int m_sendFd;
bdaddr_t m_addr;
};