diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c index b9edee1e1142771c16e870cbb8682a6008a3eb7f..80ddc5527f9bdc568089e4ebfde6021069f9ee5d 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c @@ -141,6 +141,21 @@ int main(void) if (ReportItem->Value) LEDMask = LEDS_ALL_LEDS; } + else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) && + (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) && + (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) + { + /* Get the mouse wheel value if it is contained within the current + * report, if not, skip to the next item in the parser list + */ + if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem))) + continue; + + int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize)); + + if (WheelDelta) + LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4)); + } else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) && ((ReportItem->Attributes.Usage.Usage == USAGE_X) || (ReportItem->Attributes.Usage.Usage == USAGE_Y)) && diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h index 894c1d28a1c9f223e4d5a7d3193e3ea2a3caa201..6eed93d946d7a4d62f85d47f8b5adefffcf45213 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h @@ -78,6 +78,9 @@ /** HID Report Descriptor Usage value for a Y axis movement */ #define USAGE_Y 0x31 + /** HID Report Descriptor Usage value for a Scroll Wheel movement */ + #define USAGE_SCROLL_WHEEL 0x38 + /* Function Prototypes: */ void SetupHardware(void); diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt index 79bc5c4321634dcc90c8969235be6293082071e2..a6f05ac406f404c60ddb465eebebb8d8d4de3c9d 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt @@ -47,10 +47,10 @@ * reports, allowing for correct operation across all USB mice. This * demo supports mice with a single HID report. * - * Mouse movement and button presses are displayed on the board LEDs. - * On connection to a USB mouse, the report items will be processed and - * printed as a formatted list through the USART before the mouse is - * fully enumerated. + * Mouse and scroll wheel movement and button presses are displayed + * on the board LEDs. On connection to a USB mouse, the report items + * will be processed and printed as a formatted list through the USART + * before the mouse is fully enumerated. * * Currently only single interface mice are supported. * diff --git a/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c b/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c index be0e4676690436ad052d91d36f736aac4436158d..a3e6b778e47c98111e92fbe0ce3898d678d02058 100644 --- a/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c @@ -174,7 +174,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct CDC control Class, Subclass and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) { @@ -198,7 +198,7 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) * * This comparator searches for the next Interface descriptor of the correct CDC data Class, Subclass and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) { @@ -224,7 +224,7 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) * aborting the search if another interface descriptor is found before the required endpoint (so that it may be compared * using a different comparator to determine if it is another CDC class interface). * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c index b02d9f61b1d7c9fbce4fba95a1755eb78b66a45f..b035862a1ceea3d301ddea1fc4b7e6b8bfaa8652 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c @@ -120,7 +120,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct HID Class value. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor) { @@ -146,7 +146,7 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor) * This comparator searches for the next Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c index 77392dc936f75ed0ebf128168b7a629736035f54..9d4b201211838f673e1783245c754fd326626725 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Joystick HID Class and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor) { @@ -132,7 +132,7 @@ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor) * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor) { @@ -155,7 +155,7 @@ uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor) * * This comparator searches for the next HID descriptor within the current HID interface descriptor. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextHID(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c index 67bc86416714c075526363034f575d97392857ab..03ee2cd164872b562f3eec478ee94e8b2efa6df0 100644 --- a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c @@ -97,7 +97,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Keyboard HID Class and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) { @@ -121,7 +121,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c index 52f9a0f6924de45436d538cbb3c465b81a6ea05c..e587a75329562f849764a8239291aef17627c339 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Keyboard HID Class and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) { @@ -132,7 +132,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor) { @@ -155,7 +155,7 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor) * * This comparator searches for the next HID descriptor within the current HID interface descriptor. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextHID(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c index ae75c8e48fb098aef677ac53c4262a98fafdee4f..655e7795d5d958d29080324e192dcbb6845784f0 100644 --- a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c @@ -117,7 +117,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct MIDI Streaming Class, Subclass and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor) { @@ -142,7 +142,7 @@ uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor) * This comparator searches for the next bulk IN or OUT endpoint within the current interface, aborting the search if * another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c index 3feb624ca58c232a6e02471a189bc135e64252dc..a18d7ce69334f85829ab350dabf024c24d7b7b82 100644 --- a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c @@ -119,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Mass Storage Class, Subclass and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMSInterface(void* CurrentDescriptor) { @@ -144,7 +144,7 @@ uint8_t DComp_NextMSInterface(void* CurrentDescriptor) * This comparator searches for the next Bulk Endpoint descriptor of the correct MSD interface, aborting the search if * another interface descriptor is found before the next endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c index 8df0566b4a91e321180f61a0361ecdb681b4fb01..ee260ab1d75fdd7e467cd750a88b382f646eef58 100644 --- a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c @@ -97,7 +97,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) { @@ -124,7 +124,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c index 6347fd841a00d3772c7a82150f7eb862591ff73f..3c051185c6207b11a5087422b04837f4792178f1 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) { @@ -132,7 +132,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor, * aborting the search if another interface descriptor is found before the required endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor) { @@ -155,7 +155,7 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor) * * This comparator searches for the next HID descriptor within the current HID interface descriptor. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextHID(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h index 41966da177f9b32ace7d1a6d605b619cc71c92c3..cbbac3ee59bbf05375ef2112ff2a45c47220057d 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h @@ -58,6 +58,9 @@ /** HID Report Descriptor Usage value for a Y axis movement */ #define USAGE_Y 0x31 + /** HID Report Descriptor Usage value for a Scroll Wheel movement */ + #define USAGE_SCROLL_WHEEL 0x38 + /* Enums: */ /** Enum for the possible return codes of the GetHIDReportData() function. */ enum MouseHostWithParser_GetHIDReportDataCodes_t diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index 736ab522ada36db6a9ff87a0194ee8c83915a069..d84e2d3ceb12da4c17fa017bd89c7ebc8ee3bfa4 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -270,6 +270,21 @@ void ProcessMouseReport(uint8_t* MouseReport) if (ReportItem->Value) LEDMask = LEDS_ALL_LEDS; } + else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) && + (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) && + (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) + { + /* Get the mouse wheel value if it is contained within the current + * report, if not, skip to the next item in the parser list + */ + if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem))) + continue; + + int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize)); + + if (WheelDelta) + LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4)); + } else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) && ((ReportItem->Attributes.Usage.Usage == USAGE_X) || (ReportItem->Attributes.Usage.Usage == USAGE_Y)) && diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt index 79bc5c4321634dcc90c8969235be6293082071e2..a6f05ac406f404c60ddb465eebebb8d8d4de3c9d 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt @@ -47,10 +47,10 @@ * reports, allowing for correct operation across all USB mice. This * demo supports mice with a single HID report. * - * Mouse movement and button presses are displayed on the board LEDs. - * On connection to a USB mouse, the report items will be processed and - * printed as a formatted list through the USART before the mouse is - * fully enumerated. + * Mouse and scroll wheel movement and button presses are displayed + * on the board LEDs. On connection to a USB mouse, the report items + * will be processed and printed as a formatted list through the USART + * before the mouse is fully enumerated. * * Currently only single interface mice are supported. * diff --git a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c index 043f1ad9c0c21319e3b526d3363c25b7cdfcce08..9ee5ec68439c4f26cf20f15f591c2c4de5292cf0 100644 --- a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c @@ -122,7 +122,7 @@ uint8_t ProcessConfigurationDescriptor(void) * This comparator searches for the next Bidirectional Printer Interface descriptor of the current Printer interface, * aborting the search if the end of the descriptors is found. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor) { @@ -147,7 +147,7 @@ uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor) * This comparator searches for the next Bulk Endpoint descriptor of the current Printer interface, aborting the * search if another interface descriptor is found before the next endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor) { diff --git a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c index 8163beb4530a859ba8299a5cf58e6b835ac782e0..5cee61bf0d2e5cb8c02c62a11522bae10f6ea409 100644 --- a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c @@ -139,7 +139,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * This comparator searches for the next Interface descriptor of the correct Still Image Class, Subclass and Protocol values. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor) { @@ -164,7 +164,7 @@ uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor) * This comparator searches for the next Interrupt or Bulk Endpoint descriptor of the current SI interface, aborting the * search if another interface descriptor is found before the next endpoint. * - * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum + * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor) {