1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Chrome OS EC keyboard code.
*/
#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 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;
}
EcError EcKeyboardInit() {
EcError ret;
ret = EcKeyboardRegisterCallback(KeyboardStateChanged);
if (ret != EC_SUCCESS) return ret;
return EC_SUCCESS;
}
|