简体   繁体   English

Android touch连续压力记录

[英]Android touch continuous pressure logging

I know that there exist the MotionEvent.getPressure() function which would return some pressure value from the touch screen. 我知道存在MotionEvent.getPressure()函数,该函数将从触摸屏返回一些压力值。 However, it only returns the pressure at one given time, for one given event. 但是,对于一个给定事件,它仅在给定时间返回压力。 Is it possible to get the pressure with some sampling rate, ie no more motion events are triggered, but we still measure the current pressure? 是否可以以一定的采样率获得压力,即不再触发运动事件,但是我们仍然测量当前压力?

Thanks! 谢谢!

Depending on your device, Android 4.0ish and later should be upsampling your touches to about 140 events per second. 根据您的设备,Android 4.0ish和更高版本应该将您的触摸每秒最多采样140个事件。 The most recent event you have will have the current pressure. 您最近遇到的事件将具有当前压力。 Those pressure readings in MotionEvents originate from the touchscreen driver which is simultaneously reporting changes in coordinates and changes in pressure through the kernel. MotionEvents中的压力读数来自触摸屏驱动程序,该驱动程序同时报告坐标的变化和通过内核的压力变化。 If you don't get a new event, there is no "new" pressure. 如果没有新事件,就没有“新”压力。 Put another way, there is no way to "ask" the touchscreen what the current pressure is, it only produces a stream of events. 换句话说,没有办法“询问”触摸屏当前压力是多少,它只会产生一系列事件。 You may want to look at adb getevent to get a feel for this. 您可能想看看adb getevent对此有所了解。

Make sure you are also reading the historical MotionEvents if you want the most complete touch information possible. 如果您需要尽可能完整的触摸信息,请确保您还在阅读历史性的MotionEvent。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM