diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index e378ff8cc7..66cb71c2b1 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -763,7 +763,7 @@ static void Emscripten_UpdateTouchFromEvent(SDL_WindowData *window_data, const E static void Emscripten_UpdatePenFromEvent(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) { SDL_assert(event->pointer_type == PTRTYPE_PEN); - const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); + const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) 1); // something > 0 for the single pen handle. if (pen) { // rescale (in case canvas is being scaled) double client_w, client_h; @@ -849,9 +849,10 @@ static void Emscripten_HandlePenEnter(SDL_WindowData *window_data, const Emscrip { SDL_assert(event->pointer_type == PTRTYPE_PEN); -SDL_Log("PEN ENTER pointerid=%d", event->pointerid); + // event->pointerid is one continuous interaction; it doesn't necessarily track a specific tool over time, like the same finger's ID changed on each new touch event. + // as such, we only expose a single pen, and when the touch ends, we say it lost proximity instead of the calling SDL_RemovePenDevice(). - SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); + 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); } else { @@ -862,7 +863,7 @@ SDL_Log("PEN ENTER pointerid=%d", event->pointerid); peninfo.max_tilt = 90.0f; peninfo.num_buttons = 2; peninfo.subtype = SDL_PEN_TYPE_PEN; - SDL_AddPenDevice(0, NULL, window_data->window, &peninfo, (void *) (size_t) event->pointerid, true); + SDL_AddPenDevice(0, NULL, window_data->window, &peninfo, (void *) (size_t) 1, true); } Emscripten_UpdatePenFromEvent(window_data, event); @@ -884,8 +885,7 @@ EMSCRIPTEN_KEEPALIVE void Emscripten_HandlePointerEnter(SDL_WindowData *window_d static void Emscripten_HandlePenLeave(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) { -SDL_Log("PEN LEAVE pointerid=%d", event->pointerid); - const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); + 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);