Bug 399585 - Enabling Windows 8+ pointer input breaks middle button actions
Summary: Enabling Windows 8+ pointer input breaks middle button actions
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tablets (tablet issues are only very rarely bugs in Krita!) (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-10 01:08 UTC by Tyson Tan
Modified: 2019-04-18 15:01 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Event log of Windows 1809 and Cintiq Pro 13 (918.71 KB, text/x-log)
2019-04-18 13:12 UTC, Tyson Tan
Details
Event log of Windows 1809 and Cintiq Pro 13 2 (487.87 KB, text/x-log)
2019-04-18 13:35 UTC, Tyson Tan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tyson Tan 2018-10-10 01:08:37 UTC
SUMMARY
Under Windows Krita has an option called: 
[ ] Windows 8+ Pointer Input (depends on Windows Ink) (EXPERIMENTAL)
When checked, tablet draws and right-clicks properly, but middle button actions like panning and zooming are not being recognized.

Tested on:
Windows 10 1809
krita-nightly-x64-v4.1.3.1-239-ge64348e693-setup.exe	
Wacom Cintiq Pro 13 / Wacom MobileStudio Pro 13

STEPS TO REPRODUCE
1. Enable Windows Ink in Wacom Tablet properties;
2. Enable Windows 8+ pointer in Krita;
3. Restart Krita;
4. Create a new file;
5. Try use actions associated with middle button.

OBSERVED RESULT
Tablet draws and right-clicks properly, but middle button actions like panning and zooming are not being recognized.

EXPECTED RESULT
Middle button actions functions properly like they are under WinTab mode.

SOFTWARE VERSIONS
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Dmitry Kazakov 2019-04-17 11:28:29 UTC
Hi, Tyson!

The problem is that "Windows 8+ Pointer API" is not designed for professional tablet devices. Therefore it doesn't support more than one button on the stylus barrel. There is a technical hackish workaround for reporting more than one button (which makes the protocol kind of inconsistent), but none of the drivers implement it (I tested Wacom and Huion). So we can do nothing about the problem, sorry :(

There are the following workarounds possible:

1) Map the second button to Space key in the driver. Then button+click will do pan for you and ctrl+button+click will do zoom.

2) Map the second button to "Pan" action. With such configuration Wacom driver generates Space+click. Therefore click will do panning for you and ctrl+click will do zoom. Exactly like it happens when the button is mapped to middle-button.


PS:
I have also tested Huion tablet and it seems like it doesn't report barrel buttons via WinInk at all. Again we cannot do anything about it. It needs to be reported to the manufacturer.
Comment 2 Dmitry Kazakov 2019-04-17 17:16:26 UTC
Okay, it seems like I have a workaround for the bug...
Comment 3 Dmitry Kazakov 2019-04-17 17:31:21 UTC
Git commit c30c6f424c4226531738c93a5d01548e986cba8a by Dmitry Kazakov.
Committed on 17/04/2019 at 17:30.
Pushed by dkazakov into branch 'master'.

Implement a hack for right- and middle-buttons on weird tablet devices

If should fix the following cases:

1) Wintab drivers that do not generate tablet events for right-click and
   middle-click.

2) WinInk mode. With the patch both right- and middle-clicks should be
   available with the stylus buttons.

To activate a workaround just add the following to your 'kritarc':

rightMiddleTabletButtonWorkaround=true

This hack just ignores tablet events for right- and middle-click and
starts to use mouse events for them. Please be careful, the hack will
make right- and middle-strokes less precise. And it also can just break
the tablet support completely.
Related: bug 368849

M  +0    -5    libs/ui/input/kis_input_manager.cpp
M  +36   -6    libs/ui/input/kis_input_manager_p.cpp
M  +3    -2    libs/ui/input/kis_input_manager_p.h

https://commits.kde.org/krita/c30c6f424c4226531738c93a5d01548e986cba8a
Comment 4 Dmitry Kazakov 2019-04-17 18:02:19 UTC
Hi, Tyson!

Could you please test this package and check if the workaround lets you use right and middle buttons of the stylus?

https://yadi.sk/d/db3yUdmPLm8wAg

