예제 #1
0
int main(int argc, char *argv[])
{

	char	eventFullPathName[100];
	int	eventnum;
	int	x,y,prex = 0,prey = 0;
	int	fb_fd,fp;

	struct  fb_var_screeninfo fbvar;
	struct  fb_fix_screeninfo fbfix;
	unsigned char   *fb_mapped;
	int		mem_size;


	if (argc != 2)
	{
		printf("Usage : touchapp  <event Number>\n");
		printf("To see the event number, do \"cat /proc/bus/input/devices\" \n");

		return 1;
	}
	eventnum = atoi(argv[1]);

	sprintf(eventFullPathName,"%s%d",EVENT_STR,eventnum);

	printf("touch input event name:%s\n", eventFullPathName);

	fp = open( eventFullPathName, O_RDONLY);
	if (-1 == fp)
	{
		printf("%s open fail\n",eventFullPathName);
		return 1;
	}

    if( access(FBDEV_FILE, F_OK) )
    {
        printf("%s: access error\n", FBDEV_FILE);
		close(fp);
        return 1;
    }

    if( (fb_fd = open(FBDEV_FILE, O_RDWR)) < 0)
    {
        printf("%s: open error\n", FBDEV_FILE);
		close(fp);
        return 1;
    }

    if( ioctl(fb_fd, FBIOGET_VSCREENINFO, &fbvar) )
    {
        printf("%s: ioctl error - FBIOGET_VSCREENINFO \n", FBDEV_FILE);
        goto fb_err;
    }

    if( ioctl(fb_fd, FBIOGET_FSCREENINFO, &fbfix) )
    {
        printf("%s: ioctl error - FBIOGET_FSCREENINFO \n", FBDEV_FILE);
        goto fb_err;
    }

    screen_width    =   fbvar.xres;
    screen_height   =   fbvar.yres;
    bits_per_pixel  =   fbvar.bits_per_pixel;
    line_length     =   fbfix.line_length;

    printf("screen_width : %d\n", screen_width);
    printf("screen_height : %d\n", screen_height);
    printf("bits_per_pixel : %d\n", bits_per_pixel);
    printf("line_length : %d\n", line_length);

    mem_size    =   screen_width * screen_height * 4;
    fb_mapped   =   (unsigned char *)mmap(0, mem_size,
                     PROT_READ|PROT_WRITE, MAP_SHARED, fb_fd, 0);
    if (fb_mapped < 0)
    {
        printf("mmap error!\n");
        goto fb_err;
    }

    initScreen(fb_mapped);

	while(1)
	{

		readFirstCoordinate(fp,&x, &y);
		drawCoordinate(fb_mapped,x,y, prex, prey);
		prex = x;
		prey = y;
	}

	fb_err:
	close(fb_fd);
	close(fp);

	return 0;

}
예제 #2
0
void* touchPad(void* fd)
{

	char	eventFullPathName[100];
	int	eventnum = 2;
	int	x,y,prex = 0,prey = 0;
	int	fb_fd,fp;

    	struct  fb_var_screeninfo fbvar;
    	struct  fb_fix_screeninfo fbfix;
    	unsigned char   *fb_mapped;
    	int		mem_size;

	/*
	if (argc != 2)
	{
		printf("Usage : touchapp  <event Number>\n");
		printf("To see the event number, do \"cat /proc/bus/input/devices\" \n");

		return 1;
	}
	*/	

	sprintf(eventFullPathName,"%s%d",EVENT_STR,eventnum);

	printf("touch input event name:%s\n", eventFullPathName);

	fp = open( eventFullPathName, O_RDONLY);
	if (-1 == fp)
	{
		printf("%s open fail\n",eventFullPathName);
		return;
	}

    if( access(FBDEV_FILE, F_OK) )
    {
        printf("%s: access error\n", FBDEV_FILE);
		close(fp);
        return;
    }

    if( (fb_fd = open(FBDEV_FILE, O_RDWR)) < 0)
    {
        printf("%s: open error\n", FBDEV_FILE);
		close(fp);
        return;
    }

    if( ioctl(fb_fd, FBIOGET_VSCREENINFO, &fbvar) )
    {
        printf("%s: ioctl error - FBIOGET_VSCREENINFO \n", FBDEV_FILE);
        goto fb_err;
    }

    if( ioctl(fb_fd, FBIOGET_FSCREENINFO, &fbfix) )
    {
        printf("%s: ioctl error - FBIOGET_FSCREENINFO \n", FBDEV_FILE);
        goto fb_err;
    }

    screen_width    =   fbvar.xres;
    screen_height   =   fbvar.yres;
    bits_per_pixel  =   fbvar.bits_per_pixel;
    line_length     =   fbfix.line_length;

    printf("screen_width : %d\n", screen_width);
    printf("screen_height : %d\n", screen_height);
    printf("bits_per_pixel : %d\n", bits_per_pixel);
    printf("line_length : %d\n", line_length);

    mem_size    =   screen_width * screen_height * 4;
    fb_mapped   =   (unsigned char *)mmap(0, mem_size,
                     PROT_READ|PROT_WRITE, MAP_SHARED, fb_fd, 0);
    if (fb_mapped < 0)
    {
        printf("mmap error!\n");
        goto fb_err;
    }
   //initScreen(fb_mapped);
     bitmap("main.bmp");
	pthread_t thread_cam;

	char cmd;
	
	char sFlag;
	while(1)
	{
		pthread_t thread_key;
		if(pFlag == MAIN){
			do{
				readFirstCoordinate(fp,&x, &y);
				//printf("entering!!!!!\n");
			}while(!btnClick(sen1Btn, x, y) && !btnClick(sen2Btn, x, y));
		
			pFlag = SET;
			//x=0; y=0;
			bitmap("setting.bmp");
			pthread_create(&thread_cam, NULL, &cameraview, (void*)&pFlag);	
			pthread_create(&thread_key, NULL, &keymatrix, fd);
			if(btnClick(sen1Btn, x, y)){
				sFlag = '1';
			}
			else if(btnClick(sen2Btn, x, y)) {
				sFlag ='2';
			}
			/*
			cmd = 's';
			write((*(int*)fd), &cmd, 1);
			usleep(100);
			write((*(int*)fd), &sFlag, 1);
			*/
			char sendCmd[] = {'s', ' ', '\n', '\0'};
			sendCmd[1] = sFlag;
			//printf("!!!!!!!!!!!!!!!!!!@@@@@@@@@@@@@2*************** %c^^^^ %c^^^^", sendCmd[0], sendCmd[1]);
			write((*(int*)fd), sendCmd, sizeof(sendCmd)-1);
		}	
		else if(pFlag == SET){
			int btn1, btn2;
			
			do{
				readFirstCoordinate(fp,&x, &y);
			}while(!(btn1 = btnClick(backBtn, x, y)) && !(btn2 = btnClick(applyBtn, x, y)));
		
			x=0; y=0;
			if(btn1 > 0){		// 돌아가기 버튼 눌렀을 시
                        	pFlag = MAIN;
				char sendCmd[2] = {' ', '\n'};
				sendCmd[0] = 'b';
                                write((*(int*)fd), sendCmd, sizeof(sendCmd));
				bitmap("main.bmp");
			}
			else if(btn2 > 0){	// 적용 버튼 눌렀을 시
				pFlag = MAIN;
				char sendCmd[2] = {' ', '\n'};
				sendCmd[0] = 'e';
                                write((*(int*)fd), sendCmd, sizeof(sendCmd));
				bitmap("main.bmp");
			}
		pthread_cancel(&thread_key);
		}

	}

fb_err:
	close(fb_fd);
	close(fp);

	return;

}