HID报告描述符全局项REPORT_COUNT和REPORT_SIZE
2022-05-18
2189
38
HID报告描述符全局项ReportCount和ReportSize用于指示报告描述符数据项的大小,其中:
- REPORT_COUNT:用于指定LOCAL USAGE的个数
- REPORT_SIZE:用于指定每个USAGE的数据大小。
如鼠标的X和Y坐标
USAGE (X) 09 30
USAGE (Y) 09 31
LOGICAL_MINIMUM (-127) 15 81
LOGICAL_MAXIMUM (127) 25 7F
REPORT_SIZE (8) 75 08
REPORT_COUNT (2) 95 02
INPUT (Data,Var,Rel) 81 06
这里使用了USAGE(X),USAGE(Y),使用REPORT_COUNT=2指示2个USAGE有效,其中每个USAGE的数据大小为REPORT_SIZE=8
又如:
USAGE_PAGE (Button) 05 09
USAGE_MINIMUM (Button 1) 19 01
USAGE_MAXIMUM (Button 3) 29 03
LOGICAL_MINIMUM (0) 15 00
LOGICAL_MAXIMUM (1) 25 01
REPORT_COUNT (3) 95 03
REPORT_SIZE (1) 75 01
INPUT (Data,Var,Abs) 81 02
这里指定了三个LOCAL USAGE,不过使用最大和最小值来指定(USAGE_MINIMUM (Button 1),USAGE_MAXIMUM (Button 3) ),故REPORT_COUNT=3,而每个USAG的数据大小为1,即REPORT_SIZE=1,而LOGICAL_MINIMUM和LOGICAL_MAXIMUM指定了每个USAGE的最大和最小值。
这里我们也可以截取一TP的报告描述符:
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x42, // USAGE (Tip Switch)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x01, // REPORT_COUNT (1)
可以看到,这里指定了TP是否按下的开关。
0x95,0x01, //38 GLOBAL_REPORT_COUNT(1)
...
0x05,0x01, //42 GLOBAL_USAGE_PAGE(Generic Desktop Controls)
0x75,0x10, //44 GLOBAL_REPORT_SIZE(16)
0x55,0x0E, //46 GLOBAL_UNIT_EXPONENT(14)
0x65,0x11, //48 GLOBAL_REPORT_UNIT(17)
0x09,0x30, //50 LOCAL_USAGE(X)
0x26,0x00,0x40, //52 GLOBAL_LOCAL_MAXIMUM(16384)
0x35,0x00, //55 GLOBAL_PHYSICAL_MINIMUM(0)
0x46,0x5D,0x14, //57 GLOBAL_PHYSICAL_MAXIMUM(5213)
0x81,0x42, //60 MAIN_INPUT(data var absolute NoWrap linear PreferredState NullState NonVolatile )
这里指定了2字节的X,其最大值为16384
0x09,0x31, //62 LOCAL_USAGE(Y)
0x26,0x80,0x25, //64 GLOBAL_LOCAL_MAXIMUM(9600/9600)
0x46,0x74,0x0B, //67 GLOBAL_PHYSICAL_MAXIMUM(2932)
0x81,0x42, //70 MAIN_INPUT(data var absolute NoWrap linear PreferredState NullState NonVolatile )
同样的对于Y,由于ReportCount和ReportSize是全局的,沿用X的,占2字节,只是最大值最为了9600。
另外一种的是键盘的报告描述符,其是一个数组为类型:
REPORT_COUNT (6) 95 06
REPORT_SIZE (8) 75 08
LOGICAL_MINIMUM (0) 15 00
LOGICAL_MAXIMUM (101) 25 65
USAGE_PAGE (Keyboard) 05 07
USAGE_MINIMUM (Reserved (no event indicated)) 19 00
USAGE_MAXIMUM (Keyboard Application) 29 65
INPUT (Data,Ary,Abs) 81 00
而对于数组类型,REPORT_COUNT指定了数组的个数,REPORT_SIZE指定了每个数组成员的大小。LOGICAL_MINIMUM和LOGICAL_MAXIMUM指定了数组成员可取的值。
USAGE_MINIMUM和USAGE_MAXIMUM的含义与OGICAL_MINIMUM和LOGICAL_MAXIMUM一致。
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936