diff options
Diffstat (limited to 'Demos/Host/ClassDriver')
-rw-r--r-- | Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c | 31 | ||||
-rw-r--r-- | Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c | 25 |
2 files changed, 37 insertions, 19 deletions
diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c index 1d9b2c0ff..2101ae803 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c @@ -123,24 +123,33 @@ int main(void) LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); - uint8_t PressedKeyCode = KeyboardReport.KeyCode[0]; + uint8_t KeyCode = KeyboardReport.KeyCode[0]; - if (PressedKeyCode) + if (KeyCode) { char PressedKey = 0; LEDs_ToggleLEDs(LEDS_LED2); /* Retrieve pressed key character if alphanumeric */ - 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 (PressedKeyCode == 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'; + } + if (PressedKey) putchar(PressedKey); } diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index 3ef4640c6..6e7ee6c6a 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -152,14 +152,23 @@ int main(void) 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'; + 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) |