1. /dev/input目录
我们先来看看Z-turn Board开发板中/dev/input目录下的事件都有哪些,他们都是在驱动中调用input_register_device(struct input_dev *dev)产生的。我开发板中的/dev/input目录的内容如下:
Z-turn# ls
bus mtd6 tty1 tty45
console mtd6ro tty10 tty46
cpu_dma_latency mtdblock0 tty11 tty47
event0 mtdblock1 tty12 tty48
event1 mtdblock2 tty13 tty49
event2 mtdblock3 tty14 tty5
full mtdblock4 tty15 tty50
i2c mtdblock5 tty16 tty51
i2c-0 mtdblock6 tty17 tty52
iio:device0 network_latency tty18 tty53
input network_throughput tty19 tty54
kmsg null tty2 tty55
loop-control port tty20 tty56
loop0 ppp tty21 tty57
loop1 psaux tty22 tty58
loop2 ptmx tty23 tty59
loop3 pts tty24 tty6
loop4 ram0 tty25 tty60
loop5 ram1 tty26 tty61
loop6 ram10 tty27 tty62
loop7 ram11 tty28 tty63
mem ram12 tty29 tty7
mice ram13 tty3 tty8
mmcblk0 ram14 tty30 tty9
mmcblk0p1 ram15 tty31 ttyPS0
mmcblk0p2 ram2 tty32 ttyPS1
mouse0 ram3 tty33 urandom
mtd0 ram4 tty34 vcs
mtd0ro ram5 tty35 vcs1
mtd1 ram6 tty36 vcsa
mtd1ro ram7 tty37 vcsa1
mtd2 ram8 tty38 vga_arbiter
mtd2ro ram9 tty39 watchdog
mtd3 random tty4 watchdog0
mtd3ro root tty40 xdevcfg
mtd4 snd tty41 zero
mtd4ro timer tty42
mtd5 tty tty43
mtd5ro tty0 tty44
其中,每个event上报指定的事件,如been、G-Sensor、T-Sensor、Mouse、按键等。
2. 与event对应的设备信息
与event对应的相关设备信息位于/proc/bus/input/devices,如下:
Z-turn# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-beep.3"
P: Phys=
S: Sysfs=/devices/amba.1/gpio-beep.3/input/input0
U: Uniq=
H: Handlers=kbd event0
B: PROP=0
B: EV=40001
B: SND=2
I: Bus=0018 Vendor=0000 Product=0159 Version=0000
N: Name="ADXL34x accelerometer"
P: Phys=0-0053/input0
S: Sysfs=/devices/amba.1/e0004000.i2c/i2c-0/0-0053/input/input1
U: Uniq=
H: Handlers=mouse0 event1
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=7
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys.4"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/amba.1/gpio-keys.4/input/input2
U: Uniq=
H: Handlers=kbd event2
B: PROP=0
B: EV=100003
B: KEY=40 0 0 0
从上边我们可以看出H:后边的就是对应事件的设备,其中event0-2分别是:蜂鸣器、加速度传感器、按键的对应设备号。