当前位置:   article > 正文

触摸屏程序C语言,C语言-触摸屏测试程序

触摸屏程序

#include #define TS_DEV "/dev/input/event7"

static int ts_fd = -1;

static int init_device()

{

if((ts_fd = open(TS_DEV, O_RDONLY)) < 0)

{

printf("Error open %s/n", TS_DEV);

return -1;

}

return ts_fd;

}

int main()

{

int i;

struct input_event data;

if(init_device() < 0)

return -1;

while(1)

{

read(ts_fd, &data, sizeof(data));

printf("data.type = %d, data.code = %d, data.value = %d/n",data.type,data.code,data.value);

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);

}

else if (data.type == EV_SYN)

{

printf("type: EV_SYN, event = %s, value = %d/n/n",

data.code == SYN_REPORT ? "SYN_REPORT" : "Unkown", data.value);

}

else

{

printf("type: 0x%x, event = 0x%x, value = %d/n/n", data.type, data.code, data.value);

}

}

return 0;

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/317259
推荐阅读
相关标签
  

闽ICP备14008679号