summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-10 19:18:36 +0800
committerHung-Te Lin <hungte@chromium.org>2018-08-10 11:23:24 +0000
commit21a9de0c034cf98d61a9f271cd96b7dd15ea7838 (patch)
tree359b12c5fe2eb7e3769d8986dc29a3b064fa93a9
parent370f6527e80c1ee44ac663bf87c6e39d03070b93 (diff)
downloadchrome-ec-21a9de0c034cf98d61a9f271cd96b7dd15ea7838.tar.gz
keyboard: Fix ASSIST=LWIN mapping and migrate to ToT implementation
BUG=None TEST=make BOARD=eve; tested that Win works. BRANCH=eve Change-Id: I431bf58f3260708b8ede736bf25e8dbf2570ed1b Reviewed-on: https://chromium-review.googlesource.com/1170724 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Trybot-Ready: Hung-Te Lin <hungte@chromium.org>
-rw-r--r--board/eve/board.h1
-rw-r--r--board/eve/keyboard_legacy.c182
-rw-r--r--common/keyboard_8042.c141
-rw-r--r--common/keyboard_8042_sharedlib.c24
-rw-r--r--include/config.h5
-rw-r--r--include/keyboard_8042.h54
-rw-r--r--include/keyboard_8042_sharedlib.h50
7 files changed, 198 insertions, 259 deletions
diff --git a/board/eve/board.h b/board/eve/board.h
index 794b1421ee..ee8af49017 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -76,6 +76,7 @@
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_KEYBOARD_SCANCODE_MUTABLE
+#define CONFIG_KEYBOARD_SCANCODE_CALLBACK
#define CONFIG_KEYBOARD_DYNAMIC_MAPPING
#define CONFIG_TABLET_MODE
#undef CONFIG_PECI
diff --git a/board/eve/keyboard_legacy.c b/board/eve/keyboard_legacy.c
index 3a5b5dbcfd..5ccf4a856b 100644
--- a/board/eve/keyboard_legacy.c
+++ b/board/eve/keyboard_legacy.c
@@ -8,92 +8,48 @@
#include "board_config.h"
#include "chipset.h"
#include "keyboard_8042.h"
+#include "keyboard_8042_sharedlib.h"
#include "keyboard_protocol.h"
#include "util.h"
-/**
- * Special make codes for keys to handle directly. Make code in all code sets
- * should not start with 0xf0 so we can use that to encode special values.
- */
-#define MK_PAUSE 0xf001
-#define MK_CBREAK 0xf002
-#define MK_DIM 0xf003
-#define MK_BRIGHT 0xf004
-
/* Scan codes in set2 */
-/* Use SEARCH (before translate) as Fn key. */
-#define SCANCODE_FN 0xe01f
+/* Use LWIN=SEARCH (before translate) as Fn key. */
+#define SCANCODE_FN SCANCODE_LEFT_WIN
+
+struct makecode_translate_entry {
+ uint32_t from, to;
+};
static const struct makecode_translate_entry legacy_mapping[] = {
- { 0xe007, 0xe020 }, /* ASSIST => SEARCH(Win) */
- { 0x002f, 0xe02f }, /* MENU => APP */
+ { 0xe007, SCANCODE_LEFT_WIN }, /* ASSIST => SEARCH(Win) */
+ { 0x002f, SCANCODE_APP }, /* MENU => APP */
};
/* Alternate mapping when Fn is pressed. */
static const struct makecode_translate_entry legacy_fn_mapping[] = {
- { 0x0005, 0xe038 }, /* F1 => Browser Back */
- { 0x0006, 0xe020 }, /* F2 => Browser Refresh */
- { 0x0004, 0x0078 }, /* F3 => Full Screen */
- { 0x000c, 0xe07c }, /* F4 => Print Screen */
- { 0x0003, MK_DIM }, /* F5 => Dim Screen */
- { 0x000b, MK_BRIGHT }, /* F6 => Brighten Screen */
- { 0x0083, 0xe034 }, /* F7 => Play/Pause */
- { 0x000a, 0xe023 }, /* F8 => Mute */
+ { SCANCODE_F1, 0xe038 }, /* F1 => Browser Back */
+ { SCANCODE_F2, 0xe020 }, /* F2 => Browser Refresh */
+ { SCANCODE_F3, 0x0078 }, /* F3 => Full Screen */
+ { SCANCODE_F4, 0xe07c }, /* F4 => Print Screen */
+ /* TODO(hungte) Add F5 and F6 for DIM/BRIGHT. */
+ { SCANCODE_F7, 0xe034 }, /* F7 => Play/Pause */
+ { SCANCODE_F8, 0xe023 }, /* F8 => Mute */
+
{ 0x0001, 0xe021 }, /* F9 => Vol Down */
{ 0x0009, 0xe032 }, /* F10 => Vol Up */
- { 0x0011, 0x0058 }, /* LAlt => Caps Lock */
+ { SCANCODE_LEFT_ALT, SCANCODE_CAPSLOCK },
{ 0x0049, 0xe070 }, /* Dot(.) => Insert */
{ 0x0066, 0xe071 }, /* BackSpace => Delete */
- { 0x004d, MK_PAUSE }, /* P => Pause */
- { 0x0032, MK_CBREAK }, /* B => Ctrl-Break */
-
- { 0xe075, 0xe07d }, /* Up => Page Up */
- { 0xe072, 0xe07a }, /* Down => Page Down */
- { 0xe06b, 0xe06c }, /* Left => Home */
- { 0xe074, 0xe069 }, /* Right => End */
-};
-
-static const char pause_key_scancode_set1[] = {
- 0xe1, 0x1d, 0x45, 0xe1, 0x9d, 0xc5
-};
-
-static const char pause_key_scancode_set2[] = {
- 0xe1, 0x14, 0x77, 0xe1, 0xf0, 0x14, 0xf0, 0x77
-};
-
-static const char cbreak_key_scancode_set1[] = {
- 0xe0, 0x46, 0xe0, 0xc6
-};
-
-static const char cbreak_key_scancode_set2[] = {
- 0xe0, 0x7e, 0xe0, 0xf0, 0x7e
-};
-
-struct mk_entry {
- int len;
- const char *data;
-};
-
-struct mk_data {
- struct mk_entry make_set1, make_set2, break_set1, break_set2;
-};
+ { 0x004d, SCANCODE_PAUSE }, /* P => Pause */
+ { 0x0032, SCANCODE_CTRL_BREAK }, /* B => Ctrl-Break */
-/* PAUSE and CBREAK do not have 8042 break code. */
-static const struct mk_data mk_pause = {
- {ARRAY_SIZE(pause_key_scancode_set1),
- ARRAY_BEGIN(pause_key_scancode_set1)},
- {ARRAY_SIZE(pause_key_scancode_set2),
- ARRAY_BEGIN(pause_key_scancode_set2)},
-};
-
-static const const struct mk_data mk_cbreak = {
- {ARRAY_SIZE(cbreak_key_scancode_set1),
- ARRAY_BEGIN(cbreak_key_scancode_set1)},
- {ARRAY_SIZE(cbreak_key_scancode_set2),
- ARRAY_BEGIN(cbreak_key_scancode_set2)},
+ { SCANCODE_UP, 0xe07d }, /* Up => Page Up */
+ { SCANCODE_DOWN, 0xe07a }, /* Down => Page Down */
+ { SCANCODE_LEFT, 0xe06c }, /* Left => Home */
+ { SCANCODE_RIGHT, 0xe069 }, /* Right => End */
};
/* Indicate if the mapping is KEYBOARD_MAPPING_LEGACY. */
@@ -116,72 +72,54 @@ void keyboard_board_mapping_changed(enum keyboard_mapping_type new_mapping)
is_legacy_mapping = (new_mapping == KEYBOARD_MAPPING_LEGACY);
}
-static void process_mk_data(const struct mk_entry *make_code,
- const struct mk_entry *break_code,
- int8_t pressed)
-{
- if (pressed) {
- if (make_code->len)
- i8042_send_to_host(make_code->len, make_code->data);
- } else {
- if (break_code->len)
- i8042_send_to_host(break_code->len, break_code->data);
- }
-}
-
-
-static void process_mk(const struct mk_data *data, int8_t pressed,
- enum scancode_set_list code_set)
-{
- if (code_set == SCANCODE_SET_1) {
- process_mk_data(&data->make_set1, &data->break_set1, pressed);
- } else if (code_set == SCANCODE_SET_2) {
- process_mk_data(&data->make_set2, &data->break_set2, pressed);
- }
-}
-
-/* Translate legacy keys */
-uint16_t keyboard_board_translate(uint16_t make_code, int8_t pressed,
- enum scancode_set_list code_set)
+enum ec_error_list keyboard_scancode_callback(uint32_t *make_code,
+ int8_t pressed,
+ int32_t *oneshot)
{
+ int i;
+ uint32_t m = *make_code;
if (!is_legacy_mapping)
- return make_code;
+ return EC_SUCCESS;
/* Fn must be processed because Fn makecode conflicts with Win. */
- if (make_code == SCANCODE_FN) {
+ if (m == SCANCODE_FN) {
fn_pressed = pressed;
+ *oneshot = 1;
+ *make_code = 0;
/**
* TODO(hungte): If we press Fn, X, (triggers an Fn+X make) then
* release Fn, X, then it'll trigger a X break instead of Fn+X
* break. This is a known issue and should be fixed.
*/
- return 0;
+ return EC_SUCCESS;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(legacy_mapping); i++) {
+ if (m == legacy_mapping[i].from) {
+ m = legacy_mapping[i].to;
+ /* TODO(hungte): Should we also do one-shot here? */
+ *make_code = m;
+ break;
+ }
+
}
- make_code = makecode_translate(
- make_code, ARRAY_BEGIN(legacy_mapping),
- ARRAY_SIZE(legacy_mapping));
if (!fn_pressed)
- return make_code;
-
- make_code = makecode_translate(
- make_code, ARRAY_BEGIN(legacy_fn_mapping),
- ARRAY_SIZE(legacy_fn_mapping));
- switch (make_code) {
- case MK_PAUSE:
- process_mk(&mk_pause, pressed, code_set);
- return 0;
-
- case MK_CBREAK:
- process_mk(&mk_cbreak, pressed, code_set);
- return 0;
-
- case MK_DIM:
- /* TODO(hungte): Complete how to dim screen. */
- return 0;
- case MK_BRIGHT:
- /* TODO(hungte): Complete how to brighten screen. */
- return 0;
+ return EC_SUCCESS;
+
+ for (i = 0; i < ARRAY_SIZE(legacy_fn_mapping); i++) {
+ if (m == legacy_fn_mapping[i].from) {
+ m = legacy_fn_mapping[i].to;
+ *make_code = m;
+ break;
+ }
+
}
- return make_code;
+ if (m == SCANCODE_PAUSE || m == SCANCODE_CTRL_BREAK) {
+ *oneshot = 1;
+ if (!pressed)
+ *make_code = 0;
+ }
+
+ return EC_SUCCESS;
}
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 4c3a5726d6..8902b41588 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -50,6 +50,13 @@ static enum {
STATE_SEND_TO_MOUSE,
} data_port_state = STATE_NORMAL;
+enum scancode_set_list {
+ SCANCODE_GET_SET = 0,
+ SCANCODE_SET_1,
+ SCANCODE_SET_2,
+ SCANCODE_SET_3,
+ SCANCODE_MAX = SCANCODE_SET_3,
+};
#define MAX_SCAN_CODE_LEN 4
@@ -101,7 +108,6 @@ static uint8_t controller_ram[0x20] = {
/* 0x01 - 0x1f are controller RAM */
};
static uint8_t A20_status;
-static void keyboard_special(uint16_t k);
/*
* Scancode settings
@@ -203,17 +209,6 @@ void keyboard_select_mapping(enum keyboard_mapping_type mapping)
}
#endif
-uint16_t makecode_translate(uint16_t make_code,
- const struct makecode_translate_entry *entries,
- size_t count)
-{
- for (; count > 0; count--, entries++) {
- if (make_code == entries->from)
- return entries->to;
- }
- return make_code;
-}
-
void keyboard_host_write(int data, int is_cmd)
{
struct host_byte h;
@@ -248,7 +243,7 @@ static void keyboard_enable_irq(int enable)
* @param len Number of bytes to send to the host
* @param to_host Data to send
*/
-void i8042_send_to_host(int len, const uint8_t *bytes)
+static void i8042_send_to_host(int len, const uint8_t *bytes)
{
int i;
@@ -291,7 +286,7 @@ static int is_supported_code_set(enum scancode_set_list set)
* @param scan_code An array of bytes to store the make or break code in
* @param len The number of valid bytes to send in scan_code
*/
-static void scancode_bytes(uint16_t make_code, int8_t pressed,
+static void scancode_bytes(uint32_t make_code, int8_t pressed,
enum scancode_set_list code_set, uint8_t *scan_code,
int32_t *len)
{
@@ -299,7 +294,14 @@ static void scancode_bytes(uint16_t make_code, int8_t pressed,
/* Output the make code (from table) */
if (make_code >= 0x0100) {
- scan_code[(*len)++] = make_code >> 8;
+ if (make_code < 0x010000) {
+ scan_code[(*len)++] = make_code >> 8;
+ } else {
+ /* Special key combination like SCANCODE_PAUSE. */
+ ASSERT((make_code >> 8) >= 0x0100);
+ scancode_bytes(make_code >> 8, pressed, code_set,
+ scan_code, len);
+ }
make_code &= 0xff;
}
@@ -325,19 +327,27 @@ static void scancode_bytes(uint16_t make_code, int8_t pressed,
static enum ec_error_list matrix_callback(int8_t row, int8_t col,
int8_t pressed,
enum scancode_set_list code_set,
- uint8_t *scan_code, int32_t *len)
+ uint8_t *scan_code, int32_t *len,
+ int *oneshot)
{
- uint16_t make_code;
+ uint32_t make_code;
ASSERT(scan_code);
ASSERT(len);
- if (row > KEYBOARD_ROWS || col > KEYBOARD_COLS)
+ if (row >= KEYBOARD_ROWS || col >= KEYBOARD_COLS)
return EC_ERROR_INVAL;
make_code = scancode_set2[row][col];
- if (pressed)
- keyboard_special(make_code);
+
+#ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK
+ {
+ enum ec_error_list r = keyboard_scancode_callback(
+ &make_code, pressed, oneshot);
+ if (r != EC_SUCCESS)
+ return r;
+ }
+#endif
code_set = acting_code_set(code_set);
if (!is_supported_code_set(code_set)) {
@@ -345,21 +355,18 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col,
return EC_ERROR_UNIMPLEMENTED;
}
-#ifdef CONFIG_KEYBOARD_DYNAMIC_MAPPING
- /**
- * Currently it only makes sense to apply board translation in dynamic
- * mapping. If we find more boards need special processing, then this
- * can changed to weak linking or a specific config.
- */
- make_code = keyboard_board_translate(make_code, pressed, code_set);
-#endif
-
if (!make_code) {
CPRINTS("KB scancode %d:%d missing", row, col);
return EC_ERROR_UNIMPLEMENTED;
}
scancode_bytes(make_code, pressed, code_set, scan_code, len);
+ if (*oneshot && pressed) {
+ int32_t break_len = 0;
+ scan_code += *len;
+ scancode_bytes(make_code, 0, code_set, scan_code, &break_len);
+ *len += break_len;
+ }
return EC_SUCCESS;
}
@@ -397,6 +404,7 @@ static void keyboard_wakeup(void)
static void set_typematic_key(const uint8_t *scan_code, int32_t len)
{
typematic_deadline.val = get_time().val + typematic_first_delay;
+ ASSERT(len <= sizeof(typematic_scan_code));
memcpy(typematic_scan_code, scan_code, len);
typematic_len = len;
}
@@ -408,23 +416,33 @@ void clear_typematic_key(void)
void keyboard_state_changed(int row, int col, int is_pressed)
{
- uint8_t scan_code[MAX_SCAN_CODE_LEN];
+ /**
+ * In one matrix_callback there may be scan codes generated
+ * as one shot (make+break) so we have to double the buffer.
+ * Currently the largest sequence is PAUSE (8 bytes).
+ */
+ uint8_t scan_code[MAX_SCAN_CODE_LEN * 2];
int32_t len = 0;
+ int is_oneshot = 0;
enum ec_error_list ret;
CPRINTS5("KB (%d,%d)=%d", row, col, is_pressed);
ret = matrix_callback(row, col, is_pressed, scancode_set, scan_code,
- &len);
+ &len, &is_oneshot);
if (ret == EC_SUCCESS) {
- ASSERT(len > 0);
- if (keystroke_enabled)
+ /**
+ * One shot means keys should send MAKE+BREAK at when pressed,
+ * and fire nothing when released. For example PAUSE.
+ */
+ ASSERT(len > 0 || is_oneshot);
+ if (keystroke_enabled && len)
i8042_send_to_host(len, scan_code);
}
if (is_pressed) {
keyboard_wakeup();
- set_typematic_key(scan_code, len);
+ set_typematic_key(scan_code, is_oneshot ? 0 : len);
task_wake(TASK_ID_KEYPROTO);
} else {
clear_typematic_key();
@@ -686,6 +704,13 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output)
switch (command) {
case I8042_READ_CMD_BYTE:
+ /*
+ * Ensure that the keyboard buffer is cleared before adding
+ * command byte to it. Since the host is asking for command
+ * byte, sending it buffered key press data can confuse the
+ * host and result in it taking incorrect action.
+ */
+ keyboard_clear_buffer();
output[out_len++] = read_ctl_ram(0);
break;
@@ -799,54 +824,6 @@ static void i8042_handle_from_host(void)
}
}
-/* U U D D L R L R b a */
-static void keyboard_special(uint16_t k)
-{
- static uint8_t s;
- static const uint16_t a[] = {0xe075, 0xe075, 0xe072, 0xe072, 0xe06b,
- 0xe074, 0xe06b, 0xe074, 0x0032, 0x001c};
-#ifdef HAS_TASK_LIGHTBAR
- /* Lightbar demo mode: keyboard can fake the battery state */
- switch (k) {
- case 0xe075: /* up */
- demo_battery_level(1);
- break;
- case 0xe072: /* down */
- demo_battery_level(-1);
- break;
- case 0xe06b: /* left */
- demo_is_charging(0);
- break;
- case 0xe074: /* right */
- demo_is_charging(1);
- break;
- case 0x000b: /* dim */
- demo_brightness(-1);
- break;
- case 0x0083: /* bright */
- demo_brightness(1);
- break;
- case 0x002c: /* T */
- demo_tap();
- break;
- }
-#endif
-
- if (k == a[s])
- s++;
- else if (k != 0xe075)
- s = 0;
- else if (s != 2)
- s = 1;
-
- if (s == ARRAY_SIZE(a)) {
- s = 0;
-#ifdef HAS_TASK_LIGHTBAR
- lightbar_sequence(LIGHTBAR_KONAMI);
-#endif
- }
-}
-
void keyboard_protocol_task(void *u)
{
int wait = -1;
diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c
index 0ea4dca792..513a27913d 100644
--- a/common/keyboard_8042_sharedlib.c
+++ b/common/keyboard_8042_sharedlib.c
@@ -76,20 +76,20 @@ uint8_t scancode_translate_set2_to_1(uint8_t code)
}
/*
- * Button scancodes in code set 2.
+ * Button scan codes.
* Must be in the same order as defined in keyboard_button_type.
*/
SHAREDLIB(const struct button_8042_t buttons_8042[] = {
- {0xe037, 0}, /* Power */
- {0xe021, 1}, /* Volume Down */
- {0xe032, 1}, /* Volume Up */
- {0x0016, 1}, /* 1 */
- {0x001e, 1}, /* 2 */
- {0x0026, 1}, /* 3 */
- {0x0025, 1}, /* 4 */
- {0x002e, 1}, /* 5 */
- {0x0036, 1}, /* 6 */
- {0x003d, 1}, /* 7 */
- {0x003e, 1}, /* 8 */
+ {SCANCODE_POWER, 0},
+ {SCANCODE_VOLUME_DOWN, 1},
+ {SCANCODE_VOLUME_UP, 1},
+ {SCANCODE_1, 1},
+ {SCANCODE_2, 1},
+ {SCANCODE_3, 1},
+ {SCANCODE_4, 1},
+ {SCANCODE_5, 1},
+ {SCANCODE_6, 1},
+ {SCANCODE_7, 1},
+ {SCANCODE_8, 1},
});
BUILD_ASSERT(ARRAY_SIZE(buttons_8042) == KEYBOARD_BUTTON_COUNT);
diff --git a/include/config.h b/include/config.h
index 743684e5e7..34773cb91e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1598,6 +1598,11 @@
#undef CONFIG_KEYBOARD_SCANCODE_MUTABLE
/*
+ * Allow board-specific 8042 keyboard callback when a key state is changed.
+ */
+#undef CONFIG_KEYBOARD_SCANCODE_CALLBACK
+
+/*
* Allow changing keyboard mapping dynamically (for example to provide Fn keys
* in AP firmware legacy mode).
*/
diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h
index 4ae7c15a8e..d7c62bad42 100644
--- a/include/keyboard_8042.h
+++ b/include/keyboard_8042.h
@@ -30,52 +30,20 @@ void button_state_changed(enum keyboard_button_type button, int is_pressed);
*/
void keyboard_host_write(int data, int is_cmd);
-/**
- * Send a scan code to the host.
+/*
+ * Board specific callback function when a key state is changed.
*
- * The EC lib will push the scan code bytes to host via port 0x60 and assert
- * the IBF flag to trigger an interrupt. The EC lib must queue them if the
- * host cannot read the previous byte away in time.
+ * A board may watch key events and create some easter eggs, or apply dynamic
+ * translation to the make code (i.e., remap keys).
*
- * @param len Number of bytes to send to the host
- * @param bytes Data to send
- */
-void i8042_send_to_host(int len, const uint8_t *bytes);
-
-/* Utilities for scan code and make code. */
-
-enum scancode_set_list {
- SCANCODE_GET_SET = 0,
- SCANCODE_SET_1,
- SCANCODE_SET_2,
- SCANCODE_SET_3,
- SCANCODE_MAX = SCANCODE_SET_3,
-};
-
-struct makecode_translate_entry {
- uint16_t from, to;
-};
-
-/**
- * Translate a make code to different value.
- *
- * @param make_code The value of make_code.
- * @param entries Pointer to array of struct makecode_translate_entry
- * @param count Number of elements in entries
- */
-uint16_t makecode_translate(uint16_t make_code,
- const struct makecode_translate_entry *entries,
- size_t count);
-
-/**
- * Returns a board-specific translated make code.
+ * Returning EC_SUCCESS implies the make points to a valid make code and should
+ * be processed. Any other failure will abort key processing.
*
- * @param make_code 8042 make code
- * @param pressed Whether the key was pressed
- * @param code_set 8042 scan code set
+ * @param make_code Pointer to scan code (set 2) of key in action.
+ * @param pressed Is the key being pressed (1) or released (0).
*/
-uint16_t keyboard_board_translate(
- uint16_t make_code, int8_t pressed,
- enum scancode_set_list code_set);
+enum ec_error_list keyboard_scancode_callback(uint32_t *make_code,
+ int8_t pressed,
+ int32_t *oneshot);
#endif /* __CROS_EC_KEYBOARD_8042_H */
diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h
index e475288ad5..1b9b3c7b2b 100644
--- a/include/keyboard_8042_sharedlib.h
+++ b/include/keyboard_8042_sharedlib.h
@@ -31,4 +31,54 @@ extern uint8_t scancode_translate_set2_to_1(uint8_t code);
/* Button scancodes (Power, Volume Down, Volume Up, etc.) */
extern const struct button_8042_t buttons_8042[KEYBOARD_BUTTON_COUNT];
+/* Scan code set 2 table. */
+enum scancode_values {
+ SCANCODE_1 = 0x0016,
+ SCANCODE_2 = 0x001e,
+ SCANCODE_3 = 0x0026,
+ SCANCODE_4 = 0x0025,
+ SCANCODE_5 = 0x002e,
+ SCANCODE_6 = 0x0036,
+ SCANCODE_7 = 0x003d,
+ SCANCODE_8 = 0x003e,
+
+ SCANCODE_A = 0x001c,
+ SCANCODE_B = 0x0032,
+ SCANCODE_T = 0x002c,
+
+ SCANCODE_F1 = 0x0005,
+ SCANCODE_F2 = 0x0006,
+ SCANCODE_F3 = 0x0004,
+ SCANCODE_F4 = 0x000c,
+ SCANCODE_F5 = 0x0003,
+ SCANCODE_F6 = 0x000b,
+ SCANCODE_F7 = 0x0083,
+ SCANCODE_F8 = 0x000a,
+
+ SCANCODE_UP = 0xe075,
+ SCANCODE_DOWN = 0xe072,
+ SCANCODE_LEFT = 0xe06b,
+ SCANCODE_RIGHT = 0xe074,
+
+ SCANCODE_LEFT_CTRL = 0x0014,
+ SCANCODE_RIGHT_CTRL = 0xe014,
+ SCANCODE_LEFT_ALT = 0x0011,
+ SCANCODE_RIGHT_ALT = 0xe011,
+
+ SCANCODE_LEFT_WIN = 0xe01f, /* Also known as GUI or Super key. */
+ SCANCODE_RIGHT_WIN = 0xe027,
+ SCANCODE_APP = 0xe02f,
+
+ SCANCODE_POWER = 0xe037,
+ SCANCODE_VOLUME_DOWN = 0xe021,
+ SCANCODE_VOLUME_UP = 0xe032,
+
+ SCANCODE_NUMLOCK = 0x0077,
+ SCANCODE_CAPSLOCK = 0x0058,
+ SCANCODE_SCROLL_LOCK = 0x007e,
+
+ SCANCODE_CTRL_BREAK = 0xe07e,
+ SCANCODE_PAUSE = 0xe11477, /* A special value from XT Ctrl+Num. */
+};
+
#endif /* __CROS_EC_KEYBOARD_8042_SHAREDLIB_H */