REPORT_COUNT 在第 36 页的 6.2.2.7 全局项目部分的 Device Class Definition for HID 1.11 文档中定义为:
Report Count 1001 01 nn Unsigned integer specifying the number of data
fields for the item; determines how many fields are included in the
report for this particular item (and consequently how many bits are
added to the report).
上述代码中的 nn 是项目长度指示符 (bSize),在前面的 6.2.2.2 短项目小节中定义为:
bSize Numeric expression specifying size of data:
0 = 0 bytes
1 = 1 byte
2 = 2 bytes
3 = 4 bytes
相当令人困惑的是,bSize 的有效值以十进制列出。因此,在二进制中,nn 的位将是:
00 = 0 bytes (i.e. there is no data associated with this item)
01 = 1 byte
10 = 2 bytes
11 = 4 bytes
将 REPORT_COUNT 放在一起,这是一个无符号整数,可以指定以下替代方案:
1001 01 00 = 0x94 = REPORT_COUNT with no length (can only have value 0?)
1001 01 01 = 0x95 = 1-byte REPORT_COUNT (can have a value from 0 to 255)
1001 01 10 = 0x96 = 2-byte REPORT_COUNT (can have a value from 0 to 65535)
1001 01 11 = 0x97 = 4-byte REPORT_COUNT (can have a value from 0 to 4294967295)
同理,对于LOGICAL_MAXIMUM,它是一个有符号整数(通常有例外):
0010 01 00 = 0x24 = LOGICAL_MAXIMUM with no length (can only have value 0?)
0010 01 01 = 0x25 = 1-byte LOGICAL_MAXIMUM (can have a values from -128 to 127)
0010 01 10 = 0x26 = 2-byte LOGICAL_MAXIMUM (can have a value from -32768 to 32767)
0010 01 11 = 0x27 = 4-byte LOGICAL_MAXIMUM (can have a value from -2147483648 to 2147483647)
规范不清楚零长度项目的默认值通常是什么。它仅在 6.2.2.4 主要项目部分的末尾提到,主要项目类型以及该类型中的 INPUT 项目标签具有默认值 0:
Remarks - The default data value for all Main items is zero (0).
- An Input item could have a data size of zero (0) bytes. In this case the value of
each data bit for the item can be assumed to be zero. This is functionally
identical to using a item tag that specifies a 4-byte data item followed by four
zero bytes.
假设 0 作为其他项目类型的默认值也是合理的,但对于 REPORT_COUNT(一个 GLOBAL 项目),值 0 并不是一个合理的默认值(恕我直言)。规范并没有真正说明。