예제 #1
0
static int _touch(struct device_info *dev, unsigned int x, unsigned y, int pts)
{
	char cmd[50] = {0};
	int i, retval;

	retval = check_boundary(dev, x, y);

	if(!retval){
		if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 100);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 100);
			exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH, DOWN);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
			;
		}

		for( i=0; i < pts; i++){
			if(i == 0 && dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC)
				exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 64);

			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_X, x);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_Y, y);
			event_end(dev->dev_touch, dev->dev_flag);
			usleep(dev->delay_us);
		}

		if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
			exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH ,UP);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 0);
			event_end(dev->dev_touch, dev->dev_flag);
			event_end(dev->dev_touch, dev->dev_flag);
			event_end(dev->dev_touch, dev->dev_flag);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
			event_end(dev->dev_touch, dev->dev_flag);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
			;
		}
	}else{
		printf("Error: Position is out of range\n");
	}

	return retval;
}
예제 #2
0
static int _slide(struct device_info *dev, enum action_type type)
{
	char cmd[50] = {0};
	int x = actions[type].start_x, y = actions[type].start_y;
	int off_x, off_y, i;

	if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 100);
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 100);
		exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH, DOWN);
	}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0);
	}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
		;
	}

	off_x = (actions[type].end_x - actions[type].start_x)/actions[type].num_pts;
	off_y = (actions[type].end_y - actions[type].start_y)/actions[type].num_pts;

	for( i=0; i < actions[type].num_pts; i++){
		if(i == 0 && dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC)
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 64);

		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_X, x);
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_Y, y);
		event_end(dev->dev_touch, dev->dev_flag);
		x = x + off_x;
		y = y + off_y;
		usleep(actions[type].delay_us);
	}

	if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
		exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH ,UP);
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 0);
		event_end(dev->dev_touch, dev->dev_flag);
		event_end(dev->dev_touch, dev->dev_flag);
		event_end(dev->dev_touch, dev->dev_flag);
	}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 0x21);
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_WIDTH_MAJOR, 0x21);
		event_end(dev->dev_touch, dev->dev_flag);
		exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
		event_end(dev->dev_touch, dev->dev_flag);
	}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
		;
	}

	return 0;
}
예제 #3
0
static int dm5_gaschange(void *param, int columns, char **data, char **column)
{
	UNUSED(columns);
	UNUSED(column);
	struct parser_state *state = (struct parser_state *)param;

	event_start(state);
	if (data[0])
		state->cur_event.time.seconds = atoi(data[0]);
	if (data[1]) {
		strcpy(state->cur_event.name, "gaschange");
		state->cur_event.value = lrint(strtod_flags(data[1], NULL, 0));
	}

	/* He part of the mix */
	if (data[2])
		state->cur_event.value += lrint(strtod_flags(data[2], NULL, 0)) << 16;
	event_end(state);

	return 0;
}
예제 #4
0
파일: main.c 프로젝트: malind/bam
/* *** */
static int bam(const char *scriptfile, const char **targets, int num_targets)
{
	struct CONTEXT context;
	int build_error = 0;
	int setup_error = 0;
	int report_done = 0;

	/* build time */
	time_t starttime  = time(0x0);

	/* create the cache and tmp directory */
	file_createdir(".bam");
	
	/* zero out and create memory heap, graph */
	memset(&context, 0, sizeof(struct CONTEXT));
	context.graphheap = mem_create();
	context.deferredheap = mem_create();
	context.graph = node_graph_create(context.graphheap);
	context.exit_on_error = option_abort_on_error;
	context.buildtime = timestamp();

	/* create lua context */
	/* HACK: Store the context pointer as the userdata pointer to the allocator to make
		sure that we have fast access to it. This makes the context_get_pointer call very fast */
	context.lua = lua_newstate(lua_alloctor_malloc, &context);

	/* install panic function */
	lua_atpanic(context.lua, lf_panicfunc);

	/* load cache (thread?) */
	if(option_no_cache == 0)
	{
		/* create a hash of all the external variables that can cause the
			script to generate different results */
		hash_t cache_hash = 0;
		char hashstr[64];
		int i;
		for(i = 0; i < option_num_scriptargs; i++)
			cache_hash = string_hash_add(cache_hash, option_scriptargs[i]);

		string_hash_tostr(cache_hash, hashstr);
		sprintf(cache_filename, ".bam/%s", hashstr);

		event_begin(0, "cache load", cache_filename);
		context.cache = cache_load(cache_filename);
		event_end(0, "cache load", NULL);
	}

	/* do the setup */
	setup_error = bam_setup(&context, scriptfile, targets, num_targets);

	/* done with the loopup heap */
	mem_destroy(context.deferredheap);

	/* close the lua state */
	lua_close(context.lua);
	
	/* do actions if we don't have any errors */
	if(!setup_error)
	{
		event_begin(0, "prepare", NULL);
		build_error = context_build_prepare(&context);
		event_end(0, "prepare", NULL);
		
		if(!build_error)
		{
			event_begin(0, "prioritize", NULL);
			build_error = context_build_prioritize(&context);
			event_end(0, "prioritize", NULL);
		}

		if(!build_error)
		{
			if(option_debug_nodes) /* debug dump all nodes */
				node_debug_dump(context.graph);
			else if(option_debug_nodes_detailed) /* debug dump all nodes detailed */
				node_debug_dump_detailed(context.graph);
			else if(option_debug_jobs) /* debug dump all jobs */
				node_debug_dump_jobs(context.graph);
			else if(option_debug_joblist) /* debug dumps the joblist */
				context_dump_joblist(&context);
			else if(option_debug_dot) /* debug dump all nodes as dot */
				node_debug_dump_dot(context.graph, context.target);
			else if(option_debug_jobs_dot) /* debug dump all jobs as dot */
				node_debug_dump_jobs_dot(context.graph, context.target);
			else if(option_dry)
			{
			}
			else
			{
				/* run build or clean */
				if(option_clean)
				{
					event_begin(0, "clean", NULL);
					build_error = context_build_clean(&context);
					event_end(0, "end", NULL);
				}
				else
				{
					event_begin(0, "build", NULL);
					build_error = context_build_make(&context);
					event_end(0, "build", NULL);
					report_done = 1;
				}
			}
		}
	}		

	/* save cache (thread?) */
	if(option_no_cache == 0 && setup_error == 0)
	{
		event_begin(0, "cache save", cache_filename);
		cache_save(cache_filename, context.graph);
		event_end(0, "cache save", NULL);
	}
	
	/* clean up */
	mem_destroy(context.graphheap);
	free(context.joblist);
	cache_free(context.cache);

	/* print final report and return */
	if(setup_error)
	{
		/* no error message on setup error, it reports fine itself */
		return setup_error;
	}
	else if(build_error)
		printf("%s: error: a build step failed\n", session.name);
	else if(report_done)
	{
		if(context.num_jobs == 0)
			printf("%s: targets are up to date already\n", session.name);
		else
		{
			time_t s = time(0x0) - starttime;
			if(s <= 1)
				printf("%s: done\n", session.name);
			else
				printf("%s: done (%d:%.2d)\n", session.name, (int)(s/60), (int)(s%60));
		}
	}

	return build_error;
}
예제 #5
0
파일: main.c 프로젝트: malind/bam
static int bam_setup(struct CONTEXT *context, const char *scriptfile, const char **targets, int num_targets)
{
	/* */	
	if(session.verbose)
		printf("%s: setup started\n", session.name);
	
	/* set filename */
	context->filename = scriptfile;
	
	/* set global timestamp to the script file */
	context->globaltimestamp = file_timestamp(scriptfile);

	/* */
	context->forced = option_force;
	
	/* fetch script directory */
	{
		char cwd[MAX_PATH_LENGTH];
		char path[MAX_PATH_LENGTH];

		if(!getcwd(cwd, sizeof(cwd)))
		{
			printf("%s: error: couldn't get current working directory\n", session.name);
			return -1;
		}
		
		if(path_directory(context->filename, path, sizeof(path)))
		{
			printf("%s: error: path too long '%s'\n", session.name, path);
			return -1;
		}
		
		if(path_join(cwd, -1, path, -1, context->script_directory, sizeof(context->script_directory)))
		{
			printf("%s: error: path too long when joining '%s' and '%s'\n", session.name, cwd, path);
			return -1;
		}
	}
	
	/* register all functions */
	event_begin(0, "lua setup", NULL);
	if(register_lua_globals(context->lua, context->script_directory, context->filename) != 0)
	{
		printf("%s: error: registering of lua functions failed\n", session.name);
		return -1;
	}
	event_end(0, "lua setup", NULL);

	/* load script */	
	if(session.verbose)
		printf("%s: reading script from '%s'\n", session.name, scriptfile);

	event_begin(0, "script load", NULL);
	/* push error function to stack and load the script */
	lua_getglobal(context->lua, "errorfunc");
	switch(luaL_loadfile(context->lua, scriptfile))
	{
		case 0: break;
		case LUA_ERRSYNTAX:
			lf_errorfunc(context->lua);
			return -1;
		case LUA_ERRMEM:
			printf("%s: memory allocation error\n", session.name);
			return -1;
		case LUA_ERRFILE:
			printf("%s: error opening '%s'\n", session.name, scriptfile);
			return -1;
		default:
			printf("%s: unknown error\n", session.name);
			return -1;
	}
	event_end(0, "script load", NULL);

	/* start the background stat thread */
	node_graph_start_statthread(context->graph);

	/* call the code chunk */
	event_begin(0, "script run", NULL);
	if(lua_pcall(context->lua, 0, LUA_MULTRET, -2) != 0)
	{
		node_graph_end_statthread(context->graph);
		printf("%s: script error (-t for more detail)\n", session.name);
		return -1;
	}
	event_end(0, "script run", NULL);

	/* stop the background stat thread */
	event_begin(0, "stat", NULL);
	node_graph_end_statthread(context->graph);
	event_end(0, "stat", NULL);
	
	/* run deferred functions */
	event_begin(0, "deferred cpp dependencies", NULL);
	if(run_deferred_functions(context, context->firstdeferred_cpp) != 0)
		return -1;
	event_end(0, "deferred cpp dependencies", NULL);
		
	event_begin(0, "deferred search dependencies", NULL);
	if(run_deferred_functions(context, context->firstdeferred_search) != 0)
		return -1;
	event_end(0, "deferred search dependencies", NULL);

	/* */	
	if(session.verbose)
		printf("%s: making build target\n", session.name);
	
	/* make build target */
	{
		struct NODE *node;
		int all_target = 0;
		int i;

		if(node_create(&context->target, context->graph, "_bam_buildtarget", NULL, TIMESTAMP_PSEUDO))
			return -1;

		if(num_targets)
		{
			/* search for all target */
			for(i = 0; i < num_targets; i++)
			{
				if(strcmp(targets[i], "all") == 0)
				{
					all_target = 1;
					break;
				}
			}
		}
		
		/* default too all if we have no targets or default target */
		if(num_targets == 0 && !context->defaulttarget)
			all_target = 1;
		
		if(all_target)
		{
			/* build the all target */
			for(node = context->graph->first; node; node = node->next)
			{
				if(node->firstparent == NULL && node != context->target)
				{
					if(!node_add_dependency (context->target, node))
						return -1;
				}
			}
		}
		else
		{
			if(num_targets)
			{
				for(i = 0; i < num_targets; i++)
				{
					struct NODE *node = node_find(context->graph, targets[i]);
					if(!node)
					{
						printf("%s: target '%s' not found\n", session.name, targets[i]);
						return -1;
					}
					
					if(option_dependent)
					{
						/* TODO: this should perhaps do a reverse walk up in the tree to
							find all dependent node with commandline */
						struct NODELINK *parent;
						for(parent = node->firstparent; parent; parent = parent->next)
						{
							if(!node_add_dependency (context->target, parent->node))
								return -1;
						}
								
					}
					else
					{
						if(!node_add_dependency (context->target, node))
							return -1;
					}
				}
			}
			else
			{
				if(!node_add_dependency (context->target, context->defaulttarget))
					return -1;
			}

		}
	}

	/* zero out the global timestamp if we don't want to use it */
	if(option_no_scripttimestamp)
		context->globaltimestamp = 0;

	/* */	
	if(session.verbose)
		printf("%s: setup done\n", session.name);
	
	/* return success */
	return 0;
}
예제 #6
0
static int dm4_events(void *param, int columns, char **data, char **column)
{
	UNUSED(columns);
	UNUSED(column);
	struct parser_state *state = (struct parser_state *)param;

	event_start(state);
	if (data[1])
		state->cur_event.time.seconds = atoi(data[1]);

	if (data[2]) {
		switch (atoi(data[2])) {
		case 1:
			/* 1 Mandatory Safety Stop */
			strcpy(state->cur_event.name, "safety stop (mandatory)");
			break;
		case 3:
			/* 3 Deco */
			/* What is Subsurface's term for going to
				 * deco? */
			strcpy(state->cur_event.name, "deco");
			break;
		case 4:
			/* 4 Ascent warning */
			strcpy(state->cur_event.name, "ascent");
			break;
		case 5:
			/* 5 Ceiling broken */
			strcpy(state->cur_event.name, "violation");
			break;
		case 6:
			/* 6 Mandatory safety stop ceiling error */
			strcpy(state->cur_event.name, "violation");
			break;
		case 7:
			/* 7 Below deco floor */
			strcpy(state->cur_event.name, "below floor");
			break;
		case 8:
			/* 8 Dive time alarm */
			strcpy(state->cur_event.name, "divetime");
			break;
		case 9:
			/* 9 Depth alarm */
			strcpy(state->cur_event.name, "maxdepth");
			break;
		case 10:
		/* 10 OLF 80% */
		case 11:
			/* 11 OLF 100% */
			strcpy(state->cur_event.name, "OLF");
			break;
		case 12:
			/* 12 High pO₂ */
			strcpy(state->cur_event.name, "PO2");
			break;
		case 13:
			/* 13 Air time */
			strcpy(state->cur_event.name, "airtime");
			break;
		case 17:
			/* 17 Ascent warning */
			strcpy(state->cur_event.name, "ascent");
			break;
		case 18:
			/* 18 Ceiling error */
			strcpy(state->cur_event.name, "ceiling");
			break;
		case 19:
			/* 19 Surfaced */
			strcpy(state->cur_event.name, "surface");
			break;
		case 20:
			/* 20 Deco */
			strcpy(state->cur_event.name, "deco");
			break;
		case 22:
		case 32:
			/* 22 Mandatory safety stop violation */
			/* 32 Deep stop violation */
			strcpy(state->cur_event.name, "violation");
			break;
		case 30:
			/* Tissue level warning */
			strcpy(state->cur_event.name, "tissue warning");
			break;
		case 37:
			/* Tank pressure alarm */
			strcpy(state->cur_event.name, "tank pressure");
			break;
		case 257:
			/* 257 Dive active */
			/* This seems to be given after surface when
			 * descending again. */
			strcpy(state->cur_event.name, "surface");
			break;
		case 258:
			/* 258 Bookmark */
			if (data[3]) {
				strcpy(state->cur_event.name, "heading");
				state->cur_event.value = atoi(data[3]);
			} else {
				strcpy(state->cur_event.name, "bookmark");
			}
			break;
		case 259:
			/* Deep stop */
			strcpy(state->cur_event.name, "Deep stop");
			break;
		case 260:
			/* Deep stop */
			strcpy(state->cur_event.name, "Deep stop cleared");
			break;
		case 266:
			/* Mandatory safety stop activated */
			strcpy(state->cur_event.name, "safety stop (mandatory)");
			break;
		case 267:
			/* Mandatory safety stop deactivated */
			/* DM5 shows this only on event list, not on the
			 * profile so skipping as well for now */
			break;
		default:
			strcpy(state->cur_event.name, "unknown");
			state->cur_event.value = atoi(data[2]);
			break;
		}
	}
	event_end(state);

	return 0;
}