From 3509f2c2234fb64dec61cf830499f9082ea3d698 Mon Sep 17 00:00:00 2001 From: cathery Date: Fri, 8 Nov 2019 11:59:11 +0300 Subject: [PATCH] Add vendor/product members to IUSBDevice --- ControllerUSB/include/IUSBDevice.h | 6 ++++++ SwitchUSB/source/SwitchUSBDevice.cpp | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) 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