From 50ee2483919f5d32c32e8dfae68e9b995e03b616 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 15 Dec 2017 18:09:56 -0800 Subject: [PATCH] Expose VID/PID APIs --- include/boo/inputdev/DeviceBase.hpp | 5 +++++ lib/inputdev/DeviceBase.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/boo/inputdev/DeviceBase.hpp b/include/boo/inputdev/DeviceBase.hpp index c358e31..e421f7f 100644 --- a/include/boo/inputdev/DeviceBase.hpp +++ b/include/boo/inputdev/DeviceBase.hpp @@ -50,6 +50,11 @@ public: bool sendUSBInterruptTransfer(const uint8_t* data, size_t length); size_t receiveUSBInterruptTransfer(uint8_t* data, size_t length); + inline unsigned getVendorId(); + inline unsigned getProductId(); + inline std::string_view getVendorName(); + inline std::string_view getProductName(); + /* High-Level API */ #if _WIN32 #if !WINDOWS_STORE diff --git a/lib/inputdev/DeviceBase.cpp b/lib/inputdev/DeviceBase.cpp index 5c7b308..7e8d5ed 100644 --- a/lib/inputdev/DeviceBase.cpp +++ b/lib/inputdev/DeviceBase.cpp @@ -54,6 +54,34 @@ size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length) return false; } +unsigned DeviceBase::getVendorId() +{ + if (m_token) + return m_token->getVendorId(); + return -1; +} + +unsigned DeviceBase::getProductId() +{ + if (m_token) + return m_token->getProductId(); + return -1; +} + +std::string_view DeviceBase::getVendorName() +{ + if (m_token) + return m_token->getVendorName(); + return {}; +} + +std::string_view DeviceBase::getProductName() +{ + if (m_token) + return m_token->getProductName(); + return {}; +} + #if _WIN32 #if !WINDOWS_STORE const PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor()