天天看点

gui画线和绘制鼠标



最近在hi的sample里面发现这个画线的代码,前面的3个for是画屏幕的横线,起始位置为358,结束位子362,所以线宽是362-358=4,红色线;

同理下面的为画竖线,起始位置为638,结束位置为642,线宽4,红色线。

 for(i = 0; i < 20; i++)

 {

  for (y = 358; y < 362; y++)

  {

   for (x = 0; x < maxW; x++)

   {

    *(pBuf + y * maxW + x) = HIFB_RED_1555;

   }

  }

  for (y = 0; y < maxH; y++)

  {

   for (x = 638; x < 642; x++)

   {

    *(pBuf + y * maxW + x) = HIFB_RED_1555;

   }

  }

鼠标绘制为转摘,打开鼠标这个设备,while循环,X,Y为鼠标的起始位置

int fd, retval;

     signed char buf[6];

     fd_set readfds;

     struct timeval tv;

    fd = open( "/dev/mice", O_RDONLY );

   if(fd<0)

   {

    printf("Failed to open \n");

    exit(1);

   }

   while(1)

   {

    static signed int X = 40;

    static signed int Y = 112;

    tv.tv_sec = 5;

    tv.tv_usec = 0;

    FD_ZERO(&readfds );

    FD_SET(fd, &readfds );

    retval = select( fd+1, &readfds, NULL, NULL, &tv );         

    if(retval==0)    

    {                             

     printf( "Time out!\n" );                       

    }

    if(FD_ISSET(fd,&readfds))

    {

     if(read(fd, buf, 6) <= 0)

      continue;

    }

    X += buf[1];

    Y -= buf[2];

    stPoint.s32XPos = X;                 

    stPoint.s32YPos = Y;

    printf("Button type = %d, X = %d, Y = %d\n", (buf[0] & 0x07), buf[1], buf[2]);

    printf("x=%d y=%d\n", stPoint.s32XPos, stPoint.s32YPos);

    ioctl(pstInfo->fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint);

gui

继续阅读