aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/LowLevel/MouseHostWithParser
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Host/LowLevel/MouseHostWithParser')
-rw-r--r--Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c6
-rw-r--r--Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h3
-rw-r--r--Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c15
-rw-r--r--Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt8
4 files changed, 25 insertions, 7 deletions
diff --git a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
index 6347fd841..3c051185c 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 41966da17..cbbac3ee5 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 736ab522a..d84e2d3ce 100644
--- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c
+++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c
@@ -271,6 +271,21 @@ void ProcessMouseReport(uint8_t* MouseReport)
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)) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt
index 79bc5c432..a6f05ac40 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.
*