Browse Source

Fixed right click mouse emulation for the Wacom tablet

The problems are two-fold. When this happens a WM_POINTERDOWN event is sent with IS_POINTER_INCONTACT_WPARAM() evaluating as true. So when SDL_SendPenButton() is sent for the barrel button, there is no pen in contact yet, so the right mouse button is sent. Then SDL_SendPenTouch() is sent, which generates a left button press event.

Fixes https://github.com/libsdl-org/SDL/issues/12926

(cherry picked from commit e04064350fced03888f752aa76b82d368eaa632a)
Sam Lantinga 3 months ago
parent
commit
22e968af4e
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/events/SDL_pen.c
  2. 1 1
      src/video/windows/SDL_windowsevents.c

+ 1 - 1
src/events/SDL_pen.c

@@ -565,7 +565,7 @@ void SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, SDL_Window *wind
             event.pbutton.down = down;
             SDL_PushEvent(&event);
 
-            if (window && (pen_touching == instance_id)) {
+            if (window && !pen_touching || (pen_touching == instance_id)) {
                 SDL_Mouse *mouse = SDL_GetMouse();
                 if (mouse && mouse->pen_mouse_events) {
                     SDL_SendMouseButton(timestamp, window, SDL_PEN_MOUSEID, button + 1, down);

+ 1 - 1
src/video/windows/SDL_windowsevents.c

@@ -1359,7 +1359,7 @@ 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);
+        const bool istouching = IS_POINTER_INCONTACT_WPARAM(wParam) && IS_POINTER_FIRSTBUTTON_WPARAM(wParam);
 
         // if lifting off, do it first, so any motion changes don't cause app issues.
         if (!istouching) {