diff options
author | Greg Bellows <greg.bellows@linaro.org> | 2014-11-13 15:07:47 -0600 |
---|---|---|
committer | Greg Bellows <greg.bellows@linaro.org> | 2015-01-15 16:18:57 -0600 |
commit | 794583f5c5137042a3c5d821e1e1af69356bd6c9 (patch) | |
tree | bef80589d80fd605274f10ca1dcecac884227024 | |
parent | 60b4d99397ea524a53957582b06bcea20237fb07 (diff) |
android-console: Add event types command
Add the Android emulator console "event types" command and associated help
messages. The "types" command is used to display a list of available event
types that can be used in other event commands.
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
-rw-r--r-- | android-commands.h | 7 | ||||
-rw-r--r-- | android-console.c | 42 | ||||
-rw-r--r-- | android-console.h | 1 |
3 files changed, 50 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h index 26dfcac0e..7f0d88eae 100644 --- a/android-commands.h +++ b/android-commands.h @@ -72,6 +72,13 @@ static mon_cmd_t android_power_cmds[] = { }; static mon_cmd_t android_event_cmds[] = { + { + .name = "types", + .args_type = "arg:s?", + .params = "", + .help = "list all <type> aliases", + .mhandler.cmd = android_console_event_types, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index 2ba1b3acc..b94c97dc2 100644 --- a/android-console.c +++ b/android-console.c @@ -22,6 +22,7 @@ #include "slirp/libslirp.h" #include "qmp-commands.h" #include "hw/misc/goldfish_battery.h" +#include "hw/input/goldfish_events.h" typedef struct { int is_udp; @@ -530,6 +531,7 @@ void android_console_power(Monitor *mon, const QDict *qdict) enum { CMD_EVENT, + CMD_EVENT_TYPES, }; static const char *event_help[] = { @@ -541,8 +543,42 @@ static const char *event_help[] = { " event types list all <type> aliases\n" " event codes list all <code> aliases for a given <type>\n" " event text simulate keystrokes from a given text\n", + /* CMD_EVENT_TYPES */ + "'event types' list all <type> string aliases supported by the " + "'event' subcommands", }; +void android_console_event_types(Monitor *mon, const QDict *qdict) +{ + int count = gf_get_event_type_count(); + int nn; + + monitor_printf(mon, "event <type> can be an integer or one of the" + "following aliases\n"); + + /* Loop through and print out each type found along with the count of alias + * codes if any. + */ + for (nn = 0; nn < count; nn++) { + char tmp[16]; + char *p = tmp; + int code_count; + gf_get_event_type_name(nn, p); + + code_count = gf_get_event_code_count(p); + + monitor_printf(mon, " %-8s", p); + + if (code_count > 0) { + monitor_printf(mon, " (%d code aliases)", code_count); + } + + monitor_printf(mon, "\n"); + } + + monitor_printf(mon, "OK\n"); +} + void android_console_event(Monitor *mon, const QDict *qdict) { /* This only gets called for bad subcommands and help requests */ @@ -551,6 +587,12 @@ void android_console_event(Monitor *mon, const QDict *qdict) /* Default to the first entry which is the parent help message */ int cmd = CMD_EVENT; + if (helptext) { + if (strstr(helptext, "types")) { + cmd = CMD_EVENT_TYPES; + } + } + /* If this is not a help request then we are here with a bad sub-command */ monitor_printf(mon, "%s\n%s\n", event_help[cmd], helptext ? "OK" : "KO: missing sub-command"); diff --git a/android-console.h b/android-console.h index 4c2195e25..3f97beb4c 100644 --- a/android-console.h +++ b/android-console.h @@ -36,6 +36,7 @@ void android_console_power_health(Monitor *mon, const QDict *qdict); void android_console_power_capacity(Monitor *mon, const QDict *qdict); void android_console_power(Monitor *mon, const QDict *qdict); +void android_console_event_types(Monitor *mon, const QDict *qdict); void android_console_event(Monitor *mon, const QDict *qdict); void android_monitor_print_error(Monitor *mon, const char *fmt, ...); |