Пример #1
0
  __attribute__((naked)) void shd()
  {
    int row, column, drange, y;
    unsigned int  *HammDistY,*hdis,*result, *w;

    read_reg(row, "v128.x");
    read_reg(column, "v128.y");
    read_reg(drange, "v128.z");
  
    ui_vec4 coords;
    read_coords(coords);
    
    read_reg(HammDistY, "v0.w"); /// Read value from interpolator 0
    read_reg(hdis, "v0.z"); /// Read value from interpolator 1
    read_reg(result, "v0.y"); /// Read value from interpolator 2

    y = 0;
    if(coords.x>5 && coords.x<(column-6-drange) &&coords.y>5 && coords.y<(row-6))
    {
      w = HammDistY - 6;
      for (int k = 12; k >= 0; k--)
      {
          y+= *w;
          if (y>*hdis) break;
          w++;
      }

      if (y<*hdis)
      {
        *hdis = y;
        *result = drange;
      }
    }
  }
Пример #2
0
 void read_polygon(boost::ptr_vector<geometry_type> & paths)
 {
     int num_rings = read_integer();
     if (num_rings > 0)
     {
         std::unique_ptr<geometry_type> poly(new geometry_type(geometry_type::types::Polygon));
         for (int i = 0; i < num_rings; ++i)
         {
             int num_points = read_integer();
             if (num_points > 0)
             {
                 CoordinateArray ar(num_points);
                 read_coords(ar);
                 poly->move_to(ar[0].x, ar[0].y);
                 for (int j = 1; j < num_points ; ++j)
                 {
                     poly->line_to(ar[j].x, ar[j].y);
                 }
                 poly->close_path();
             }
         }
         if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices
             paths.push_back(poly.release());
     }
 }
void 
IstreamComplex2DFmt::init() const
{
  base::init();
  if(! coords_read) {
    read_coords();
  }
}
Пример #4
0
 void read_linestring(boost::ptr_vector<geometry_type> & paths)
 {
     geometry_type* line = new geometry_type(LineString);
     int num_points = read_integer();
     CoordinateArray ar(num_points);
     read_coords(ar);
     line->move_to(ar[0].x, ar[0].y);
     for (int i = 1; i < num_points; ++i)
     {
         line->line_to(ar[i].x, ar[i].y);
     }
     paths.push_back(line);
 }
Пример #5
0
 geometry_ptr read_linestring()
 {
     geometry_ptr line(new line_string<vertex2d>(srid_));
     int num_points=read_integer();
     CoordinateArray ar(num_points);
     read_coords(ar);
     line->set_capacity(num_points);
     line->move_to(ar[0].x,ar[0].y);
     for (int i=1;i<num_points;++i)
     {
         line->line_to(ar[i].x,ar[i].y);
     }
     return line;
 }
Пример #6
0
 void read_linestring(boost::ptr_vector<geometry_type> & paths)
 {
     int num_points = read_integer();
     if (num_points > 0)
     {
         CoordinateArray ar(num_points);
         read_coords(ar);
         std::unique_ptr<geometry_type> line(new geometry_type(geometry_type::types::LineString));
         line->move_to(ar[0].x, ar[0].y);
         for (int i = 1; i < num_points; ++i)
         {
             line->line_to(ar[i].x, ar[i].y);
         }
         paths.push_back(line.release());
     }
 }
Пример #7
0
 void read_polygon(boost::ptr_vector<geometry_type> & paths)
 {
     geometry_type* poly = new geometry_type(Polygon);
     int num_rings = read_integer();
     unsigned capacity = 0;
     for (int i = 0; i < num_rings; ++i)
     {
         int num_points = read_integer();
         capacity += num_points;
         CoordinateArray ar(num_points);
         read_coords(ar);
         poly->move_to(ar[0].x, ar[0].y);
         for (int j = 1; j < num_points; ++j)
         {
             poly->line_to(ar[j].x, ar[j].y);
         }
     }
     paths.push_back(poly);
 }
