While-E
While-E

Reputation: 1555

Get maximum touch event size for a device?

How do I get access to the values of InputDevice.MotionRange getMotionRange(int axis), so I can find the maximum acceptable size of a touchEvent on a given phone?

[edit] To clarify, I'm looking to pair the results of MotionEvent.getSize() (1f being the largest acceptable touch event area) with a function that will actually tell me this property of the phone? Thus getting an approximate size in px/dips whatever of the touch area.

Basically trying to do something like below:

final InputDevice device = event.getDevice();

Cheers!

Upvotes: 0

Views: 2077

Answers (1)

Mark Allison
Mark Allison

Reputation: 21909

There are different values for different touch events. The best place to start is the ViewConfiguration class, specifically the fields which have "slop" in their name. If you want to know how far your finger has to move to be classed as a scroll event, you would use getScaledTouchSlop(); and if you wanted to know the maximum permissible distance between two taps for them to register as a double tap, you would use getScaledDoubleTapSlop().

You can obtain the ViewConfiguration for any given Context by calling:

ViewConfiguration vc = ViewConfiguration.get( context );

Upvotes: 1

Related Questions