Bladeren bron

pen: Windows can't check WM_POINTER[DOWN|UP] for touches directly.

These events fire for other things, such as pressing a barrel button while
the pen is hovering.

The correct thing to do is check IS_POINTER_INCONTACT_WPARAM in the event.

If the pen is already touching or not, SDL_SendPenTouch() will do the right
thing, so it's safe to call it even if we're already in the right state.

(cherry picked from commit ea67133e4f97b349dda6f1915b1d25e74c4acb26)
Ryan C. Gordon 10 maanden geleden
bovenliggende
commit
e37e96cfff
1 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. 4 2
      src/video/windows/SDL_windowsevents.c

+ 4 - 2
src/video/windows/SDL_windowsevents.c

@@ -1359,8 +1359,10 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
         const Uint64 timestamp = WIN_GetEventTimestamp();
         SDL_Window *window = data->window;
 
+        const bool istouching = IS_POINTER_INCONTACT_WPARAM(wParam);
+
         // if lifting off, do it first, so any motion changes don't cause app issues.
-        if (msg == WM_POINTERUP) {
+        if (!istouching) {
             SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, false);
         }
 
@@ -1390,7 +1392,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
         }
 
         // if setting down, do it last, so the pen is positioned correctly from the first contact.
-        if (msg == WM_POINTERDOWN) {
+        if (istouching) {
             SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, true);
         }