[Bf-blender-cvs] [1b535e87199] master: Mask all button down/up and switch back to using relative button input.

Nicholas Rishel noreply at git.blender.org
Sat Oct 31 00:32:25 CET 2020


Commit: 1b535e871998c021c6233c32ffd95a563a655980
Author: Nicholas Rishel
Date:   Fri May 22 19:27:19 2020 -0700
Branches: master
https://developer.blender.org/rB1b535e871998c021c6233c32ffd95a563a655980

Mask all button down/up and switch back to using relative button input.

Signed-off-by: Nicholas Rishel <rishel.nick at gmail.com>

===================================================================

M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.h

===================================================================

diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 954f186bddd..e2d900a41b5 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -1016,7 +1016,6 @@ void GHOST_WindowWin32::updateWintab(bool active)
       // window is active.
       m_tabletInRange = false;
       m_wintab.numSysButtons = 0;
-      m_wintab.sysButtonsPressed = 0;
     }
   }
 }
@@ -1043,6 +1042,9 @@ void GHOST_WindowWin32::initializeWintab()
     lc.lcPktData = PACKETDATA;
     lc.lcPktMode = PACKETMODE;
     lc.lcMoveMask = PACKETDATA;
+    // Mask all buttons, or button events won't occur for Wintab libaries that don't mask the
+    // system context buttons by default
+    lc.lcBtnUpMask = lc.lcBtnDnMask = ~0;
     // Wacom maps y origin to the tablet's bottom
     // Invert to match Windows y origin mapping to the screen top
     lc.lcOutExtY = -lc.lcOutExtY;
@@ -1354,31 +1356,25 @@ GHOST_TSuccess GHOST_WindowWin32::getWintabInfo(std::vector<GHOST_WintabInfoWin3
     outWintabInfo[i].x = pkt.pkX;
     outWintabInfo[i].y = pkt.pkY;
 
-    // Some Wintab libraries don't handle relative button input correctly, so we track button
-    // presses manually.
-    DWORD buttonsChanged = m_wintab.sysButtonsPressed ^ pkt.pkButtons;
-
-    // Find the index for the changed button from the button map.
-    DWORD physicalButton = 0;
-    for (DWORD diff = (unsigned)buttonsChanged >> 1; diff > 0; diff = (unsigned)diff >> 1) {
-      physicalButton++;
-    }
-
-    if (buttonsChanged &&
-        wintabMouseToGhost(pkt.pkCursor, physicalButton, outWintabInfo[i].button)) {
-      if (buttonsChanged & pkt.pkButtons) {
-        outWintabInfo[i].type = GHOST_kEventButtonDown;
-      }
-      else {
-        outWintabInfo[i].type = GHOST_kEventButtonUp;
+    if (pkt.pkButtons &&
+        wintabMouseToGhost(pkt.pkCursor, LOWORD(pkt.pkButtons), outWintabInfo[i].button)) {
+      switch (HIWORD(pkt.pkButtons)) {
+        case TBN_DOWN:
+          outWintabInfo[i].type = GHOST_kEventButtonDown;
+          break;
+        case TBN_UP:
+          outWintabInfo[i].type = GHOST_kEventButtonUp;
+          break;
+        default:
+          printf("%x TBN_NONE, but why?", m_hWnd);
+          outWintabInfo[i].type = GHOST_kEventCursorMove;
+          break;
       }
     }
     else {
       outWintabInfo[i].type = GHOST_kEventCursorMove;
     }
 
-    m_wintab.sysButtonsPressed = pkt.pkButtons;
-
     // Wintab does not support performance counters, so use low frequency counter instead
     outWintabInfo[i].time = system->tickCountToMillis(pkt.pkTime);
     outWintabInfo[i].tabletData = tabletData;
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 328191d837a..913d75b1708 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -40,7 +40,7 @@
 // PACKETDATA and PACKETMODE modify structs in pktdef.h, so make sure they come first
 #define PACKETDATA \
   (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR | PK_X | PK_Y | PK_TIME)
-#define PACKETMODE 0
+#define PACKETMODE PK_BUTTONS
 #include <pktdef.h>
 
 class GHOST_SystemWin32;
@@ -618,8 +618,6 @@ class GHOST_WindowWin32 : public GHOST_Window {
     UINT numDevices = 0;
     /** Number of cursors currently in contact mapped to system buttons */
     GHOST_TUns8 numSysButtons = 0;
-    /** Cursors currently in contact mapped to system buttons */
-    DWORD sysButtonsPressed = 0;
     LONG maxPressure = 0;
     LONG maxAzimuth = 0, maxAltitude = 0;
     /* Queue size doesn't change once set, so reuse the same buffer */



More information about the Bf-blender-cvs mailing list