diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-10-16 12:37:28 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-19 12:19:32 -0700 |
commit | 9fda2eea0861911537922ce3e45b118297f5030d (patch) | |
tree | c3d6822f5088ee561a2b0414300e3efb755e33d6 | |
parent | 59dc8df73fa71f3064fd225cf89fed65bf1b25a9 (diff) | |
download | chrome-ec-9fda2eea0861911537922ce3e45b118297f5030d.tar.gz |
Keyboard: switch column and row of scancode table
This patch switches column and row of scancode_set2. That is,
scancode_set2[ROWS][COLS] =
{0x00, 0x01, 0x02, ...,
0x10, 0x11, ...,
0x20, ...,
becomes
scancode_set2[COLS][ROWS] =
{0x00, 0x10, 0x20, ...,
0x01, 0x11, ...,
0x02, ...,
This will allow us to extend the table for a keypad without losing
too much readability.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:117126568
BRANCH=none
TEST=Verify keyboard functionality on Sona.
Change-Id: I49a7c0796d5c91989f1d3686c80743fb4bcd5ba7
Reviewed-on: https://chromium-review.googlesource.com/1285291
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | board/eve/board.c | 4 | ||||
-rw-r--r-- | chip/stm32/usb_hid_keyboard.c | 32 | ||||
-rw-r--r-- | common/keyboard_8042.c | 4 | ||||
-rw-r--r-- | common/keyboard_8042_sharedlib.c | 83 | ||||
-rw-r--r-- | include/keyboard_8042_sharedlib.h | 8 |
5 files changed, 63 insertions, 68 deletions
diff --git a/board/eve/board.c b/board/eve/board.c index df95551535..46260c0672 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -487,9 +487,9 @@ static void board_init(void) if (board_get_version() == 4) { /* Set F13 to new defined key on EVT */ CPRINTS("Overriding F13 scan code"); - scancode_set2[3][9] = 0xe007; + scancode_set2[9][3] = 0xe007; #ifdef CONFIG_KEYBOARD_DEBUG - keycap_label[3][9] = KLLI_F13; + keycap_label[9][3] = KLLI_F13; #endif } #endif diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index f30eedde13..e177aa8ed7 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -116,24 +116,20 @@ struct usb_hid_keyboard_output_report { * * Assistant key is mapped as 0xf0, but this key code is never actually send. */ -const uint8_t keycodes[KEYBOARD_ROWS][KEYBOARD_COLS] = { - { 0x00, 0xe3, 0x3a, 0x05, 0x43, 0x87, 0x11, 0x00, 0x2e, - 0x00, 0xe6, 0x00, 0x00 }, - { 0x00, 0x29, 0x3d, 0x0a, 0x40, 0x00, 0x0b, 0x00, 0x34, - 0x42, 0x00, 0x2a, 0x90 }, - { 0xe0, 0x2b, 0x3c, 0x17, 0x3f, 0x30, 0x1c, 0x64, 0x2F, - 0x41, 0x89, 0x00, 0x00 }, - { 0xe3, 0x35, 0x3b, 0x22, 0x3e, 0x00, 0x23, 0x00, 0x2d, - 0x68, 0x00, 0x31, 0x91 }, - { 0xe4, 0x04, 0x07, 0x09, 0x16, 0x0e, 0x0d, 0x00, 0x33, - 0x0f, 0x31, 0x28, 0x00 }, - { HID_KEYBOARD_ASSISTANT_KEY, - 0x1d, 0x06, 0x19, 0x1b, 0x36, 0x10, 0xe1, 0x38, - 0x37, 0x00, 0x2c, 0x00 }, - { 0x00, 0x1e, 0x20, 0x21, 0x1f, 0x25, 0x24, 0x00, 0x27, - 0x26, 0xe2, 0x51, 0x4f }, - { 0x00, 0x14, 0x08, 0x15, 0x1a, 0x0c, 0x18, 0xe5, 0x13, - 0x12, 0x00, 0x52, 0x50 } +const uint8_t keycodes[KEYBOARD_COLS][KEYBOARD_ROWS] = { + {0x00, 0x00, 0xe0, 0xe3, 0xe4, HID_KEYBOARD_ASSISTANT_KEY, 0x00, 0x00}, + {0xe3, 0x29, 0x2b, 0x35, 0x04, 0x1d, 0x1e, 0x14}, + {0x3a, 0x3d, 0x3c, 0x3b, 0x07, 0x06, 0x20, 0x08}, + {0x05, 0x0a, 0x17, 0x22, 0x09, 0x19, 0x21, 0x15}, + {0x43, 0x40, 0x3f, 0x3e, 0x16, 0x1b, 0x1f, 0x1a}, + {0x87, 0x00, 0x30, 0x00, 0x0e, 0x36, 0x25, 0x0c}, + {0x11, 0x0b, 0x1c, 0x23, 0x0d, 0x10, 0x24, 0x18}, + {0x00, 0x00, 0x64, 0x00, 0x00, 0xe1, 0x00, 0xe5}, + {0x2e, 0x34, 0x2F, 0x2d, 0x33, 0x38, 0x27, 0x13}, + {0x00, 0x42, 0x41, 0x68, 0x0f, 0x37, 0x26, 0x12}, + {0xe6, 0x00, 0x89, 0x00, 0x31, 0x00, 0xe2, 0x00}, + {0x00, 0x2a, 0x00, 0x31, 0x28, 0x2c, 0x51, 0x52}, + {0x00, 0x90, 0x00, 0x91, 0x00, 0x00, 0x4f, 0x50}, }; /* HID descriptors */ diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index e561762843..124ac8adee 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -309,7 +309,7 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col, if (row >= KEYBOARD_ROWS || col >= KEYBOARD_COLS) return EC_ERROR_INVAL; - make_code = scancode_set2[row][col]; + make_code = scancode_set2[col][row]; #ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK { @@ -385,7 +385,7 @@ void keyboard_state_changed(int row, int col, int is_pressed) enum ec_error_list ret; #ifdef CONFIG_KEYBOARD_DEBUG - char mylabel = keycap_label[row][col]; + char mylabel = keycap_label[col][row]; if (mylabel & KEYCAP_LONG_LABEL_BIT) CPRINTS("KB (%d,%d)=%d %s", row, col, is_pressed, diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c index 214eaafb5a..98d71cc1f9 100644 --- a/common/keyboard_8042_sharedlib.c +++ b/common/keyboard_8042_sharedlib.c @@ -16,23 +16,20 @@ #ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE SHAREDLIB(const #endif -uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS] = { - {0x0000, 0xe01f, 0x0005, 0x0032, 0x0009, 0x0051, 0x0031, 0x0000, 0x0055, - 0x0000, 0xe011, 0x0000, 0x0000}, - {0x0000, 0x0076, 0x000c, 0x0034, 0x0083, 0x0000, 0x0033, 0x0000, 0x0052, - 0x0001, 0x0000, 0x0066, 0x0064}, - {0x0014, 0x000d, 0x0004, 0x002c, 0x000b, 0x005b, 0x0035, 0x0061, 0x0054, - 0x000a, 0x006a, 0x0000, 0x0000}, - {0xe01f, 0x000e, 0x0006, 0x002e, 0x0003, 0x0000, 0x0036, 0x0000, 0x004e, - 0x002f, 0x0000, 0x005d, 0x0067}, - {0xe014, 0x001c, 0x0023, 0x002b, 0x001b, 0x0042, 0x003b, 0x0000, 0x004c, - 0x004b, 0x005d, 0x005a, 0x0000}, - {0xe007, 0x001a, 0x0021, 0x002a, 0x0022, 0x0041, 0x003a, 0x0012, 0x004a, - 0x0049, 0x0000, 0x0029, 0x0000}, - {0x0000, 0x0016, 0x0026, 0x0025, 0x001e, 0x003e, 0x003d, 0x0000, 0x0045, - 0x0046, 0x0011, 0xe072, 0xe074}, - {0x0000, 0x0015, 0x0024, 0x002d, 0x001d, 0x0043, 0x003c, 0x0059, 0x004d, - 0x0044, 0x0000, 0xe075, 0xe06b}, +uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS] = { + {0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0xe007, 0x0000, 0x0000}, + {0xe01f, 0x0076, 0x000d, 0x000e, 0x001c, 0x001a, 0x0016, 0x0015}, + {0x0005, 0x000c, 0x0004, 0x0006, 0x0023, 0x0021, 0x0026, 0x0024}, + {0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x002a, 0x0025, 0x002d}, + {0x0009, 0x0083, 0x000b, 0x0003, 0x001b, 0x0022, 0x001e, 0x001d}, + {0x0051, 0x0000, 0x005b, 0x0000, 0x0042, 0x0041, 0x003e, 0x0043}, + {0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x003a, 0x003d, 0x003c}, + {0x0000, 0x0000, 0x0061, 0x0000, 0x0000, 0x0012, 0x0000, 0x0059}, + {0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x004a, 0x0045, 0x004d}, + {0x0000, 0x0001, 0x000a, 0x002f, 0x004b, 0x0049, 0x0046, 0x0044}, + {0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000}, + {0x0000, 0x0066, 0x0000, 0x005d, 0x005a, 0x0029, 0xe072, 0xe075}, + {0x0000, 0x0064, 0x0000, 0x0067, 0x0000, 0x0000, 0xe074, 0xe06b}, } #ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE ) @@ -82,31 +79,33 @@ char * const keycap_long_label[KLLI_MAX & KEYCAP_LONG_LABEL_INDEX_BITMASK] = { #ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE SHAREDLIB(const #endif -char keycap_label[KEYBOARD_ROWS][KEYBOARD_COLS] = { - {KLLI_UNKNO, KLLI_SEARC, KLLI_F1, 'b', KLLI_F10, - KLLI_UNKNO, 'n', KLLI_UNKNO, '=', KLLI_UNKNO, - KLLI_R_ALT, KLLI_UNKNO, KLLI_UNKNO}, - {KLLI_UNKNO, KLLI_ESC, KLLI_F4, 'g', KLLI_F7, - KLLI_UNKNO, 'h', KLLI_UNKNO, '\'', KLLI_F9, - KLLI_UNKNO, KLLI_B_SPC, KLLI_UNKNO}, - {KLLI_L_CTR, KLLI_TAB, KLLI_F3, 't', KLLI_F6, - ']', 'y', KLLI_UNKNO, '[', KLLI_F8, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO}, - {KLLI_UNKNO, '~', KLLI_F2, '5', KLLI_F5, - KLLI_UNKNO, '6', KLLI_UNKNO, '-', KLLI_UNKNO, - KLLI_UNKNO, '\\', KLLI_UNKNO}, - {KLLI_R_CTR, 'a', 'd', 'f', 's', - 'k', 'j', KLLI_UNKNO, ';', '|', - KLLI_UNKNO, KLLI_ENTER, KLLI_UNKNO}, - {KLLI_UNKNO, 'z', 'c', 'v', 'x', - ',', 'm', KLLI_L_SHT, '/', '.', - KLLI_UNKNO, KLLI_SPACE, KLLI_UNKNO}, - {KLLI_UNKNO, '1', '3', '4', '2', - '8', '7', KLLI_UNKNO, '0', '9', - KLLI_L_ALT, KLLI_DOWN, KLLI_RIGHT}, - {KLLI_UNKNO, 'q', 'e', 'r', 'w', - 'i', 'u', KLLI_R_SHT, 'p', 'o', - KLLI_UNKNO, KLLI_UP, KLLI_LEFT}, +char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS] = { + {KLLI_UNKNO, KLLI_UNKNO, KLLI_L_CTR, KLLI_UNKNO, + KLLI_R_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO}, + {KLLI_SEARC, KLLI_ESC, KLLI_TAB, '~', + 'a', 'z', '1', 'q'}, + {KLLI_F1, KLLI_F4, KLLI_F3, KLLI_F2, + 'd', 'c', '3', 'e'}, + {'b', 'g', 't', '5', + 'f', 'v', '4', 'r'}, + {KLLI_F10, KLLI_F7, KLLI_F6, KLLI_F5, + 's', 'x', '2', 'w'}, + {KLLI_UNKNO, KLLI_UNKNO, ']', KLLI_UNKNO, + 'k', ',', '8', 'i'}, + {'n', 'h', 'y', '6', + 'j', 'm', '7', 'u'}, + {KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_L_SHT, KLLI_UNKNO, KLLI_R_SHT}, + {'=', '\'', '[', '-', + ';', '/', '0', 'p'}, + {KLLI_UNKNO, KLLI_F9, KLLI_F8, KLLI_UNKNO, + '|', '.', '9', 'o'}, + {KLLI_R_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_L_ALT, KLLI_UNKNO}, + {KLLI_UNKNO, KLLI_B_SPC, KLLI_UNKNO, '\\', + KLLI_ENTER, KLLI_SPACE, KLLI_DOWN, KLLI_UP}, + {KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_RIGHT, KLLI_LEFT}, } #ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE ) diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h index e944e74af2..1cff2544dc 100644 --- a/include/keyboard_8042_sharedlib.h +++ b/include/keyboard_8042_sharedlib.h @@ -19,9 +19,9 @@ struct button_8042_t { /* The standard Chrome OS keyboard matrix table. */ #ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE -extern uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS]; +extern uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS]; #else -extern const uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS]; +extern const uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS]; #endif /* Translation from scan code set 2 to set 1. */ @@ -70,9 +70,9 @@ enum keycap_long_label_idx { extern const char * const keycap_long_label[]; #ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE -extern char keycap_label[KEYBOARD_ROWS][KEYBOARD_COLS]; +extern char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS]; #else -extern const char keycap_label[KEYBOARD_ROWS][KEYBOARD_COLS]; +extern const char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS]; #endif #endif |