开发者

How to make a USB device multi-touch enabled?

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 ma开发者_运维知识库de 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


I got it. You would have to send a control message to the device.

int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
                     __u8 requesttype, __u16 value, __u16 index, void *data,
                     __u16 size, int timeout)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