Browse Source

reassign internal keycode numbers

teensy4-core
PaulStoffregen 8 years ago
parent
commit
e918923dd5
3 changed files with 219 additions and 155 deletions
  1. +1
    -1
      teensy3/keylayouts.c
  2. +167
    -132
      teensy3/keylayouts.h
  3. +51
    -22
      teensy3/usb_keyboard.c

+ 1
- 1
teensy3/keylayouts.c View File

@@ -36,7 +36,7 @@
#ifdef M
#undef M
#endif
#define M(n) ((n) & 0x3FFF)
#define M(n) ((n) & KEYCODE_MASK)

const KEYCODE_TYPE keycodes_ascii[] = {
M(ASCII_20), M(ASCII_21), M(ASCII_22), M(ASCII_23),

+ 167
- 132
teensy3/keylayouts.h View File

@@ -67,138 +67,148 @@ extern "C"{
// http://en.wikipedia.org/wiki/Keyboard_layout


#define MODIFIERKEY_CTRL ( 0x01 | 0x8000 )
#define MODIFIERKEY_SHIFT ( 0x02 | 0x8000 )
#define MODIFIERKEY_ALT ( 0x04 | 0x8000 )
#define MODIFIERKEY_GUI ( 0x08 | 0x8000 )
#define MODIFIERKEY_LEFT_CTRL ( 0x01 | 0x8000 )
#define MODIFIERKEY_LEFT_SHIFT ( 0x02 | 0x8000 )
#define MODIFIERKEY_LEFT_ALT ( 0x04 | 0x8000 )
#define MODIFIERKEY_LEFT_GUI ( 0x08 | 0x8000 )
#define MODIFIERKEY_RIGHT_CTRL ( 0x10 | 0x8000 )
#define MODIFIERKEY_RIGHT_SHIFT ( 0x20 | 0x8000 )
#define MODIFIERKEY_RIGHT_ALT ( 0x40 | 0x8000 )
#define MODIFIERKEY_RIGHT_GUI ( 0x80 | 0x8000 )

#define KEY_MEDIA_VOLUME_INC 0x01
#define KEY_MEDIA_VOLUME_DEC 0x02
#define KEY_MEDIA_MUTE 0x04
#define KEY_MEDIA_PLAY_PAUSE 0x08
#define KEY_MEDIA_NEXT_TRACK 0x10
#define KEY_MEDIA_PREV_TRACK 0x20
#define KEY_MEDIA_STOP 0x40
#define KEY_MEDIA_EJECT 0x80

#define KEY_A ( 4 | 0x4000 )
#define KEY_B ( 5 | 0x4000 )
#define KEY_C ( 6 | 0x4000 )
#define KEY_D ( 7 | 0x4000 )
#define KEY_E ( 8 | 0x4000 )
#define KEY_F ( 9 | 0x4000 )
#define KEY_G ( 10 | 0x4000 )
#define KEY_H ( 11 | 0x4000 )
#define KEY_I ( 12 | 0x4000 )
#define KEY_J ( 13 | 0x4000 )
#define KEY_K ( 14 | 0x4000 )
#define KEY_L ( 15 | 0x4000 )
#define KEY_M ( 16 | 0x4000 )
#define KEY_N ( 17 | 0x4000 )
#define KEY_O ( 18 | 0x4000 )
#define KEY_P ( 19 | 0x4000 )
#define KEY_Q ( 20 | 0x4000 )
#define KEY_R ( 21 | 0x4000 )
#define KEY_S ( 22 | 0x4000 )
#define KEY_T ( 23 | 0x4000 )
#define KEY_U ( 24 | 0x4000 )
#define KEY_V ( 25 | 0x4000 )
#define KEY_W ( 26 | 0x4000 )
#define KEY_X ( 27 | 0x4000 )
#define KEY_Y ( 28 | 0x4000 )
#define KEY_Z ( 29 | 0x4000 )
#define KEY_1 ( 30 | 0x4000 )
#define KEY_2 ( 31 | 0x4000 )
#define KEY_3 ( 32 | 0x4000 )
#define KEY_4 ( 33 | 0x4000 )
#define KEY_5 ( 34 | 0x4000 )
#define KEY_6 ( 35 | 0x4000 )
#define KEY_7 ( 36 | 0x4000 )
#define KEY_8 ( 37 | 0x4000 )
#define KEY_9 ( 38 | 0x4000 )
#define KEY_0 ( 39 | 0x4000 )
#define KEY_ENTER ( 40 | 0x4000 )
#define KEY_ESC ( 41 | 0x4000 )
#define KEY_BACKSPACE ( 42 | 0x4000 )
#define KEY_TAB ( 43 | 0x4000 )
#define KEY_SPACE ( 44 | 0x4000 )
#define KEY_MINUS ( 45 | 0x4000 )
#define KEY_EQUAL ( 46 | 0x4000 )
#define KEY_LEFT_BRACE ( 47 | 0x4000 )
#define KEY_RIGHT_BRACE ( 48 | 0x4000 )
#define KEY_BACKSLASH ( 49 | 0x4000 )
#define KEY_NON_US_NUM ( 50 | 0x4000 )
#define KEY_SEMICOLON ( 51 | 0x4000 )
#define KEY_QUOTE ( 52 | 0x4000 )
#define KEY_TILDE ( 53 | 0x4000 )
#define KEY_COMMA ( 54 | 0x4000 )
#define KEY_PERIOD ( 55 | 0x4000 )
#define KEY_SLASH ( 56 | 0x4000 )
#define KEY_CAPS_LOCK ( 57 | 0x4000 )
#define KEY_F1 ( 58 | 0x4000 )
#define KEY_F2 ( 59 | 0x4000 )
#define KEY_F3 ( 60 | 0x4000 )
#define KEY_F4 ( 61 | 0x4000 )
#define KEY_F5 ( 62 | 0x4000 )
#define KEY_F6 ( 63 | 0x4000 )
#define KEY_F7 ( 64 | 0x4000 )
#define KEY_F8 ( 65 | 0x4000 )
#define KEY_F9 ( 66 | 0x4000 )
#define KEY_F10 ( 67 | 0x4000 )
#define KEY_F11 ( 68 | 0x4000 )
#define KEY_F12 ( 69 | 0x4000 )
#define KEY_PRINTSCREEN ( 70 | 0x4000 )
#define KEY_SCROLL_LOCK ( 71 | 0x4000 )
#define KEY_PAUSE ( 72 | 0x4000 )
#define KEY_INSERT ( 73 | 0x4000 )
#define KEY_HOME ( 74 | 0x4000 )
#define KEY_PAGE_UP ( 75 | 0x4000 )
#define KEY_DELETE ( 76 | 0x4000 )
#define KEY_END ( 77 | 0x4000 )
#define KEY_PAGE_DOWN ( 78 | 0x4000 )
#define KEY_RIGHT ( 79 | 0x4000 )
#define KEY_LEFT ( 80 | 0x4000 )
#define KEY_DOWN ( 81 | 0x4000 )
#define KEY_UP ( 82 | 0x4000 )
#define KEY_NUM_LOCK ( 83 | 0x4000 )
#define KEYPAD_SLASH ( 84 | 0x4000 )
#define KEYPAD_ASTERIX ( 85 | 0x4000 )
#define KEYPAD_MINUS ( 86 | 0x4000 )
#define KEYPAD_PLUS ( 87 | 0x4000 )
#define KEYPAD_ENTER ( 88 | 0x4000 )
#define KEYPAD_1 ( 89 | 0x4000 )
#define KEYPAD_2 ( 90 | 0x4000 )
#define KEYPAD_3 ( 91 | 0x4000 )
#define KEYPAD_4 ( 92 | 0x4000 )
#define KEYPAD_5 ( 93 | 0x4000 )
#define KEYPAD_6 ( 94 | 0x4000 )
#define KEYPAD_7 ( 95 | 0x4000 )
#define KEYPAD_8 ( 96 | 0x4000 )
#define KEYPAD_9 ( 97 | 0x4000 )
#define KEYPAD_0 ( 98 | 0x4000 )
#define KEYPAD_PERIOD ( 99 | 0x4000 )
#define KEY_MENU ( 101 | 0x4000 )
#define KEY_F13 ( 104 | 0x4000 )
#define KEY_F14 ( 105 | 0x4000 )
#define KEY_F15 ( 106 | 0x4000 )
#define KEY_F16 ( 107 | 0x4000 )
#define KEY_F17 ( 108 | 0x4000 )
#define KEY_F18 ( 109 | 0x4000 )
#define KEY_F19 ( 110 | 0x4000 )
#define KEY_F20 ( 111 | 0x4000 )
#define KEY_F21 ( 112 | 0x4000 )
#define KEY_F22 ( 113 | 0x4000 )
#define KEY_F23 ( 114 | 0x4000 )
#define KEY_F24 ( 115 | 0x4000 )

#define MODIFIERKEY_CTRL ( 0x01 | 0xE000 )
#define MODIFIERKEY_SHIFT ( 0x02 | 0xE000 )
#define MODIFIERKEY_ALT ( 0x04 | 0xE000 )
#define MODIFIERKEY_GUI ( 0x08 | 0xE000 )
#define MODIFIERKEY_LEFT_CTRL ( 0x01 | 0xE000 )
#define MODIFIERKEY_LEFT_SHIFT ( 0x02 | 0xE000 )
#define MODIFIERKEY_LEFT_ALT ( 0x04 | 0xE000 )
#define MODIFIERKEY_LEFT_GUI ( 0x08 | 0xE000 )
#define MODIFIERKEY_RIGHT_CTRL ( 0x10 | 0xE000 )
#define MODIFIERKEY_RIGHT_SHIFT ( 0x20 | 0xE000 )
#define MODIFIERKEY_RIGHT_ALT ( 0x40 | 0xE000 )
#define MODIFIERKEY_RIGHT_GUI ( 0x80 | 0xE000 )

#define KEY_SYSTEM_POWER_DOWN ( 0x81 | 0xE200 )
#define KEY_SYSTEM_SLEEP ( 0x82 | 0xE200 )
#define KEY_SYSTEM_WAKE_UP ( 0x83 | 0xE200 )

#define KEY_MEDIA_PLAY ( 0xB0 | 0xE400 )
#define KEY_MEDIA_PAUSE ( 0xB1 | 0xE400 )
#define KEY_MEDIA_RECORD ( 0xB2 | 0xE400 )
#define KEY_MEDIA_FAST_FORWARD ( 0xB3 | 0xE400 )
#define KEY_MEDIA_REWIND ( 0xB4 | 0xE400 )
#define KEY_MEDIA_NEXT_TRACK ( 0xB5 | 0xE400 )
#define KEY_MEDIA_PREV_TRACK ( 0xB6 | 0xE400 )
#define KEY_MEDIA_STOP ( 0xB7 | 0xE400 )
#define KEY_MEDIA_EJECT ( 0xB8 | 0xE400 )
#define KEY_MEDIA_RANDOM_PLAY ( 0xB0 | 0xE400 )
#define KEY_MEDIA_PLAY_PAUSE ( 0xCD | 0xE400 )
#define KEY_MEDIA_PLAY_SKIP ( 0xCE | 0xE400 )
#define KEY_MEDIA_MUTE ( 0xE2 | 0xE400 )
#define KEY_MEDIA_VOLUME_INC ( 0xE9 | 0xE400 )
#define KEY_MEDIA_VOLUME_DEC ( 0xEA | 0xE400 )

#define KEY_A ( 4 | 0xF000 )
#define KEY_B ( 5 | 0xF000 )
#define KEY_C ( 6 | 0xF000 )
#define KEY_D ( 7 | 0xF000 )
#define KEY_E ( 8 | 0xF000 )
#define KEY_F ( 9 | 0xF000 )
#define KEY_G ( 10 | 0xF000 )
#define KEY_H ( 11 | 0xF000 )
#define KEY_I ( 12 | 0xF000 )
#define KEY_J ( 13 | 0xF000 )
#define KEY_K ( 14 | 0xF000 )
#define KEY_L ( 15 | 0xF000 )
#define KEY_M ( 16 | 0xF000 )
#define KEY_N ( 17 | 0xF000 )
#define KEY_O ( 18 | 0xF000 )
#define KEY_P ( 19 | 0xF000 )
#define KEY_Q ( 20 | 0xF000 )
#define KEY_R ( 21 | 0xF000 )
#define KEY_S ( 22 | 0xF000 )
#define KEY_T ( 23 | 0xF000 )
#define KEY_U ( 24 | 0xF000 )
#define KEY_V ( 25 | 0xF000 )
#define KEY_W ( 26 | 0xF000 )
#define KEY_X ( 27 | 0xF000 )
#define KEY_Y ( 28 | 0xF000 )
#define KEY_Z ( 29 | 0xF000 )
#define KEY_1 ( 30 | 0xF000 )
#define KEY_2 ( 31 | 0xF000 )
#define KEY_3 ( 32 | 0xF000 )
#define KEY_4 ( 33 | 0xF000 )
#define KEY_5 ( 34 | 0xF000 )
#define KEY_6 ( 35 | 0xF000 )
#define KEY_7 ( 36 | 0xF000 )
#define KEY_8 ( 37 | 0xF000 )
#define KEY_9 ( 38 | 0xF000 )
#define KEY_0 ( 39 | 0xF000 )
#define KEY_ENTER ( 40 | 0xF000 )
#define KEY_ESC ( 41 | 0xF000 )
#define KEY_BACKSPACE ( 42 | 0xF000 )
#define KEY_TAB ( 43 | 0xF000 )
#define KEY_SPACE ( 44 | 0xF000 )
#define KEY_MINUS ( 45 | 0xF000 )
#define KEY_EQUAL ( 46 | 0xF000 )
#define KEY_LEFT_BRACE ( 47 | 0xF000 )
#define KEY_RIGHT_BRACE ( 48 | 0xF000 )
#define KEY_BACKSLASH ( 49 | 0xF000 )
#define KEY_NON_US_NUM ( 50 | 0xF000 )
#define KEY_SEMICOLON ( 51 | 0xF000 )
#define KEY_QUOTE ( 52 | 0xF000 )
#define KEY_TILDE ( 53 | 0xF000 )
#define KEY_COMMA ( 54 | 0xF000 )
#define KEY_PERIOD ( 55 | 0xF000 )
#define KEY_SLASH ( 56 | 0xF000 )
#define KEY_CAPS_LOCK ( 57 | 0xF000 )
#define KEY_F1 ( 58 | 0xF000 )
#define KEY_F2 ( 59 | 0xF000 )
#define KEY_F3 ( 60 | 0xF000 )
#define KEY_F4 ( 61 | 0xF000 )
#define KEY_F5 ( 62 | 0xF000 )
#define KEY_F6 ( 63 | 0xF000 )
#define KEY_F7 ( 64 | 0xF000 )
#define KEY_F8 ( 65 | 0xF000 )
#define KEY_F9 ( 66 | 0xF000 )
#define KEY_F10 ( 67 | 0xF000 )
#define KEY_F11 ( 68 | 0xF000 )
#define KEY_F12 ( 69 | 0xF000 )
#define KEY_PRINTSCREEN ( 70 | 0xF000 )
#define KEY_SCROLL_LOCK ( 71 | 0xF000 )
#define KEY_PAUSE ( 72 | 0xF000 )
#define KEY_INSERT ( 73 | 0xF000 )
#define KEY_HOME ( 74 | 0xF000 )
#define KEY_PAGE_UP ( 75 | 0xF000 )
#define KEY_DELETE ( 76 | 0xF000 )
#define KEY_END ( 77 | 0xF000 )
#define KEY_PAGE_DOWN ( 78 | 0xF000 )
#define KEY_RIGHT ( 79 | 0xF000 )
#define KEY_LEFT ( 80 | 0xF000 )
#define KEY_DOWN ( 81 | 0xF000 )
#define KEY_UP ( 82 | 0xF000 )
#define KEY_NUM_LOCK ( 83 | 0xF000 )
#define KEYPAD_SLASH ( 84 | 0xF000 )
#define KEYPAD_ASTERIX ( 85 | 0xF000 )
#define KEYPAD_MINUS ( 86 | 0xF000 )
#define KEYPAD_PLUS ( 87 | 0xF000 )
#define KEYPAD_ENTER ( 88 | 0xF000 )
#define KEYPAD_1 ( 89 | 0xF000 )
#define KEYPAD_2 ( 90 | 0xF000 )
#define KEYPAD_3 ( 91 | 0xF000 )
#define KEYPAD_4 ( 92 | 0xF000 )
#define KEYPAD_5 ( 93 | 0xF000 )
#define KEYPAD_6 ( 94 | 0xF000 )
#define KEYPAD_7 ( 95 | 0xF000 )
#define KEYPAD_8 ( 96 | 0xF000 )
#define KEYPAD_9 ( 97 | 0xF000 )
#define KEYPAD_0 ( 98 | 0xF000 )
#define KEYPAD_PERIOD ( 99 | 0xF000 )
#define KEY_MENU ( 101 | 0xF000 )
#define KEY_F13 ( 104 | 0xF000 )
#define KEY_F14 ( 105 | 0xF000 )
#define KEY_F15 ( 106 | 0xF000 )
#define KEY_F16 ( 107 | 0xF000 )
#define KEY_F17 ( 108 | 0xF000 )
#define KEY_F18 ( 109 | 0xF000 )
#define KEY_F19 ( 110 | 0xF000 )
#define KEY_F20 ( 111 | 0xF000 )
#define KEY_F21 ( 112 | 0xF000 )
#define KEY_F22 ( 113 | 0xF000 )
#define KEY_F23 ( 114 | 0xF000 )
#define KEY_F24 ( 115 | 0xF000 )

// for compatibility with Leonardo's slightly different names
#define KEY_UP_ARROW KEY_UP
@@ -225,6 +235,7 @@ extern "C"{

#define SHIFT_MASK 0x40
#define KEYCODE_TYPE uint8_t
#define KEYCODE_MASK 0x007F

#define ASCII_20 KEY_SPACE // 32
#define ASCII_21 KEY_1 + SHIFT_MASK // 33 !
@@ -339,6 +350,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_6 + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_QUOTE
#define DEADKEY_GRAVE_ACCENT KEY_TILDE
@@ -555,6 +567,7 @@ extern "C"{
#define ACUTE_ACCENT_BITS 0x0400
#define GRAVE_ACCENT_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_TILDE
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -772,6 +785,7 @@ extern "C"{
#define DIAERESIS_BITS 0x0400
#define TILDE_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
#define DEADKEY_CIRCUMFLEX KEY_6 + SHIFT_MASK + ALTGR_MASK
@@ -995,6 +1009,7 @@ extern "C"{
#define CEDILLA_BITS 0x0500

#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_LEFT_BRACE
#define DEADKEY_ACUTE_ACCENT KEY_SLASH + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_QUOTE
@@ -1214,6 +1229,7 @@ extern "C"{
#define TILDE_BITS 0x0600
#define RING_ABOVE_BITS 0x0700
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x0FFF
#define DEADKEY_CIRCUMFLEX KEY_LEFT_BRACE
#define DEADKEY_DIAERESIS KEY_LEFT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_SEMICOLON + RCTRL_MASK
@@ -1428,6 +1444,7 @@ extern "C"{
#define SHIFT_MASK 0x0040
#define ALTGR_MASK 0x0080
#define KEYCODE_TYPE uint8_t
#define KEYCODE_MASK 0x00FF
#define KEY_NON_US_100 63

#define ASCII_20 KEY_SPACE // 32
@@ -1643,6 +1660,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_RIGHT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -1867,6 +1885,7 @@ extern "C"{
#define DIAERESIS_BITS 0x0300
#define TILDE_BITS 0x0400
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_LEFT_BRACE
#define DEADKEY_GRAVE_ACCENT KEY_7 + ALTGR_MASK
#define DEADKEY_DIAERESIS KEY_LEFT_BRACE + SHIFT_MASK
@@ -2087,6 +2106,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_RIGHT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -2309,6 +2329,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_RIGHT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -2532,6 +2553,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_RIGHT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -2755,6 +2777,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_LEFT_BRACE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_QUOTE
#define DEADKEY_GRAVE_ACCENT KEY_LEFT_BRACE
@@ -2976,6 +2999,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_BACKSLASH
#define DEADKEY_ACUTE_ACCENT KEY_RIGHT_BRACE + SHIFT_MASK
#define DEADKEY_GRAVE_ACCENT KEY_RIGHT_BRACE + SHIFT_MASK
@@ -3194,6 +3218,7 @@ extern "C"{
#define SHIFT_MASK 0x40
#define ALTGR_MASK 0x80
#define KEYCODE_TYPE uint8_t
#define KEYCODE_MASK 0x00FF
#define KEY_NON_US_100 63

#define ASCII_20 KEY_SPACE // 32
@@ -3406,6 +3431,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_QUOTE + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_LEFT_BRACE
#define DEADKEY_GRAVE_ACCENT KEY_LEFT_BRACE + SHIFT_MASK
@@ -3622,6 +3648,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define ACUTE_ACCENT_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_LEFT_BRACE
#define DEADKEY_ACUTE_ACCENT KEY_QUOTE + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_BACKSLASH + ALTGR_MASK
@@ -3842,6 +3869,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define ACUTE_ACCENT_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_EQUAL
#define DEADKEY_ACUTE_ACCENT KEY_MINUS + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -4062,6 +4090,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define ACUTE_ACCENT_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_EQUAL
#define DEADKEY_ACUTE_ACCENT KEY_MINUS + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_EQUAL + SHIFT_MASK
@@ -4282,6 +4311,7 @@ extern "C"{
#define GRAVE_ACCENT_BITS 0x0300
#define DIAERESIS_BITS 0x0400
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_QUOTE + ALTGR_MASK
#define DEADKEY_ACUTE_ACCENT KEY_LEFT_BRACE
#define DEADKEY_GRAVE_ACCENT KEY_BACKSLASH + ALTGR_MASK
@@ -4494,6 +4524,7 @@ extern "C"{
#define GRAVE_ACCENT_BITS 0x0100
#define ACUTE_ACCENT_BITS 0x0200
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x03FF
#define DEADKEY_ACUTE_ACCENT KEY_QUOTE + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_TILDE
#define KEY_NON_US_100 63
@@ -4712,6 +4743,7 @@ extern "C"{
#define DIAERESIS_BITS 0x0400
#define RING_ABOVE_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_QUOTE + ALTGR_MASK
#define DEADKEY_ACUTE_ACCENT KEY_QUOTE
#define DEADKEY_GRAVE_ACCENT KEY_BACKSLASH + ALTGR_MASK
@@ -4933,6 +4965,7 @@ extern "C"{
#define TILDE_BITS 0x0400
#define DIAERESIS_BITS 0x0500
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x07FF
#define DEADKEY_CIRCUMFLEX KEY_3 + SHIFT_MASK
#define DEADKEY_ACUTE_ACCENT KEY_SEMICOLON + ALTGR_MASK
#define DEADKEY_GRAVE_ACCENT KEY_BACKSLASH + ALTGR_MASK
@@ -5172,6 +5205,7 @@ extern "C"{
//#define DIAERESIS_BITS 0x0A00
#define CEDILLA_BITS 0x0B00
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x0FFF
#define DEADKEY_ACUTE_ACCENT KEY_EQUAL // TODO: is it KEY_9 + ALTGR_MASK
#define DEADKEY_DEGREE_SIGN KEY_TILDE + SHIFT_MASK // TODO: is it KEY_5 + ALTGR_MASK
#define DEADKEY_CARON KEY_EQUAL + SHIFT_MASK // TODO: is it KEY_2 + ALTGR_MASK
@@ -5421,6 +5455,7 @@ extern "C"{
#define DOUBLE_ACUTE_BITS 0x0900
#define DIAERESIS_BITS 0x0A00
#define KEYCODE_TYPE uint16_t
#define KEYCODE_MASK 0x0FFF
#define DEADKEY_CEDILLA KEY_TILDE
#define DEADKEY_CARON KEY_2 + ALTGR_MASK
#define DEADKEY_CIRCUMFLEX KEY_3 + ALTGR_MASK

+ 51
- 22
teensy3/usb_keyboard.c View File

@@ -123,8 +123,8 @@ static KEYCODE_TYPE unicode_to_keycode(uint16_t cpoint)
// Unicode code points beyond U+FFFF are not supported
// technically this input should probably be called UCS-2
if (cpoint < 32) {
if (cpoint == 10) return KEY_ENTER & 0x3FFF;
if (cpoint == 11) return KEY_TAB & 0x3FFF;
if (cpoint == 10) return KEY_ENTER & KEYCODE_MASK;
if (cpoint == 11) return KEY_TAB & KEYCODE_MASK;
return 0;
}
if (cpoint < 128) {
@@ -290,6 +290,14 @@ static uint8_t keycode_to_key(KEYCODE_TYPE keycode)
}


// Input can be:
// 32 - 127 ASCII direct (U+0020 to U+007F) <-- uses layout
// 128 - 0xC1FF Unicode direct (U+0080 to U+C1FF) <-- uses layout
// 0xC200 - 0xDFFF Unicode UTF8 packed (U+0080 to U+07FF) <-- uses layout
// 0xE000 - 0xE0FF Modifier key (bitmap, 8 keys, shift/ctrl/alt/gui)
// 0xE200 - 0xE2FF System key (HID usage code, within usage page 1)
// 0xE400 - 0xE7FF Media/Consumer key (HID usage code, within usage page 12)
// 0xF000 - 0xFFFF Normal key (HID usage code, within usage page 7)

void usb_keyboard_press_keycode(uint16_t n)
{
@@ -300,16 +308,27 @@ void usb_keyboard_press_keycode(uint16_t n)
#endif

msb = n >> 8;
if (msb >= 0xC2 && msb <= 0xDF) {
n = (n & 0x3F) | ((uint16_t)(msb & 0x1F) << 6);
} else
if (msb == 0x80) {
usb_keyboard_press_key(0, n);
return;
} else
if (msb == 0x40) {
usb_keyboard_press_key(n, 0);
return;

if (msb >= 0xC2) {
if (msb <= 0xDF) {
n = (n & 0x3F) | ((uint16_t)(msb & 0x1F) << 6);
} else if (msb == 0xF0) {
usb_keyboard_press_key(n, 0);
return;
} else if (msb == 0xE0) {
usb_keyboard_press_key(0, n);
return;
#ifdef KEYMEDIA_INTERFACE
} else if (msb == 0xE2) {
// TODO: system keys
return;
} else if (msb >= 0xE4 && msb <= 0xE7) {
// TODO: media/consumer keys
return;
#endif
} else {
return;
}
}
keycode = unicode_to_keycode(n);
if (!keycode) return;
@@ -340,16 +359,26 @@ void usb_keyboard_release_keycode(uint16_t n)
uint8_t key, mod, msb;

msb = n >> 8;
if (msb >= 0xC2 && msb <= 0xDF) {
n = (n & 0x3F) | ((uint16_t)(msb & 0x1F) << 6);
} else
if (msb == 0x80) {
usb_keyboard_release_key(0, n);
return;
} else
if (msb == 0x40) {
usb_keyboard_release_key(n, 0);
return;
if (msb >= 0xC2) {
if (msb <= 0xDF) {
n = (n & 0x3F) | ((uint16_t)(msb & 0x1F) << 6);
} else if (msb == 0xF0) {
usb_keyboard_release_key(n, 0);
return;
} else if (msb == 0xE0) {
usb_keyboard_release_key(0, n);
return;
#ifdef KEYMEDIA_INTERFACE
} else if (msb == 0xE2) {
// TODO: system keys
return;
} else if (msb >= 0xE4 && msb <= 0xE7) {
// TODO: media/consumer keys
return;
#endif
} else {
return;
}
}
KEYCODE_TYPE keycode = unicode_to_keycode(n);
if (!keycode) return;

Loading…
Cancel
Save