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

@@ -868,7 +868,7 @@ static void Emscripten_HandlePenEnter(SDL_WindowData *window_data, const Emscrip
SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) 1); // something > 0 for the single pen handle.
if (pen) {
SDL_SendPenProximity(0, pen, window_data->window, true);
SDL_SendPenProximity(0, pen, window_data->window, true, true);
} else {
// Web browsers offer almost none of this information as specifics, but can without warning offer any of these specific things.
SDL_PenInfo peninfo;
@@ -902,7 +902,7 @@ static void Emscripten_HandlePenLeave(SDL_WindowData *window_data, const Emscrip
const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) 1); // something > 0 for the single pen handle.
if (pen) {
Emscripten_UpdatePointerFromEvent(window_data, event); // last data updates?
SDL_SendPenProximity(0, pen, window_data->window, false);
SDL_SendPenProximity(0, pen, window_data->window, false, false);
}
}