1) Unpack the package
2) Add to %LOCALAPPDATA%\kritarc: 'rightMiddleTabletButtonWorkaround=true'
3) Run Krita, if needed, activate WinInk and restart
4) Test the buttons
Comment 5 Tyson Tan 2019-04-18 01:58:50 UTC
Hi Dmitry! Thank you for the patch and I've tested it on Windows 10 1809 with Cintiq Pro 13 and Intuos Pro 2 M. Both the drivers and Krita have their Windows Ink enabled. Sadly it didn't work as intended for me.

1) The good part is the mouse event seems to be recognized by Krita:

# Tablet Tester Information BEGIN

Pen tip brought near
Mouse press X=73 Y=127 B=4
Mouse move X=74 Y=127 B=4
Mouse move X=75 Y=127 B=4
Mouse move X=75 Y=128 B=4
Mouse move X=75 Y=129 B=4
Mouse move X=74 Y=129 B=4
Mouse move X=74 Y=130 B=4
Mouse move X=74 Y=129 B=4
Mouse move X=75 Y=129 B=4
Mouse release
Pen tip taken away
Pen tip brought near
Pen tip taken away

# Tablet Tester Information END

2) But for some reason Krita wouldn't pan the canvas according to most of my attempts.

3) For the roughly 1/30 chance when the canvas managed to pan, I could not stop it by releasing the middle button. And then I was stuck under the panning state, none of the stylus's buttons worked. I had to use my mouse's middle button to snap out of it.

4) Although I have no idea how it works, is it possible that Krita expects the mouse cursor to stay still while pressing the middle button here? It was the only human random factor in this test, I think.
Comment 6 Bug Janitor Service 2019-04-18 04:33:11 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 7 Dmitry Kazakov 2019-04-18 12:50:32 UTC
Hi, Tyson!

Could you please generate a tablet log for one middle-button stroke?

Manual: https://docs.krita.org/en/KritaFAQ.html#windows
 
Don't forget to press Ctrl+Shift+T before recording the stroke
Comment 8 Tyson Tan 2019-04-18 13:12:54 UTC
Created attachment 119487 [details]
Event log of Windows 1809 and Cintiq Pro 13

The event log was generated with:
1) a few failed middle click attempts;
2) 1 right click;
3) 1 successful middle click attempt, but it stuck there;
4) 1 middle click from my mouse to snap out of it.

Hope it helps!
Comment 9 Tyson Tan 2019-04-18 13:35:18 UTC
Created attachment 119488 [details]
Event log of Windows 1809 and Cintiq Pro 13 2

It worked after I cleared kritarc and everything. This is the event log when it was working.
Comment 10 Dmitry Kazakov 2019-04-18 13:39:28 UTC
Okay, thank you for your testing!
Comment 11 Halla Rempt 2019-04-18 14:19:51 UTC
Closing then.
Comment 12 Dmitry Kazakov 2019-04-18 14:52:46 UTC
Git commit 4e602f7aaa64256051f4057b3aa81f5108ee0fc7 by Dmitry Kazakov.
Committed on 18/04/2019 at 14:50.
Pushed by dkazakov into branch 'master'.

Add a GUI settings for useRightMiddleTabletButtonWorkaround

Some tablet devices don't pass barrel-button clicks via tablet API.
If you have such a device, you can try activate this workaround.
Krita will try to read right- and middle-button clicks from the
mouse events stream. It may or may not work on your device
(depends on the tablet driver implementation).
CC:kimageshop@kde.org

M  +9    -0    libs/ui/dialogs/kis_dlg_preferences.cc
M  +43   -33   libs/ui/forms/wdgtabletsettings.ui
M  +1    -1    libs/ui/input/kis_input_manager_p.cpp
M  +10   -0    libs/ui/kis_config.cc
M  +3    -0    libs/ui/kis_config.h

https://commits.kde.org/krita/4e602f7aaa64256051f4057b3aa81f5108ee0fc7
Comment 13 Tyson Tan 2019-04-18 15:01:31 UTC
Thank you Dmitry! This is going to help many new users! :D