diff options
Diffstat (limited to 'cros_ec/lib/ec_keyboard.c')
-rw-r--r-- | cros_ec/lib/ec_keyboard.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cros_ec/lib/ec_keyboard.c b/cros_ec/lib/ec_keyboard.c index f126f9eed8..4e4b9d91e4 100644 --- a/cros_ec/lib/ec_keyboard.c +++ b/cros_ec/lib/ec_keyboard.c @@ -6,11 +6,43 @@ */ #include "cros_ec/include/ec_common.h" +#include "cros_ec/include/ec_keyboard.h" #include "chip_interface/keyboard.h" +#include "host_interface/i8042.h" -static void KeyboardStateChanged(int col, int row, int is_pressed) { - PRINTF("File %s:%s(): col=%d row=%d is_pressed=%d\n", - __FILE__, __FUNCTION__, col, row, is_pressed); + +static EcKeyboardMatrixCallback matrix_callback; + +static void KeyboardStateChanged(int row, int col, int is_pressed) { + uint8_t scan_code[MAX_SCAN_CODE_LEN]; + int len; + EcError ret; + + PRINTF("File %s:%s(): row=%d col=%d is_pressed=%d\n", + __FILE__, __FUNCTION__, row, col, is_pressed); + + EC_ASSERT(matrix_callback); + + ret = matrix_callback(row, col, is_pressed, scan_code, &len); + if (ret == EC_SUCCESS) { + EC_ASSERT(len > 0); + + EcI8042SendScanCode(len, scan_code); + } else { + /* FIXME: long-term solution is to ignore this key. However, keep + * assertion in the debug stage. */ + EC_ASSERT(ret == EC_SUCCESS); + } +} + + +EcError EcKeyboardMatrixRegisterCallback( + int8_t row_num, int8_t col_num, + EcKeyboardMatrixCallback callback) { + + matrix_callback = callback; + + return EC_SUCCESS; } |