AndroidMTSPort* mts_port_create(void* opaque) { AndroidMTSPort* mtsp; ANEW0(mtsp); mtsp->opaque = opaque; /* Initialize default MTS descriptor. */ multitouch_init(mtsp); /* Create JPEG compressor. Put message header + MTFrameHeader in front of the * compressed data. this way we will have entire query ready to be * transmitted to the device. */ mtsp->jpeg_compressor = jpeg_compressor_create(sdkctl_message_get_header_size() + sizeof(MTFrameHeader), 4096); mtsp->sdkctl = sdkctl_socket_new(SDKCTL_MT_TIMEOUT, "multi-touch", _on_multitouch_socket_connection, _on_multitouch_port_connection, _on_multitouch_message, mtsp); sdkctl_init_recycler(mtsp->sdkctl, 64, 8); /* Create a direct packet that will wrap up framebuffer updates. Note that * we need to do this after we have initialized the recycler! */ mtsp->fb_packet = sdkctl_direct_packet_new(mtsp->sdkctl); /* Now we can initiate connection witm MT port on the device. */ sdkctl_socket_connect(mtsp->sdkctl, SDKCTL_DEFAULT_TCP_PORT, SDKCTL_MT_TIMEOUT); return mtsp; }
/* allocate a new QemudClient object */ static QemudClient* qemud_client_alloc( int channel_id, void* clie_opaque, QemudClientRecv clie_recv, QemudClientClose clie_close, QemudSerial* serial, QemudClient** pclients ) { QemudClient* c; ANEW0(c); c->serial = serial; c->channel = channel_id; c->clie_opaque = clie_opaque; c->clie_recv = clie_recv; c->clie_close = clie_close; c->framing = 0; c->need_header = 1; qemud_sink_reset(c->header, FRAME_HEADER_SIZE, c->header0); qemud_client_prepend(c, pclients); return c; }
AvdInfo* avdInfo_newForAndroidBuild( const char* androidBuildRoot, const char* androidOut, AvdInfoParams* params ) { AvdInfo* i; ANEW0(i); i->inAndroidBuild = 1; i->androidBuildRoot = ASTRDUP(androidBuildRoot); i->androidOut = ASTRDUP(androidOut); i->contentPath = ASTRDUP(androidOut); i->targetArch = path_getBuildTargetArch(i->androidOut); i->apiLevel = path_getBuildTargetApiLevel(i->androidOut); /* TODO: find a way to provide better information from the build files */ i->deviceName = ASTRDUP("<build>"); /* There is no config.ini in the build */ i->configIni = NULL; if (_avdInfo_getCoreHwIniPath(i, i->androidOut) < 0 ) goto FAIL; /* Read the build skin's hardware.ini, if any */ _avdInfo_getBuildSkinHardwareIni(i); return i; FAIL: avdInfo_free(i); return NULL; }
static SkinKeyboard* skin_keyboard_create_from_charmap_name(const char* charmap_name, int use_raw_keys, SkinKeyCodeFlushFunc keycode_flush) { SkinKeyboard* kb; ANEW0(kb); kb->charmap = skin_charmap_get_by_name(charmap_name); if (!kb->charmap) { // Charmap name was not found. Default to "qwerty2" */ kb->charmap = skin_charmap_get_by_name(DEFAULT_ANDROID_CHARMAP); fprintf(stderr, "### warning, skin requires unknown '%s' charmap, reverting to '%s'\n", charmap_name, kb->charmap->name ); } kb->raw_keys = use_raw_keys; kb->enabled = 0; /* add default keyset */ if (skin_keyset_get_default()) { kb->kset = skin_keyset_get_default(); } else { kb->kset = skin_keyset_new_from_text( skin_keyset_get_default_text()); } skin_keycodes_buffer_init(kb->keycodes, keycode_flush); return kb; }
static SkinKeyboard* skin_keyboard_create_from_charmap_name(const char* charmap_name, int use_raw_keys) { SkinKeyboard* kb; ANEW0(kb); kb->charmap = android_get_charmap_by_name(charmap_name); if (!kb->charmap) { // Charmap name was not found. Default to the first charmap in the array. kb->charmap = android_get_charmap_by_index(0); fprintf(stderr, "### warning, skin requires unknown '%s' charmap, reverting to '%s'\n", charmap_name, kb->charmap->name ); } kb->raw_keys = use_raw_keys; kb->enabled = 0; /* add default keyset */ if (android_keyset) kb->kset = android_keyset; else kb->kset = skin_keyset_new_from_text( skin_keyset_get_default() ); return kb; }
AsyncSocketConnector* async_socket_connector_new(const SockAddress* address, int retry_to, asc_event_cb cb, void* cb_opaque, Looper* looper) { AsyncSocketConnector* connector; if (cb == NULL) { W("No callback for AsyncSocketConnector for socket '%s'", sock_address_to_string(address)); errno = EINVAL; return NULL; } ANEW0(connector); connector->fd = -1; connector->retry_to = retry_to; connector->on_connected_cb = cb; connector->on_connected_cb_opaque = cb_opaque; connector->ref_count = 1; /* Copy socket address. */ #ifdef _WIN32 connector->address = *address; #else if (sock_address_get_family(address) == SOCKET_UNIX) { sock_address_init_unix(&connector->address, sock_address_get_path(address)); } else { connector->address = *address; } #endif /* Create a looper for asynchronous I/O. */ if (looper == NULL) { connector->looper = looper_newCore(); if (connector->looper == NULL) { E("Unable to create I/O looper for AsyncSocketConnector for socket '%s'", _asc_socket_string(connector)); cb(cb_opaque, connector, ASIO_STATE_FAILED); _async_socket_connector_free(connector); return NULL; } connector->owns_looper = 1; } else { connector->looper = looper; connector->owns_looper = 0; } /* Create a timer that will be used for connection retries. */ loopTimer_init(connector->connector_timer, connector->looper, _on_async_socket_connector_retry, connector); T("ASC %s: New connector object", _asc_socket_string(connector)); return connector; }
static Pipe* pipe_new0(PipeDevice* dev) { Pipe* pipe; ANEW0(pipe); pipe->device = dev; return pipe; }
static QEMUClock *qemu_new_clock(int type) { QEMUClock *clock; ANEW0(clock); clock->type = type; clock->enabled = 1; return clock; }
static IniFile* iniFile_alloc( void ) { IniFile* i; ANEW0(i); return i; }
/* Allocates AdbDbgClient instance. */ static AdbDbgClient* _adb_dbg_client_new(void) { AdbDbgClient* adb_dbg_client; ANEW0(adb_dbg_client); return adb_dbg_client; }
SkinUI* skin_ui_create(SkinFile* layout_file, const char* initial_orientation, const SkinUIFuncs* ui_funcs, const SkinUIParams* ui_params) { SkinUI* ui; ANEW0(ui); ui->layout_file = layout_file; ui->layout = skin_file_select_layout(layout_file->layouts, initial_orientation); ui->ui_funcs = ui_funcs; ui->ui_params = ui_params[0]; ui->keyboard = skin_keyboard_create(ui->ui_params.keyboard_charmap, ui->ui_params.keyboard_raw_keys, ui_funcs->keyboard_flush); ui->window = NULL; skin_keyboard_enable(ui->keyboard, 1); skin_keyboard_on_command(ui->keyboard, _skin_ui_handle_key_command, ui); ui->window = skin_window_create(ui->layout, ui->ui_params.window_x, ui->ui_params.window_y, ui->ui_params.window_scale, 0, ui->ui_funcs->window_funcs); if (!ui->window) { skin_ui_free(ui); return NULL; } if (ui->ui_params.enable_trackball) { ui->trackball = skin_trackball_create(ui->ui_funcs->trackball_params); skin_window_set_trackball(ui->window, ui->trackball); } ui->lcd_brightness = 128; /* 50% */ skin_window_set_lcd_brightness(ui->window, ui->lcd_brightness ); if (ui->onion) { skin_window_set_onion(ui->window, ui->onion, ui->onion_rotation, ui->onion_alpha); } skin_ui_reset_title(ui); skin_window_enable_touch(ui->window, ui->ui_params.enable_touch); skin_window_enable_dpad(ui->window, ui->ui_params.enable_dpad); skin_window_enable_qwerty(ui->window, ui->ui_params.enable_keyboard); skin_window_enable_trackball(ui->window, ui->ui_params.enable_trackball); return ui; }
void* pipeConnector_new(Pipe* pipe) { PipeConnector* pcon; ANEW0(pcon); pcon->pipe = pipe; pipe->funcs = &pipeConnector_funcs; return pcon; }
static void* pingPongPipe_init( void* hwpipe, void* svcOpaque, const char* args ) { PingPongPipe* ppipe; D("%s: hwpipe=%p", __FUNCTION__, hwpipe); ANEW0(ppipe); pingPongPipe_init0(ppipe, hwpipe, svcOpaque); return ppipe; }
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) { QEMUTimer *ts; ANEW0(ts); ts->clock = clock; ts->cb = cb; ts->opaque = opaque; return ts; }
static void* zeroPipe_init( void* hwpipe, void* svcOpaque, const char* args ) { ZeroPipe* zpipe; D("%s: hwpipe=%p", __FUNCTION__, hwpipe); ANEW0(zpipe); zpipe->hwpipe = hwpipe; return zpipe; }
/* Creates and initializes a new AdbGuest instance. */ static AdbGuest* _adb_guest_new(AdbServer* adb_srv) { AdbGuest* adb_guest; ANEW0(adb_guest); alist_init(&adb_guest->list_entry); adb_guest->adb_srv = adb_srv; return adb_guest; }
/* Creates and initializes a new AdbHost instance. */ static AdbHost* _adb_host_new(AdbServer* adb_srv) { AdbHost* adb_host; ANEW0(adb_host); alist_init(&adb_host->list_entry); adb_host->adb_srv = adb_srv; adb_host->host_so = -1; return adb_host; }
/* Allocates an instance of LinuxCameraDevice structure. * Return: * Allocated instance of LinuxCameraDevice structure. Note that this routine * also sets 'opaque' field in the 'header' structure to point back to the * containing LinuxCameraDevice instance. */ static LinuxCameraDevice* _camera_device_alloc(void) { LinuxCameraDevice* cd; ANEW0(cd); memset(cd, 0, sizeof(*cd)); cd->header.opaque = cd; cd->handle = -1; return cd; }
static void* throttlePipe_init( void* hwpipe, void* svcOpaque, const char* args ) { ThrottlePipe* pipe; ANEW0(pipe); pingPongPipe_init0(&pipe->pingpong, hwpipe, svcOpaque); pipe->timer = timer_new(QEMU_CLOCK_VIRTUAL, SCALE_NS, throttlePipe_timerFunc, pipe); /* For now, limit to 500 KB/s in both directions */ pipe->sendRate = 1e9 / (500*1024*8); pipe->recvRate = pipe->sendRate; return pipe; }
AIntMap* aintMap_new(void) { AIntMap* map; ANEW0(map); map->size = 0; map->capacity = 4; map->keys = map->keys0; map->values = map->values0; return map; }
static void* throttlePipe_init( void* hwpipe, void* svcOpaque, const char* args ) { ThrottlePipe* pipe; ANEW0(pipe); pingPongPipe_init0(&pipe->pingpong, hwpipe, svcOpaque); pipe->timer = qemu_new_timer_ns(vm_clock, throttlePipe_timerFunc, pipe); pipe->sendRate = 1e9 / (500*1024*8); pipe->recvRate = pipe->sendRate; return pipe; }
SkinTrackBall* skin_trackball_create ( SkinTrackBallParameters* params ) { TrackBall ball; ANEW0(ball); trackball_init( ball, params->diameter, params->ring, params->ball_color, params->dot_color, params->ring_color ); return ball; }
AvdInfo* avdInfo_new( const char* name, AvdInfoParams* params ) { AvdInfo* i; if (name == NULL) return NULL; if (!_checkAvdName(name)) { derror("virtual device name contains invalid characters"); exit(1); } ANEW0(i); i->deviceName = ASTRDUP(name); if ( _avdInfo_getSdkRoot(i) < 0 || _avdInfo_getRootIni(i) < 0 || _avdInfo_getContentPath(i) < 0 || _avdInfo_getConfigIni(i) < 0 || _avdInfo_getCoreHwIniPath(i, i->contentPath) < 0 ) goto FAIL; i->apiLevel = _avdInfo_getApiLevel(i); // Add for device target infromation. _getContentTarget(i); /* look for image search paths. handle post 1.1/pre cupcake * obsolete SDKs. */ _avdInfo_getSearchPaths(i); // Find the build.prop and boot.prop files and read them. _avdInfo_getPropertyFile(i, "build.prop", i->buildProperties); _avdInfo_getPropertyFile(i, "boot.prop", i->bootProperties); _avdInfo_extractBuildProperties(i); /* don't need this anymore */ iniFile_free(i->rootIni); i->rootIni = NULL; return i; FAIL: avdInfo_free(i); return NULL; }
AvdInfo* avdInfo_newForAndroidBuild( const char* androidBuildRoot, const char* androidOut, AvdInfoParams* params ) { AvdInfo* i; ANEW0(i); i->inAndroidBuild = 1; i->androidBuildRoot = ASTRDUP(androidBuildRoot); i->androidOut = ASTRDUP(androidOut); i->contentPath = ASTRDUP(androidOut); // Find the build.prop file and read it. char* buildPropPath = path_getBuildBuildProp(i->androidOut); if (buildPropPath) { _avdInfo_readPropertyFile(i, buildPropPath, i->buildProperties); free(buildPropPath); } // FInd the boot.prop file and read it. char* bootPropPath = path_getBuildBootProp(i->androidOut); if (bootPropPath) { _avdInfo_readPropertyFile(i, bootPropPath, i->bootProperties); free(bootPropPath); } _avdInfo_extractBuildProperties(i); i->deviceName = ASTRDUP("<build>"); /* out/target/product/<name>/config.ini, if exists, provide configuration * from build files. */ if (_avdInfo_getConfigIni(i) < 0 || _avdInfo_getCoreHwIniPath(i, i->androidOut) < 0) goto FAIL; /* Read the build skin's hardware.ini, if any */ _avdInfo_getBuildSkinHardwareIni(i); return i; FAIL: avdInfo_free(i); return NULL; }
void multitouch_init(AndroidMTSPort* mtsp) { if (!_is_mt_initialized) { MTSState* const mts_state = &_MTSState; DisplayState* const ds = get_displaystate(); DisplayUpdateListener* dul; int index; /* * Initialize the descriptor. */ memset(mts_state, 0, sizeof(MTSState)); mts_state->tracked_ptr_num = 0; mts_state->current_slot = -1; for (index = 0; index < MTS_POINTERS_NUM; index++) { mts_state->tracked_pointers[index].tracking_id = MTS_POINTER_UP; } mts_state->mtsp = mtsp; mts_state->fb_header.header_size = sizeof(MTFrameHeader); mts_state->fb_transfer_in_progress = 0; /* * Set framebuffer update listener. */ ANEW0(dul); dul->opaque = &_MTSState; dul->dpy_update = _mt_fb_update; /* Initialize framebuffer information in the screen descriptor. */ mts_state->ds = ds; mts_state->fb_header.disp_width = ds->surface->width; mts_state->fb_header.disp_height = ds->surface->height; mts_state->fb_header.x = mts_state->fb_header.y = 0; mts_state->fb_header.w = mts_state->fb_header.h = 0; mts_state->fb_header.bpp = ds->surface->pf.bytes_per_pixel; mts_state->fb_header.bpl = ds->surface->linesize; mts_state->fb_transfer_in_progress = 0; register_displayupdatelistener(ds, dul); _is_mt_initialized = 1; } }
static HwSensorClient* _hwSensorClient_new( HwSensors* sensors ) { HwSensorClient* cl; ANEW0(cl); cl->sensors = sensors; cl->enabledMask = 0; cl->delay_ms = 800; cl->timer = timer_new(QEMU_CLOCK_VIRTUAL, SCALE_NS, _hwSensorClient_tick, cl); cl->next = sensors->clients; sensors->clients = cl; return cl; }
static HwSensorClient* _hwSensorClient_new( HwSensors* sensors ) { HwSensorClient* cl; ANEW0(cl); cl->sensors = sensors; cl->enabledMask = 0; cl->delay_ms = 800; cl->timer = qemu_new_timer_ns(vm_clock, _hwSensorClient_tick, cl); cl->next = sensors->clients; sensors->clients = cl; return cl; }
static void glooper_timer_init(Looper* looper, LoopTimer* timer, LoopTimerFunc callback, void* opaque) { GLoopTimer* tt; ANEW0(tt); tt->deadline = DURATION_INFINITE; tt->callback = callback; tt->opaque = opaque; tt->looper = (GLooper*) looper; glooper_addTimer(tt->looper, tt); timer->impl = tt; timer->clazz = (LoopTimerClass*) &glooptimer_class; }
static void glooper_io_init(Looper* looper, LoopIo* user, int fd, LoopIoFunc callback, void* opaque) { GLooper* gg = (GLooper*)looper; GLoopIo* io; ANEW0(io); io->fd = fd; io->callback = callback; io->opaque = opaque; io->looper = (GLooper*) looper; io->wanted = 0; io->ready = 0; socket_set_nonblock(fd); glooper_addIo(gg, io); user->impl = io; user->clazz = (LoopIoClass*) &gloopio_class; }
AvdInfo* avdInfo_new( const char* name, AvdInfoParams* params ) { AvdInfo* i; if (name == NULL) return NULL; if (!_checkAvdName(name)) { derror("virtual device name contains invalid characters"); exit(1); } ANEW0(i); i->deviceName = ASTRDUP(name); if ( _avdInfo_getSdkRoot(i) < 0 || _avdInfo_getRootIni(i) < 0 || _avdInfo_getContentPath(i) < 0 || _avdInfo_getConfigIni(i) < 0 || _avdInfo_getCoreHwIniPath(i, i->contentPath) < 0 ) goto FAIL; i->apiLevel = _avdInfo_getApiLevel(i); /* look for image search paths. handle post 1.1/pre cupcake * obsolete SDKs. */ _avdInfo_getSearchPaths(i); /* don't need this anymore */ iniFile_free(i->rootIni); i->rootIni = NULL; return i; FAIL: avdInfo_free(i); return NULL; }