简体   繁体   English

Android MotionEvent压力测量单位

[英]Android MotionEvent pressure unit of measurement

I am using the getPressure(index) method from the MotionEvent instance to get a value of the pressure applied to screen. 我正在使用MotionEvent实例中的getPressure(index)方法来获取应用于屏幕的压力值。

I am trying to figure out how to convert that value to at least an approximation of a standard measurement unit. 我试图弄清楚如何将该值转换为至少近似的标准测量单位。

in Android the pressure value is a float ranging from 0 to 1. I need to express it in Newtons in some way. 在Android中,压力值是一个从0到1的浮点数。我需要以某种方式用牛顿表示它。 From what i understood this is different across devices so its not possible get a really precise unit measurement but i am fine with an approximation. 从我的理解,这是不同的设备,所以它不可能得到一个非常精确的单位测量,但我很好近似。

Like what amount in newtons is normal for a stylus touching the screen on full force (the device measuring 1.0f of pressure) 类似于牛顿的数量是正常的触笔触摸屏幕的全力(该设备测量1.0f的压力)

I think you can only guess, and know that the results will be affected by huge uncertainity. 我想你只能猜测,并且知道结果会受到巨大不确定性的影响。 Solutions I see: 解决方案我看到:

  1. Put an object of appropriate, known weight on the screen. 在屏幕上放置一个适当的已知重量的物体。 Don't know about screens, but if it needs human skin to trigger the event, you can put your finger on the screen (making no strength on it) and then put some object on your finger. 不了解屏幕,但如果它需要人体皮肤来触发事件,你可以将手指放在屏幕上(没有力量),然后在手指上放一些物体。

  2. Take a stylus, and by debugging learn how much force you need to get a 0.5f result. 拿一支手写笔,通过调试了解获得0.5f结果所需的力量。 Then take a scale (foreign speaker here; I mean the tool that measures weights..?) and apply the same pressure on it with the stylus, and read the results. 然后拿一个刻度(外国扬声器在这里;我指的是测量重量的工具......?)并用触笔对其施加相同的压力,并读取结果。

In both cases, you can have a single map point (eg, 0.5f -> 10 N ), and then assume a linear dependency (knowing also that 0f -> 0 N ) to fill the whole range. 在这两种情况下,您可以使用单个地图点(例如, 0.5f -> 10 N ),然后假设线性相关性(也知道0f -> 0 N )来填充整个范围。

With some patience you can fill different values too - I would not expect the relation to be linear actually. 有了一些耐心,你也可以填写不同的值 - 我不希望这种关系实际上是线性的。

getPressure returns a value 0-1 because the way pressure is calculated is device-dependant. getPressure返回值0-1,因为计算压力的方式取决于设备。 Some devices will calculate the value from how much of the area of your finger is touching the screen. 有些设备会根据手指触摸屏幕的大小来计算值。 So from that it's probably not possible to convert to newtons in a way which will work on multiple Android devices unless you write a solution for each one. 因此,除非您为每个设备编写解决方案,否则可能无法以多种Android设备的方式转换为牛顿。

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

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