免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3060 | 回复: 0
打印 上一主题 下一主题

Linux上,触摸屏模拟产生的事件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-05-12 14:27 |只看该作者 |倒序浏览
众所周知,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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP