From 0e35681c48f6e2fb136a452b12de238ff9ae3bc4 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Mon, 9 Oct 2017 14:21:30 -0700 Subject: [PATCH] Add idVendor() & idProduct() to HID parser class --- USBHost_t36.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/USBHost_t36.h b/USBHost_t36.h index 9138c17..cfbe277 100644 --- a/USBHost_t36.h +++ b/USBHost_t36.h @@ -405,6 +405,10 @@ private: // Device drivers may inherit from this base class, if they wish to receive // HID input data fully decoded by the USBHIDParser driver class USBHIDInput { +public: + operator bool() { return (mydevice != nullptr); } + uint16_t idVendor() { return (mydevice != nullptr) ? mydevice->idVendor : 0; } + uint16_t idProduct() { return (mydevice != nullptr) ? mydevice->idProduct : 0; } private: virtual bool claim_collection(Device_t *dev, uint32_t topusage); virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax); @@ -414,6 +418,8 @@ private: void add_to_list(); USBHIDInput *next; friend class USBHIDParser; +protected: + Device_t *mydevice = NULL; }; /************************************************/ @@ -755,7 +761,6 @@ protected: virtual void hid_input_end(); virtual void disconnect_collection(Device_t *dev); private: - Device_t *mydevice = NULL; uint8_t collections_claimed = 0; volatile bool mouseEvent = false; uint8_t buttons = 0; @@ -780,7 +785,6 @@ protected: virtual void hid_input_end(); virtual void disconnect_collection(Device_t *dev); private: - Device_t *mydevice = NULL; uint8_t collections_claimed = 0; bool anychange = false; volatile bool joystickEvent = false;