Reputation: 952
I am trying to program a joystick in which the user only sends his coordinates if he stopped moving his thumb (or at least only a little, shaking for example).
I cannot find an touchevent for that.
Further explanation: brown = thumb, red is the area/circle that gets tolerated (moving in that space the next 2 seconds will count as 1 coordinate)
int actionType = event.getAction();
if (actionType == MotionEvent.ACTION_MOVE){}
This is how i retrieve my toucheventdata. i would need something like ACTION_HOLD
and a timer. Am i missing something?
Upvotes: 0
Views: 147
Reputation: 26
Try to round the coordinates.
Divide the coordinates with an integer (ex. 10),
Cast the result into an integer (or round it) and multiply with the same integer in the next Step.
Example:
5,30 / 10 = 0,53
(int) 0,53 = 0
0 * 10 = 0
14,4 / 10 = 1,44
(int) 1,44 = 1
1 * 10 = 10
Upvotes: 1