Hello forum,
sorry for a lengthy post - tldr; at the bottom
I'm currently struggeling with a problem related to the USB capabilites of a leonardo board.
What I'm trying to read accomplish is to read and parse joystick data from a USB host board, and pass the information to the PC using the pluggable USB feature of the leonardo board.
Basically I'm trying to implement a (joystick-) USB hub that can intercept data and fire some light effects / drive a motor, etc. on certain joystick actions.
I can read and parse the joystick data fine.
I can also make the leonardo act as a joystick.
The problem is, that the USB HID Descriptor in the PluggableUSB api has to be static because it is initializd on board startup. I understand now that "pluggable" means you can plug into the API, but not hot-plug...
This limits me to one specific joystick that is hard-wired in the program code.
I would like it to pass through the original joystick descriptor and the reports at runtime.
By adding a second Constructor to HIDSubDescriptor I was able to circumvent the PROGMEM limitation of the data secion but the new descriptor is not used because getDescritptor() is only called during board initialization.
my code:
node = new HIDSubDescriptor(myBuffer, bufSize, false);
HID().AppendDescriptor(node);
class HIDSubDescriptor {
public:
HIDSubDescriptor *next = NULL;
HIDSubDescriptor(const void *d, const uint16_t l) : data(d), length(l), progmem(true) { }
HIDSubDescriptor(const void *d, const uint16_t l, bool pgm) : data(d), length(l), progmem(pgm) { }
const void* data;
const uint16_t length;
const bool progmem;
};
HID.cpp
HIDSubDescriptor* node;
for (node = rootNode; node; node = node->next) {
int res = USB_SendControl((node->progmem)?TRANSFER_PGM:0, node->data, node->length);
if (res == -1)
tldr;
Is there any way to force the leonardo / mico USB Stack to reinitialize so that PluggableUSB instances that were added during runtime will be honored?
I'm aware that would also reset the serial line, etc, but that won't matter for my case.
Thanks for any input
Tobias