Linux 下鼠标对应的文件

系统 CentOS  内核 2.6  鼠标:usb 2.0

鼠标对应的设备文件是  /dev/input/event1


在linux 下,执行如下的操作,然后移动鼠标会得到哪下的数据:

[root@bogon input]# cat /dev/input/event1
(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�

读取鼠标,显示:

程序如下:

[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3. #include <fcntl.h>  
  4. #include <unistd.h>  
  5. #include <linux/input.h>  
  6.   
  7. #define MOUSEFILE "/dev/input/event1"  
  8.   
  9.   
  10. int main()  
  11. {  
  12.    int fd;  
  13.    struct input_event ie;  
  14.   
  15.    if((fd = open(MOUSEFILE, O_RDONLY)) == -1)  
  16.    {  
  17.        perror("opening device");  
  18.        exit(EXIT_FAILURE);  
  19.    }  
  20.   
  21.   
  22.    while(read(fd, &ie, sizeof(struct input_event)))  
  23.    {  
  24.         printf("time %ld.%06ld\ttype %d\tcode %d\tvalue %d\n",  
  25.         ie.time.tv_sec, ie.time.tv_usec, ie.type, ie.code, ie.value);  
  26.     }  
  27.   
  28.    return 0;  
  29. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值