Altered format on test report_descriptor.h

This commit is contained in:
Angel Cascarino
2021-12-20 12:51:26 +00:00
parent d3d9b5ba23
commit ab96a726d6

View File

@@ -5,6 +5,8 @@
#include "xua_hid_report.h" #include "xua_hid_report.h"
#define USB_HID_REPORT_ID_CONSUMER ( 0x02 )
#if 0 #if 0
/* Existing static report descriptor kept for reference */ /* Existing static report descriptor kept for reference */
unsigned char hidReportDescriptor[] = unsigned char hidReportDescriptor[] =
@@ -29,8 +31,6 @@ unsigned char hidReportDescriptor[] =
}; };
#endif #endif
#define USB_HID_REPORT_ID_CONSUMER ( 0x02 )
/* /*
* Define non-configurable items in the HID Report descriptor. * Define non-configurable items in the HID Report descriptor.
*/ */
@@ -64,41 +64,56 @@ static const USB_HID_Short_Item_t hidReportCount2 = {
static const USB_HID_Short_Item_t hidReportCount6 = { 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), .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
.data = { 0x06, 0x00 } }; .data = { 0x06, 0x00 } };
static const USB_HID_Short_Item_t hidReportSize1 = { 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), .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
.data = { 0x01, 0x00 } }; .data = { 0x01, 0x00 } };
static const USB_HID_Short_Item_t hidUsageConsumerControl = { static const USB_HID_Short_Item_t hidUsageConsumerControl = {
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
.data = { 0x01, 0x00 } }; .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 } }; * 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( USB_HID_REPORT_ID_CONSUMER, 1, 0, 0 ) };
/* /*
* Define configurable items in the HID Report descriptor. * Define configurable items in the HID Report descriptor.
*/ */
static USB_HID_Report_Element_t hidUsageByte0Bit5 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xE2, 0x00 }, static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 5 ) }; // Mute .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
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 }, .item.data = { 0xE2, 0x00 },
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 4 ) }; // Vol- .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 5 )
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 }, }; // Mute
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 3 ) }; // Vol+ static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
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 }, .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 2 ) }; // Scan Prev .item.data = { 0xEA, 0x00 },
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( USB_HID_REPORT_ID_CONSUMER, 0, 0, 4 )
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 1 ) }; // Scan Next }; // Vol-
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 }, static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 0 ) }; // Play .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
.item.data = { 0xE9, 0x00 },
static USB_HID_Short_Item_t hidReportID1 = { .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 3 )
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID), }; // Vol+
.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00} }; static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
static const USB_HID_Report_Element_t hidReportConsumer = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), .item.data = { 0xB6, 0x00 },
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 }, .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 2 )
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 1, 0, 0 ) }; // 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( USB_HID_REPORT_ID_CONSUMER, 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( USB_HID_REPORT_ID_CONSUMER, 0, 0, 0 )
}; // Play
/* /*
* List the configurable items in the HID Report descriptor. * List the configurable items in the HID Report descriptor.
@@ -113,18 +128,18 @@ static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
}; };
/* /*
* 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[] = {
&(hidReportConsumer.item), &(hidReportPageConsumer.item),
&hidUsagePageConsumer,
&hidUsageConsumerControl, &hidUsageConsumerControl,
&hidCollectionApplication, &hidCollectionApplication,
&hidLogicalMinimum0, &hidLogicalMinimum0,
@@ -144,10 +159,6 @@ static const USB_HID_Short_Item_t * const hidReportDescriptorItems[] = {
&hidCollectionEnd &hidCollectionEnd
}; };
static const USB_HID_Report_Element_t* const hidReports[] = {
&hidReportConsumer
};
/* /*
* Define the number of HID Reports * Define the number of HID Reports
* Due to XC not supporting designated initializers, this constant has a hard-coded value. * Due to XC not supporting designated initializers, this constant has a hard-coded value.