Last week's libinput 1.2 release included the new graphics tablet support. This work, originally started as Lyude's 2014 GSoC project enables the use of drawing tablets through libinput (think Wacom tablets, not iPad/Android tablet).
Wacom tablets provide three input types: pen-like tools, buttons and touch rings/strips on the tablet itself, and touch. libinput's tablet support work focuses on the tool support only, pad buttons are still work in progress. Touch is already supported, either through the touchpad interfaces for external tablets (e.g. Intuos) or touchscreen interfaces for direct-touch tablets (e.g. Cintiq). So the below only talks about how to get events from tools, the pad events will be covered in a separate post when it's ready.
How do things work in the xf86-input-wacom driver, the current standard for tablet support in Linux? The driver checks the kernel device node for capabilities and creates multiple X devices, usually pen, eraser, cursor, and pad. When a pen comes into proximity the driver sends events through the pen device, etc. The pen device has all possible axes available but some (e.g. rotation) won't be used unless you're actually using an Wacom Art Pen. Unless specifically configured, all pens send through the same device, all erasers send through the same device, etc.
The libinput tablet API is a notable departure from this approach. In libinput, each tool is a separate entity generating events. A client doesn't wait for events from the tablet, it waits for events from a tool. The tablet itself is little more than an idle device. This has a couple of effects:
- A struct libinput_tablet_tool is created on-the-fly as a tool comes into proximity and its this struct that events are tied to.
- This means we default to per-tool handling. Two pens will always be separate and never multiplexed through one device. [1]
- The tool can be uniquely identified [1]. It's easy to track a tool across two tablets even though this is quite a niche case.
- A client can query the tool struct for capabilities, but not the tablet. Hence you cannot know what capabilities are available until a tool is in proximity.
- The tool-based approach theoretically enables us to have multiple tools in proximity simultaneously, though no current hardware supports this.
I just pushed the tablet support for the xf86-input-libinput driver and this driver reflects the new approach that libinput takes. When a tablet is detected, we create one device that has no axes and serves as the parent device. Once the first tool comes into proximity, a new device is created with the exact capabilities that the tool provides and the serial number in the name:
$> xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] [...] ⎜ ↳ Wacom Intuos5 touch M Pen Pen (0x99800b93) id=21 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] [...] ↳ Wacom Intuos5 touch M Pen id=11 [slave keyboard (3)]Device 11 is effectively mute (in the future this may become the Pad device, not sure yet). Device 21 appeared once I moved the tool into proximity. That tool has all the properties for configuration as they appear on the device. So far this works, but it means static configuration becomes more difficult. If you are still using xinit scripts or other scripts that only run once on login and not once per new device then the options may not apply correctly.
[1] provided the hardware can uniquely identify the pens
2 comments:
Hi,
quick question: will libinput support other brands of graphics and display tablets besides Wacom?
We (intend to) support any graphics tablet that's supported by the kernel. The main focus is on Wacom tablets though, mainly because of their market share and because they require a number of custom features.
Post a Comment