参考的是这个帖子: https://blog.csdn.net/A694543965/article/details/79834008
能不能单纯的只读 /dev/mice 的数据, 因为触摸屏是绝对坐标, 鼠标是相对坐标, 这样全读到会出事的.
离线
#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;
}
离线
不知道嵌入式Qt如何实现 触摸屏(绝对坐标)和鼠标(相对坐标)都能愉快共用的
离线