add test for mouse_open

add hid descriptor for mouse & mouse interface to descriptor_test
refractor extract function hidh_interface_status
fix error with MACRO HID_REPORT_ITEM with zero data size --> redundant semicolon
This commit is contained in:
hathach
2013-04-07 15:48:01 +07:00
parent 3d8a4ef8c8
commit 10c08ab404
5 changed files with 129 additions and 29 deletions

View File

@@ -92,10 +92,10 @@ const uint8_t keyboard_report_descriptor[] = {
HID_OUTPUT ( HID_CONSTANT ),
HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
HID_USAGE_MIN ( 0 ),
HID_USAGE_MAX ( 101 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 101 ),
HID_USAGE_MIN ( 0 ),
HID_USAGE_MAX ( 101 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 101 ),
HID_REPORT_COUNT ( 6 ),
HID_REPORT_SIZE ( 8 ),
@@ -103,6 +103,42 @@ const uint8_t keyboard_report_descriptor[] = {
HID_COLLECTION_END
};
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
const uint8_t mouse_report_descriptor[] = {
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
HID_USAGE (HID_USAGE_DESKTOP_POINTER),
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ),
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ),
HID_USAGE_MIN ( 1 ),
HID_USAGE_MAX ( 3 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 1 ),
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
HID_REPORT_SIZE ( 1 ),
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 5 ),
HID_INPUT ( HID_CONSTANT ), /* reserved */
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_X ),
HID_USAGE ( HID_USAGE_DESKTOP_Y ),
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
HID_REPORT_COUNT ( 2 ), /* X, Y position */
HID_REPORT_SIZE ( 8 ),
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
HID_COLLECTION_END,
HID_COLLECTION_END
};
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
const app_configuration_desc_t desc_configuration =
{
@@ -120,7 +156,7 @@ const app_configuration_desc_t desc_configuration =
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
},
///// USB HID Keyboard interface
//------------- HID Keyboard -------------//
.keyboard_interface =
{
.bLength = sizeof(tusb_descriptor_interface_t),
@@ -155,5 +191,41 @@ const app_configuration_desc_t desc_configuration =
.bInterval = 0x0A
},
//------------- HID Mouse -------------//
.mouse_interface =
{
.bLength = sizeof(tusb_descriptor_interface_t),
.bDescriptorType = TUSB_DESC_INTERFACE,
.bInterfaceNumber = 2,
.bAlternateSetting = 0x00,
.bNumEndpoints = 1,
.bInterfaceClass = TUSB_CLASS_HID,
.bInterfaceSubClass = HID_SUBCLASS_BOOT,
.bInterfaceProtocol = HID_PROTOCOL_MOUSE,
.iInterface = 0x00
},
.mouse_hid =
{
.bLength = sizeof(tusb_hid_descriptor_hid_t),
.bDescriptorType = HID_DESC_HID,
.bcdHID = 0x0111,
.bCountryCode = HID_Local_NotSupported,
.bNumDescriptors = 1,
.bReportType = HID_DESC_REPORT,
.wReportLength = sizeof(mouse_report_descriptor)
},
.mouse_endpoint =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_ENDPOINT,
.bEndpointAddress = 0x82,
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
.wMaxPacketSize = 0x08,
.bInterval = 0x0A
},
.ConfigDescTermination = 0,
};