如题
离线
可以用 by-id, 这样只对同款鼠标有效, 而且嵌入式设备先开机, 后插入鼠标, 还不能打开设备, 因为设备名都不存在.
# ls /dev/input/by-path/ -l
total 0
lrwxrwxrwx 1 root root 9 Jan 1 10:35 platform-1c1a000.usb-usb-0:1.1:1.0-event-mouse -> ../event2
lrwxrwxrwx 1 root root 9 Jan 1 10:35 platform-1c1a000.usb-usb-0:1.1:1.0-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 Jan 1 00:00 platform-1c1a000.usb-usb-0:1.4:1.0-event -> ../event1
lrwxrwxrwx 1 root root 9 Jan 1 00:00 platform-rotary@0-event -> ../event0
#
#
# ls /dev/input/by-id/ -l
total 0
lrwxrwxrwx 1 root root 9 Jan 1 00:00 usb-2M_WebCam_2M_WebCam-event-if00 -> ../event1
lrwxrwxrwx 1 root root 9 Jan 1 10:35 usb-SIGMACHIP_Usb_Mouse-event-mouse -> ../event2
lrwxrwxrwx 1 root root 9 Jan 1 10:35 usb-SIGMACHIP_Usb_Mouse-mouse -> ../mouse0
离线
貌似可以用 /dev/input/mice
请问 /dev/input/mouse 与 /dev/input/mice 有什么区别?
http://whycan.com/t_5988.html#p59466
(出处:哇酷开发者社区)
离线
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char** argv)
{
int fd, bytes;
unsigned char data[3];
const char *pDevice = "/dev/input/mice";
// Open Mouse
fd = open(pDevice, O_RDWR);
if(fd == -1)
{
printf("ERROR Opening %s\n", pDevice);
return -1;
}
int left, middle, right;
signed char x, y;
while(1)
{
// Read Mouse
bytes = read(fd, data, sizeof(data));
if(bytes > 0)
{
left = data[0] & 0x1;
right = data[0] & 0x2;
middle = data[0] & 0x4;
x = data[1];
y = data[2];
printf("x=%d, y=%d, left=%d, middle=%d, right=%d\n", x, y, left, middle, right);
}
}
return 0;
}
# /mnt/media/mmcblk1p1/test1
x=1, y=1, left=0, middle=0, right=0
x=-6, y=-5, left=0, middle=0, right=0
x=-9, y=-9, left=0, middle=0, right=0
x=-9, y=-9, left=0, middle=0, right=0
x=-8, y=-10, left=0, middle=0, right=0
x=-7, y=-11, left=0, middle=0, right=0
x=-5, y=-9, left=0, middle=0, right=0
x=-6, y=-8, left=0, middle=0, right=0
x=-4, y=-9, left=0, middle=0, right=0
x=-3, y=-7, left=0, middle=0, right=0
x=-3, y=-6, left=0, middle=0, right=0
x=-1, y=-6, left=0, middle=0, right=0
x=0, y=-6, left=0, middle=0, right=0
x=0, y=-5, left=0, middle=0, right=0
x=-1, y=-2, left=0, middle=0, right=0
x=0, y=-2, left=0, middle=0, right=0
x=-1, y=-1, left=0, middle=0, right=0
x=-1, y=-2, left=0, middle=0, right=0
x=0, y=1, left=0, middle=0, right=0
x=0, y=2, left=0, middle=0, right=0
x=1, y=5, left=0, middle=0, right=0
x=1, y=6, left=0, middle=0, right=0
x=1, y=6, left=0, middle=0, right=0
x=1, y=6, left=0, middle=0, right=0
x=2, y=6, left=0, middle=0, right=0
x=1, y=4, left=0, middle=0, right=0
离线
还有一个奇怪的问题, 为什么只有 /dev/input/mice, 却没有 /dev/input/keyboard ???
离线
离线
找到一个mdev实现的脚本,
把 /dev/input/eventX 映射成 /dev/input/touchscreen0
离线