X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/849b9535e7f4ca84aa909cfb9e985ae29f14be72..24f730fce3f2022762011d795c3feada5ef874b3:/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index b47858e31..c29d4debd 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -37,7 +37,7 @@ #include "MouseHostWithParser.h" /** Main program entry point. This routine configures the hardware required by the application, then - * starts the scheduler to run the application tasks. + * enters a loop to run the application tasks in sequence. */ int main(void) { @@ -173,7 +173,7 @@ void Mouse_HID_Task(void) { puts_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n")); - if (!(HIDReportInfo->TotalReportItems)) + if (!(HIDReportInfo.TotalReportItems)) puts_P(PSTR("Not a valid Mouse." ESC_FG_WHITE)); else printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); @@ -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 = HID_ALIGN_DATA(ReportItem, int16_t); + + 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))