關於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