我用usb鼠标的历程改了一个USB游戏控制设备,枚举是成功了,可是数据一直通信不上,无论是输入还是输出,用BUS Hound监控,发现输入的数据总是只有四个,原来鼠标的报告描述符里面设定的的确是4个字节的输入,可是我已经改了啊,而且在端点描述符上面我也有定义啊,怎么还是不能用呢??是还要改动哪边呢??
const u8 Joystick_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC] =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
0x00, /*bcdUSB usb2.0*/
0x02,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
0x00, /*bDeviceProtocol*/
0x40, /*bMaxPacketSize40*/
0x33, /*idVendor */
0x21,
0x12, /*idProduct*/
0x54,
0x01, /*bcdDevice rel. 2.00*/
0x02,
1, /*Index of string descriptor describing
manufacturer */
2, /*Index of string descriptor describing
product*/
3, /*Index of string descriptor describing the
device serial number */
0x01 /*bNumConfigurations*/
}
; /* Joystick_DeviceDescriptor */
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 Joystick_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
JOYSTICK_SIZ_CONFIG_DESC,
/* wTotalLength: Bytes returned */
0x00,
0x01, /*bNumInterfaces: 1 interface*/
0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing
the configuration*/
0x80, /*bmAttributes: bus powered */
0x28, /*MaxPower 200 mA: this current is used for detecting Vbus*/
/************** Descriptor of Joystick Mouse interface ****************/
/* 09 */
0x09, /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
0x00, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
0x02, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0, /*iInterface: Index of string descriptor*/
/******************** Descriptor of Joystick Mouse HID ********************/
/* 18 */
0x09, /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
0x10, /*bcdHID: HID Class Spec release number*/
0x01,
0x00, /*bCountryCode: Hardware target country*/
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22, /*bDescriptorType*/
JOYSTICK_SIZ_REPORT_DESC,/*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Joystick Mouse endpoint ********************/
/* 27 */
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
0x81, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
0x40, /*wMaxPacketSize: 4 Byte max */
0x00,
0x02, /*bInterval: Polling Interval (32 ms)*/
/* 34 */
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
0x01, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
0x40, /*wMaxPacketSize: 4 Byte max */
0x00,
0x02, /*bInterval: Polling Interval (32 ms)*/
/* 41 */
}
; /* MOUSE_ConfigDescriptor */
const u8 Joystick_ReportDescriptor[JOYSTICK_SIZ_REPORT_DESC] =
{
0x05,0x01,
0x09,0x04,
0xa1,0x01,
0x05,0x02,
0x09,0xbb,
0x15,0x81,
0x25,0x7F,
0x75,0x08,
0x95,0x01,
0x81,0x02,
0x05,0x01,
0x09,0x01,
0xa1,0x00,
0x09,0x30,
0x09,0x31,
0x09,0x32,
0x09,0x33,
0x09,0x34,
0x09,0x35,
0x95,0x06,
0x81,0x02,
0xc0,
0x09,0x39,
0x15,0x00,
0x25,0x03,
0x35,0x00,
0x46,0x0e,0x01,
0x65,0x14,
0x55,0x00,
0x75,0x04,
0x95,0x01,
0x81,0x42,
0x05,0x09,
0x19,0x01,
0x29,0x13,
0x15,0x00,
0x25,0x01,
0x35,0x00,
0x45,0x01,
0x75,0x01,
0x95,0x13,
0x65,0x00,
0x81,0x02,
0x95,0x07,
0x06,0x00,0xff,
0x09,0x02,
0x91,0x02,
0xc0,
}
; /* Joystick_ReportDescriptor */
|