mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-26 19:14:18 +01:00
Allow WiimoteControllerProvider
to receive L2CapWiimote
s
This commit is contained in:
parent
34f08a4edf
commit
ee60171b26
@ -4,6 +4,10 @@
|
||||
|
||||
#include "input/api/Wiimote/hidapi/HidapiWiimote.h"
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#include "input/api/Wiimote/l2cap/L2CapWiimote.h"
|
||||
#endif
|
||||
|
||||
#include <numbers>
|
||||
#include <queue>
|
||||
|
||||
@ -45,7 +49,12 @@ std::vector<std::shared_ptr<ControllerBase>> WiimoteControllerProvider::get_cont
|
||||
return writeable && not_already_connected;
|
||||
};
|
||||
|
||||
for (auto& device : WiimoteDevice_t::get_devices())
|
||||
auto devices = HidapiWiimote::get_devices();
|
||||
#if BOOST_OS_LINUX
|
||||
const auto& l2capDevices = L2CapWiimote::get_devices();
|
||||
std::ranges::copy(l2capDevices, std::back_inserter(devices));
|
||||
#endif
|
||||
for (auto& device : devices)
|
||||
{
|
||||
if (!valid_new_device(device))
|
||||
continue;
|
||||
|
@ -19,5 +19,3 @@ private:
|
||||
const std::string m_path;
|
||||
|
||||
};
|
||||
|
||||
using WiimoteDevice_t = HidapiWiimote;
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ class L2CapWiimote : public WiimoteDevice
|
||||
std::optional<std::vector<uint8>> read_data() override;
|
||||
bool operator==(WiimoteDevice& o) const override;
|
||||
|
||||
static void AddCandidateAddresses(const std::vector<bdaddr_t>& addrs);
|
||||
static std::vector<WiimoteDevicePtr> get_devices();
|
||||
private:
|
||||
int m_recvFd;
|
||||
|
Loading…
Reference in New Issue
Block a user