1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-01 01:38:44 +00:00

Add vendor/product members to IUSBDevice

This commit is contained in:
cathery 2019-11-08 11:59:11 +03:00
parent d6ddf1c933
commit 3509f2c223
2 changed files with 15 additions and 4 deletions

View File

@ -10,6 +10,9 @@ class IUSBDevice
protected:
std::vector<std::unique_ptr<IUSBInterface>> m_interfaces{};
uint16_t m_vendorID;
uint16_t m_productID;
public:
virtual ~IUSBDevice() = default;
@ -22,4 +25,7 @@ public:
//Get the raw reference to interfaces vector.
virtual std::vector<std::unique_ptr<IUSBInterface>> &GetInterfaces() { return m_interfaces; }
virtual uint16_t GetVendor() { return m_vendorID; }
virtual uint16_t GetProduct() { return m_productID; }
};

View File

@ -44,10 +44,15 @@ void SwitchUSBDevice::Reset()
void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length)
{
m_interfaces.clear();
m_interfaces.reserve(length);
for (int i = 0; i != length; ++i)
if (length > 0)
{
m_interfaces.push_back(std::make_unique<SwitchUSBInterface>(interfaces[i]));
m_vendorID = interfaces->device_desc.idVendor;
m_productID = interfaces->device_desc.idProduct;
m_interfaces.clear();
m_interfaces.reserve(length);
for (int i = 0; i != length; ++i)
{
m_interfaces.push_back(std::make_unique<SwitchUSBInterface>(interfaces[i]));
}
}
}