The Main item type is used for the Input, Output, Feature, Collection, and End Collection tags. A Main item is usually preceded by one or more Global or Local items that provide the rest of the description of the Main item.
Table 22.5 shows the set of possible item tags if the item type is Main (0). The number of data bytes and their definition is also shown. See the HID specification for full details.
Table 22.5 Main item tags
TagBits | Name | Databytes | Data |
---|---|---|---|
1000 | Input | 1-4 | Bit 0: 0=Data 1=Constant |
Bit 1: 0=Array 1=Variable | |||
Bit 2: 0=Absolute 1=Relative | |||
Bit 3: 0=No Wrap 1=Wrap | |||
Bit 4: 0=Linear 1=Non Linear | |||
Bit 5: 0=Preferred State 1=No Preferred | |||
Bit 6: 0=No Null position 1=Null state | |||
Bit 7: Reserved | |||
Bit 8: 0=Bit Field 1=Buffered Bytes | |||
Bit 31-9: Reserved | |||
1001 | Output | 1-4 | same as above, except Bit 7: 0=Non Volatile 1=Volatile |
1011 | Feature | 1-4 | same as Output |
1010 | Collection | 1 | 0x00 Physical group of axes |
0x01 Application mouse, keyboard | |||
0x02 Logical interrelated data | |||
0x03-0x7F Reserved | |||
0x80-0xFF Vendor-defined | |||
1100 | End collection | 0 | |
others |
|
The Input, Output, and Feature tags allow for up to four data bytes. However, if all the data bits in the top bytes are 0, they can be missed out. So, if bits 8-31 are 0 then the item data size can be given as 1 byte. Further, if no data bits are set at all, the data size can be zero.
For example, two bytes A1 01 (1010 0001 0000 0001) represent 'Collection, Main, 1 data byte'. The data byte is 0x01 (i.e., Application). Therefore, A1 01 is interpreted as 'Collection (Application)'.
The one byte C0 (1100 0000) is 'End collection, Main, 0 data bytes', and so just means 'End Collection'.
The two bytes 81 02 (1000 0001 0000 0010) represent 'Input, Main, 1 data byte'. The data byte just has bit 1 set and so means Data, Variable, Absolute, etc. So 81 02 can be written as 'Input (Data, Variable, Absolute)'.
Input, Output, and Feature Controls
As shown in the earlier example, an Input, an Output, or a Feature item must be preceded by various other items that further describe the controls. The preceding items can be Global if the setting lasts for more than one control. They can be Local if they provide just the setting for one control.
Input, Output, and Feature items must have Report Size and Report Count preceding Global items. Report Count specifies the number of controls, each of Report Size number of bits.