Add support for Mouse Scrollwheel to the MouseHostWithParser demos.
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 4 Nov 2009 05:18:43 +0000 (05:18 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 4 Nov 2009 05:18:43 +0000 (05:18 +0000)
17 files changed:
Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h
Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt
Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c
Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c
Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c
Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c
Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c
Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c
Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h
Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c
Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt
Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c
Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c

index b9edee1..80ddc55 100644 (file)
@@ -142,6 +142,21 @@ int main(void)
                                                          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
index 894c1d2..6eed93d 100644 (file)
@@ -78,6 +78,9 @@
                /** 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
index 79bc5c4..a6f05ac 100644 (file)
  *  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
index be0e467..a3e6b77 100644 (file)
@@ -174,7 +174,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -198,7 +198,7 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
  *\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
@@ -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\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
index b02d9f6..b035862 100644 (file)
@@ -120,7 +120,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -146,7 +146,7 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
  *  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
index 77392dc..9d4b201 100644 (file)
@@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -132,7 +132,7 @@ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)
  *  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
@@ -155,7 +155,7 @@ uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)
  *\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
index 67bc864..03ee2cd 100644 (file)
@@ -97,7 +97,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -121,7 +121,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
  *  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
index 52f9a0f..e587a75 100644 (file)
@@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -132,7 +132,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
  *  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
@@ -155,7 +155,7 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
  *\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
index ae75c8e..655e779 100644 (file)
@@ -117,7 +117,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -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\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
index 3feb624..a18d7ce 100644 (file)
@@ -119,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -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\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
index 8df0566..ee260ab 100644 (file)
@@ -97,7 +97,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -124,7 +124,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
  *  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
index 6347fd8..3c05118 100644 (file)
@@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -132,7 +132,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
  *  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
@@ -155,7 +155,7 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
  *\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
index 41966da..cbbac3e 100644 (file)
@@ -58,6 +58,9 @@
                /** 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
index 736ab52..d84e2d3 100644 (file)
@@ -271,6 +271,21 @@ void ProcessMouseReport(uint8_t* MouseReport)
                          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
index 79bc5c4..a6f05ac 100644 (file)
  *  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
index 043f1ad..9ee5ec6 100644 (file)
@@ -122,7 +122,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *  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
@@ -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\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
index 8163beb..5cee61b 100644 (file)
@@ -139,7 +139,7 @@ uint8_t ProcessConfigurationDescriptor(void)
  *\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
@@ -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\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