1
0
mirror of https://github.com/cathery/sys-con.git synced 2025-02-05 06:39:56 +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: protected:
std::vector<std::unique_ptr<IUSBInterface>> m_interfaces{}; std::vector<std::unique_ptr<IUSBInterface>> m_interfaces{};
uint16_t m_vendorID;
uint16_t m_productID;
public: public:
virtual ~IUSBDevice() = default; virtual ~IUSBDevice() = default;
@ -22,4 +25,7 @@ public:
//Get the raw reference to interfaces vector. //Get the raw reference to interfaces vector.
virtual std::vector<std::unique_ptr<IUSBInterface>> &GetInterfaces() { return m_interfaces; } 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,6 +44,10 @@ void SwitchUSBDevice::Reset()
void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length) void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length)
{ {
if (length > 0)
{
m_vendorID = interfaces->device_desc.idVendor;
m_productID = interfaces->device_desc.idProduct;
m_interfaces.clear(); m_interfaces.clear();
m_interfaces.reserve(length); m_interfaces.reserve(length);
for (int i = 0; i != length; ++i) for (int i = 0; i != length; ++i)
@ -51,3 +55,4 @@ void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length)
m_interfaces.push_back(std::make_unique<SwitchUSBInterface>(interfaces[i])); m_interfaces.push_back(std::make_unique<SwitchUSBInterface>(interfaces[i]));
} }
} }
}