From 90652295956b6f4bcccb740aeb4f7c546327e499 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 30 Sep 2015 16:35:43 +0200 Subject: [PUSB] callbacks are now pure virtual methods This change allows the compiler to handle callbacks resolution. Callbacks now must be implemented on the class that extends PUSBListNode and this is forced by compiler by means of pure virtual methods. Also the calls to HID.interface() and HID.endpoint() can now be simplified to interface() and endpoint() respectively since the methods are no more static. --- cores/arduino/PluggableUSB.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cores/arduino/PluggableUSB.h') diff --git a/cores/arduino/PluggableUSB.h b/cores/arduino/PluggableUSB.h index d4a1096..c08bc99 100644 --- a/cores/arduino/PluggableUSB.h +++ b/cores/arduino/PluggableUSB.h @@ -28,9 +28,6 @@ class PUSBListNode { public: PUSBListNode() { } - bool (*setup)(USBSetup& setup, uint8_t i); - int (*getInterface)(uint8_t* interfaceNum); - int (*getDescriptor)(int8_t t); int8_t numEndpoints; int8_t numInterfaces; uint8_t *endpointType; @@ -39,6 +36,10 @@ public: inline int8_t endpoint() const { return pluggedEndpoint; } protected: + virtual bool setup(USBSetup& setup, uint8_t i) = 0; + virtual int getInterface(uint8_t* interfaceNum) = 0; + virtual int getDescriptor(int8_t t) = 0; + uint8_t pluggedInterface; int8_t pluggedEndpoint; -- cgit v1.2.3-18-g5258