Report descriptors are composed of pieces of information. Each piece of information is called an Item.
报告描述符由一些数据片组成。这些数据片被叫做Item。
All items have a one-byte prefix that contains the item tag, item type, and item size.
每一个Item都包含一个字节的前缀,这个前缀中包含了三个信息--item tag,、item type、item size。
An item may include optional item data。
Item可以包含一个可选的数据段。
The size of the data portion of an item is determined by its fundamental type.
Item的数据部分的长度取决于Item的基本类型。
There are two basic types of items: short items and long items.
Item有两种基本类型:short items and long item。
long item格式 (原文件名:long item.jpg)
short item格式 (原文件名:short item.jpg)
There are three categories of short item tags: Main, Global, and Local.
short item 的 item tags 有三种类型:Main, Global, and Local.
Main items: </center>
Main items are used to either define or group certain types of data fields within a Report descriptor. There are two types of Main items: data and non-data. Data-type Main items are used to create a field within a report and include Input, Output, and Feature. Other items do not create fields and are subsequently referred to as non-data Main items.
(原文件名:MAIN Item.jpg)
(原文件名:MAIN Item1.jpg)
好了,到此我们应该可以对照实际应用的报告描述符,寻找其中的 Main items了。
至此我们已经可以明白报告描述符中的几个MAIN Item的意义,接下来继续看Global Item 和 Local Item.
Global Item: </center>
Global items describe rather than define data from a control. A new Main item assumes the characteristics of the item state table. Global items can change the state table. As a result Global item tags apply to all subsequently defined items unless overridden by another Global item.
(原文件名:Global Item.jpg)
(原文件名:Global Item1.jpg)
至此我们已经可以明白报告描述符中的几个Global Item的意义
Local Item: </center>
Local item tags define characteristics of controls. These items do not carry over to the next Main item. If a Main item defines more than one control, it may be preceded by several similar Local item tags. For example, an Input item may have several Usage tags associated with it, one for each control.
(原文件名:Local Item.jpg)
至此我们已经可以明白报告描述符中的几个Local Item的意义
//该报告描述符号由HID Descriptor tool生成
以下是一个USB鼠标的报告描述符
code char MouseReportDescriptor[63] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application) 这就是一个MAIN Item,可以对应上图查看
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) 这就是一个MAIN Item,可以对应上图查看
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs) 这就是一个MAIN Item,可以对应上图查看
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) 这就是一个MAIN Item,可以对应上图查看
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x91, 0x03, // OUTPUT (Cnst,Var,Abs) 这就是一个MAIN Item,可以对应上图查看
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) 这就是一个MAIN Item,可以对应上图查看
0xc0 // END_COLLECTION 这就是一个MAIN Item,可以对应上图查看
};
USB HID Report Descriptor 报告描述符详解,布布扣,bubuko.com
USB HID Report Descriptor 报告描述符详解
原文地址:http://www.cnblogs.com/AlwaysOnLines/p/3859557.html