Handle CANCEL touch events

Handling this event is part of the API but was never done. This caused
unstoppable key-repeat.

This event isn't common, the only way I found on Android 10 is to switch
to the emoji keyboard while holding a key. Some apps might cause this
event more often.
This commit is contained in:
Jules Aguillon 2022-03-15 20:44:02 +01:00
parent fadedfd58f
commit d53ee811d9
2 changed files with 16 additions and 3 deletions

View File

@ -129,6 +129,9 @@ public class Keyboard2View extends View
for (p = 0; p < event.getPointerCount(); p++)
_pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
break;
case MotionEvent.ACTION_CANCEL:
_pointers.onTouchCancel(event.getPointerId(event.getActionIndex()));
break;
default:
return (false);
}

View File

@ -95,6 +95,16 @@ public final class Pointers implements Handler.Callback
}
}
public void onTouchCancel(int pointerId)
{
Pointer ptr = getPtr(pointerId);
if (ptr == null)
return;
stopKeyRepeat(ptr);
removePtr(ptr);
_handler.onPointerFlagsChanged();
}
public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key)
{
KeyValue value = key.key0;