X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/64e5c4084f862267d96b0947f462de7058f3dc4c..a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d:/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c index 022a102d3..b6411858a 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -81,8 +81,8 @@ int main(void) uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; - if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, - sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) + if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { printf("Error Retrieving Configuration Descriptor.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -132,15 +132,14 @@ int main(void) { HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; + /* Update the report item value if it is contained within the current report */ + if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem))) + continue; + + /* Determine what report item is being tested, process updated value as needed */ if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) { - /* Get the mouse button 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; - if (ReportItem->Value) LEDMask = LEDS_ALL_LEDS; } @@ -148,12 +147,6 @@ int main(void) (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) @@ -164,12 +157,6 @@ int main(void) (ReportItem->Attributes.Usage.Usage == USAGE_Y)) && (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) { - /* Get the mouse relative position 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 DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize)); if (ReportItem->Attributes.Usage.Usage == USAGE_X) @@ -278,7 +265,7 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* CurrentItem) /* Iterate through the item's collection path, until either the root collection node or a collection with the * Mouse Usage is found - this prevents Joysticks, which use identical descriptors except for the Joystick usage - * parent node, from being erronously treated as a mouse + * parent node, from being erroneously treated as a mouse by the demo */ for (HID_CollectionPath_t* CurrPath = CurrentItem->CollectionPath; CurrPath != NULL; CurrPath = CurrPath->Parent) {