diff options
author | Nicholas Rishel <rishel.nick@gmail.com> | 2020-05-24 02:48:18 +0300 |
---|---|---|
committer | Nicholas Rishel <rishel.nick@gmail.com> | 2020-10-31 02:29:03 +0300 |
commit | b98ea1b268ee4440085f54537ac50ed9cf5f2f57 (patch) | |
tree | 42c78527997060792407cfc88c83e9f8a69aac3a | |
parent | c4821079b71dd873841220477931368298249549 (diff) |
Revert "Mask all button down/up and switch back to using relative button input."
This reverts commit 045aaf6f78f1fbb6e2bbefd234b7bae04844d42b.
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 36 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.h | 4 |
2 files changed, 23 insertions, 17 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 3d6eaeb7f20..199d1c98c2c 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -1016,6 +1016,7 @@ void GHOST_WindowWin32::updateWintab(bool active) // window is active. m_tabletInRange = false; m_wintab.numSysButtons = 0; + m_wintab.sysButtonsPressed = 0; } } } @@ -1042,9 +1043,6 @@ 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; @@ -1356,25 +1354,31 @@ GHOST_TSuccess GHOST_WindowWin32::getWintabInfo(std::vector<GHOST_WintabInfoWin3 outWintabInfo[i].x = pkt.pkX; outWintabInfo[i].y = pkt.pkY; - 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; + // 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; } } 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 43a6746f75f..00ba63df170 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 PK_BUTTONS +#define PACKETMODE 0 #include <pktdef.h> class GHOST_SystemWin32; @@ -618,6 +618,8 @@ 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 */ |