Warning, /graphics/krita/3rdparty/ext_qt/0029-Add-a-workaround-for-button-mapping-on-Lenovo-Yoga-C.patch is written in an unsupported language. File is not indexed.

0001 From 380305eb033ef5d5cdf471caad07dca9e2c94641 Mon Sep 17 00:00:00 2001
0002 From: Dmitry Kazakov <dimula73@gmail.com>
0003 Date: Tue, 1 Sep 2020 11:11:50 +0300
0004 Subject: [PATCH 10/47] Add a workaround for button mapping on Lenovo Yoga C940
0005 
0006 Its wintab driver fails to report button mapping and assings nothing
0007 to all the stylus' buttons. In such a case, force-map the stylus press to
0008 the left mouse button.
0009 ---
0010  .../windows/qwindowstabletsupport.cpp         | 21 +++++++++++++++----
0011  1 file changed, 17 insertions(+), 4 deletions(-)
0012 
0013 diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
0014 index f0087556cf..17380a0e4f 100644
0015 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
0016 +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
0017 @@ -544,10 +544,23 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
0018       */
0019      BYTE logicalButtons[32];
0020      memset(logicalButtons, 0, 32);
0021 -    m_winTab32DLL.wTInfo(WTI_CURSORS + currentCursor, CSR_SYSBTNMAP, &logicalButtons);
0022 -    m_devices[m_currentDevice].buttonsMap[0x1] = logicalButtons[0];
0023 -    m_devices[m_currentDevice].buttonsMap[0x2] = logicalButtons[1];
0024 -    m_devices[m_currentDevice].buttonsMap[0x4] = logicalButtons[2];
0025 +    const int numMappedButtons = m_winTab32DLL.wTInfo(WTI_CURSORS + currentCursor, CSR_SYSBTNMAP, &logicalButtons);
0026 +
0027 +    if (numMappedButtons <= 0 || !logicalButtons[0]) {
0028 +        /**
0029 +         * Some WinTab drivers (e.g. Lenovo Yoga C940) fail to report tablet
0030 +         * button mapping and return zeros in the entire mapping array. If that
0031 +         * is the case, map stylus press to the left mouse button as a fallback.
0032 +         */
0033 +        qCWarning(lcQpaTablet) << "WARNING: driver reports that stylus press is not mapped to any mouse button. Force-map it to left button";
0034 +        m_devices[m_currentDevice].buttonsMap[0x1] = 0x1;
0035 +        m_devices[m_currentDevice].buttonsMap[0x2] = 0x2;
0036 +        m_devices[m_currentDevice].buttonsMap[0x4] = 0x4;
0037 +    } else {
0038 +        m_devices[m_currentDevice].buttonsMap[0x1] = logicalButtons[0];
0039 +        m_devices[m_currentDevice].buttonsMap[0x2] = logicalButtons[1];
0040 +        m_devices[m_currentDevice].buttonsMap[0x4] = logicalButtons[2];
0041 +    }
0042  
0043      m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
0044      m_state = PenProximity;
0045 -- 
0046 2.20.1.windows.1
0047