summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-10 19:39:31 +0800
committerHung-Te Lin <hungte@chromium.org>2018-08-10 11:41:43 +0000
commit1f4e047d83efa1679b9bd493ed79f885c9c664cf (patch)
treee256702ed00cb6774eb32d1e986aa3ac9484f83a
parent21a9de0c034cf98d61a9f271cd96b7dd15ea7838 (diff)
downloadchrome-ec-1f4e047d83efa1679b9bd493ed79f885c9c664cf.tar.gz
keyboard: Support both Alt+Fn and Fn+Alt as Capslock.
The ChromeOS supports both Alt+Search and Search+Alt as Capslock, and we should allow both in legacy mode. BUG=None TEST=make BOARD=eve; manually tested BRANCH=eve Change-Id: I853738e4ec1563cd38d1b8882b47d2cf980ebee4 Reviewed-on: https://chromium-review.googlesource.com/1170727 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/keyboard_legacy.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/board/eve/keyboard_legacy.c b/board/eve/keyboard_legacy.c
index 5ccf4a856b..0e5619c678 100644
--- a/board/eve/keyboard_legacy.c
+++ b/board/eve/keyboard_legacy.c
@@ -56,7 +56,7 @@ static const struct makecode_translate_entry legacy_fn_mapping[] = {
static int is_legacy_mapping;
/* Indicate if Fn key is already pressed. */
-static int fn_pressed;
+static uint8_t fn_pressed, alt_pressed;
/* Override the board_init_keyboard_mapping in board.c */
void board_init_keyboard_mapping(int reset)
@@ -81,11 +81,18 @@ enum ec_error_list keyboard_scancode_callback(uint32_t *make_code,
if (!is_legacy_mapping)
return EC_SUCCESS;
- /* Fn must be processed because Fn makecode conflicts with Win. */
- if (m == SCANCODE_FN) {
+ switch (m) {
+ case SCANCODE_LEFT_ALT:
+ alt_pressed = pressed;
+ break;
+ case SCANCODE_FN:
+ /* Fn must be processed because Fn makecode conflicts with Win. */
fn_pressed = pressed;
*oneshot = 1;
- *make_code = 0;
+
+ /* Special case: convert to caps lock if ALT pressed. */
+ *make_code = (pressed && alt_pressed) ? SCANCODE_CAPSLOCK : 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