mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
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 ea67133e4f
)
This commit is contained in:

committed by
Sam Lantinga

parent
56c76c20a0
commit
e37e96cfff
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user