Linux下测试键盘鼠标触摸屏触摸板(2)

static int test_touch_screen()
{
        if(init_device(TOUS_DEV) < 0)
               return -1;
        while(1)
        {
               read(ts_fd, &data, sizeof(data));
               if (data.type == EV_KEY)
               {
                       printf(" type: EV_KEY, event = %s, value = %d\n\n",
                         data.code == BTN_TOUCH ? "BTN_TOUCH" : "Unkown", data.value);
                }
                else if(data.type == EV_ABS)
                {
                        printf(" type: EV_ABS, event = %s, value = %d\n\n",
                          data.code == ABS_X ? "ABS_X" :
                          data.code == ABS_Y ? "ABS_Y" :
                          data.code == ABS_PRESSURE ? "ABS_PRESSURE" :"Unkown", data.value);
                 }
         }
         return 0;
}

static int test_touch_pancel()
{
         if(init_device(TOUP_DEV) < 0)
               return -1;
         while(1)
         {
                read(ts_fd, &data, sizeof(data));
                if (data.type == EV_KEY)
                {
                       printf(" type = EV_KEY, code = %s, value = %d\n",
                         data.code == BTN_LEFT ? "MOUSE_LEFT" :
                         data.code == BTN_RIGHT ? "MOUSE_RIGHT" :
                         data.code == BTN_MIDDLE ? "MOUSE_MIDDLE" :
                         data.code == BTN_SIDE ? "MOUSE_SIDE" :
                          "Unkonw", data.value);
                 }
                 else if(data.type == EV_REL)
                 {
                        printf(" type = EV_ABS, code = %s, value = %d\n",
                           data.code == REL_X ? "ABS_X" :
                           data.code == REL_Y ? "ABS_Y" :
                           data.code == ABS_WHEEL ? "MOUSE_WHEEL" :
                           data.code == ABS_PRESSURE ? "ABS_PRESSURE" :
                             "Unkown", data.value);
                  }
         }
         return 0;
}

int main()
{
         static int i;
select:  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwsxwx.html