summaryrefslogtreecommitdiff
path: root/include/keyboard_8042.h
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-09 11:45:15 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-17 11:17:57 -0700
commitcd8cc76e3034c1935245b9b20e7fc4efbb0b0471 (patch)
tree8df7b9e8921d728d0849f9931ed90bf4300ad1d8 /include/keyboard_8042.h
parent195a3e8589312d0bc96f37c08e266539d7895d74 (diff)
downloadchrome-ec-cd8cc76e3034c1935245b9b20e7fc4efbb0b0471.tar.gz
keyboard: Add CONFIG_KEYBOARD_SCANCODE_CALLBACK for board-specific hooks.
Many devices may want board-specific keyboard hooks, for example allowing easter egg (to replace the key_special today), or to provide dynamic translation. Both can be done by having a callback whenever the key state is changed (after scancode is found). The new CONFIG_KEYBOARD_SCANCODE_CALLBACK allows boards to define their own hook keyboard_scancode_callback so the keystrokes can be either changed or monitored. BUG=b:72200093 TEST=make buildall -j BRANCH=eve Change-Id: I02e3bf5c217b2f30b942d96ecb2c493ce200638f Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1168281 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/keyboard_8042.h')
-rw-r--r--include/keyboard_8042.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h
index 00fdc9901b..7bde59ac35 100644
--- a/include/keyboard_8042.h
+++ b/include/keyboard_8042.h
@@ -28,4 +28,21 @@ void button_state_changed(enum keyboard_button_type button, int is_pressed);
*/
void keyboard_host_write(int data, int is_cmd);
+/*
+ * Board specific callback function when a key state is changed.
+ *
+ * A board may watch key events and create some easter eggs, or apply dynamic
+ * translation to the make code (i.e., remap keys).
+ *
+ * Returning EC_SUCCESS implies *make_code is still a valid make code to be
+ * processed. Any other return value will abort processing of this make code.
+ * If callback alters *make_code or aborts key processing when pressed=1, it is
+ * responsible for also altering/aborting the matching pressed=0 call.
+ *
+ * @param make_code Pointer to scan code (set 2) of key in action.
+ * @param pressed Is the key being pressed (1) or released (0).
+ */
+enum ec_error_list keyboard_scancode_callback(uint16_t *make_code,
+ int8_t pressed);
+
#endif /* __CROS_EC_KEYBOARD_8042_H */