summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Bellows <greg.bellows@linaro.org>2014-11-17 11:48:35 -0600
committerGreg Bellows <greg.bellows@linaro.org>2014-11-19 17:08:01 -0600
commit1da0d9d8181a5a8449f27780e2ae7f41c7b0982d (patch)
treee20a58b8debd8bbcbb072a61f0632a1546340fd1
parent67fc9dd4a130b0ae5605fa4c4f5e711da34f0cfe (diff)
android-console: Add event codes command
Add the Android emulator console "event codes" command and associated help messages. The "codes" command is used to display a list of available event codes for a specified type. Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
-rw-r--r--android-commands.h7
-rw-r--r--android-console.c41
-rw-r--r--android-console.h1
3 files changed, 49 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h
index b1bebedf8..25a9a3a01 100644
--- a/android-commands.h
+++ b/android-commands.h
@@ -79,6 +79,13 @@ static mon_cmd_t android_event_cmds[] = {
.help = "list all <type> aliases",
.mhandler.cmd = android_console_event_types,
},
+ {
+ .name = "codes",
+ .args_type = "arg:s?",
+ .params = "",
+ .help = "list all <code> aliases for a given <type>",
+ .mhandler.cmd = android_console_event_codes,
+ },
{ NULL, NULL, },
};
diff --git a/android-console.c b/android-console.c
index 2c55714fb..9562e7557 100644
--- a/android-console.c
+++ b/android-console.c
@@ -516,6 +516,7 @@ void android_console_power(Monitor *mon, const QDict *qdict)
enum {
CMD_EVENT,
CMD_EVENT_TYPES,
+ CMD_EVENT_CODES,
};
static const char *event_help[] = {
@@ -530,6 +531,9 @@ static const char *event_help[] = {
/* CMD_EVENT_TYPES */
"'event types' list all <type> string aliases supported by the "
"'event' subcommands",
+ /* CMD_EVENT_CODES */
+ "'event codes <type>' lists all <code> string aliases for a given "
+ "event <type>",
};
void android_console_event_types(Monitor *mon, const QDict *qdict)
@@ -563,6 +567,41 @@ void android_console_event_types(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "OK\n");
}
+void android_console_event_codes(Monitor *mon, const QDict *qdict)
+{
+ const char *arg = qdict_get_try_str(qdict, "arg");
+
+ int count, nn;
+
+ if (!arg) {
+ monitor_printf(mon, "KO: argument missing, try 'event codes <type>'\n");
+ return;
+ }
+
+ count = gf_get_event_code_count(arg);
+
+ /* If the type is invalid then bail */
+ if (count < 0) {
+ monitor_printf(mon,
+ "KO: bad argument, see 'event types' for valid values\n");
+ return;
+ }
+
+ if (count == 0) {
+ monitor_printf(mon, "no code aliases defined for this type\n");
+ } else {
+ monitor_printf(mon, "type '%s' accepts the following <code> aliases:\n",
+ arg);
+ for (nn = 0; nn < count; nn++) {
+ char temp[20], *p = temp;
+ gf_get_event_code_name(arg, nn, p);
+ monitor_printf(mon, " %-12s\r\n", p);
+ }
+ }
+
+ monitor_printf(mon, "OK\n");
+}
+
void android_console_event(Monitor *mon, const QDict *qdict)
{
/* This only gets called for bad subcommands and help requests */
@@ -574,6 +613,8 @@ void android_console_event(Monitor *mon, const QDict *qdict)
if (helptext) {
if (strstr(helptext, "types")) {
cmd = CMD_EVENT_TYPES;
+ } else if (strstr(helptext, "codes")) {
+ cmd = CMD_EVENT_CODES;
}
}
diff --git a/android-console.h b/android-console.h
index 3f97beb4c..270f08757 100644
--- a/android-console.h
+++ b/android-console.h
@@ -37,6 +37,7 @@ 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_codes(Monitor *mon, const QDict *qdict);
void android_console_event(Monitor *mon, const QDict *qdict);
void android_monitor_print_error(Monitor *mon, const char *fmt, ...);