blob: 102d4e40b08de5845ca28184f7e1cc2335e14943 [file] [log] [blame]
David 'Digit' Turnerf8456272011-02-02 12:34:14 +01001/* 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' Turner74d7ace2011-02-02 13:21:03 +010018#include "android/config.h"
David 'Digit' Turner2507cab2011-02-10 16:29:17 +010019#include "android/avd/hw-config.h"
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010020
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' Turner755811e2011-02-07 13:38:25 +010026void user_config_init( void );
27void user_config_done( void );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010028
David 'Digit' Turner755811e2011-02-07 13:38:25 +010029void user_config_get_window_pos( int *window_x, int *window_y );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010030
31#define ONE_MB (1024*1024)
32
33unsigned convertBytesToMB( uint64_t size );
34uint64_t convertMBToBytes( unsigned megaBytes );
35
36extern SkinKeyset* android_keyset;
37void parse_keyset(const char* keyset, AndroidOptions* opts);
38void write_default_keyset( void );
39
40extern const char* skin_network_speed;
41extern const char* skin_network_delay;
42
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010043/* Find the skin corresponding to our options, and return an AConfig pointer
44 * and the base path to load skin data from
45 */
46void parse_skin_files(const char* skinDirPath,
47 const char* skinName,
48 AndroidOptions* opts,
David 'Digit' Turner2507cab2011-02-10 16:29:17 +010049 AndroidHwConfig* hwConfig,
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010050 AConfig* *skinConfig,
51 char* *skinPath);
52
53/* Returns the amount of pixels used by the default display. */
54int64_t get_screen_pixels(AConfig* skinConfig);
55
56void init_sdl_ui(AConfig* skinConfig,
57 const char* skinPath,
58 AndroidOptions* opts);
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010059
Vladimir Chtchetkine83ffd662011-02-11 12:40:59 -080060/* Creates and initializes AvdInfo instance for the given options.
61 * Param:
62 * opts - Options passed to the main()
63 * inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from
64 * AVD file, or 1 if AvdInfo has been initialized from the build directory.
65 * Return:
66 * AvdInfo instance initialized for the given options.
67 */
68struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild);
69
70/* Updates hardware configuration for the given AVD and options.
71 * Param:
72 * hwConfig - Hardware configuration to update.
73 * avd - AVD info containig paths for the hardware configuration.
74 * opts - Options passed to the main()
75 * inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD
76 * has been initialized from the build directory.
77 */
78void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd,
79 AndroidOptions* opts, int inAndroidBuild);
80
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010081#endif /* ANDROID_MAIN_COMMON_H */