Skip to content

PUSBCallbacks - is it necessary to require static functions? (PluggableUSB in 1.6.6) #3874

Closed
@Teiwaz83

Description

@Teiwaz83

The PUSBCallbacks struct (in PluggableUSB.h) is defined like so:

typedef struct __attribute__((packed))
{
  bool (*setup)(USBSetup& setup, u8 i);
  int (*getInterface)(u8* interfaceNum);
  int (*getDescriptor)(int8_t t);
  int8_t numEndpoints;
  int8_t numInterfaces;
  uint8_t *endpointType;
} PUSBCallbacks;

This requires the methods setup, getInterface, and getDescriptor to all be static. I haven't dug very far past this (the whole point of PluggableUSB is to keep me as far form the inner horrors of USB as possible!) - but is this necessary? Requiring these methods to be static really complicates setting up classes which can manage their own interfaces and endpoints. If you want each instance of a class to have its own interface/endpoint to make Windows see it as a separate device, you need to be using unique information when building the interface descriptor, which generally you want to be doing in getInterface. GetInterface having to be static prevents you from easily correlating a created interface with a specific instance of your class.

Metadata

Metadata

Assignees

Labels

Component: CoreRelated to the code for the standard Arduino APIComponent: USB DeviceOpposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...)Library: HIDThe HID Arduino libraryfeature requestA request to make an enhancement (not a bug fix)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions