aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2010-07-22 11:23:19 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2010-07-22 11:23:19 -0700
commit43552dc4fa64aad0c9fdb8f4c92ae7ac79406596 (patch)
treeb1263d1a7fc5cf44f4f05334d73927dd91148609
parent2fa5173bd1ce7341c50adac676a317945f0969c7 (diff)
downloadexternal_qemu-43552dc4fa64aad0c9fdb8f4c92ae7ac79406596.zip
external_qemu-43552dc4fa64aad0c9fdb8f4c92ae7ac79406596.tar.gz
external_qemu-43552dc4fa64aad0c9fdb8f4c92ae7ac79406596.tar.bz2
Remove UI dependency from goldfish_event_device.c
Change-Id: Iea5edfbae0caff45161c814d631d35d2e6d61d1c
-rw-r--r--android/charmap.c23
-rw-r--r--android/charmap.h6
-rw-r--r--android/console.c2
-rw-r--r--android/main.c5
-rw-r--r--hw/goldfish_events_device.c3
-rw-r--r--qemu-options.hx4
-rw-r--r--vl-android.c21
7 files changed, 59 insertions, 5 deletions
diff --git a/android/charmap.c b/android/charmap.c
index af4163a..553ad67 100644
--- a/android/charmap.c
+++ b/android/charmap.c
@@ -265,8 +265,8 @@ static const AKeyCharmap _qwerty2_charmap =
/* Custom character map created with -charmap option. */
static AKeyCharmap android_custom_charmap = { 0 };
-const AKeyCharmap** android_charmaps = 0;
-int android_charmap_count = 0;
+static const AKeyCharmap** android_charmaps = 0;
+static int android_charmap_count = 0;
/* Checks if a character represents an end of the line.
* Returns a non-zero value if ch is an EOL character. Returns
@@ -693,6 +693,13 @@ parse_kcm_file(const char* kcm_file_path, AKeyCharmap* char_map) {
int
android_charmap_setup(const char* kcm_file_path) {
+ // android_charmap_count being non-zero is used here as a flag,
+ // indicating that charmap has been initialized for the running
+ // executable.
+ if (android_charmap_count != 0) {
+ return 0;
+ }
+
if (NULL != kcm_file_path) {
if (!parse_kcm_file(kcm_file_path, &android_custom_charmap)) {
// Here we have two default charmaps and the custom one.
@@ -820,3 +827,15 @@ android_charmap_reverse_map_unicode(const AKeyCharmap* cmap,
/* no match */
return 0;
}
+
+const AKeyCharmap*
+android_get_default_charmap(void)
+{
+ return android_get_charmap_by_index(0);
+}
+
+const char*
+android_get_default_charmap_name(void)
+{
+ return android_get_default_charmap()->name;
+}
diff --git a/android/charmap.h b/android/charmap.h
index 08b059d..6bf35c0 100644
--- a/android/charmap.h
+++ b/android/charmap.h
@@ -90,4 +90,10 @@ android_charmap_reverse_map_unicode(const AKeyCharmap* cmap,
int down,
AKeycodeBuffer* keycodes);
+/* Gets default charmap (index 0) */
+const AKeyCharmap* android_get_default_charmap(void);
+
+/* Gets name of the default charmap (index 0) */
+const char* android_get_default_charmap_name(void);
+
#endif /* _android_charmap_h */
diff --git a/android/console.c b/android/console.c
index a7b55e9..f913f7d 100644
--- a/android/console.c
+++ b/android/console.c
@@ -1807,7 +1807,7 @@ do_event_text( ControlClient client, char* args )
}
/* Get default charmap. */
- charmap = android_get_charmap_by_index(0);
+ charmap = android_get_default_charmap();
if (charmap == NULL) {
control_write( client, "KO: no character map active in current device layout/config\r\n" );
return -1;
diff --git a/android/main.c b/android/main.c
index 04d715c..88ce36b 100644
--- a/android/main.c
+++ b/android/main.c
@@ -2174,6 +2174,11 @@ int main(int argc, char **argv)
args[n++] = opts->http_proxy;
}
+ if (opts->charmap) {
+ args[n++] = "-charmap";
+ args[n++] = opts->charmap;
+ }
+
/* physical memory */
args[n++] = "-m";
args[n++] = opts->memory;
diff --git a/hw/goldfish_events_device.c b/hw/goldfish_events_device.c
index 9050aa6..9e98dac 100644
--- a/hw/goldfish_events_device.c
+++ b/hw/goldfish_events_device.c
@@ -274,7 +274,8 @@ void events_dev_init(uint32_t base, qemu_irq irq)
AndroidHwConfig* config = android_hw;
s = (events_state *) qemu_mallocz(sizeof(events_state));
- s->name = android_skin_keycharmap;
+ // Use name of the default charmap.
+ s->name = android_get_default_charmap_name();
/* now set the events capability bits depending on hardware configuration */
/* apparently, the EV_SYN array is used to indicate which other
diff --git a/qemu-options.hx b/qemu-options.hx
index e67033a..ed89bc5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1619,4 +1619,8 @@ DEF("http-proxy", HAS_ARG, QEMU_OPTION_http_proxy, \
"-http-proxy <proxy>"
" make TCP connections through a HTTP/HTTPS proxy\n")
+DEF("charmap", HAS_ARG, QEMU_OPTION_charmap, \
+ "-charmap <file>"
+ " use specific key character map\n")
+
#endif
diff --git a/vl-android.c b/vl-android.c
index 1673426..ea40275 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -186,7 +186,7 @@
unsigned long android_verbose;
#endif // CONFIG_STANDALONE_CORE
-#ifdef CONFIG_SKINS
+#if defined(CONFIG_SKINS) && !defined(CONFIG_STANDALONE_CORE)
#undef main
#define main qemu_main
#endif
@@ -334,6 +334,8 @@ extern char* android_op_ports;
extern char* android_op_port;
extern char* android_op_report_console;
extern char* op_http_proxy;
+// Path to the file containing specific key character map.
+char* op_charmap_file = NULL;
extern void dprint( const char* format, ... );
@@ -5740,10 +5742,27 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_http_proxy:
op_http_proxy = (char*)optarg;
break;
+
+ case QEMU_OPTION_charmap:
+ op_charmap_file = (char*)optarg;
+ break;
}
}
}
+ /* Initialize character map. */
+ if (android_charmap_setup(op_charmap_file)) {
+ if (op_charmap_file) {
+ fprintf(stderr,
+ "Unable to initialize character map from file %s.\n",
+ op_charmap_file);
+ } else {
+ fprintf(stderr,
+ "Unable to initialize default character map.\n");
+ }
+ exit(1);
+ }
+
/* If no data_dir is specified then try to find it relative to the
executable path. */
if (!data_dir) {