Add support for Mouse Scrollwheel to the MouseHostWithParser demos.

This commit is contained in:
Dean Camera 2009-11-04 05:18:43 +00:00
parent 87b2572ae5
commit ba8ffa4cb7
17 changed files with 70 additions and 34 deletions

View file

@ -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)
{

View file

@ -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

View file

@ -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)) &&

View file

@ -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.
*