LEDMask = LEDS_ALL_LEDS;\r
}\r
else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&\r
+ (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) &&\r
+ (ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
+ {\r
+ /* Get the mouse wheel value if it is contained within the current \r
+ * report, if not, skip to the next item in the parser list\r
+ */\r
+ if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
+ continue; \r
+\r
+ int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
+ \r
+ if (WheelDelta)\r
+ LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4));\r
+ }\r
+ else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&\r
((ReportItem->Attributes.Usage.Usage == USAGE_X) ||\r
(ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&\r
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
/** HID Report Descriptor Usage value for a Y axis movement */\r
#define USAGE_Y 0x31\r
\r
+ /** HID Report Descriptor Usage value for a Scroll Wheel movement */\r
+ #define USAGE_SCROLL_WHEEL 0x38\r
+\r
/* Function Prototypes: */\r
void SetupHardware(void);\r
\r
* reports, allowing for correct operation across all USB mice. This\r
* demo supports mice with a single HID report.\r
* \r
- * Mouse movement and button presses are displayed on the board LEDs.\r
- * On connection to a USB mouse, the report items will be processed and\r
- * printed as a formatted list through the USART before the mouse is\r
- * fully enumerated.\r
+ * Mouse and scroll wheel movement and button presses are displayed\r
+ * on the board LEDs. On connection to a USB mouse, the report items\r
+ * will be processed and printed as a formatted list through the USART\r
+ * before the mouse is fully enumerated.\r
* \r
* Currently only single interface mice are supported.\r
*\r
*\r
* This comparator searches for the next Interface descriptor of the correct CDC control Class, Subclass and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct CDC data Class, Subclass and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)\r
{\r
* aborting the search if another interface descriptor is found before the required endpoint (so that it may be compared\r
* using a different comparator to determine if it is another CDC class interface).\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct HID Class value.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Joystick HID Class and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next HID descriptor within the current HID interface descriptor.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextHID(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Keyboard HID Class and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Keyboard HID Class and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next HID descriptor within the current HID interface descriptor.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextHID(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct MIDI Streaming Class, Subclass and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next bulk IN or OUT endpoint within the current interface, aborting the search if\r
* another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Mass Storage Class, Subclass and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMSInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next Bulk Endpoint descriptor of the correct MSD interface, aborting the search if\r
* another interface descriptor is found before the next endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,\r
* aborting the search if another interface descriptor is found before the required endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next HID descriptor within the current HID interface descriptor.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextHID(void* CurrentDescriptor)\r
{\r
/** HID Report Descriptor Usage value for a Y axis movement */\r
#define USAGE_Y 0x31\r
\r
+ /** HID Report Descriptor Usage value for a Scroll Wheel movement */\r
+ #define USAGE_SCROLL_WHEEL 0x38\r
+ \r
/* Enums: */\r
/** Enum for the possible return codes of the GetHIDReportData() function. */\r
enum MouseHostWithParser_GetHIDReportDataCodes_t\r
LEDMask = LEDS_ALL_LEDS;\r
}\r
else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&\r
+ (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) &&\r
+ (ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
+ {\r
+ /* Get the mouse wheel value if it is contained within the current \r
+ * report, if not, skip to the next item in the parser list\r
+ */\r
+ if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
+ continue; \r
+\r
+ int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
+ \r
+ if (WheelDelta)\r
+ LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4));\r
+ }\r
+ else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&\r
((ReportItem->Attributes.Usage.Usage == USAGE_X) ||\r
(ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&\r
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
* reports, allowing for correct operation across all USB mice. This\r
* demo supports mice with a single HID report.\r
* \r
- * Mouse movement and button presses are displayed on the board LEDs.\r
- * On connection to a USB mouse, the report items will be processed and\r
- * printed as a formatted list through the USART before the mouse is\r
- * fully enumerated.\r
+ * Mouse and scroll wheel movement and button presses are displayed\r
+ * on the board LEDs. On connection to a USB mouse, the report items\r
+ * will be processed and printed as a formatted list through the USART\r
+ * before the mouse is fully enumerated.\r
* \r
* Currently only single interface mice are supported.\r
*\r
* This comparator searches for the next Bidirectional Printer Interface descriptor of the current Printer interface,\r
* aborting the search if the end of the descriptors is found.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next Bulk Endpoint descriptor of the current Printer interface, aborting the\r
* search if another interface descriptor is found before the next endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor)\r
{\r
*\r
* This comparator searches for the next Interface descriptor of the correct Still Image Class, Subclass and Protocol values.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor)\r
{\r
* This comparator searches for the next Interrupt or Bulk Endpoint descriptor of the current SI interface, aborting the\r
* search if another interface descriptor is found before the next endpoint.\r
*\r
- * \return A value from the \ref DSEARCH_Return_ErrorCodes_t enum\r
+ * \return A value from the DSEARCH_Return_ErrorCodes_t enum\r
*/\r
uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor)\r
{\r