Allow WiimoteControllerProvider to receive L2CapWiimotes

This commit is contained in:
capitalistspz 2024-09-26 01:42:24 +01:00
parent 32cb2bf3b5
commit e5d1d0e649
4 changed files with 19 additions and 6 deletions

View file

@ -2,7 +2,7 @@
#include <bluetooth/l2cap.h>
namespace {
// TODO: Add procedure to get addresses. Should add to PairingDialog
// TODO: Get addresses upon user request via PairingDialog
std::vector<bdaddr_t> s_address;
std::mutex s_addressMutex;
@ -39,6 +39,12 @@ L2CapWiimote::~L2CapWiimote()
::close(m_sendFd);
}
void L2CapWiimote::AddCandidateAddresses(const std::vector<bdaddr_t>& addrs)
{
std::scoped_lock lock(s_addressMutex);
std::ranges::copy(addrs, std::back_inserter(s_address));
}
std::vector<WiimoteDevicePtr> L2CapWiimote::get_devices()
{
s_addressMutex.lock();
@ -123,5 +129,4 @@ bool L2CapWiimote::operator==(WiimoteDevice& rhs) const
if (!mote)
return false;
return m_recvFd == mote->m_recvFd || m_recvFd == mote->m_sendFd;
}
}