From 541ddb0f889c2630e457fbab475cf6e2f781b54c Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Thu, 4 May 2017 16:40:49 +0800 Subject: [PATCH] keyboard_scan: Add option to not handle special key combinations On some boards, the special alt-volup-r/h combinations do not make a lot of sense, so we can just not process them and save a little bit of code space. BRANCH=none BUG=b:37422577 TEST=Flash hammer, alt-volup-r/h does not do anything special TEST=make newsizes shows we save 124 bytes in hammer RW. Change-Id: I92770fd6b8ff90780162a6b1de428a550bb44e9b Reviewed-on: https://chromium-review.googlesource.com/495967 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Vincent Palatin --- common/keyboard_scan.c | 4 ++++ include/config.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index fa8ce3d98f..3ad4805b90 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -272,6 +272,7 @@ static int read_matrix(uint8_t *state) return pressed ? 1 : 0; } +#ifdef CONFIG_KEYBOARD_RUNTIME_KEYS /** * Check special runtime key combinations. * @@ -365,6 +366,7 @@ static int check_runtime_keys(const uint8_t *state) return 0; } +#endif /* CONFIG_KEYBOARD_RUNTIME_KEYS */ /** * Check for ghosting in the keyboard state. @@ -506,9 +508,11 @@ static int check_keys_changed(uint8_t *state) CPRINTF("]\n"); #endif +#ifdef CONFIG_KEYBOARD_RUNTIME_KEYS /* Swallow special keys */ if (check_runtime_keys(state)) return 0; +#endif #ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP keyboard_fifo_add(state); diff --git a/include/config.h b/include/config.h index 817dc659f6..07c02acd5a 100644 --- a/include/config.h +++ b/include/config.h @@ -1515,6 +1515,12 @@ /* Print keyboard scan time intervals. */ #undef CONFIG_KEYBOARD_PRINT_SCAN_TIMES +/* + * Support for extra runtime key combinations (e.g. alt+volup+h/r for hibernate + * and warm reboot, respectively). + */ +#define CONFIG_KEYBOARD_RUNTIME_KEYS + /* * Call board-supplied keyboard_suppress_noise() function when the debounced * keyboard state changes. Some boards use this to send a signal to the audio