Пример #8
0
        geometry_ptr read_polygon() 
        {
            geometry_ptr poly(new polygon<vertex2d>(srid_));
	    
            int num_rings=read_integer();

            for (int i=0;i<num_rings;++i)
            {
                int num_points=read_integer();
                CoordinateArray ar(num_points);
                read_coords(ar);
                poly->move_to(ar[0].x,ar[0].y);

                for (int j=1;j<num_points;++j)
                {
                    poly->line_to(ar[j].x,ar[j].y);
                }
                poly->line_to(ar[0].x,ar[0].y);
		
            }
            return poly;
        }
Пример #9
0
int main(int argc, char **argv) {

	struct i2c_client cliente;
	int retval;
	struct uinput_user_dev uidev;
	
	if (argc<3) {
		printf("Version 7\n");
		printf("Format: driver [-res XxY] [-gpio PATH] [-invert_x] [-invert_y] DEVICE FW_FILE\n\n");
		printf("-res XxY: specifies that the screen resolution is X width and Y height (default: 800x480)\n");
		printf("-gpio PATH: sets the path to the GPIO device that enables and disables the touch chip\n");
		printf("-invert_x: inverts the X coordinates\n");
		printf("-invert_y: inverts the Y coordinates\n");
		printf("-new_scroll: do scroll with a single finger\n");
		printf("DEVICE: path to the I2C device where the GSLx680 chip is connected\n");
		printf("FW_FILE: path to the firmware file for the GSLx680 chip\n");
		return 0;
	}

	char *adapter=NULL;
	char *firmware=NULL;
	char *option;
	cliente.invert_x=0;
	cliente.invert_y=0;
	cliente.gpio="/sys/devices/virtual/misc/sun4i-gpio/pin/pb3";
	cliente.resx=SCREEN_MAX_X;
	cliente.resy=SCREEN_MAX_Y;

#ifdef USE_FB
	int fb_dev;
	fb_dev=open("/dev/fb0",O_RDWR);
	if (fb_dev>0) {
		struct fb_var_screeninfo vinfo;
		if (0==ioctl (fb_dev, FBIOGET_VSCREENINFO, &vinfo)) {
			cliente.resx=vinfo.xres;
			cliente.resy=vinfo.yres;
	    }
	    close(fb_dev);
	}
#endif

	int loop=1;
	while(loop<argc) {
		option=argv[loop];
		loop++;
		if (option[0]=='-') {
			if (!strcmp(option,"-invert_x")) {
				cliente.invert_x=1;
				continue;
			}
			if (!strcmp(option,"-invert_y")) {
				cliente.invert_y=1;
				continue;
			}
			if (!strcmp(option,"-new_scroll")) {
				cliente.new_scroll=1;
				continue;
			}
			if (loop==argc) {
				printf("Error: option %s doesn't have parameters\n",option);
				return -1;
			}
			if (!strcmp(option,"-res")) {
				if (2!=sscanf(argv[loop],"%dx%d",&cliente.resx,&cliente.resy)) {
					printf("Error: resolution %s has an incorrect format\n",argv[loop]);
					return -1;
				}
				loop++;
				continue;
			}
			if (!strcmp(option,"-gpio")) {
				cliente.gpio=strdup(argv[loop]);
				loop++;
				continue;
			}
			printf("Unknown option %s\n",option);
			return -1;
		}
		if (adapter==NULL) {
			adapter=strdup(option);
			continue;
		}
		if (firmware==NULL) {
			firmware=strdup(option);
			continue;
		}
		printf("Too many parameters\n");
		return -1;
	}

	if (adapter==NULL) {
		printf("Missing adapter path\n");
		return -1;
	}

	if (firmware==NULL) {
		printf("Missing firmware path\n");
		return -1;
	}

	printf("Connecting to device %s, firmware %s\n",adapter,firmware);
	
	cliente.adapter=open(adapter,O_RDWR);
	if (cliente.adapter<0) {
		printf("Can't open device %s\n",adapter);
		return -1;
	}

	send_value(0,&cliente);
	usleep(100000);
	send_value(1,&cliente);

	if (ioctl(cliente.adapter, I2C_SLAVE, GSLX680_I2C_ADDR) < 0) {
		printf("Error selecting device %d\n",GSLX680_I2C_ADDR);
		return -2;
	}

	cliente.ufile=open("/dev/uinput", O_WRONLY | O_NONBLOCK);
	if (cliente.ufile<0) {
		cliente.ufile=open("/dev/input/uinput", O_WRONLY | O_NONBLOCK);
		if (cliente.ufile<0) {
			printf("Can't connect to UINPUT interface.\n");
			return -2;
		}
	}

	retval = ioctl(cliente.ufile, UI_SET_EVBIT, EV_KEY);
	retval = ioctl(cliente.ufile, UI_SET_KEYBIT, BTN_TOUCH);

	retval = ioctl(cliente.ufile, UI_SET_EVBIT, EV_ABS);
	retval = ioctl(cliente.ufile, UI_SET_ABSBIT, ABS_X);
	retval = ioctl(cliente.ufile, UI_SET_ABSBIT, ABS_Y);
	
	
	memset(&uidev, 0, sizeof(uidev));

	snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "gsl1680-uinput");
	uidev.id.bustype = BUS_I2C;
	uidev.id.vendor  = 0x1;
	uidev.id.product = 0x1;
	uidev.id.version = 1;
	uidev.absmin[ABS_X] = 0;
	uidev.absmax[ABS_X] = cliente.resx-1;
	uidev.absmin[ABS_Y] = 0;
	uidev.absmax[ABS_Y] = cliente.resy-1;
	retval = write(cliente.ufile, &uidev, sizeof(uidev));
	
	retval = ioctl(cliente.ufile, UI_DEV_CREATE);
	retval = ioctl(cliente.ufile, UI_SET_PROPBIT,INPUT_PROP_DIRECT);
	retval = ioctl(cliente.ufile, UI_SET_PROPBIT,INPUT_PROP_POINTER);

	cliente.mfile=open("/dev/uinput", O_WRONLY | O_NONBLOCK);
	if (cliente.mfile<0) {
		cliente.mfile=open("/dev/input/uinput", O_WRONLY | O_NONBLOCK);
		if (cliente.mfile<0) {
			printf("Can't connect to UINPUT interface.\n");
			return -2;
		}
	}

	/* When a device uses ABSolute pointing, the X server doesn't allows to also use RELative pointing.
	 * But we need it to allow scrolling and zooming, so we define another device, this time with only
	 * relative pointing.
	 * It also can emit the LEFT CONTROL key to emulate zoom in and zoom out (CTRL+vertical scroll)
	 * Finally, it allows to emit CONTROL+MENU key to interface with TabletWM
	 */

	retval = ioctl(cliente.mfile, UI_SET_EVBIT, EV_KEY);
	retval = ioctl(cliente.mfile, UI_SET_KEYBIT, BTN_LEFT);
	retval = ioctl(cliente.mfile, UI_SET_KEYBIT, BTN_RIGHT);
	retval = ioctl(cliente.mfile, UI_SET_KEYBIT, KEY_LEFTCTRL);
	retval = ioctl(cliente.mfile, UI_SET_KEYBIT, KEY_COMPOSE);

	retval = ioctl(cliente.mfile, UI_SET_EVBIT, EV_REL);
	retval = ioctl(cliente.mfile, UI_SET_RELBIT, REL_X);
	retval = ioctl(cliente.mfile, UI_SET_RELBIT, REL_Y);
	retval = ioctl(cliente.mfile, UI_SET_RELBIT, REL_WHEEL);
	retval = ioctl(cliente.mfile, UI_SET_RELBIT, REL_HWHEEL);
	
	memset(&uidev, 0, sizeof(uidev));
	snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "gsl1680-2-uinput");
	uidev.id.bustype = BUS_I2C;
	uidev.id.vendor  = 0x1;
	uidev.id.product = 0x2;
	uidev.id.version = 1;
	retval = write(cliente.mfile, &uidev, sizeof(uidev));
	
	retval = ioctl(cliente.mfile, UI_SET_PROPBIT,INPUT_PROP_POINTER);
	
	retval = ioctl(cliente.mfile, UI_DEV_CREATE);

	init_chip(&cliente,firmware);

	while(1) {
		read_coords(&cliente);
		usleep(20000); // do 50 reads per second
	}
}