aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/ClassDriver
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-11-04 05:18:43 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-11-04 05:18:43 +0000
commitba8ffa4cb70a45f4e487a874276759d81ae8ae2e (patch)
tree8e79babeeb60718effd321758943f4c2292e6177 /Demos/Host/ClassDriver
parent87b2572ae50d20f04dfa6bfbd9e0b8b20ee650e9 (diff)
downloadlufa-ba8ffa4cb70a45f4e487a874276759d81ae8ae2e.tar.gz
lufa-ba8ffa4cb70a45f4e487a874276759d81ae8ae2e.tar.bz2
lufa-ba8ffa4cb70a45f4e487a874276759d81ae8ae2e.zip
Add support for Mouse Scrollwheel to the MouseHostWithParser demos.
Diffstat (limited to 'Demos/Host/ClassDriver')
-rw-r--r--Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c15
-rw-r--r--Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h3
-rw-r--r--Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt8
3 files changed, 22 insertions, 4 deletions
diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
index b9edee1e1..80ddc5527 100644
--- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
+++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
@@ -142,6 +142,21 @@ int main(void)
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/ClassDriver/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h
index 894c1d28a..6eed93d94 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 79bc5c432..a6f05ac40 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.
*