天天看點

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

繼續閱讀