diff options
author | Nicholas Rishel <rishel.nick@gmail.com> | 2020-05-23 05:27:19 +0300 |
---|---|---|
committer | Nicholas Rishel <rishel.nick@gmail.com> | 2020-10-31 02:29:03 +0300 |
commit | 1b535e871998c021c6233c32ffd95a563a655980 (patch) | |
tree | 1a97c09aa593571b2f6a36e932f45891e20bf2df /intern | |
parent | 3281507f7b745052b2b58565e7e95f60b1c9c400 (diff) |
Mask all button down/up and switch back to using relative button input.
Signed-off-by: Nicholas Rishel <rishel.nick@gmail.com>
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 36 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.h | 4 |
2 files changed, 17 insertions, 23 deletions
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 */ |