X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/849b9535e7f4ca84aa909cfb9e985ae29f14be72..c58c53dba90fdc19d38f5e5d6957f2ede2a740f3:/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index e9af0c0b2..78ec56aa3 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.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) + Copyright 2010 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 + 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 @@ -48,7 +48,10 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface = .Config = { .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, .HIDInterfaceProtocol = HID_NON_BOOT_PROTOCOL, @@ -58,7 +61,7 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface = /** 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) { @@ -78,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); @@ -104,7 +107,7 @@ int main(void) break; } - if (USB_HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0) + if (HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0) { printf("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -127,18 +130,16 @@ int main(void) { HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; - /* Check if the current report item is a keyboard scancode */ + /* Update the report item value if it is contained within the current report */ + if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem))) + continue; + + /* Determine what report item is being tested, process updated value as needed */ if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD) && (ReportItem->Attributes.BitSize == 8) && (ReportItem->Attributes.Logical.Maximum > 1) && (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) { - /* Retrieve the keyboard scancode from the report data retrieved from the device if it is - * contained within the current report, if not, skip to the next item in the parser list - */ - if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem))) - continue; - /* Key code is an unsigned char in length, cast to the appropriate type */ uint8_t KeyCode = (uint8_t)ReportItem->Value; @@ -251,20 +252,15 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8 * we aren't interested in (preventing us from being able to extract them later on, but saving on the RAM they would * have occupied). * - * \param CurrentItemAttributes Pointer to the attrbutes of the item the HID report parser is currently working with + * \param[in] CurrentItem Pointer to the item the HID report parser is currently working with * * \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded */ -bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_Attributes_t* CurrentItemAttributes) +bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* CurrentItem) { - /* Check the attributes of the current item - see if we are interested in it or not */ - if (CurrentItemAttributes->Usage.Page == USAGE_PAGE_KEYBOARD) - { - /* Only store KEYBOARD usage page items into the Processed HID Report structure to save RAM */ - return true; - } - else - { - return false; - } + /* Check the attributes of the current item - see if we are interested in it or not; + * only store KEYBOARD usage page items into the Processed HID Report structure to + * save RAM and ignore the rest + */ + return (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD); }