I read many articles from my predecessors on the Internet, that is, I cannot understand the meanings of the numeric characters in the report descriptor. After a few twists and turns, I finally got a general idea.
Code char mousereportdescriptor [63] = {
0x05, 0x01, // usage_page (generic desktop)
0x09, 0x06, // usage (keyboard)
0xa1, 0x01, // collection (Application)
0x05, 0x07, // usage_page (keyboard)
0x19, 0xe0, // usage_minimum (Keyboard leftcontrol)
0x29, 0xe7, // usage_maximum (keyboard right GUI)
0x15, 0x00, // logical_minimum (0)
0x25, 0x01, // logical_maximum (1)
0x75, 0x01, // report_size (1)
0x95, 0x08, // report_count (8)
0x81, 0x02, // input (data, VAR, ABS)
0x95, 0x01, // report_count (1)
0x75, 0x08, // report_size (8)
0x81, 0x03, // input (cnst, VAR, ABS)
0x95, 0x05, // report_count (5)
0x75, 0x01, // report_size (1)
0x05, 0x08, // usage_page (LEDs)
0x19, 0x01, // usage_minimum (num lock)
0x29, 0x05, // usage_maximum (Kana)
0x91, 0x02, // output (data, VAR, ABS)
0x95, 0x01, // report_count (1)
0x75, 0x03, // report_size (3)
0x91, 0x03, // output (cnst, VAR, ABS)
0x95, 0x06, // report_count (6)
0x75, 0x08, // report_size (8)
0x15, 0x00, // logical_minimum (0)
0x25, 0xff, // logical_maximum (255)
0x05, 0x07, // usage_page (keyboard)
0x19, 0x00, // usage_minimum (Reserved (no event indicated ))
0x29, 0x65, // usage_maximum (Keyboard Application)
0x81, 0x00, // input (data, ary, ABS)
0xc0 // end_collection
};
Generally, the net text is mostly the above report descriptor, which is said to be generated using a tool. Some of them are also accompanied by Chinese instructions, but they are also descriptive, instead of sharding, explain the meaning of these characters, for example, the first line of the array 0x05, 0x01, // usage_page (generic desktop)
We can see at a glance the text behind the double slash is a description of the previous number, that is, 0x05, 0x01 represents the meaning of usage_page (generic desktop), however, the description is not clear about the reason. For familiar people, this is naturally not a problem, but it will take some effort for new users.
0x05, 0x01 represents usage_page (generic desktop), which is defined by report descriptors on page 24th of device class definition for Human Interface Device (HID.
It is divided into two parts. 0x05 is a part, indicating the prefix and 0x01 is the data part.
0x05 is converted to binary, that is, 0000 01001. According to the definition of HID 5.3 generic item format, this byte is divided into three parts, bit0 ~ Bit1 indicates the length of the data following the prefix. Two values can represent up to 4 bytes of data, that is, bsize; bit2 ~ Bit3 indicates the type of This prefix. There are three types in total: 0 = Main, 1 = Global, 2 = Local, 3 = reserved; bit4 ~ Bit7 indicates the prefix tag, which is generally divided into input (1000 NN of binary, that is, bit4 ~ Bit7 = 1000, representing a tag, bit2 ~ Bit3 = 00, representing main, bit0 ~ Bit1 = nn, indicating that the prefix is followed by the data represented by NN), output (Binary 1001 00 NN), feature (1011 00 NN), collection (1010 00 NN ), end collection (1100 00 NN). Following this principle, we can parse the meaning expressed by 0x05.
0x05 to binary is 0000 0101, its 4-bit height is 0, indicating the tag is usage page tag (Protocol 45 pages), bit2 ~ Bit3 = 01 indicates the type. It can be seen from the protocol that this is a global item (36 pages of the Protocol), bit0 ~ Bit1 = 01 indicates that the data length followed by this prefix is 1 byte, that is, after 0x05, there is 0x01 as the Data Part Of This prefix, 0x01 indicates the fifth page and directory of General desktop page (Universal Serial Bus hid Usage Table). Therefore, the two numbers are combined to define usage_page (generic desktop.
To understand the report descriptor, we need two documents: Device class definition for Human Interface Device (HID) and Universal Serial Bus hid usage tables.