Example #1
0
File: linear.c Project: pedwo/tslib
TSAPI struct tslib_module_info *linear_mod_init(struct tsdev *dev, const char *params)
{

	struct tslib_linear *lin;
	struct stat sbuf;
	FILE *pcal_fd;
	int index;
	char *calfile;

	lin = malloc(sizeof(struct tslib_linear));
	if (lin == NULL)
		return NULL;

	lin->module.ops = &linear_ops;

// Use default values that leave ts numbers unchanged after transform
	lin->a[0] = 1;
	lin->a[1] = 0;
	lin->a[2] = 0;
	lin->a[3] = 0;
	lin->a[4] = 1;
	lin->a[5] = 0;
	lin->a[6] = 1;
	lin->p_offset = 0;
	lin->p_mult   = 1;
	lin->p_div    = 1;
	lin->swap_xy  = 0;

	/*
	 * Check calibration file
	 */
	if( (calfile = getenv("TSLIB_CALIBFILE")) == NULL) calfile = TS_POINTERCAL;
	if (stat(calfile, &sbuf)==0) {
		pcal_fd = fopen(calfile, "r");
		for (index = 0; index < 7; index++)
			if (fscanf(pcal_fd, "%d", &lin->a[index]) != 1) break;
		fscanf(pcal_fd, "%d %d", &lin->cal_res_x, &lin->cal_res_y);
#ifdef DEBUG
		printf("Linear calibration constants: ");
		for(index=0;index<7;index++) printf("%d ",lin->a[index]);
		printf("\n");
#endif /*DEBUG*/
		fclose(pcal_fd);
	}
		
		
	/*
	 * Parse the parameters.
	 */
	if (tslib_parse_vars(&lin->module, linear_vars, NR_VARS, params)) {
		free(lin);
		return NULL;
	}

	return &lin->module;
}
Example #2
0
TSAPI struct tslib_module_info *cy8mrln_palmpre_mod_init(struct tsdev *dev, const char *params)
{
	struct tslib_cy8mrln_palmpre *info;
	struct cy8mrln_palmpre_input input;
	int ret = 0;

	info = malloc(sizeof(struct tslib_cy8mrln_palmpre));
	if (info == NULL)
		return NULL;
	info->module.ops = &cy8mrln_palmpre_ops;
	/* required to set the default valuse */
	info->module.dev = dev;
	info->last_valid_samples = NULL;
	info->last_n_valid_samples = 0;

	cy8mrln_palmpre_set_verbose(info, DEFAULT_VERBOSE);
	cy8mrln_palmpre_set_scanrate(info, DEFAULT_SCANRATE);
	cy8mrln_palmpre_set_timestamp_mode(info, DEFAULT_TIMESTAMP_MODE);
	cy8mrln_palmpre_set_sleepmode(info, DEFAULT_SLEEPMODE);
	cy8mrln_palmpre_set_wot_scanrate(info, DEFAULT_WOT_SCANRATE);
	cy8mrln_palmpre_set_wot_threshold(info, DEFAULT_WOT_THRESHOLD);
	cy8mrln_palmpre_set_gesture_height(info, DEFAULT_GESTURE_HEIGHT);
	cy8mrln_palmpre_set_noise(info, DEFAULT_NOISE);
	cy8mrln_palmpre_set_pressure(info, DEFAULT_PRESSURE);
	cy8mrln_palmpre_set_sensor_offset_x (info, DEFAULT_SENSOR_OFFSET_X);
	cy8mrln_palmpre_set_sensor_offset_y (info, DEFAULT_SENSOR_OFFSET_Y);
	cy8mrln_palmpre_set_sensor_delta_x (info, DEFAULT_SENSOR_DELTA_X);
	cy8mrln_palmpre_set_sensor_delta_y (info, DEFAULT_SENSOR_DELTA_Y);

	info->discard_frames = 0;


	if (tslib_parse_vars(&info->module, cy8mrln_palmpre_vars, NR_VARS, params)) {
		free(info);
		return NULL;
	}

	/* We need the intial values the touchscreen repots with no touch input for
	 * later use */
	do {
		ret = read(dev->fd, &input, sizeof(input));
	} while (ret <= 0);

	memcpy(info->references, input.field, H_FIELDS * V_FIELDS * sizeof(uint16_t));

	return &(info->module);
}
TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
{
	struct tslib_dejitter *djt;

	djt = malloc(sizeof(struct tslib_dejitter));
	if (djt == NULL)
		return NULL;

	memset(djt, 0, sizeof(struct tslib_dejitter));
	djt->module.ops = &dejitter_ops;

	djt->delta = 100;
        djt->head = 0;

	if (tslib_parse_vars(&djt->module, dejitter_vars, NR_VARS, params)) {
		free(djt);
		return NULL;
	}
	djt->delta = sqr (djt->delta);

	return &djt->module;
}
Example #4
0
TSAPI struct tslib_module_info *variance_mod_init(struct tsdev *dev, const char *params)
{
	struct tslib_variance *var;

	var = malloc(sizeof(struct tslib_variance));
	if (var == NULL)
		return NULL;

	var->module.ops = &variance_ops;

	var->delta = 30;
	var->flags = 0;

	if (tslib_parse_vars(&var->module, variance_vars, NR_VARS, params)) {
		free(var);
		return NULL;
	}

        var->delta = sqr (var->delta);

	return &var->module;
}
Example #5
0
TSAPI struct tslib_module_info *waveshare_mod_init(struct tsdev *dev,
						   const char *params)
{
	struct tslib_input *i;

	(void) dev;

	i = malloc(sizeof(struct tslib_input));
	if (i == NULL)
		return NULL;

	i->module.ops = &waveshare_ops;
	i->vendor = 0;
	i->product = 0;
	i->len = 25;

	if (tslib_parse_vars(&i->module, raw_vars, NR_VARS, params)) {
		free(i);
		return NULL;
	}

	return &(i->module);
}
Example #6
0
TSAPI struct tslib_module_info *input_mod_init(struct tsdev *dev, const char *params)
{
	struct tslib_input *i;

	i = malloc(sizeof(struct tslib_input));
	if (i == NULL)
		return NULL;

	i->module.ops = &__ts_input_ops;
	i->current_x = 0;
	i->current_y = 0;
	i->current_p = 0;
	i->sane_fd = 0;
	i->using_syn = 0;
	i->grab_events = 0;

	if (tslib_parse_vars(&i->module, raw_vars, NR_VARS, params)) {
		free(i);
		return NULL;
	}

	return &(i->module);
}
TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
{

	struct tslib_pthres *p;

	p = malloc(sizeof(struct tslib_pthres));
	if (p == NULL)
		return NULL;

	p->module.ops = &pthres_ops;

	p->pmin = 1;
	p->pmax = INT_MAX;

	/*
	 * Parse the parameters.
	 */
	if (tslib_parse_vars(&p->module, pthres_vars, NR_VARS, params)) {
		free(p);
		return NULL;
	}

	return &p->module;
}
Example #8
0
File: linear.c Project: tonyho/LDD
TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
{

	struct tslib_linear *lin;
	struct stat sbuf;
	int pcal_fd;
	char pcalbuf[200];
	int index;
	char *tokptr;
	char *calfile=NULL;
	char *defaultcalfile = "/etc/pointercal";

	lin = malloc(sizeof(struct tslib_linear));
	if (lin == NULL)
		return NULL;

	lin->module.ops = &linear_ops;

// Use default values that leave ts numbers unchanged after transform
	lin->a[0] = 1;
	lin->a[1] = 0;
	lin->a[2] = 0;
	lin->a[3] = 0;
	lin->a[4] = 1;
	lin->a[5] = 0;
	lin->a[6] = 1;
	lin->p_offset = 0;
	lin->p_mult   = 1;
	lin->p_div    = 1;
	lin->swap_xy  = 0;

	/*
	 * Check calibration file
	 */
	if( (calfile = getenv("TSLIB_CALIBFILE")) == NULL) calfile = defaultcalfile;
	if(stat(calfile,&sbuf)==0) {
		pcal_fd = open(calfile,O_RDONLY);
		read(pcal_fd,pcalbuf,200);
		lin->a[0] = atoi(strtok(pcalbuf," "));
		index=1;
		while(index<7) {
			tokptr = strtok(NULL," ");
			if(*tokptr!='\0') {
				lin->a[index] = atoi(tokptr);
				index++;
			}
		}
#ifdef DEBUG
		printf("Linear calibration constants: ");
		for(index=0;index<7;index++) printf("%d ",lin->a[index]);
		printf("\n");
#endif /*DEBUG*/
		close(pcal_fd);
	}
		
		
	/*
	 * Parse the parameters.
	 */
	if (tslib_parse_vars(&lin->module, linear_vars, NR_VARS, params)) {
		free(lin);
		return NULL;
	}

	return &lin->module;
}