X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/6c5c9212d816674c67aa3708b73558b023478b94..05fcf7e2a79bebb978d4aeaef26b12f70c6826f8:/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c index a6605f00f..ed8f723c0 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c @@ -45,7 +45,10 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface = .Config = { .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, .HIDInterfaceProtocol = HID_BOOT_KEYBOARD_PROTOCOL, }, @@ -53,7 +56,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) { @@ -73,8 +76,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); @@ -99,7 +102,7 @@ int main(void) break; } - if (USB_HID_Host_SetBootProtocol(&Keyboard_HID_Interface) != 0) + if (HID_Host_SetBootProtocol(&Keyboard_HID_Interface) != 0) { printf("Could not Set Boot Protocol Mode.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -113,27 +116,27 @@ int main(void) case HOST_STATE_Configured: if (HID_Host_IsReportReceived(&Keyboard_HID_Interface)) { - USB_KeyboardReport_Data_t KeyboardReport; - uint8_t ReportID = 0; - - HID_Host_ReceiveReport(&Keyboard_HID_Interface, false, &ReportID, &KeyboardReport); + USB_KeyboardReport_Data_t KeyboardReport; + HID_Host_ReceiveReport(&Keyboard_HID_Interface, &KeyboardReport); LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); - if (KeyboardReport.KeyCode) + uint8_t PressedKeyCode = KeyboardReport.KeyCode[0]; + + if (PressedKeyCode) { char PressedKey = 0; LEDs_ToggleLEDs(LEDS_LED2); /* Retrieve pressed key character if alphanumeric */ - if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D)) - PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A'; - else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27)) - PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0'; - else if (KeyboardReport.KeyCode == 0x2C) + if ((PressedKeyCode >= 0x04) && (PressedKeyCode <= 0x1D)) + PressedKey = (PressedKeyCode - 0x04) + 'A'; + else if ((PressedKeyCode >= 0x1E) && (PressedKeyCode <= 0x27)) + PressedKey = (PressedKeyCode - 0x1E) + '0'; + else if (PressedKeyCode == 0x2C) PressedKey = ' '; - else if (KeyboardReport.KeyCode == 0x28) + else if (PressedKeyCode == 0x28) PressedKey = '\n'; if (PressedKey)