From 1b535e871998c021c6233c32ffd95a563a655980 Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Fri, 22 May 2020 19:27:19 -0700 Subject: Mask all button down/up and switch back to using relative button input. Signed-off-by: Nicholas Rishel --- intern/ghost/intern/GHOST_WindowWin32.cpp | 36 ++++++++++++++----------------- intern/ghost/intern/GHOST_WindowWin32.h | 4 +--- 2 files changed, 17 insertions(+), 23 deletions(-) (limited to 'intern') 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> 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 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 */ -- cgit v1.2.3