diff --git a/ControllerUSB/include/IUSBDevice.h b/ControllerUSB/include/IUSBDevice.h index 5c0cd80..b22052a 100644 --- a/ControllerUSB/include/IUSBDevice.h +++ b/ControllerUSB/include/IUSBDevice.h @@ -10,6 +10,9 @@ class IUSBDevice protected: std::vector> 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> &GetInterfaces() { return m_interfaces; } + + virtual uint16_t GetVendor() { return m_vendorID; } + virtual uint16_t GetProduct() { return m_productID; } }; \ No newline at end of file diff --git a/SwitchUSB/source/SwitchUSBDevice.cpp b/SwitchUSB/source/SwitchUSBDevice.cpp index 10ccb5d..bcb4152 100644 --- a/SwitchUSB/source/SwitchUSBDevice.cpp +++ b/SwitchUSB/source/SwitchUSBDevice.cpp @@ -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(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(interfaces[i])); + } } } \ No newline at end of file