Bug 408454

Summary: [Wacom] Eraser (as a side stylus button) doesn't always switch to an eraser in 4.2.x
Product: [Applications] krita Reporter: Yaroslav <OddMorning>
Component: Tablets (tablet issues are only very rarely bugs in Krita!)Assignee: Dmitry Kazakov <dimula73>
Status: RESOLVED UPSTREAM    
Severity: normal CC: akin.feyijinmi, cybermotroncom, halla
Priority: NOR    
Version: 4.2.1   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Wacom Preferences menu
Log of some lines drawn with and without button pressed
Log from “v4.2.0-beta-291-g9044a28b53”

Description Yaroslav 2019-06-08 14:09:38 UTC
Created attachment 120693 [details]
Wacom Preferences menu

OS: Windows 10 (18362.145)
Krita: 4.2.1
Tablet: Wacom Bamboo Fun Pen & Touch CTH661
Driver: 5.3.5-3 (the last available “Previous Generation Products” version on Wacom site)

I prefer to use a side stylus button as a eraser because it's faster than flipping pen every time I need to erase something. And this way worked more or less stable (sometimes I had to press the button twice to unstuck the stuck eraser brush) in versions 4.1.7 and below. But in 4.2.x and 4.3.0-prealpha (git f7971aa) the button press doesn't work, i.e. current brush doesn't switch to the eraser one.
I should mention that pen's eraser tip still works as expected.

Reproducible: Always

Steps to Reproduce:
1. Select non-eraser brush
2. Keep a pen above surface and hold an assigned to eraser mode side stylus button (or just hold that button and try to erase something)

Actual Results:
Brush doesn't change. There's a small chance (≈1 of 20) for a button press leave a spot like I touched the tablet surface with a pen tip, and even smaller change (≈1 of 50) for an actual brush-to-eraser-and-back-to-brush switch.

Expected Results:
Brush switches to eraser when button is pressed and switches to previous brush when released (4.1.7 behavior).
Comment 1 Halla Rempt 2019-06-08 14:41:30 UTC
Could you make a tablet log so we can see what arrives in Krita's even stream?  See https://docs.krita.org/en/KritaFAQ.html#what-if-your-tablet-is-not-recognized-by-krita for instructions on making a tablet log.
Comment 2 Yaroslav 2019-06-08 15:17:24 UTC
Created attachment 120701 [details]
Log of some lines drawn with and without button pressed
Comment 3 Halla Rempt 2019-06-12 12:34:14 UTC
Thanks. Dmitry, can you take a look?
Comment 4 Dmitry Kazakov 2019-06-14 15:18:15 UTC
Hi, Yaroslav!

How do you configure your Wacom tablet to generate eraser tip for a button press? I cannot find any driver option for that :(
Comment 5 Yaroslav 2019-06-14 17:11:00 UTC
Hi, Dmitry! Check the “Wacom Preferences menu” attachment. I have a previous generation tablet so that window looks different from the configuration menu of newer tablets. But I'm almost sure new tablets have such option as well.
Comment 6 Dmitry Kazakov 2019-06-19 11:29:48 UTC
Git commit f0d23431d760a2bb7a3c9cc37fd61698a70ba429 by Dmitry Kazakov.
Committed on 19/06/2019 at 11:29.
Pushed by dkazakov into branch 'master'.

Fix switching of pointer type by the stylus tip

We should check if any button is pressed by the already mapped value,
but not raw value of the buttons. Wintab will always report the button
to be pressed, although it is unmapped by CSR_SYSBTNMAP
Related: bug 405747

M  +27   -25   3rdparty/ext_qt/0024-Fetch-stylus-button-remapping-from-WinTab-driver.patch
M  +9    -7    3rdparty/ext_qt/0026-Fetch-mapped-screen-size-from-the-Wintab-driver.patch
M  +28   -10   3rdparty/ext_qt/0027-Switch-stylus-pointer-type-when-the-tablet-is-in-the.patch
M  +6    -4    3rdparty/ext_qt/0028-Fix-updating-tablet-pressure-resolution-on-every-pro.patch

https://invent.kde.org/kde/krita/commit/f0d23431d760a2bb7a3c9cc37fd61698a70ba429
Comment 7 Dmitry Kazakov 2019-06-19 14:51:34 UTC
*** Bug 408076 has been marked as a duplicate of this bug. ***
Comment 8 Halla Rempt 2019-06-20 10:49:28 UTC
Git commit a9870aa6e2c90ce2cc8cc1066f2dddc7719ae1cc by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 20/06/2019 at 10:33.
Pushed by rempt into branch 'krita/4.2'.

Fix switching of pointer type by the stylus tip

We should check if any button is pressed by the already mapped value,
but not raw value of the buttons. Wintab will always report the button
to be pressed, although it is unmapped by CSR_SYSBTNMAP
Related: bug 405747

M  +27   -25   3rdparty/ext_qt/0024-Fetch-stylus-button-remapping-from-WinTab-driver.patch
M  +9    -7    3rdparty/ext_qt/0026-Fetch-mapped-screen-size-from-the-Wintab-driver.patch
M  +28   -10   3rdparty/ext_qt/0027-Switch-stylus-pointer-type-when-the-tablet-is-in-the.patch
M  +6    -4    3rdparty/ext_qt/0028-Fix-updating-tablet-pressure-resolution-on-every-pro.patch

https://invent.kde.org/kde/krita/commit/a9870aa6e2c90ce2cc8cc1066f2dddc7719ae1cc
Comment 9 Yaroslav 2019-06-20 17:18:16 UTC
Created attachment 121038 [details]
Log from “v4.2.0-beta-291-g9044a28b53”

I just tested the “krita-nightly-x64-v4.2.0-beta-291-g9044a28b53” build which contains the “f0d2343” commit but the problem is still here
Comment 10 Dmitry Kazakov 2019-06-24 10:15:24 UTC
Hi, Yaroslav!

Could you please check this package?
https://yadi.sk/d/irZNe39sm_JyzQ

Just in case the nightly you tested didnt' include the qt patches...
Comment 11 Yaroslav 2019-06-24 10:48:15 UTC
Of course! I just checked it, but sadly nothing is changed…
Comment 12 Dmitry Kazakov 2019-06-25 14:10:56 UTC
Hi, Yaroslav!

I have checked what happens. It looks like the driver sends "tablet tip press" event as soon as you press "erase" button. It also happens in "hold+tip" mode. That is clearly a bug in the driver. The erase button must be remapped to SBN_NONE by the driver, but it doesn't happen. I don't know why. 

When I was fixing this bu initially, I observed this behavior, but now it doesn't work for some reason. It might be that the driver got updated.

Anyway, I cannot do anything to it. It needs to be fixed in the driver :(
Comment 13 Yaroslav 2019-06-25 18:47:42 UTC
Oh, I see.
Wacom doesn't update drivers for my tablet since 2015, so it seems I have to stick with Krita 4.1.7 forever… or until I buy a new tablet. Anyway, thanks for the support!