The Report descriptor is unlike other descriptors in that it is not simply a table of values. The length and content of a Report descriptor vary depending on the number of data fields required for the device’s report or reports. The Report descriptor is made up of items that provide information about the device. The first part of an item contains three fields: item type, item tag, and item size. Together these fields identify the kind of information the item provides.

    报告描述符与其他描述符不同,它并非简单的数值表格。其长度和内容会根据设备报告所需数据字段的数量而变化。报告描述符由描述设备信息的“项”组成。每个项的开头部分包含三个字段:项类型、项标签和数据长度。这些字段共同标识了该项所提供的信息类别。

    There are three item types: Main, Global, and Local. There are five Main item tags currently defined:

    共有三种项类型:项 (Main)、全局项 (Global)​ 和局部项 (Local)。目前定义了五种主项标签:

    • Input item tag: Refers to the data from one or more similar controls on a device. For example, variable data such as reading the position of a single axis or a group of levers or array data such as one or more push buttons or switches.

      输入项标签 (Input item tag):指来自设备上一个或多个类似控制器的数据。例如,可变数据(如读取单个轴或一组操纵杆的位置)或阵列数据(如一个或多个按钮或开关的状态)。

    • Output item tag: Refers to the data to one or more similar controls on a device such as setting the position of a single axis or a group of levers (variable data). Or, it can represent data to one or more LEDs (array data).

      输出项标签 (Output item tag):指发送到设备上一个或多个类似控制器的数据,例如设置单个轴或一组操纵杆的位置(可变数据)。或者,它可以表示发送到一个或多个LED的数据(阵列数据)。

    • Feature item tag: Describes device input and output not intended for consumption by the end user —for example, a software feature or Control Panel toggle.

      特征项标签 (Feature item tag):描述设备上并非供最终用户直接使用的输入和输出——例如,一项软件功能或控制面板的切换开关。

    • Collection item tag: A meaningful grouping of Input, Output, and Feature items—for example, mouse, keyboard, joystick, and pointer.

      集合项标签 (Collection item tag):用于对输入、输出和特征项进行有意义的逻辑分组——例如,鼠标、键盘、游戏杆和指针。

    • End Collection item tag: A terminating item used to specify the end of a collection of items.

      结束集合项标签 (End Collection item tag):一个用于标记一个项集合结束的终结项。

    The Report descriptor provides a description of the data provided by each control in a device. Each Main item tag (Input, Output, or Feature) identifies the size of the data returned by a particular control, and identifies whether the data is absolute or relative, and other pertinent information. Preceding Local and Global items define the minimum and maximum data values, and so forth. A Report descriptor is the complete set of all items for a device. By looking at a Report descriptor alone, an application knows how to handle incoming data, as well as what the data could be used for.

    报告描述符用于描述设备中每个控制器所提供的数据。每个主项标签(输入、输出或特征)标识了特定控制器所返回数据的大小,并指明该数据是绝对的还是相对的,以及其他相关信息。位于主项之前的局部项全局项则定义了数据的最小值最大值等属性。报告描述符是一个设备所有项的完整集合。仅通过查看报告描述符,应用程序就能了解如何处理传入的数据,以及这些数据可用于何种目的。

    One or more fields of data from controls are defined by a Main item and further described by the preceding Global and Local items. Local items only describe the data fields defined by the next Main item. Global items become the default attributes for all subsequent data fields in that descriptor. For example, consider the following (details omitted for brevity):

    设备控制器的一个或多个数据字段由主项定义,并由其之前的全局项和局部项进一步描述。局部项仅描述由下一个主项定义的数据字段。全局项则成为该描述符中所有后续数据字段的默认属性。
    例如,考虑以下简化的描述符示例(为突出重点省略了细节):

    Report Size (3)
    Report Count (2)
    Input
    Report Size (8)
    Input
    Output

    The item parser interprets the Report descriptor items above and creates the following reports (the LSB is on the left):

    项解析器会解释上述报告描述符中的各项,并创建以下报告(最低有效位位于左侧):

    6.2.2 Report Descriptor - 图1

    A Report descriptor may contain several Main items. A Report descriptor must include each of the following items to describe a control’s data (all other items are optional):

    一个报告描述符可以包含多个主项。为了描述一个控制器的数据,报告描述符必须包含以下各项(其他所有项均为可选项):

    • Input (Output or Feature)
    • Usage
    • Usage Page
    • Logical Minimum
    • Logical Maximum
    • Report Size
    • Report Count

    The following is a coding sample of items being used to define a 3-button mouse. In this case, Main items are preceded by Global items like Usage, Report Count or Report Size (each line is a new item).

    以下是一个用于定义三键鼠标的项编码示例。在此示例中,每个主项前都带有诸如用途 (Usage)报告数量 (Report Count)报告大小 (Report Size)全局项(每一行代表一个新的项)。

    Usage Page (Generic Desktop), ;Use the Generic Desktop Usage Page
    Usage (Mouse),
        Collection (Application), ;Start Mouse collection
            Usage (Pointer),
                Collection (Physical), ;Start Pointer collection
                    Usage Page (Buttons)
                    Usage Minimum (1),
                    Usage Maximum (3),
                    Logical Minimum (0),
                    Logical Maximum (1), ;Fields return values from 0 to 1
                    Report Count (3),
                    Report Size (1), ;Create three 1 bit fields (button 1, 2, & 3)
                    Input (Data, Variable, Absolute), ;Add fields to the input report.
                    Report Count (1),
                    Report Size (5), ;Create 5 bit constant field
                    Input (Constant), ;Add field to the input report
                    Usage Page (Generic Desktop),
                    Usage (X),
                    Usage (Y),
                    Logical Minimum (-127),
                    Logical Maximum (127), ;Fields return values from -127 to 127
                    Report Size (8),
                    Report Count (2), ;Create two 8 bit fields (X & Y position)
                    Input (Data, Variable, Relative), ;Add fields to the input report
                End Collection, ;Close Pointer collection
        End Collection ;Close Mouse collection