如何使 USB 设备支持多点触控?
我正在为 Linux 制作第一个 USB 设备驱动程序,并且正在尝试连接触摸屏设备。
我在Win7中尝试过这个设备,使用Win7的默认触摸板驱动程序。 使用线路监视器/读取器,我能够通过多点触控启用获取原始数据。 为了示例,我们假设多点触摸数据标头是 [0x8301] 和 [0x8701] 分别用于第一次和第二次触摸。
现在,使用多点触摸禁用,原始数据标头将是[0x8101]
现在,使用我为Linux制作的驱动程序,我只能让它输出[0x8101 ],这是一个一键式数据标头。
所以我猜测在初始化代码的这一部分中,我必须对设备说它是多点触控设备。或者我可能初始化错误。
struct input_dev *input_dev;
input_dev = input_allocate_device();
input_dev->name = usb_mtouch->name;
input_dev->phys = usb_mtouch->phys;
usb_to_input_id(usb_mtouch->udev, &input_dev->id);
input_dev->dev.parent = &interface->dev;
input_set_drvdata(input_dev, usb_mtouch);
input_dev->open = mtouchdrv_open;
input_dev->close = mtouchdrv_close;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);
input_set_abs_params(input_dev, ABS_X, usb_mtouch->x_min, usb_mtouch->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_Y, usb_mtouch->y_min, usb_mtouch->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0, usb_mtouch->press_max, 0, 0);
input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
另外,我使用的是 Linux 2.6.24。
谢谢!
名泽
I'm making my first USB device driver for Linux, and I'm trying to connect a touch panel device.
I have tried this device in Win7, using Win7's default touch panel driver.
Using a line monitor/reader, I was able to get the raw data with multi-touch ENABLED.
Let's just say for sample's sake a multi-touch data header is [0x8301] and [0x8701]
for the first and second touch respectively.
Now with multi-touch DISABLED the raw data header would be [0x8101]
Now with the driver I made for Linux, I can only get it to output [0x8101], which is a one touch data header.
So I'm guessing somewhere in this part of the initialization code, I have to say to the device it is a multi-touch device. Or I'm probably initializing it wrongly.
struct input_dev *input_dev;
input_dev = input_allocate_device();
input_dev->name = usb_mtouch->name;
input_dev->phys = usb_mtouch->phys;
usb_to_input_id(usb_mtouch->udev, &input_dev->id);
input_dev->dev.parent = &interface->dev;
input_set_drvdata(input_dev, usb_mtouch);
input_dev->open = mtouchdrv_open;
input_dev->close = mtouchdrv_close;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);
input_set_abs_params(input_dev, ABS_X, usb_mtouch->x_min, usb_mtouch->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_Y, usb_mtouch->y_min, usb_mtouch->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0, usb_mtouch->press_max, 0, 0);
input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
Also, I am using Linux 2.6.24.
Thanks!
Naze
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了它。您必须向设备发送控制消息。
大多数设备默认启用一键式。因此,向设备发送消息就可以了。
棘手的部分是发送什么消息。因为Win7可以做到一键或多点触摸。我所做的只是比较两者的初始化序列。并在 Linux 上应用“丢失”的消息。
I got it. You would have to send a control message to the device.
Most devices are one-touched enabled by default. So sending a message to the device will do the trick.
The tricky part is what message to send. Since Win7 can make it one-touch or multi-touch. What I did was just compare the the Initialization Sequence on both. And apply the "missing" messages on Linux.