通过ADB检测多个触摸事件?
我正在尝试从我的PC上接收从Android设备到C#应用程序的触摸事件。
我的项目涉及将屏幕分为我想检测到的触摸事件的多个部分。我的设备可以注册0到4000的ABS_MT_POINTION_Y更新,因此0到1000是第一部分,1001至2000是第二部分等。
我正在翻译哪个部分被触摸/释放到我的PC上的键入/UP事件,将检测到第三方应用程序。
我正在使用ADB命令shell getEvent -l </code>从连接的设备接收这些事件。
要在C#中接收此信息,我为adb.exe创建过程并从标准图流中读取行,我感兴趣的上述命令的输出是:
EV_KEY BTN_TOUCH DOWN
EV_ABS ABS_MT_POSITION_Y 0000091e
EV_KEY BTN_TOUCH UP
这一切都很好,但是我注意到了一个问题:仅此问题:屏幕的初始触摸被认为是btn_touch down事件。如果我触摸并握住屏幕的一部分,并尝试同时触摸屏幕的另一部分,那么第二次触摸不会引起这些事件。
另一方面,很难从这些事件中确定触摸屏幕的事件会增加BTN_Touch UP事件,因为位置事件与按钮事件并不真正相关。
是否有更可靠的方法来执行此操作?如果我可以在事件发生的位置以及同时在屏幕的多个区域接收触摸,那将是很好的。
I'm trying to receive touch events from my Android device to a C# application on my PC.
My project involves splitting the screen into multiple sections that I want to detect touch events in. Eg. My device can register ABS_MT_POSITION_Y updates from 0 to 4000, so 0 to 1000 is the 1st section, 1001 to 2000 is the 2nd section and so on.
I am translating which section is touched/released to key down/up events on my PC which a 3rd party app will be detecting.
I'm using the adb command shell getevent -l
to receive these events from the connected device.
To receive this in C#, I create process for adb.exe and read lines from the StandardOutput stream, the output from the above mentioned command that I'm interested in are:
EV_KEY BTN_TOUCH DOWN
EV_ABS ABS_MT_POSITION_Y 0000091e
EV_KEY BTN_TOUCH UP
This is all well and good, but I noticed an issue: Only the initial touch of the screen is considered a BTN_TOUCH DOWN event. If I touch and hold one part of the screen, and attempt to touch another part of the screen at the same time, the 2nd touch does not raise these events.
On another note, it's difficult to determine from these events which touch on the screen would have raised the BTN_TOUCH UP event as the position events do not really relate to the button events.
Is there a more reliable way of doing this? It would be nice if I could receive both a touch down/up event along with the position where the event happened and also receive touches in multiple areas of the screen at the same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论