MCPcopy Create free account
hub / github.com/MHeironimus/ArduinoJoystickLibrary / getDescriptor

Method getDescriptor

src/DynamicHID/DynamicHID.cpp:48–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48int DynamicHID_::getDescriptor(USBSetup& setup)
49{
50 // Check if this is a HID Class Descriptor request
51 if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
52 if (setup.wValueH != DYNAMIC_HID_REPORT_DESCRIPTOR_TYPE) { return 0; }
53
54 // In a HID Class Descriptor wIndex cointains the interface number
55 if (setup.wIndex != pluggedInterface) { return 0; }
56
57 int total = 0;
58 DynamicHIDSubDescriptor* node;
59 for (node = rootNode; node; node = node->next) {
60 int res = USB_SendControl((node->inProgMem ? TRANSFER_PGM : 0), node->data, node->length);
61 if (res == -1)
62 return -1;
63 total += res;
64 }
65
66 // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
67 // due to the USB specs, but Windows and Linux just assumes its in report mode.
68 protocol = DYNAMIC_HID_REPORT_PROTOCOL;
69
70 return total;
71}
72
73uint8_t DynamicHID_::getShortName(char *name)
74{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected