Merge remote-tracking branch 'angel/feature/multiple_hid_reports' into feature/multiple_hid_reports_tests

This commit is contained in:
Ciaran Woodward
2021-12-08 11:28:37 +00:00
3 changed files with 57 additions and 33 deletions

2
.gitignore vendored
View File

@@ -20,6 +20,8 @@
test_results.csv test_results.csv
_build* _build*
**/.venv/** **/.venv/**
**/.vscode/**
**.egg-info
# waf build files # waf build files
.lock-waf_* .lock-waf_*

View File

@@ -29,41 +29,51 @@ unsigned char hidReportDescriptor[] =
}; };
#endif #endif
#define USB_HID_REPORT_ID_CONSUMER ( 0x02 )
#define USB_HID_USAGE_PAGE_ID_CONSUMER (0x02)
/* /*
* 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 = 0xA1, .data = { 0x01, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidCollectionApplication = { .header = 0xA1, .data = { 0x01, 0x00 }};
static const USB_HID_Short_Item_t hidCollectionEnd = { .header = 0xC0, .data = { 0x00, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidCollectionEnd = { .header = 0xC0, .data = { 0x00, 0x00 }};
static const USB_HID_Short_Item_t hidInputConstArray = { .header = 0x81, .data = { 0x01, 0x00 }};
static const USB_HID_Short_Item_t hidInputConstArray = { .header = 0x81, .data = { 0x01, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidInputDataVar = { .header = 0x81, .data = { 0x02, 0x00 }};
static const USB_HID_Short_Item_t hidInputDataVar = { .header = 0x81, .data = { 0x02, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidLogicalMaximum0 = { .header = 0x25, .data = { 0x00, 0x00 }};
static const USB_HID_Short_Item_t hidLogicalMaximum1 = { .header = 0x25, .data = { 0x01, 0x00 }};
static const USB_HID_Short_Item_t hidLogicalMaximum0 = { .header = 0x25, .data = { 0x00, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidLogicalMinimum0 = { .header = 0x15, .data = { 0x00, 0x00 }};
static const USB_HID_Short_Item_t hidLogicalMaximum1 = { .header = 0x25, .data = { 0x01, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidReportCount2 = { .header = 0x95, .data = { 0x02, 0x00 }};
static const USB_HID_Short_Item_t hidLogicalMinimum0 = { .header = 0x15, .data = { 0x00, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidReportCount6 = { .header = 0x95, .data = { 0x06, 0x00 }};
static const USB_HID_Short_Item_t hidReportSize1 = { .header = 0x75, .data = { 0x01, 0x00 }};
static const USB_HID_Short_Item_t hidReportCount2 = { .header = 0x95, .data = { 0x02, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = 0x09, .data = { 0x01, 0x00 }};
static const USB_HID_Short_Item_t hidReportCount6 = { .header = 0x95, .data = { 0x06, 0x00 }, .location = 0x00 }; static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = 0x05, .data = { 0x0C, 0x00 }};
static const USB_HID_Short_Item_t hidReportSize1 = { .header = 0x75, .data = { 0x01, 0x00 }, .location = 0x00 };
static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = 0x09, .data = { 0x01, 0x00 }, .location = 0x00 };
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = 0x05, .data = { 0x0C, 0x00 }, .location = 0x00 };
/* /*
* Define configurable items in the HID Report descriptor. * Define configurable items in the HID Report descriptor.
*/ */
static USB_HID_Short_Item_t hidUsageByte0Bit5 = { .header = 0x09, .data = { 0xE2, 0x00 }, .location = 0x50 }; // Mute static USB_HID_Report_Element_t hidUsageByte0Bit5 = { .item.header = 0x09, .item.data = { 0xE2, 0x00 },
static USB_HID_Short_Item_t hidUsageByte0Bit4 = { .header = 0x09, .data = { 0xEA, 0x00 }, .location = 0x40 }; // Vol- .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 5 ) }; // Mute
static USB_HID_Short_Item_t hidUsageByte0Bit3 = { .header = 0x09, .data = { 0xE9, 0x00 }, .location = 0x30 }; // Vol+ static USB_HID_Report_Element_t hidUsageByte0Bit4 = { .item.header = 0x09, .item.data = { 0xEA, 0x00 },
static USB_HID_Short_Item_t hidUsageByte0Bit2 = { .header = 0x09, .data = { 0xB6, 0x00 }, .location = 0x20 }; // Scan Prev .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 4 ) }; // Vol-
static USB_HID_Short_Item_t hidUsageByte0Bit1 = { .header = 0x09, .data = { 0xB5, 0x00 }, .location = 0x10 }; // Scan Next static USB_HID_Report_Element_t hidUsageByte0Bit3 = { .item.header = 0x09, .item.data = { 0xE9, 0x00 },
static USB_HID_Short_Item_t hidUsageByte0Bit0 = { .header = 0x09, .data = { 0xB0, 0x00 }, .location = 0x00 }; // Play .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 3 ) }; // Vol+
static USB_HID_Report_Element_t hidUsageByte0Bit2 = { .item.header = 0x09, .item.data = { 0xB6, 0x00 },
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 2 ) }; // Scan Prev
static USB_HID_Report_Element_t hidUsageByte0Bit1 = { .item.header = 0x09, .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 = 0x09, .item.data = { 0xB0, 0x00 },
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 0 ) }; // Play
static USB_HID_Short_Item_t hidReportID1 = { .header = 0x85, .data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00}};
static const USB_HID_Report_Element_t hidReportConsumer = {
.item = { .header = 0x05, .data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 }},
.location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 1, 0, 0 )
};
/* /*
* List the configurable items in the HID Report descriptor. * List the configurable items 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,
@@ -75,25 +85,26 @@ static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
/* /*
* List Usage pages in the HID Report descriptor, one per byte. * List Usage pages in the HID Report descriptor, one per byte.
*/ */
static const USB_HID_Short_Item_t* const hidUsagePages[] = { static const USB_HID_Short_Item_t * const hidUsagePages[] = {
&hidUsagePageConsumer &hidUsagePageConsumer
}; };
/* /*
* 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),
&hidUsagePageConsumer, &hidUsagePageConsumer,
&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,
@@ -103,10 +114,21 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
&hidCollectionEnd &hidCollectionEnd
}; };
static const USB_HID_Report_Element_t* const hidReports[] = {
&hidReportConsumer
};
/* /*
* Define the length of the HID Report. * Define the length of the HID Report.
* This value must match the number of Report bytes defined by hidReportDescriptorItems. * This value must match the number of Report bytes defined by hidReportDescriptorItems.
*/ */
#define HID_REPORT_LENGTH ( 1 ) #define HID_REPORT_LENGTH ( 1 )
/*
* Define the number of HID Reports
* 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_COUNT ( 1 )
#endif // __hid_report_descriptor_h__ #endif // __hid_report_descriptor_h__

View File

@@ -143,7 +143,7 @@ void hidCaptureReportTime( const unsigned id, const unsigned time )
{ {
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) { for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
if( id == hidGetElementReportId( hidReports[ idx ]->location )) { if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
s_hidNextReportTime[ idx ] = time; s_hidReportTime[ idx ] = time;
} }
} }
} }