Fix typos and outdated information.
[pub/USBasp.git] / Demos / Host / LowLevel / KeyboardHostWithParser / KeyboardHostWithParser.c
index bdf4a28..356aba8 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
@@ -225,7 +225,7 @@ void Keyboard_HID_Task(void)
                                        uint8_t KeyboardReport[Pipe_BytesInPipe()];
 
                                        /* Load in the keyboard report */
                                        uint8_t KeyboardReport[Pipe_BytesInPipe()];
 
                                        /* Load in the keyboard report */
-                                       Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe());
+                                       Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe(), NULL);
 
                                        /* Process the read in keyboard report from the device */
                                        ProcessKeyboardReport(KeyboardReport);
 
                                        /* Process the read in keyboard report from the device */
                                        ProcessKeyboardReport(KeyboardReport);
@@ -278,15 +278,24 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport)
 
                                char PressedKey = 0;
 
 
                                char PressedKey = 0;
 
-                               /* Convert scan-code to printable character if alphanumeric */
-                               if ((KeyCode >= 0x04) && (KeyCode <= 0x1D))
-                                 PressedKey = (KeyCode - 0x04) + 'A';
-                               else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27))
-                                 PressedKey = (KeyCode - 0x1E) + '0';
-                               else if (KeyCode == 0x2C)
-                                 PressedKey = ' ';
-                               else if (KeyCode == 0x28)
-                                 PressedKey = '\n';
+                               /* Retrieve pressed key character if alphanumeric */
+                               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)