Possibly taking advantage of tablet hover distance info?

Hi guys!

Recently I’ve been looking at implementing brush features that takes advantage of the hovering distance info that wacom (and other?) tablets reported back to system.
I believe this has a lot of potential to e.g. simulate airbrush on a screen tablet like cintiq, and it could also be used to produce “leaky pen” effect, or as a dynamic smudging input. The brush engine of Krita certainly can take advantage of this easily.

The hovering distance value ranges from 0-1024 from touch to fully lifted up. On windows wintab, it’s available through pkt.pkZ (Must enable the Z axis in the packet data tho). HOWEVER on linux, the information is available yet not exposed through XI2, so X11 applications won’t have that information other than to read raw inputs directly, which requires sudo. This is fixable in xf86-input-wacom , and I made an issue stating the problem there.

I was wondering if there’s any developer of Krita who’s more familiar with the xf86-input-wacom thing that could help push this forward a bit, then we can have reliable access of hover distance on both linux and windows, then it’s trivial to add that to the brush engine in Krita.

Any thoughts?

Yiming (I also made Our Paint )

4 Likes

What is XI2?

Now I’m curious if my tablet reports hover distance too :slight_smile:

1 Like

Actually one of the rare things I was missing in Krita and which I used in Photoshop a few times back in the days. It still requires a special stylus you have to use which replaces the nib with a button you press just like with a real air brush. It’s kind of a niche tool and I personally know nobody who’s actually using it (I lost mine many years ago and didn’t really bothered replacing it), and it was a Wacom only thing for many years (don’t know if it still is). However it would make Krita more feature complete and make the airbrush usable for those who have one. I’m sure there are people who actually use their air brush stylus. Since Krita gets it’s signals from Qt, not directly from xinput and xwacom (or libinput on Wayland) I wonder if it’s actually a limitation of Qt and the reason that Krita doesn’t have it.

From Qts documentation it looks like it could be possible, they have a Z axis in their event handler at least in Qt6 and I assume in 5 too.

The z parameter gives the Z coordinate of the device on the tablet; this is usually given by a wheel on a 4D mouse. If the device does not support a Z-axis (i.e. QPointingDevice::capabilities() does not include ZPosition), pass 0 here.

From QTabletEvent Class | Qt GUI 6.7.1

It assumes the driver reports the device capabilities correctly.

1 Like

I’m actually not sure about the QT way of handling Z axis as wheel. For pen the way to do it is hovering distance (for Wacom Wintab it’s simply pkt.pkZ), and since linux up to this point in X11 doesn’t send distance value to user space, I doubt QT is gonna have the correct value there.

Wacom did came out with an actual airbrush pen that had a wheel (?) on it, although from what I can gather, it still requires the nib to be pushed against the surface. However, I do believe all tablet devices supports distance (since they have to have hover). If you are on linux, you can use evdev or something to read /dev/input/event* where * is the stylus device (Or just use sudo on any joystick configuration software then select the stylus), and you will see the distance being reported.

Since Krita have a big user base in linux, I’m hoping we could push this change forward.

Xi2 is a input extension thing for X11. (As a generic user you probably don’t need to know that lol).

Chances are your tablet is supporting that.

The wheel on a 3D (4D?) mouse is functional equal to the hovering distance on a tablet. The documentation lists that as an example but ultimately it’s the driver’s responsibility to just send the correct values as arguments and Krita can pretty much use it device agnostic then. Wouldn’t even have to be called hovering distance (although might make the most sense in terms of a painting application).

The one that I had had a wheel (i think, it’s was simply too long ago) however it didn’t control the z axis but instead just the size (the opening/pressure on a real air brush, also doubled as scroll wheel in menus) and another simple button to press for painting. Hovering distance was used and basically controlled the spread or opacity and how far the ink would spray on combination with the tilt of the pen. It was actually quite cool to use.

2 Likes

Well good luck getting new features into any part of the X11 stack…my impression is that this whole code is considered frozen unless it’s something that helps XWayland.

Apart from that, the idea in general sounds interesting.
I’m just not sure if it’s really useful enough to put a lot of effort into.
My tablet (XP-Pen Deco 01 V2) may not be the best example, as the tilt feature in general is very coarse, but the tablet basically can’t determine a tilt at all when the pen is hovering more than a few millimeters.
And the max hover distance in general is not that large either…that doesn’t sound like it could adequately simulate a real airbrush, but I won’t judge before even giving it a chance.

1 Like

The wacom pro pen 2 feels quite smooth when I read the hover distance, and tilt is responsive. My surface pen 2 isn’t that great, it’s just like that, the tilt is very laggy and sometimes wrong, hover pretty much useless as well. For wacom art pen, the hover only reports 8 distances, so that’s not that much use either. Haven’t been rich enough to try wacom pro pen 3 gen but may be interesting.

Well good luck getting new features into any part of the X11 stack…my impression is that this whole code is considered frozen unless it’s something that helps XWayland.

We are not trying to change X11, but make a fix on the xf86 side that provide an extra valuator to X11. So it should be good.

1 Like