简体   繁体   中英

Android touch continuous pressure logging

I know that there exist the MotionEvent.getPressure() function which would return some pressure value from the touch screen. 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. 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. 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.

Make sure you are also reading the historical MotionEvents if you want the most complete touch information possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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