Bug 331358

Summary: Rotation: Brush Option Does Not Read From Tablet
Product: [Applications] krita Reporter: Benjamin Slack <iam>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: dimula73, halla, xb_creations
Priority: NOR    
Version: 2.8 Beta   
Target Milestone: ---   
Platform: unspecified   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Log from Krita Session using Tablet and Artpen
Patch that should fix the rotation sensor on Windows
New rotation patch for both Windows and Linux
Newer rotation patch with a crash fixed on Linux
Fourth version of the patch that fixes a crash on Linux

Description Benjamin Slack 2014-02-21 03:23:00 UTC
I use a wacom 6D artpen, that supports barrel rotation. Finding a tool that supports this is always difficult, with Painter and PS being the only two to date I've found which do so properly. I was excited to try Krita when it became available for windows and so dived straight into seeing if this feature worked.

Opening the default block brush, I disabled stroke direction for rotation and enabled "rotation" itself, mapping the input 1:1. Unfortunately under this 2.8(3) beta, it appears that rotation either: 1. doesn't map at all, the brush is static and set to the rotation specified in the main slider at the top or ; 2. the rotation goes mad, rolling continually.

I've opened the diagnostics to confirm that the driver is reporting back the art pen's rotation and that it works in Adobe Photoshop. I can only assume the feature is borked in this build. Thank you for your brief attention and if there's something I can do to assist in testing a fix, don't hesitate to contact me.

Reproducible: Always

Steps to Reproduce:
1. Select Brush (block)
2. Open Brush Editor
3. Disable Rotation input drawing direction
4. Enabled "Rotation" input.
5. Draw with 6d Artpen (Wacom Intuos 3)
Actual Results:  
Brush rotates at speed (perhaps with input of radians to degrees not being translated correctly?)

Expected Results:  
Expect brush to match the barrel rotation of the artpen.

Windows 7 Pro, SP1, 32GB Ram, Intel i7 (4 core, HT), Intel 240GB SSD primary drive, 2 1TB Seagate Secondary drives, NVIDIA 660Ti 2GB Videocard, Wacom Intuos 3 with 6D Artpen 6.3.6w3 driver revision.
Comment 1 Dmitry Kazakov 2014-02-21 04:56:09 UTC
Hi, Benjamin!

Thank you very much for your report! This problem is really important for us. Could you please generate and attach the tablet events log, so we could see what is happening there?

To do this you need to:
0) Install DebugView app (http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx)
 and run it
1) Open any image in Krita
2) Press Ctrl+Shift+T (you'll see a message telling the logging is activated)
3) Paint with the rotation-capable stylus
4) Attach the output generated in DebugView
Comment 2 Halla Rempt 2014-02-21 10:32:50 UTC
Hm, we had the same report before. But the only artpen the project has is with Lukas, who recently became a father and hasn't got a lot of time :-( I'm tempted to just get one for the cintiq wacom donated recently so we can test.
Comment 3 Halla Rempt 2014-02-21 11:57:36 UTC
Okay, I ordered a new art pen :-)
Comment 4 Benjamin Slack 2014-02-22 14:41:23 UTC
Created attachment 85275 [details]
Log from Krita Session using Tablet and Artpen

Sorry about the delay, see attached log as requested.
Comment 5 Halla Rempt 2014-02-24 10:11:27 UTC
Yes, I recently got an art marker as well, and I can confirm the issues. See also http://forum.kde.org/viewtopic.php?f=137&t=119319&p=302891#p302891
Comment 6 Odysseas 2014-02-24 11:23:48 UTC
This is a repost from the link above:

rotation feature with the latest build so far (2.7.9.11):

Rotation is recognized, but:
1- The tip rotates like crazy even when I am not moving the stylus at all. This is fixed by moving the percentage slider all the way to 0.1%, and then I notice that the rotation goes towards the opposite direction. Logically this can be easily solved by manipulating the curve. But:
2- If I change the curve in any way, krita stops recognizing stylus rotation unless I restart the program. This happens only for the specific feature I changed. For example:

I have rotation set to "rotation", I change the curve and it stops working for the rest of the session. But if I go to size and set it to rotation, it works - except if I change the curve here as well.
Comment 7 Dmitry Kazakov 2014-02-25 06:18:07 UTC
Here is the problem piece of code:

virtual qreal value(const KisPaintInformation& info) {
        return info.rotation() / 28 + 0.5; // it appears that rotation is between -14 and +14
}

And for this very device the resolution of the rotation is 400+. I need to find out how to get a real rotational resolution.
Comment 8 Dmitry Kazakov 2014-02-25 08:17:16 UTC
Created attachment 85314 [details]
Patch that should fix the rotation sensor on Windows

This patch should fix the rotational sensor on Windows. I have no rotation-capable device, so please someone test it :)
Comment 9 Dmitry Kazakov 2014-02-25 09:18:41 UTC
Created attachment 85315 [details]
New rotation patch for both Windows and Linux

This new patch should fix the rotation on both Windows and Linux platforms
Comment 10 Dmitry Kazakov 2014-02-25 09:35:44 UTC
Created attachment 85316 [details]
Newer rotation patch with a crash fixed on Linux
Comment 11 Odysseas 2014-02-25 10:24:01 UTC
I can test it but I am not sure where to paste this piece of code (windows)

