Is event handling in android mode accurate?

Error

I have a strange mistake in the piano application. Sometimes the keys (and thus the notes) hang. I did a lot of debugging and narrowed it down to what seems like a fuzzy android processing when handling motion events:

 DEBUG/(2091): ACTION_DOWN A4
 DEBUG/(2091): KeyDown: A4
 DEBUG/(2091): ACTION_MOVE A4 => A4
 DEBUG/(2091): ACTION_MOVE ignoring
 DEBUG/(2091): ACTION_MOVE A4 => A4
 DEBUG/(2091): ACTION_MOVE ignoring
 DEBUG/(2091): ACTION_MOVE A4 => A4
 DEBUG/(2091): ACTION_MOVE ignoring
 DEBUG/(2091): ACTION_UP B4 //HOW CAN THIS BE????
 DEBUG/(2091): KeyUp: B4
 DEBUG/(2091): Stream is null, can't stop
 DEBUG/(2091): Hanging Note: A4 X=240-287 EventX=292 Y=117-200 EventY=164
 DEBUG/(2091): KeyUp Note:   B4 X=288-335 EventX=292 Y=117-200 EventY=164

It is clear that here it is clear that from nowhere I unexpectedly received ACTION_UPfor another note. Shouldn't I get it first ACTION_MOVE?

As shown at the end of the log, this is definitely not an error in detecting an area, since the event is ACTION_UPclearly in area B4.

Login Information

Each onTouchEvent()call is logged, so the log is accurate.

Corresponding pseudo code for ACTION_MOVE logging:

 Key oldKey = Key.get(event.getHistoricalX(), event.getHistoricalY());
 Key newKey = Key.get(event.getX(), event.getY());

Question

Is this the usual behavior for Android (jumping in coordinates)?

ACTION_UP - ACTION_MOVE ?

+3
1

, - Android. , , , , .

, "TouchEvents" . , / , , . , .

List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
    int len = touchEvents.size();
    for(int i = 0; i < len; i++) {
        TouchEvent event = touchEvents.get(i);

        if(event.type == TouchEvent.TOUCH_DRAGGED || event.type == TouchEvent.TOUCH_DOWN) ...    

: "game.getInput(). getTouchEvents()" TouchEvent , getTouchEvent

, , -, !

0

Source: https://habr.com/ru/post/1748737/


All Articles