6.2.2.8 Local Items
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.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - -- - -- -- - - - - - - - - - - - - - - - -
It is important that Usage be used properly. While very specific usages
exist (landing gear, bicycle wheel, and so on) those usages are intended to
identify devices that have very specific applications. A joystick with generic
buttons should never assign an application-specific usage to any button.
Instead, it should assign a generic usage such as “Button.” However, an
- - - - - - - - - - -- - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
It is also important to remember that Usage items convey information about
the intended use for the data and may not correspond to what is actually being
measured. For example, a joystick would have an X and Y Usage associated
with its axis data (and not Usages Rx and Ry.)
- - - - - - - - - - -- - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If a Usage Minimum is declared as and extended usage then the associated
Usage Maximum must also be declared as an extended usage.
z
Interpretation of Usage, Usage Minimum or Usage Maximum items vary as a
function of the item’s bSize field. If the bSize field = 3 then the item is
interpreted as a 32 bit unsigned value where the high order 16 bits defines the
Usage Page and the low order 16 bits defines the Usage ID . 32 bit usage items
that define both the Usage Page and Usage ID are often referred to as
“Extended” Usages.
If the bSize field = 1 or 2 then the Usage is interpreted as an unsigned value
that selects a Usage ID on the currently defined Usage Page. When the parser
encounters a main item it concatenates the last declared Usage Page with a
Usage to form a complete usage value. Extended usages can be used to
override the currently defined Usage Page for individual usages.
Usage的含义,是由bSize定的,不同的bSize对应不同的含义。
bSize=3时,对应的后面的Data是4个字节,此Usage = 高16bits + 低16bits= Usage Page + Usage ID,此时也成此Usage=Usage Page+Usage ID的情况为扩展的Usage(Extended Usage)
bSize=1或2时,对应的Data为1或2个字节,此Usage是无符号数,Usage = Usage ID,此Usage ID所代表的含义,是由当前所属的Usage Page所决定的。即,此时前面已经有了对应的Usage Page的定义了,然后此处Usage=Usage ID,共同组成了 Usage Page + Usage ID,决定了最终的用途。
而上述情况中,bSize=1或2是最常见的情况,而bSize=3的时候,很少见。
即,
常见的是:bSize=1或2,Usage=Usage ID,加上前面已定义的Usage Page,组成Usage Page+Usage ID,决定设备的用途(Usage);
少见的是:bSize=3,Usage=Usage Page + Usage ID,覆盖(override)了之前的Usage Page,自己此处重新定了Usage Page及Usage ID,决定设备的用途(Usage)。
之所以上面bSize=3,Usage=Usage Page +Usage ID被称为扩展的Usage,估计本意也就是让此Usage=Usage ID(bSize=1或2),所以当Usage =Usage Page + Usage ID的情况才被称为扩展的Usage。
【总结】
USB的HID的Spec,很多内容,必须要有一定了解的基础上,才容易看懂其含义的。。。