Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3002614
  • 博文数量: 674
  • 博客积分: 17881
  • 博客等级: 上将
  • 技术积分: 4849
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-17 10:15
文章分类

全部博文(674)

文章存档

2013年(34)

2012年(146)

2011年(197)

2010年(297)

分类: LINUX

2011-07-26 09:20:29

#include
#include
#include
#include
#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;
}
 
 
阅读(1498) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~