Understanding USBCore for Arduino micro

IDE version is 1.8.4, recent enough.

I am trying to understand USBCore for Arduino micro so I can re-purpose it to enumerate a specific HID device that does the following:

bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard

Currently my micro does this:
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None

In my user code, I have used both Keyboard and Mouse libraries. My bootloader may be a bit older but I don't know if that makes enough difference to the above descriptor, which I thought was in the user code.

From reading the USBCore.h, I found the typedef of interface descriptor and a macro to create one:

//	Interface
typedef struct
{
	u8 len;		// 9
	u8 dtype;	// 4
	u8 number;
	u8 alternate;
	u8 numEndpoints;
	u8 interfaceClass;
	u8 interfaceSubClass;
	u8 protocol;
	u8 iInterface;
} InterfaceDescriptor;
#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \
	{ 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 }

Strangely enough the "9" was a magic number although this was already defined earlier:

#define USB_CONFIGUARTION_DESC_SIZE 9

I am still going through USBCore.cpp, which is long. I didn't spot where the actual interface descriptor is created, maybe not in this code but elsewhere?

Any pointers and advice where to find the code that creates the interface structures and "load" them up would be appreciated?

Thanks.

Another thing I am trying to understand is what PluggableUSB does. I don't understand its terms such as node etc. Is it supposed to handle host requests to get various descriptors?

As I vaguely recall, Keyboard, Mouse, USBMIDI, joystick, etc. register their interfaces with PluggableUSB. USBCore calls PluggableUSB to get the interface descriptors. USBCore sends the configuration descriptor with the number of interfaces which is tracked by PluggableUSB.

This was helpful when I was working in this area a few years ago.

Thanks. I'll find some time to dig into PluggableHID.
For now, I traced everything to USB_Send (uint8_t ep, const void* data, int len); declared in USBAPI.h
I can't find its definition. Any idea where I can find the source code?

The reason I'm trying to find it is a call from HID.h. It hardcodes a report ID (2) in its call, which traces to USB_Send.

I wish to find out how to NOT send report ID since I got rid of USB CDC and won't be using mouse, which is hard coded report ID (1).

Thanks.

USB_Send is in USBCore.cpp. "grep -r" is useful for browsing source code. grep searchs all files in a directory tree for a string. Wildcards are supported. Windows has a similar command named findstr.

ctags is also useful but is requires a ctags aware editor such as vim or emacs.

Ctags is a programming tool that generates an index file of names found in source and header files of various programming languages. Depending on the language, functions, variables, class members, macros and so on may be indexed. These tags allow definitions to be quickly and easily located by a text editor or other utility. -- Wikipedia