(In reply to comment #8)
> Created attachment 85314 [details]
> Patch that should fix the rotation sensor on Windows
> 
> This patch should fix the rotational sensor on Windows. I have no
> rotation-capable device, so please someone test it :)
Comment 12 Dmitry Kazakov 2014-02-25 11:58:38 UTC
Created attachment 85317 [details]
Fourth version of the patch that fixes a crash on Linux
Comment 13 Benjamin Slack 2014-02-26 03:06:43 UTC
Happy to test any patches, but don't have the capacity to build here. Point me at a binary and I'll give it a shot.
Comment 14 Halla Rempt 2014-02-27 11:14:22 UTC
I tested the patch, and the behaviour is fixed on Linux, but not on Windows. Dmitry and I need to sit together with our stock of test tablets to fix it, so that'll be May, during the Krita sprint.
Comment 15 Dmitry Kazakov 2014-05-08 13:36:21 UTC
Ok, this bug awaits for a fix on Windows. We'll take a look at it during the sprint.
Comment 16 Dmitry Kazakov 2014-05-12 18:24:16 UTC
Git commit d38ce2cbfeac38bfdaae42548f77e89fda63cb4e by Dmitry Kazakov.
Committed on 12/05/2014 at 11:58.
Pushed by dkazakov into branch 'master'.

Fix tablet stylus rotation on Linux

The Windows part will be fixed during the upcoming sprint.

M  +1    -1    krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensors.h
M  +3    -1    krita/ui/input/wintab/kis_tablet_support.h
M  +9    -1    krita/ui/input/wintab/kis_tablet_support_win.cpp
M  +6    -2    krita/ui/input/wintab/kis_tablet_support_x11.cpp

http://commits.kde.org/calligra/d38ce2cbfeac38bfdaae42548f77e89fda63cb4e
Comment 17 Dmitry Kazakov 2014-05-22 16:18:23 UTC
Git commit d739dc5c256affcbf085e2734c67c7be501b9e3d by Dmitry Kazakov.
Committed on 22/05/2014 at 16:14.
Pushed by dkazakov into branch 'master'.

Fixed rotation tablet sensor on Windows

Wintab returns bogus resolution for rotation so just use
standard values instead

M  +2    -0    krita/ui/input/wintab/kis_tablet_support.h
M  +3    -7    krita/ui/input/wintab/kis_tablet_support_win.cpp

http://commits.kde.org/calligra/d739dc5c256affcbf085e2734c67c7be501b9e3d
Comment 18 Dmitry Kazakov 2014-05-22 16:28:38 UTC
Git commit 97f30c7d6cc7cbc940ad7d8eefc94d42fbd1f7fd by Dmitry Kazakov.
Committed on 22/05/2014 at 16:28.
Pushed by dkazakov into branch 'master'.

Make rotation on Linux be consistent with rotation on Windows

Yeah, the two drivers return really different values :) Even the
axes are laid out in opposite directions.

M  +21   -26   krita/ui/input/wintab/kis_tablet_support_x11.cpp

http://commits.kde.org/calligra/97f30c7d6cc7cbc940ad7d8eefc94d42fbd1f7fd
Comment 19 Dmitry Kazakov 2014-05-30 14:52:47 UTC
Git commit cc5b3c1a580720855a26c33baf6fba94c07ddbee by Dmitry Kazakov.
Committed on 30/05/2014 at 14:52.
Pushed by dkazakov into branch 'master'.

Fix artifacts when rotation stylus sensor is activated

The angular stylus function is wrapped nead 2 * pi point
so we should use a bit more complicated algorithm to fix handle it

M  +11   -1    krita/image/brushengine/kis_paint_information.cc
M  +9    -0    krita/image/kis_global.h

http://commits.kde.org/calligra/cc5b3c1a580720855a26c33baf6fba94c07ddbee
Comment 20 Dmitry Kazakov 2014-08-23 14:54:00 UTC
Git commit 543482d4677d68e91236fd0aeaf3d9020399202e by Dmitry Kazakov.
Committed on 12/05/2014 at 11:58.
Pushed by dkazakov into branch 'calligra/2.8'.

Fix tablet stylus rotation on Linux

The Windows part will be fixed during the upcoming sprint.

M  +1    -1    krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensors.h
M  +3    -1    krita/ui/input/wintab/kis_tablet_support.h
M  +9    -1    krita/ui/input/wintab/kis_tablet_support_win.cpp
M  +6    -2    krita/ui/input/wintab/kis_tablet_support_x11.cpp

http://commits.kde.org/calligra/543482d4677d68e91236fd0aeaf3d9020399202e
Comment 21 Dmitry Kazakov 2014-08-23 14:54:01 UTC
Git commit 1a24a4dc26c905ae011ec0dd174cbae737169aeb by Dmitry Kazakov.
Committed on 22/05/2014 at 16:28.
Pushed by dkazakov into branch 'calligra/2.8'.

Make rotation on Linux be consistent with rotation on Windows

Yeah, the two drivers return really different values :) Even the
axes are laid out in opposite directions.

M  +21   -26   krita/ui/input/wintab/kis_tablet_support_x11.cpp

http://commits.kde.org/calligra/1a24a4dc26c905ae011ec0dd174cbae737169aeb