From 863d1010d9c8fa4342b1b0ea860bcfb096806acc Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Fri, 16 Mar 2012 12:25:23 -0700 Subject: Cleanup harware properties. 1. Remove unused hw.camera.maxHorizontalPixels, and hw.camera.maxVerticalPixels parameters. 2. Combine hw.touchScreen, and hw.multiTouch under one property: hw.screen Change-Id: I3cdf64f7d7e46486110cbc0769f9d98a61f0bea5 --- android/avd/hardware-properties.ini | 29 ++++++----------------------- android/avd/hw-config.c | 18 ++++++++++++++++++ android/avd/hw-config.h | 7 +++++++ android/help.c | 2 +- android/main.c | 26 ++++++++------------------ android/qemulator.c | 4 ++-- hw/goldfish_events_device.c | 12 ++++++------ vl-android.c | 2 +- 8 files changed, 49 insertions(+), 51 deletions(-) diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 241bf54..fdabcb5 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -46,19 +46,12 @@ default = 0 abstract = Device ram size description = The amount of physical RAM on the device, in megabytes. -# Touch screen support -name = hw.touchScreen -type = boolean -default = yes -abstract = Touch-screen support -description = Whether there is a touch screen or not on the device. - -# Multi-touch screen support -name = hw.multiTouch -type = boolean -default = no -abstract = Multi-touch screen support -description = Whether there is a multi-touch screen or not on the device. +# Touch screen type +name = hw.screen +type = string +default = touch +abstract = Touch screen type +description = Defines type of the screen. Can be 'touch', 'multi-touch', or 'no-touch'. # Hardware main keys (back/home) name = hw.mainKeys @@ -128,16 +121,6 @@ default = yes abstract = Camera support description = Whether the device has a camera. -name = hw.camera.maxHorizontalPixels -type = integer -default = 640 -abstract = Maximum horizontal camera pixels - -name = hw.camera.maxVerticalPixels -type = integer -default = 480 -abstract = Maximum vertical camera pixels - # GPS support name = hw.gps type = boolean diff --git a/android/avd/hw-config.c b/android/avd/hw-config.c index 65796d9..2d50ef7 100644 --- a/android/avd/hw-config.c +++ b/android/avd/hw-config.c @@ -125,3 +125,21 @@ androidHwConfig_done( AndroidHwConfig* config ) #include "android/avd/hw-config-defs.h" } + +int +androidHwConfig_isScreenNoTouch( AndroidHwConfig* config ) +{ + return strcmp(config->hw_screen, "no-touch") == 0; +} + +int +androidHwConfig_isScreenTouch( AndroidHwConfig* config ) +{ + return strcmp(config->hw_screen, "touch") == 0; +} + +int +androidHwConfig_isScreenMultiTouch( AndroidHwConfig* config ) +{ + return strcmp(config->hw_screen, "multi-touch") == 0; +} diff --git a/android/avd/hw-config.h b/android/avd/hw-config.h index 3c2480a..fd99e45 100644 --- a/android/avd/hw-config.h +++ b/android/avd/hw-config.h @@ -57,4 +57,11 @@ int androidHwConfig_write( AndroidHwConfig* hwConfig, /* Finalize a given hardware configuration */ void androidHwConfig_done( AndroidHwConfig* config ); +/* Checks if screen doesn't support touch, or multi-touch */ +int androidHwConfig_isScreenNoTouch( AndroidHwConfig* config ); +/* Checks if screen supports touch (but not multi-touch). */ +int androidHwConfig_isScreenTouch( AndroidHwConfig* config ); +/* Checks if screen supports multi-touch. */ +int androidHwConfig_isScreenMultiTouch( AndroidHwConfig* config ); + #endif /* _ANDROID_AVD_HW_CONFIG_H */ diff --git a/android/help.c b/android/help.c index db46d21..db630e0 100644 --- a/android/help.c +++ b/android/help.c @@ -1497,7 +1497,7 @@ help_screen(stralloc_t* out) " touch -> emulate a touch screen\n" " multi-touch -> emulate a multi-touch screen\n" - " off -> disable touch and multi-touch screen emulation\n\n" + " no-touch -> disable touch and multi-touch screen emulation\n\n" " Default mode for screen emulation is 'touch'.\n\n" ); diff --git a/android/main.c b/android/main.c index 5aaf65e..f8ad54b 100644 --- a/android/main.c +++ b/android/main.c @@ -1273,26 +1273,16 @@ int main(int argc, char **argv) /* Setup screen emulation */ if (opts->screen) { - if (!strcmp(opts->screen, "touch")) { - hw->hw_touchScreen = 1; - hw->hw_multiTouch = 0; - } else if (!strcmp(opts->screen, "multi-touch")) { - hw->hw_multiTouch = 1; - hw->hw_touchScreen = 0; - } else if (!strcmp(opts->screen, "off")) { - hw->hw_touchScreen = 0; - hw->hw_multiTouch = 0; - } else { - derror("Invalid value for -screen parameter: %s\n", opts->screen); - derror("Valid values are: touch, multi-touch, or off\n"); + if (strcmp(opts->screen, "touch") && + strcmp(opts->screen, "multi-touch") && + strcmp(opts->screen, "no-touch")) { + + derror("Invalid value for -screen parameter: %s\n" + "Valid values are: touch, multi-touch, or no-touch\n", + opts->screen); exit(1); } - } else { - /* If both, touch and multitouch are set in hw.ini, choose multi-touch - * for screen emulation. */ - if (hw->hw_touchScreen && hw->hw_multiTouch) { - hw->hw_touchScreen = 0; - } + hw->hw_screen = ASTRDUP(opts->screen); } while(argc-- > 0) { diff --git a/android/qemulator.c b/android/qemulator.c index cd97510..eb3b59e 100644 --- a/android/qemulator.c +++ b/android/qemulator.c @@ -81,8 +81,8 @@ qemulator_setup( QEmulator* emulator ) qemulator_set_title(emulator); - skin_window_enable_touch ( emulator->window, android_hw->hw_touchScreen != 0 || - android_hw->hw_multiTouch != 0); + skin_window_enable_touch ( emulator->window, + !androidHwConfig_isScreenNoTouch(android_hw)); skin_window_enable_dpad ( emulator->window, android_hw->hw_dPad != 0 ); skin_window_enable_qwerty( emulator->window, android_hw->hw_keyboard != 0 ); skin_window_enable_trackball( emulator->window, android_hw->hw_trackBall != 0 ); diff --git a/hw/goldfish_events_device.c b/hw/goldfish_events_device.c index 83e9fdf..0aa5a1f 100644 --- a/hw/goldfish_events_device.c +++ b/hw/goldfish_events_device.c @@ -271,11 +271,11 @@ static void events_put_mouse(void *opaque, int dx, int dy, int dz, int buttons_s * in android/skin/trackball.c and android/skin/window.c */ if (dz == 0) { - if (android_hw->hw_multiTouch) { + if (androidHwConfig_isScreenMultiTouch(android_hw)) { /* Convert mouse event into multi-touch event */ multitouch_update_pointer(MTES_MOUSE, 0, dx, dy, (buttons_state & 1) ? 0x81 : 0); - } else if (android_hw->hw_touchScreen) { + } else if (androidHwConfig_isScreenTouch(android_hw)) { enqueue_event(s, EV_ABS, ABS_X, dx); enqueue_event(s, EV_ABS, ABS_Y, dy); enqueue_event(s, EV_ABS, ABS_Z, dz); @@ -402,7 +402,7 @@ void events_dev_init(uint32_t base, qemu_irq irq) if (config->hw_trackBall) { events_set_bit(s, EV_KEY, BTN_MOUSE); } - if (config->hw_touchScreen) { + if (androidHwConfig_isScreenTouch(config)) { events_set_bit(s, EV_KEY, BTN_TOUCH); } @@ -451,7 +451,7 @@ void events_dev_init(uint32_t base, qemu_irq irq) * * EV_ABS events are sent when the touchscreen is pressed */ - if (config->hw_touchScreen || config->hw_multiTouch) { + if (!androidHwConfig_isScreenNoTouch(config)) { ABSEntry* abs_values; events_set_bit (s, EV_SYN, EV_ABS ); @@ -468,7 +468,7 @@ void events_dev_init(uint32_t base, qemu_irq irq) * There is no need to save/restore this array in a snapshot * since the values only depend on the hardware configuration. */ - s->abs_info_count = config->hw_multiTouch ? ABS_MAX * 4 : 3 * 4; + s->abs_info_count = androidHwConfig_isScreenMultiTouch(config) ? ABS_MAX * 4 : 3 * 4; const int abs_size = sizeof(uint32_t) * s->abs_info_count; s->abs_info = malloc(abs_size); memset(s->abs_info, 0, abs_size); @@ -478,7 +478,7 @@ void events_dev_init(uint32_t base, qemu_irq irq) abs_values[ABS_Y].max = config->hw_lcd_height-1; abs_values[ABS_Z].max = 1; - if (config->hw_multiTouch) { + if (androidHwConfig_isScreenMultiTouch(config)) { /* * Setup multitouch. */ diff --git a/vl-android.c b/vl-android.c index b7d4bb9..ebff1eb 100644 --- a/vl-android.c +++ b/vl-android.c @@ -4260,7 +4260,7 @@ int main(int argc, char **argv, char **envp) cpu_model); /* Initialize multi-touch emulation. */ - if (android_hw->hw_multiTouch) { + if (androidHwConfig_isScreenMultiTouch(android_hw)) { mts_port_create(NULL); } -- cgit v1.1