summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-05-29 17:11:23 +0800
committerVic Yang <victoryang@chromium.org>2012-05-29 17:11:23 +0800
commitabce21c6cfcce85145cec4bf0c7b4001bdb63f48 (patch)
treeef28dfd2c55cddd9d6b22a562d9ef3515d8daf0e /util
parentf2678998617771edbfb3574b66c4573d75e6dda7 (diff)
downloadchrome-ec-abce21c6cfcce85145cec4bf0c7b4001bdb63f48.tar.gz
Add host command to simulate key press
In order to enable automatic keyboard testing, let's add key press simulating command to ectool. BUG=chrome-os-partner:9188 TEST='ectool kbpress 4 6 1' and see 'j' pressed. 'ectool kbpress 4 6 0' and see 'j' released. Change-Id: I5a445e13aad2bd09aa6e9a1d62995cf34b782aeb
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 4c9ff31bb5..abdb9a0938 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -57,6 +57,8 @@ const char help_str[] =
" Erases EC flash\n"
" hello\n"
" Checks for basic communication with EC\n"
+ " kbpress\n"
+ " Simulate key press\n"
" lightbar [CMDS]\n"
" Various lightbar control commands\n"
" vboot get\n"
@@ -1036,6 +1038,46 @@ int cmd_usb_charge_set_mode(int argc, char *argv[])
}
+int cmd_kbpress(int argc, char *argv[])
+{
+ struct ec_params_mkbp_simulate_key p;
+ char *e;
+ int rv;
+
+ if (argc != 4) {
+ fprintf(stderr,
+ "Usage: %s <row> <col> <0|1>\n", argv[0]);
+ return -1;
+ }
+ p.row = strtol(argv[1], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad row.\n");
+ return -1;
+ }
+ p.col = strtol(argv[2], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad column.\n");
+ return -1;
+ }
+ p.pressed = strtol(argv[3], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad pressed flag.\n");
+ return -1;
+ }
+
+ printf("%s row %d col %d.\n", p.pressed ? "Pressing" : "Releasing",
+ p.row,
+ p.col);
+
+ rv = ec_command(EC_CMD_MKBP_SIMULATE_KEY,
+ &p, sizeof(p), NULL, 0);
+ if (rv)
+ return rv;
+ printf("Done.\n");
+ return 0;
+}
+
+
int cmd_pstore_info(int argc, char *argv[])
{
struct ec_response_pstore_info r;
@@ -1452,6 +1494,7 @@ const struct command commands[] = {
{"flashwrite", cmd_flash_write},
{"flashinfo", cmd_flash_info},
{"hello", cmd_hello},
+ {"kbpress", cmd_kbpress},
{"lightbar", cmd_lightbar},
{"vboot", cmd_vboot},
{"pstoreinfo", cmd_pstore_info},