zoukankan      html  css  js  c++  java
  • android 模拟点击事件

    引用:http://bbs.chinaunix.net/thread-2317735-1-1.html

    众所周知,Linux上可以通过sendEvent来模拟键盘或者鼠标点击事件。而Android是基于Linux2.6平台的,所以也应该可以模拟点击事件,
    在很多网络文章中也有提到。但是我在Motolola的Xoom,Android3.0系统上,试图通过
    adb -d shell sendevent /dev/input/event6 3 0 180
    adb -d shell sendevent /dev/input/event6 3 1 70
    adb -d shell sendevent /dev/input/event6 1 330 1
    adb -d shell sendevent /dev/input/event6 0 0 0 
    adb -d shell sendevent /dev/input/event6 1 330 0 
    adb -d shell sendevent /dev/input/event6 0 0 0 
    来点击一个应用程序,发现无效。但在模拟器的同一个位置是可以点击到的,所以怀疑有问题。
    于是我分别用getevent来获取模拟器上点击的事件与在XOOM上点击的事件,发现两者不同。

    在模拟器上:  得到的Event是  /dev/input/event0 3 0 180 
                                                /dev/input/event0 3 1 70
                        ...........
                       这6个事件
    在真机上,我用cat /proc/bus/input/devices对比了列出的内容,touchscreen是event6, 但是得到的event却是

       /dev/input/event6: 0003 0030 0000003c

    /dev/input/event6: 0003 0032 00000004

    /dev/input/event6: 0003 0035 000008b6

    /dev/input/event6: 0003 0036 000005ab

    /dev/input/event6: 0003 0034 000000f0

    /dev/input/event6: 0003 0039 00000000

    /dev/input/event6: 0000 0002 00000000

    /dev/input/event6: 0000 0000 00000000
    ......等几十条事件
      我不明白,
    1. 为什么模拟器上点击一下只有固定6条格式,但是模拟器上出现了几十条???

    2. 参考国内很多网络资料也说,用 0003代表要控制绝对坐标,后面跟0或者1表示x或者y坐标,为什么这里却是更的0030,0032,0035,0036,0034,0039,0002这些信息??

    有哪位愿意指点,非常感谢
      

    附录: 用cat获得的设备对应event信息
    # cat /proc/bus/input/devices
    cat /proc/bus/input/devices
    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="compass"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input0
    U: Uniq=
    H: Handlers=event0
    B: EV=5
    B: REL=3f8

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="accelerometer"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input1
    U: Uniq=
    H: Handlers=event1
    B: EV=d
    B: REL=7
    B: ABS=100 7

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="max9635_als"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input2
    U: Uniq=
    H: Handlers=event2
    B: EV=11
    B: MSC=8

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="gyroscope"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input3
    U: Uniq=
    H: Handlers=event3
    B: EV=5
    B: REL=38

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="barometer"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input4
    U: Uniq=
    H: Handlers=event4
    B: EV=9
    B: ABS=1000000

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="cpcap-key"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input5
    U: Uniq=
    H: Handlers=event5 keyreset keyreset
    B: EV=3
    B: KEY=4 0 0 0 800 0 0 0

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="qtouch-touchscreen"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input6
    U: Uniq=
    H: Handlers=event6
    B: EV=b
    B: KEY=400 0 4 0 0 0 0 0 0 0 0
    B: ABS=2750000 11030003

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="stingray-keypad"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input7
    U: Uniq=
    H: Handlers=event7 keyreset keychord
    B: EV=3
    B: KEY=c0000 0 0 0

  • 相关阅读:
    HackerRank "Arithmetic Expressions" !
    HackerRank "Poker Nim"
    HackerRank "Nimble Game"
    HackerRank "Misère Nim"
    HackerRank "Triangle Numbers"
    HackerRank "Flipping the Matrix"
    HackerRank "Chessboard Game, Again!"
    HackerRank "Tower Breakers, Again!"
    HackerRank
    HackerRank "Richie Rich"
  • 原文地址:https://www.cnblogs.com/sode/p/2961383.html
Copyright © 2011-2022 走看看