天天看点

linux input设备如何固定event handler

在qt开发时,碰到的问题,usb输入设备(鼠标,usb 电容屏等)上电后会自动分配input节点,比如usb鼠标插着上电后,自动分配到/dev/input/event0 mouse0,插拔一次后,节点会自动往后增加,变为/dev/input/event1mouse1

对于鼠标类型的设备,/dev/input/mousex 的所有消息都会汇总到/dev/input/mice,因此,qt的qws_mouse_proto输入可以指定intellimouse=/dev/input/mice,鼠标插拔即使mousex变化也都能使用。

但是,对于usb触控类型输入设备,使用的event接口,向应用层汇报的是绝对坐标信息,不是mouse的相对坐标信息,所以当eventx设备号变化后,应用层就无法识别了,因为没有像/dev/input/mice这样的接口。而大部分应用触控都使用了tslib,tslib_tsdevice=/dev/input/event0, 

直接给出需要修改的地方:

共有3处:drivers/input/input.c  input_register_device函数

linux input设备如何固定event handler

drivers/input/mousedev.c   mousedev_connect函数

linux input设备如何固定event handler

drivers/input/evdev.c  evdev_connect函数

linux input设备如何固定event handler

结果如下,我的三个设备都固定为event6  event7  event8  ,usb设备任意插拔,event handler也不会变化

/ # 

/ # cat /proc/bus/input/devices 

i: bus=0018 vendor=0000 product=0000 version=0000

n: name="gt928 touchscreen"

p: phys=1-0014/input0

s: sysfs=/devices/virtual/input/input6

u: uniq=

h: handlers=mouse6 event6 

b: ev=b

b: key=400 0 0 0 0 0 0 0 0 0 0

b: abs=1000003

i: bus=0000 vendor=0000 product=0000 version=0000

n: name="ads7846 touchscreen"

p: phys=spi1.0/input0

s: sysfs=/devices/platform/omap2_mcspi.1/spi1.0/input/input7

h: handlers=mouse7 event7 

i: bus=0003 vendor=0eef product=0001 version=0100

n: name="egalax inc. usb touchcontroller"

p: phys=usb-ehci-omap.0-1.1/input0

s: sysfs=/devices/platform/ehci-omap.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input8

h: handlers=mouse8 event8 

继续阅读