X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7f9f97c792dee6875fbca9806422bdd7d6c5a657..a9e0935a90346beb0c981924becc1f55d969a08b:/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index 8fe3edefe..91ca84477 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -70,6 +70,7 @@ int main(void) puts_P(PSTR(ESC_FG_CYAN "Keyboard Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + sei(); for (;;) { @@ -84,7 +85,7 @@ int main(void) if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { - printf("Error Retrieving Configuration Descriptor.\r\n"); + puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -93,7 +94,7 @@ int main(void) if (HID_Host_ConfigurePipes(&Keyboard_HID_Interface, ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) { - printf("Attached Device Not a Valid Keyboard.\r\n"); + puts_P(PSTR("Attached Device Not a Valid Keyboard.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -101,7 +102,7 @@ int main(void) if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { - printf("Error Setting Device Configuration.\r\n"); + puts_P(PSTR("Error Setting Device Configuration.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -109,15 +110,14 @@ int main(void) if (HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0) { - printf("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n"); + puts_P(PSTR("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - LEDs_SetAllLEDs(LEDS_NO_LEDS); - - printf("Keyboard Enumerated.\r\n"); + puts_P(PSTR("Keyboard Enumerated.\r\n")); + LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: @@ -130,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;