David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 1 | /* Copyright (C) 2011 The Android Open Source Project |
| 2 | ** |
| 3 | ** This software is licensed under the terms of the GNU General Public |
| 4 | ** License version 2, as published by the Free Software Foundation, and |
| 5 | ** may be copied, distributed, and modified under those terms. |
| 6 | ** |
| 7 | ** This program is distributed in the hope that it will be useful, |
| 8 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | ** GNU General Public License for more details. |
| 11 | */ |
| 12 | #ifndef ANDROID_MAIN_COMMON_H |
| 13 | #define ANDROID_MAIN_COMMON_H |
| 14 | |
| 15 | #include <stdint.h> |
| 16 | #include "android/cmdline-option.h" |
| 17 | #include "android/skin/keyset.h" |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 18 | #include "android/config.h" |
David 'Digit' Turner | 2507cab | 2011-02-10 16:29:17 +0100 | [diff] [blame] | 19 | #include "android/avd/hw-config.h" |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 20 | |
| 21 | /* Common routines used by both android/main.c and android/main-ui.c */ |
| 22 | |
| 23 | /** Emulator user configuration (e.g. last window position) |
| 24 | **/ |
| 25 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 26 | void user_config_init( void ); |
| 27 | void user_config_done( void ); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 28 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 29 | void user_config_get_window_pos( int *window_x, int *window_y ); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 30 | |
| 31 | #define ONE_MB (1024*1024) |
| 32 | |
| 33 | unsigned convertBytesToMB( uint64_t size ); |
| 34 | uint64_t convertMBToBytes( unsigned megaBytes ); |
| 35 | |
| 36 | extern SkinKeyset* android_keyset; |
| 37 | void parse_keyset(const char* keyset, AndroidOptions* opts); |
| 38 | void write_default_keyset( void ); |
| 39 | |
David 'Digit' Turner | 092361e | 2011-03-01 13:14:18 +0100 | [diff] [blame] | 40 | #define NETWORK_SPEED_DEFAULT "full" |
| 41 | #define NETWORK_DELAY_DEFAULT "none" |
| 42 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 43 | extern const char* skin_network_speed; |
| 44 | extern const char* skin_network_delay; |
| 45 | |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 46 | /* Find the skin corresponding to our options, and return an AConfig pointer |
| 47 | * and the base path to load skin data from |
| 48 | */ |
| 49 | void parse_skin_files(const char* skinDirPath, |
| 50 | const char* skinName, |
| 51 | AndroidOptions* opts, |
David 'Digit' Turner | 2507cab | 2011-02-10 16:29:17 +0100 | [diff] [blame] | 52 | AndroidHwConfig* hwConfig, |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 53 | AConfig* *skinConfig, |
| 54 | char* *skinPath); |
| 55 | |
| 56 | /* Returns the amount of pixels used by the default display. */ |
| 57 | int64_t get_screen_pixels(AConfig* skinConfig); |
| 58 | |
| 59 | void init_sdl_ui(AConfig* skinConfig, |
| 60 | const char* skinPath, |
| 61 | AndroidOptions* opts); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 62 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame^] | 63 | /* Sanitize options. This deals with a few legacy options that are now |
| 64 | * handled differently. Call before anything else that needs to read |
| 65 | * the options list. |
| 66 | */ |
| 67 | void sanitizeOptions( AndroidOptions* opts ); |
| 68 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 69 | /* Creates and initializes AvdInfo instance for the given options. |
| 70 | * Param: |
| 71 | * opts - Options passed to the main() |
| 72 | * inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from |
| 73 | * AVD file, or 1 if AvdInfo has been initialized from the build directory. |
| 74 | * Return: |
| 75 | * AvdInfo instance initialized for the given options. |
| 76 | */ |
| 77 | struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild); |
| 78 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame^] | 79 | /* Populate the hwConfig fields corresponding to the kernel/disk images |
| 80 | * used by the emulator. This will zero *hwConfig first. |
| 81 | */ |
| 82 | void findImagePaths( AndroidHwConfig* hwConfig, |
| 83 | AndroidOptions* opts ); |
| 84 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 85 | /* Updates hardware configuration for the given AVD and options. |
| 86 | * Param: |
| 87 | * hwConfig - Hardware configuration to update. |
| 88 | * avd - AVD info containig paths for the hardware configuration. |
| 89 | * opts - Options passed to the main() |
| 90 | * inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD |
| 91 | * has been initialized from the build directory. |
| 92 | */ |
| 93 | void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd, |
| 94 | AndroidOptions* opts, int inAndroidBuild); |
| 95 | |
David 'Digit' Turner | bdb6f2d | 2011-02-23 15:57:25 +0100 | [diff] [blame] | 96 | /* Called from android/main.c to handle options specific to the standalone |
| 97 | * UI program. This is a no-op otherwise. |
| 98 | */ |
| 99 | void handle_ui_options( AndroidOptions* opts ); |
| 100 | |
| 101 | /* Called from android/main.c to potentially attach to a core from the |
| 102 | * standalone UI program. This is a no-op otherwise. |
| 103 | */ |
| 104 | int attach_ui_to_core( AndroidOptions* opts ); |
| 105 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 106 | #endif /* ANDROID_MAIN_COMMON_H */ |