Guarantee that pens are in proximity before motion and button events

This also delays pen proximity out events to make sure that the pen is really gone before delivering them. On Android, you get a HOVER_EXIT event when the pen contacts the surface, which we don't want to treat as the pen leaving proximity.
This commit is contained in:
Sam Lantinga
2026-02-05 10:21:08 -08:00
parent cd7fc90c87
commit bddf6d3e2a
9 changed files with 77 additions and 25 deletions

View File

@@ -78,12 +78,12 @@ void Android_OnPen(SDL_Window *window, int pen_id_in, SDL_PenDeviceType device_t
// we don't compare tip flags above because MotionEvent.getButtonState doesn't return stylus tip/eraser state.
switch (action) {
case ACTION_HOVER_ENTER:
SDL_SendPenProximity(0, pen, window, true);
SDL_SendPenProximity(0, pen, window, true, true);
break;
case ACTION_CANCEL:
case ACTION_HOVER_EXIT: // strictly speaking, this can mean both "proximity out" and "left the View" but close enough.
SDL_SendPenProximity(0, pen, window, false);
SDL_SendPenProximity(0, pen, window, false, false);
break;
case ACTION_DOWN: