Update examples to work with new API
This commit is contained in:
@@ -32,21 +32,43 @@ unsigned char hidReportDescriptor[] =
|
|||||||
/*
|
/*
|
||||||
* Define non-configurable items in the HID Report descriptor.
|
* Define non-configurable items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t hidCollectionApplication = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION), .data = { 0x01, 0x00 } };
|
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||||
static const USB_HID_Short_Item_t hidCollectionEnd = { .header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION), .data = { 0x00, 0x00 } };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidInputConstArray = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x01, 0x00 } };
|
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||||
static const USB_HID_Short_Item_t hidInputDataVar = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x02, 0x00 } };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x02, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x00, 0x00 } };
|
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x01, 0x00 } };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM), .data = { 0x00, 0x00 } };
|
.data = { 0x00, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidReportCount2 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x02, 0x00 } };
|
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||||
static const USB_HID_Short_Item_t hidReportCount6 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x06, 0x00 } };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
static const USB_HID_Short_Item_t hidReportSize1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE), .data = { 0x01, 0x00 } };
|
.data = { 0x02, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
|
.data = { 0x06, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0x01, 0x00 } };
|
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||||
@@ -93,9 +115,9 @@ static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
|||||||
}; // Play
|
}; // Play
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List the configurable items in the HID Report descriptor.
|
* List the configurable elements in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||||
&hidUsageByte0Bit0,
|
&hidUsageByte0Bit0,
|
||||||
&hidUsageByte0Bit1,
|
&hidUsageByte0Bit1,
|
||||||
&hidUsageByte0Bit2,
|
&hidUsageByte0Bit2,
|
||||||
@@ -105,27 +127,28 @@ static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List Usage pages in the HID Report descriptor, one per byte.
|
* List HID Reports, one per Report ID. This should be a usage page item with the relevant
|
||||||
|
* If not using report IDs - still have one with report ID 0
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidUsagePages[] = {
|
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||||
&hidUsagePageConsumer
|
&hidReportPageConsumer
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List all items in the HID Report descriptor.
|
* List all items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||||
&hidUsagePageConsumer,
|
&(hidReportPageConsumer.item),
|
||||||
&hidUsageConsumerControl,
|
&hidUsageConsumerControl,
|
||||||
&hidCollectionApplication,
|
&hidCollectionApplication,
|
||||||
&hidLogicalMinimum0,
|
&hidLogicalMinimum0,
|
||||||
&hidLogicalMaximum1,
|
&hidLogicalMaximum1,
|
||||||
&hidUsageByte0Bit0,
|
&(hidUsageByte0Bit0.item),
|
||||||
&hidUsageByte0Bit1,
|
&(hidUsageByte0Bit1.item),
|
||||||
&hidUsageByte0Bit2,
|
&(hidUsageByte0Bit2.item),
|
||||||
&hidUsageByte0Bit3,
|
&(hidUsageByte0Bit3.item),
|
||||||
&hidUsageByte0Bit4,
|
&(hidUsageByte0Bit4.item),
|
||||||
&hidUsageByte0Bit5,
|
&(hidUsageByte0Bit5.item),
|
||||||
&hidReportSize1,
|
&hidReportSize1,
|
||||||
&hidReportCount6,
|
&hidReportCount6,
|
||||||
&hidInputDataVar,
|
&hidInputDataVar,
|
||||||
@@ -136,9 +159,10 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the length of the HID Report.
|
* Define the number of HID Reports
|
||||||
* This value must match the number of Report bytes defined by hidReportDescriptorItems.
|
* Due to XC not supporting designated initializers, this constant has a hard-coded value.
|
||||||
|
* It must equal ( sizeof hidReports / sizeof ( USB_HID_Report_Element_t* ))
|
||||||
*/
|
*/
|
||||||
#define HID_REPORT_LENGTH ( 1 )
|
#define HID_REPORT_COUNT ( 1 )
|
||||||
|
|
||||||
#endif // __hid_report_descriptor_h__
|
#endif // __hid_report_descriptor_h__
|
||||||
|
|||||||
@@ -32,38 +32,92 @@ unsigned char hidReportDescriptor[] =
|
|||||||
/*
|
/*
|
||||||
* Define non-configurable items in the HID Report descriptor.
|
* Define non-configurable items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t hidCollectionApplication = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||||
static const USB_HID_Short_Item_t hidCollectionEnd = { .header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION), .data = { 0x00, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidInputConstArray = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||||
static const USB_HID_Short_Item_t hidInputDataVar = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x02, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x02, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x00, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x01, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM), .data = { 0x00, 0x00 }, .location = 0x00 };
|
.data = { 0x00, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidReportCount2 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x02, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||||
static const USB_HID_Short_Item_t hidReportCount6 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x06, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
static const USB_HID_Short_Item_t hidReportSize1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE), .data = { 0x01, 0x00 }, .location = 0x00 };
|
.data = { 0x02, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
|
.data = { 0x06, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), .data = { 0x0C, 0x00 }, .location = 0x00 };
|
/*
|
||||||
|
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||||
|
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||||
|
*/
|
||||||
|
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||||
|
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC( 0, 2, 0, 0 )
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define configurable items in the HID Report descriptor.
|
* Define configurable items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit5 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xE2, 0x00 }, .location = 0x50 }; // Mute
|
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit4 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xEA, 0x00 }, .location = 0x40 }; // Vol-
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit3 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xE9, 0x00 }, .location = 0x30 }; // Vol+
|
.item.data = { 0xE2, 0x00 },
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit2 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB6, 0x00 }, .location = 0x20 }; // Scan Prev
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB5, 0x00 }, .location = 0x10 }; // Scan Next
|
}; // Mute
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB0, 0x00 }, .location = 0x00 }; // Play
|
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xEA, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||||
|
}; // Vol-
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xE9, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||||
|
}; // Vol+
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB6, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||||
|
}; // Scan Prev
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB5, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||||
|
}; // Scan Next
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB0, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||||
|
}; // Play
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List the configurable items in the HID Report descriptor.
|
* List the configurable elements in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||||
&hidUsageByte0Bit0,
|
&hidUsageByte0Bit0,
|
||||||
&hidUsageByte0Bit1,
|
&hidUsageByte0Bit1,
|
||||||
&hidUsageByte0Bit2,
|
&hidUsageByte0Bit2,
|
||||||
@@ -73,27 +127,28 @@ static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List Usage pages in the HID Report descriptor, one per byte.
|
* List HID Reports, one per Report ID. This should be a usage page item with the relevant
|
||||||
|
* If not using report IDs - still have one with report ID 0
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidUsagePages[] = {
|
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||||
&hidUsagePageConsumer
|
&hidReportPageConsumer
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List all items in the HID Report descriptor.
|
* List all items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||||
&hidUsagePageConsumer,
|
&(hidReportPageConsumer.item),
|
||||||
&hidUsageConsumerControl,
|
&hidUsageConsumerControl,
|
||||||
&hidCollectionApplication,
|
&hidCollectionApplication,
|
||||||
&hidLogicalMinimum0,
|
&hidLogicalMinimum0,
|
||||||
&hidLogicalMaximum1,
|
&hidLogicalMaximum1,
|
||||||
&hidUsageByte0Bit0,
|
&(hidUsageByte0Bit0.item),
|
||||||
&hidUsageByte0Bit1,
|
&(hidUsageByte0Bit1.item),
|
||||||
&hidUsageByte0Bit2,
|
&(hidUsageByte0Bit2.item),
|
||||||
&hidUsageByte0Bit3,
|
&(hidUsageByte0Bit3.item),
|
||||||
&hidUsageByte0Bit4,
|
&(hidUsageByte0Bit4.item),
|
||||||
&hidUsageByte0Bit5,
|
&(hidUsageByte0Bit5.item),
|
||||||
&hidReportSize1,
|
&hidReportSize1,
|
||||||
&hidReportCount6,
|
&hidReportCount6,
|
||||||
&hidInputDataVar,
|
&hidInputDataVar,
|
||||||
@@ -104,9 +159,10 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the length of the HID Report.
|
* Define the number of HID Reports
|
||||||
* This value must match the number of Report bytes defined by hidReportDescriptorItems.
|
* Due to XC not supporting designated initializers, this constant has a hard-coded value.
|
||||||
|
* It must equal ( sizeof hidReports / sizeof ( USB_HID_Report_Element_t* ))
|
||||||
*/
|
*/
|
||||||
#define HID_REPORT_LENGTH ( 1 )
|
#define HID_REPORT_COUNT ( 1 )
|
||||||
|
|
||||||
#endif // __hid_report_descriptor_h__
|
#endif // __hid_report_descriptor_h__
|
||||||
|
|||||||
@@ -32,38 +32,92 @@ unsigned char hidReportDescriptor[] =
|
|||||||
/*
|
/*
|
||||||
* Define non-configurable items in the HID Report descriptor.
|
* Define non-configurable items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t hidCollectionApplication = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||||
static const USB_HID_Short_Item_t hidCollectionEnd = { .header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION), .data = { 0x00, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidInputConstArray = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||||
static const USB_HID_Short_Item_t hidInputDataVar = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT), .data = { 0x02, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||||
|
.data = { 0x02, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x00, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM), .data = { 0x01, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM), .data = { 0x00, 0x00 }, .location = 0x00 };
|
.data = { 0x00, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||||
|
.data = { 0x00, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidReportCount2 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x02, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||||
static const USB_HID_Short_Item_t hidReportCount6 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x06, 0x00 }, .location = 0x00 };
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
static const USB_HID_Short_Item_t hidReportSize1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE), .data = { 0x01, 0x00 }, .location = 0x00 };
|
.data = { 0x02, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||||
|
.data = { 0x06, 0x00 } };
|
||||||
|
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0x01, 0x00 }, .location = 0x00 };
|
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||||
|
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.data = { 0x01, 0x00 } };
|
||||||
|
|
||||||
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), .data = { 0x0C, 0x00 }, .location = 0x00 };
|
/*
|
||||||
|
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||||
|
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||||
|
*/
|
||||||
|
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||||
|
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC( 0, 2, 0, 0 )
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define configurable items in the HID Report descriptor.
|
* Define configurable items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit5 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xE2, 0x00 }, .location = 0x50 }; // Mute
|
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit4 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xEA, 0x00 }, .location = 0x40 }; // Vol-
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit3 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xE9, 0x00 }, .location = 0x30 }; // Vol+
|
.item.data = { 0xE2, 0x00 },
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit2 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB6, 0x00 }, .location = 0x20 }; // Scan Prev
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB5, 0x00 }, .location = 0x10 }; // Scan Next
|
}; // Mute
|
||||||
static USB_HID_Short_Item_t hidUsageByte0Bit0 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0xB0, 0x00 }, .location = 0x00 }; // Play
|
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xEA, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||||
|
}; // Vol-
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xE9, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||||
|
}; // Vol+
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB6, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||||
|
}; // Scan Prev
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB5, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||||
|
}; // Scan Next
|
||||||
|
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||||
|
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||||
|
.item.data = { 0xB0, 0x00 },
|
||||||
|
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||||
|
}; // Play
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List the configurable items in the HID Report descriptor.
|
* List the configurable elements in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||||
&hidUsageByte0Bit0,
|
&hidUsageByte0Bit0,
|
||||||
&hidUsageByte0Bit1,
|
&hidUsageByte0Bit1,
|
||||||
&hidUsageByte0Bit2,
|
&hidUsageByte0Bit2,
|
||||||
@@ -73,27 +127,28 @@ static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List Usage pages in the HID Report descriptor, one per byte.
|
* List HID Reports, one per Report ID. This should be a usage page item with the relevant
|
||||||
|
* If not using report IDs - still have one with report ID 0
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidUsagePages[] = {
|
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||||
&hidUsagePageConsumer
|
&hidReportPageConsumer
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List all items in the HID Report descriptor.
|
* List all items in the HID Report descriptor.
|
||||||
*/
|
*/
|
||||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||||
&hidUsagePageConsumer,
|
&(hidReportPageConsumer.item),
|
||||||
&hidUsageConsumerControl,
|
&hidUsageConsumerControl,
|
||||||
&hidCollectionApplication,
|
&hidCollectionApplication,
|
||||||
&hidLogicalMinimum0,
|
&hidLogicalMinimum0,
|
||||||
&hidLogicalMaximum1,
|
&hidLogicalMaximum1,
|
||||||
&hidUsageByte0Bit0,
|
&(hidUsageByte0Bit0.item),
|
||||||
&hidUsageByte0Bit1,
|
&(hidUsageByte0Bit1.item),
|
||||||
&hidUsageByte0Bit2,
|
&(hidUsageByte0Bit2.item),
|
||||||
&hidUsageByte0Bit3,
|
&(hidUsageByte0Bit3.item),
|
||||||
&hidUsageByte0Bit4,
|
&(hidUsageByte0Bit4.item),
|
||||||
&hidUsageByte0Bit5,
|
&(hidUsageByte0Bit5.item),
|
||||||
&hidReportSize1,
|
&hidReportSize1,
|
||||||
&hidReportCount6,
|
&hidReportCount6,
|
||||||
&hidInputDataVar,
|
&hidInputDataVar,
|
||||||
@@ -104,9 +159,10 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the length of the HID Report.
|
* Define the number of HID Reports
|
||||||
* This value must match the number of Report bytes defined by hidReportDescriptorItems.
|
* Due to XC not supporting designated initializers, this constant has a hard-coded value.
|
||||||
|
* It must equal ( sizeof hidReports / sizeof ( USB_HID_Report_Element_t* ))
|
||||||
*/
|
*/
|
||||||
#define HID_REPORT_LENGTH ( 1 )
|
#define HID_REPORT_COUNT ( 1 )
|
||||||
|
|
||||||
#endif // __hid_report_descriptor_h__
|
#endif // __hid_report_descriptor_h__
|
||||||
|
|||||||
Reference in New Issue
Block a user