关于android的event(android的命令行获取事件)


input
getevent
sendevent

event设备目录:
    /proc/bus/input/devices
event设备信息:
    cat /proc/bus/input/devices

crw-rw---- root     input     13,  64 1970-01-03 16:24 event0
crw-rw---- root     input     13,  65 1970-01-03 16:24 event1
crw-rw---- root     input     13,  66 1970-01-03 16:24 event2
crw-rw---- root     input     13,  67 1970-01-03 16:24 event3
crw-rw---- root     input     13,  68 1970-01-03 16:24 event4
crw-rw---- root     input     13,  69 2016-12-15 19:27 event5
crw-rw---- root     input     13,  70 2016-12-15 19:27 event6
crw-rw---- root     input     13,  63 1970-01-03 16:24 mice




root@Coolpad5263S:/dev/input # cat /proc/bus/input/devices
I: Bus=0018 Vendor=0000 Product=0000 Version=0000
N: Name="msg2xxx"
P: Phys=I2C
S: Sysfs=/devices/soc.0/78b9000.i2c/i2c-5/5-0026/input/input1
U: Uniq=
H: Handlers=kbd kgsl event0
B: PROP=2
B: EV=b
B: KEY=400 0 0 0 0 1000 40000800 0 0 0 0
B: ABS=650000 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="proximity"
P: Phys=
S: Sysfs=/devices/virtual/input/input2
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=9
B: ABS=2000000

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="mxc622x"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=event2
B: PROP=0
B: EV=9
B: ABS=7

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="qpnp_pon"
P: Phys=qpnp_pon/input0
S: Sysfs=/devices/virtual/input/input4
U: Uniq=
H: Handlers=kbd event3
B: PROP=10
B: EV=3
B: KEY=140000 0 0 0

I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/soc.0/gpio_keys.64/input/input5
U: Uniq=
H: Handlers=kbd event4
B: PROP=0
B: EV=3
B: KEY=80000 0 0 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="msm8909-skuc-snd-card Button Jack"
P: Phys=ALSA
S: Sysfs=/devices/soc.0/sound.68/sound/card0/input6
U: Uniq=
H: Handlers=kbd event5
B: PROP=0
B: EV=3
B: KEY=1e 4 0 0 0 0 0 0 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="msm8909-skuc-snd-card Headset Jack"
P: Phys=ALSA
S: Sysfs=/devices/soc.0/sound.68/sound/card0/input7
U: Uniq=
H: Handlers=event6
B: PROP=0
B: EV=21
B: SW=1c054

root@Coolpad5263S:/dev/input #




I line:这行包含身份信息,显示了 bus type是 3 (usb), vendor, product, version等信息。
N line:这行包含了名字信息。
P line:这行包含了物理设备信息。
H line: 这行包含了与设备关联的 handler drivers。
B line: 这些行包含了显示设备能力的一些位域 (bitfield)。






root@Coolpad5263S:/dev/input # getevent
add device 1: /dev/input/event6
  name:     "msm8909-skuc-snd-card Headset Jack"//耳机插拔事件
add device 2: /dev/input/event5
  name:     "msm8909-skuc-snd-card Button Jack"//耳机按键事件
add device 3: /dev/input/event3
  name:     "qpnp_pon"                                                    //PMIC按键事件
add device 4: /dev/input/event2
  name:     "mxc622x"                                                        //陀螺仪
add device 5: /dev/input/event1
  name:     "proximity"                                                        //距离传感器
could not get driver version for /dev/input/mice, Not a typewriter
add device 6: /dev/input/event0
  name:     "msg2xxx"                                                        //触摸屏
add device 7: /dev/input/event4
  name:     "gpio-keys"                                                    //通用输入输出





name:     "msm8x16-snd-card-mtp Headset Jack"    //耳机插拔事件
name:     "msm8x16-snd-card-mtp Button Jack"    //耳机按键事件
name:     "qpnp_pon"                //PMIC按键事件
name:     "compass"                    //指南针
name:     "FT5x36"                    //触摸屏
name:     "light"                        //光感
name:     "gpio-keys"              //gpio按键事件





shell@android:/proc/bus/input # getevent
  name:     "pmic8xxx_pwrkey"                //电源按键
  name:     "mione-keypad"                    //按键
  name:     "8660_handset"                    
  name:     "accelerometer"                    //重力传感器
  name:     "proximity"                         //距离传感器
  name:     "lightsensor"                    //光敏
  name:     "compass"                            //罗盘
  name:     "mXT-touch"                    //触摸屏幕





key=$(ls /sys/devices/platform/gpio-keys.0/input)
sleep 1

key_value=${key:5}

echo $key_value

command="event$key_value"


#Send events to get power Hold menu
sendevent /dev/input/$command 1 116 1 && echo PASSED | grep PASSED || exit_fun 
sendevent /dev/input/$command 0 0 0 && echo PASSED | grep PASSED || exit_fun 
sendevent /dev/input/$command 1 116 0 && echo PASSED | grep PASSED || exit_fun

大概这样子,截取之前写的一个部分





EventHub.cpp


event   几的问题。
http://stackoverflow.com/questions/20005358/what-is-android-dev-input-eventx-file-used-for




sendevent /dev/input/event0 1 116 1(0074转化为十进制后为116)
sendevent /dev/input/event0 0 0 0
sleep 3
sendevent /dev/input/event0 1 116 0
sendevent /dev/input/event0 0 0 0



sendevent /dev/input/event0 1 116 1 && sendevent /dev/input/event0 0 0 0 && sleep 3 && sendevent /dev/input/event0 1 116 0 && sendevent /dev/input/event0 0 0 0

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM