Skip to content

Commit 1fb2e22

Browse files
committed
[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.
1 parent e91b6c9 commit 1fb2e22

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hardware/arduino/avr/cores/arduino/PluggableUSB.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
class PUSBListNode {
2929
public:
3030
PUSBListNode() { }
31-
bool (*setup)(USBSetup& setup, uint8_t i);
32-
int (*getInterface)(uint8_t* interfaceNum);
33-
int (*getDescriptor)(int8_t t);
3431
int8_t numEndpoints;
3532
int8_t numInterfaces;
3633
uint8_t *endpointType;
@@ -39,6 +36,10 @@ class PUSBListNode {
3936
inline int8_t endpoint() const { return pluggedEndpoint; }
4037

4138
protected:
39+
virtual bool setup(USBSetup& setup, uint8_t i) = 0;
40+
virtual int getInterface(uint8_t* interfaceNum) = 0;
41+
virtual int getDescriptor(int8_t t) = 0;
42+
4243
uint8_t pluggedInterface;
4344
int8_t pluggedEndpoint;
4445

0 commit comments

Comments
 (0)