iphone touch shape or raw data

2020-07-26 09:13发布

问题:

Anyone know if it is yet possible to detect the touch shape? Maybe through getting the raw touchscreen data?

I found this question/answer here: How to get raw touchscreen data?

That mentions GSEvent, but it is quite old.

I'd like to try to get a rough calculation of the pressure of the touch by its shape/area, but of course UITouch only gives a calculated point.

回答1:

Yes, raw touch data is contained in the GSEventRecord object, particularly what you are looking for is the pathMajorRadius property on GSPathInfo, which gives the major radious on the tap. This is a rough estimate of the pressure, but take into account big/small fingers give also different measures.

Watch out for the pathPressure property also in GSPathInfo, it does NOT contain the pressure. It always contains 1, capacitive screens (like the iPad's or IPhone's) do not measure pressure at all.

If you are planning submitting your app in the app store, you won't be able to do it if you include access to private frameworks (like in this case, GSEvent.h in the GraphicServices framework). But what you need to do is catch every UIEvent in the sendEvent method of your subclassed UIApplication, then use the methods in https://github.com/kennytm/iphone-private-frameworks/blob/master/GraphicsServices/GSEvent.h to get the information of the GSEvent.