Fix typos and outdated information.
[pub/USBasp.git] / Demos / Host / LowLevel / KeyboardHost / KeyboardHost.c
index 269fe27..7af114b 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2011.
 
   dean [at] fourwalledcubicle [dot] com
 
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  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
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -149,13 +149,15 @@ void ReadNextReport(void)
        if (Pipe_IsReadWriteAllowed())
        {
                /* Read in keyboard report data */
        if (Pipe_IsReadWriteAllowed())
        {
                /* Read in keyboard report data */
-               Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
+               Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport), NULL);
 
                /* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */
                LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
 
 
                /* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */
                LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
 
+               uint8_t KeyCode = KeyboardReport.KeyCode[0];
+
                /* Check if a key has been pressed */
                /* Check if a key has been pressed */
-               if (KeyboardReport.KeyCode)
+               if (KeyCode)
                {
                        /* Toggle status LED to indicate keypress */
                        LEDs_ToggleLEDs(LEDS_LED2);
                {
                        /* Toggle status LED to indicate keypress */
                        LEDs_ToggleLEDs(LEDS_LED2);
@@ -163,14 +165,23 @@ void ReadNextReport(void)
                        char PressedKey = 0;
 
                        /* Retrieve pressed key character if alphanumeric */
                        char PressedKey = 0;
 
                        /* Retrieve pressed key character if alphanumeric */
-                       if ((KeyboardReport.KeyCode[0] >= 0x04) && (KeyboardReport.KeyCode[0] <= 0x1D))
-                         PressedKey = (KeyboardReport.KeyCode[0] - 0x04) + 'A';
-                       else if ((KeyboardReport.KeyCode[0] >= 0x1E) && (KeyboardReport.KeyCode[0] <= 0x27))
-                         PressedKey = (KeyboardReport.KeyCode[0] - 0x1E) + '0';
-                       else if (KeyboardReport.KeyCode[0] == 0x2C)
-                         PressedKey = ' ';
-                       else if (KeyboardReport.KeyCode[0] == 0x28)
-                         PressedKey = '\n';
+                       if ((KeyCode >= HID_KEYBOARD_SC_A) && (KeyCode <= HID_KEYBOARD_SC_Z))
+                       {
+                               PressedKey = (KeyCode - HID_KEYBOARD_SC_A) + 'A';
+                       }
+                       else if ((KeyCode >= HID_KEYBOARD_SC_1_AND_EXCLAMATION) &
+                                        (KeyCode <= HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS))
+                       {
+                               PressedKey = (KeyCode - HID_KEYBOARD_SC_1_AND_EXCLAMATION) + '0';
+                       }
+                       else if (KeyCode == HID_KEYBOARD_SC_SPACE)
+                       {
+                               PressedKey = ' ';
+                       }
+                       else if (KeyCode == HID_KEYBOARD_SC_ENTER)
+                       {
+                               PressedKey = '\n';
+                       }
 
                        /* Print the pressed key character out through the serial port if valid */
                        if (PressedKey)
 
                        /* Print the pressed key character out through the serial port if valid */
                        if (PressedKey)
@@ -233,7 +244,7 @@ void Keyboard_HID_Task(void)
                        USB_ControlRequest = (USB_Request_Header_t)
                                {
                                        .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
                        USB_ControlRequest = (USB_Request_Header_t)
                                {
                                        .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
-                                       .bRequest      = REQ_SetProtocol,
+                                       .bRequest      = HID_REQ_SetProtocol,
                                        .wValue        = 0,
                                        .wIndex        = 0,
                                        .wLength       = 0,
                                        .wValue        = 0,
                                        .wIndex        = 0,
                                        .wLength       = 0,