Skip to content

Commit ea67133

Browse files
committed
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.
1 parent f131791 commit ea67133

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/video/windows/SDL_windowsevents.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,10 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
13281328
const Uint64 timestamp = WIN_GetEventTimestamp();
13291329
SDL_Window *window = data->window;
13301330

1331+
const bool istouching = IS_POINTER_INCONTACT_WPARAM(wParam);
1332+
13311333
// if lifting off, do it first, so any motion changes don't cause app issues.
1332-
if (msg == WM_POINTERUP) {
1334+
if (!istouching) {
13331335
SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, false);
13341336
}
13351337

@@ -1359,7 +1361,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
13591361
}
13601362

13611363
// if setting down, do it last, so the pen is positioned correctly from the first contact.
1362-
if (msg == WM_POINTERDOWN) {
1364+
if (istouching) {
13631365
SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, true);
13641366
}
13651367

0 commit comments

Comments
 (0)