code uint8 ReportDescriptor[]=
{
#ifdef TOUCH_SCREEN
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x04, // USAGE (Touch Screen)
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORTID_MTOUCH, // REPORT_ID (Touch)
0x09, 0x22, // USAGE (Finger)
//contact 1
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)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x32, // USAGE (In Range)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x81, 0x03, // INPUT (Cnst,Ary,Abs)
0x75, 0x08, // REPORT_SIZE (8)
0x09, 0x51, // USAGE ( Contact Identifier)
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desk..
0x26,(uint8)(SCRN_RESOLUTION_X&0xFF),(uint8)((SCRN_RESOLUTION_X>>8)&0xFF), LOGICAL_MAXIMUM
0x75, 0x10, // REPORT_SIZE (16)
0x55, 0x00, // UNIT_EXPONENT (0)
0x65, 0x00, // UNIT (00)
0x09, 0x30, // USAGE (X)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46,(uint8)(SCRN_RESOLUTION_X&0xFF),(uint8)((SCRN_RESOLUTION_X>>8)&0xFF), // PHYSICAL_MAXIMUM (1920)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x26, (uint8)(SCRN_RESOLUTION_Y&0xFF),(uint8)((SCRN_RESOLUTION_Y>>8)&0xFF), // LOGICAL_MAXIMUM
0x46, (uint8)(SCRN_RESOLUTION_Y&0xFF),(uint8)((SCRN_RESOLUTION_Y>>8)&0xFF), // PHYSICAL_MAXIMUM (1080)
0x09, 0x31, // USAGE (Y)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
//contact 2
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x22, // USAGE (Finger)
0xa1, 0x02, // COLLECTION (Logical)
0x05, 0x0d, // USAGE_PAGE (Digitizers)
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)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x32, // USAGE (In Range)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x81, 0x03, // INPUT (Cnst,Ary,Abs)
0x75, 0x08, // REPORT_SIZE (8)
0x09, 0x51, // USAGE ( Contact Identifier)
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desk..
0x26,(uint8)(SCRN_RESOLUTION_X&0xFF),(uint8)((SCRN_RESOLUTION_X>>8)&0xFF), // LOGICAL_MAXIMUM ()
0x75, 0x10, // REPORT_SIZE (16)
0x55, 0x00, // UNIT_EXPONENT (0)
0x65, 0x00, // UNIT (0)
0x09, 0x30, // USAGE (X)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46,(uint8)(SCRN_RESOLUTION_X&0xFF),(uint8)((SCRN_RESOLUTION_X>>8)&0xFF),// 0xA0, 0x05, // PHYSICAL_MAXIMUM ()
0x81, 0x02, // INPUT (Data,Var,Abs)
0x26, (uint8)(SCRN_RESOLUTION_Y&0xFF),(uint8)((SCRN_RESOLUTION_Y>>8)&0xFF), // LOGICAL_MAXIMUM ()
0x46, (uint8)(SCRN_RESOLUTION_Y&0xFF),(uint8)((SCRN_RESOLUTION_Y>>8)&0xFF), // PHYSICAL_MAXIMUM ()
0x09, 0x31, // USAGE (Y)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x54, // USAGE (Actual count)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x08, // LOGICAL_MAXIMUM (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x55, // USAGE(Maximum Count)
0xb1, 0x02, // FEATURE (Data,Var,Abs)
0xc0, // END_COLLECTION
0x09, 0x0E, // USAGE (Device Configuration)
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORTID_FEATURE, // REPORT_ID (Configuration)
0x09, 0x23, // USAGE (Device Settings)
0xa1, 0x02, // COLLECTION (logical)
0x09, 0x52, // USAGE (Device Mode)
0x09, 0x53, // USAGE (Device Identifier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x0a, // LOGICAL_MAXIMUM (10)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0xb1, 0x02, // FEATURE (Data,Var,Abs
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
};
在报告描述符中的最后,有一个Feature主项目,做项目时就遇到这个问题不会处理,后来查阅了协议文档,处理如下:
USB协议定义了多种请求类型,Feature就需要在类输入请求中的GET_REPORT请求代码下返回Feature请求的内容。主机发送的8字节请求数据的值分别为:
bmRequestType 10100001;
bRequest 3; 协议中定义GET_REPORT的值为3
wValue的高8位代表Report的类型,该值为3就表示Feature报告;
wValue的低8位代表报告ID;
因此,我们可以根据以上请求的值判断当前请求是否要获取Feature报告,如果是,就可以讲所要数据(像报告描述符,配置描述符那样预先定义好的数据)写入端点0中。
注意:以上给出的报告描述符是两点触摸的描述符,是可以直接使用的,个别宏替换下就可以了。