From b8dfa976ce796ede92dfefa6a39eb0a3b08acdce Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 28 Oct 2010 23:11:49 +0000 Subject: =?UTF-8?q?Added=20standard=20keyboard=20HID=20report=20scancode?= =?UTF-8?q?=20defines=20(thanks=20to=20L=C3=A1szl=C3=B3=20Monda).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'Demos/Host/ClassDriver/KeyboardHost') 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); } -- cgit v1.2.3