diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-10-28 23:11:49 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-10-28 23:11:49 +0000 |
commit | b8dfa976ce796ede92dfefa6a39eb0a3b08acdce (patch) | |
tree | 8144660271140732a299511aa31159c12239ee55 /Demos/Host/LowLevel/KeyboardHostWithParser | |
parent | 2d49c09b384375298a4995b79c4b29e8d9390cd6 (diff) | |
download | lufa-b8dfa976ce796ede92dfefa6a39eb0a3b08acdce.tar.gz lufa-b8dfa976ce796ede92dfefa6a39eb0a3b08acdce.tar.bz2 lufa-b8dfa976ce796ede92dfefa6a39eb0a3b08acdce.zip |
Added standard keyboard HID report scancode defines (thanks to László Monda).
Diffstat (limited to 'Demos/Host/LowLevel/KeyboardHostWithParser')
-rw-r--r-- | Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c index 3cd0f4407..064407a62 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -278,15 +278,24 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport) 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) |