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函数



drivers/input/mousedev.c   mousedev_connect函数



drivers/input/evdev.c  evdev_connect函数



结果如下,我的三个设备都固定为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
U: Uniq=
H: Handlers=mouse7 event7 
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003


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
U: Uniq=
H: Handlers=mouse8 event8 
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003


/ # 

  • 16
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值