Bug 476982

Summary: Support pen calibration in UI
Product: [Applications] systemsettings Reporter: David REVOY <info>
Component: kcm_tabletAssignee: Joshua Goins <josh>
Status: RESOLVED FIXED    
Severity: wishlist CC: aleixpol, josh, nate, nicolas.fella, notafurry, raghu
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.2.0
Sentry Crash Report:
Attachments: ^ video IRL of the bug

Description David REVOY 2023-11-14 09:48:28 UTC
Created attachment 163143 [details]
^ video IRL of the bug

Hi,

I jumped to the Wayland session this morning to evaluate it, and one of my first show-stopper for making art is the lack of configuration tool for calibrating the stylus.

I have a big offset between the tip of my stylus and the cursor position due to not having any possibilities to fix the parralax (see short MP4 video in attachement, no audio, only 13 seconds).

On X11, I could use the kcm_tablet plugin to perform a calibration, or use xinput-calibrator ( https://github.com/tias/xinput_calibrator ) to get the four coordinate and apply them with something like `xsetwacom set "UGTABLET Artist Pro 16 (Gen2) stylus" Area 125 45 32810 32792` and fix the parralax.

This issue is important if you want to maintain https://kde.org/for/creators/ compatible with the Wayland session, because I don't know any artists/graphists able to design, draw or paint on a display tablet without parralax correction ...

Here are steps of what I'm used to see on the user experience side, for references in case you don't know how other products solved it:
1. Map the tablet to a monitor (Important: many 'display pen tablet' after being connected transform the desktop into a multi-monitor setup [1] [2] and after that the stylus enter a mapping accross all monitors. It must be restricted to a single monitor before starting a calibration).
2. User usually click on a 'calibrate' button in the system settings/tablet  GUI.
3. The display fills with a unified color (or a grid), and shows:
    - Four 'targets' to click on their center, they look like a crosses, it must be precise. They usually appears step by step on the four corners.
    - A button to cancel calibration (Escape key on keyboard also cancel it). I also met the case with a 'timer' so the calibration cancel automatically if the four targets are not clicked within a time period. I'm not fan of it, because it put pressure on user to perform the calibration in a given time.
    - Sometime a button to restore default ( 0 calibration ).
    (see [3] [4] [5] )
Once calibration is done, these set of coordinate must also be applied to the "eraser" tip of the same stylus, because it is often a separate device requiring also the same parallax.

That's all, thank you for the work on Wayland!

Note: with Fedora 40 KDE Wayland only in the horyzon, I cross finger I'll can continue to use GNU/Linux for making my webcomic Pepper&Carrot. Being forced to become in exile for finding a distro with X11 just to configure my tablet or getting back to Windows because of Wayland would be so frustrating and devastating for my efforts of 100% FLOSS workflow over the last 14 years.

[1] https://www.davidrevoy.com/article993/review-of-a-new-tablet-soon
[2] https://www.davidrevoy.com/article999/current-workspace-setup
[3] https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/2043260534312/original/9V8rRXmG0w7bjlgA3UhpQreS0exVisLWqw.png?1632393352
[4] https://lh4.googleusercontent.com/-pVSVTIEy9lA/VNBYzOK5hnI/AAAAAAAA3FM/Jdrk6lCMrww/w490/Calibration%2B2.jpg
[5] https://storyart.education/wp-content/uploads/2016/08/Screen-Shot-2016-08-17-at-8.52.01-AM.png
Comment 1 Nicolas Fella 2023-11-14 11:55:45 UTC
On the backend/KWin side we expose a "calibration Matrix" property already, which I _think_ is all we need to make this work. 

In principle you could already set that via the InputDevice DBus interface, but that's not user-friendly at all. What we are lacking is the interactive GUI integration for it
Comment 2 Joshua Goins 2023-11-14 23:18:56 UTC
Implemented a working prototype, thanks for all of the information! I should be able to integrate it into the Tablet KCM before the feature freeze.
Comment 3 Bug Janitor Service 2023-11-15 23:06:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1833
Comment 4 Joshua Goins 2024-07-07 01:45:29 UTC
Git commit 9d9a72f32492f55f8bc1fdd2fd778f013a03d81a by Joshua Goins.
Committed on 07/07/2024 at 01:38.
Pushed by redstrate into branch 'master'.

kcms/tablet: Add pen calibration tool

This adds a new pen calibration window to the Tablet KCM, if supported
by the pen device. This allows to fix possible parallax issues with the
out-of-box calibration matrix.

M  +5    -0    kcms/tablet/CMakeLists.txt
A  +219  -0    kcms/tablet/calibrationtool.cpp     [License: LGPL(v2.0+)]
A  +59   -0    kcms/tablet/calibrationtool.h     [License: LGPL(v2.0+)]
M  +35   -0    kcms/tablet/kcmtablet.cpp
A  +246  -0    kcms/tablet/ui/Calibration.qml     [License: GPL(v2.0+)]
M  +44   -0    kcms/tablet/ui/main.qml

https://invent.kde.org/plasma/plasma-desktop/-/commit/9d9a72f32492f55f8bc1fdd2fd778f013a03d81a
Comment 5 Joshua Goins 2024-07-07 01:46:08 UTC
Hehe, much much later than the first feature freeze I hoped to get it into!
Comment 6 David REVOY 2024-07-07 07:16:52 UTC
Hey, no problem, and a big big thank you. I'll test it!