Help writing a virtual touchpad

Andrea Somaini andrea.somaini00 at
Tue May 11 08:15:39 UTC 2021

Thanks a lot for your detailed response, that blog post was amazing and it made some things much more clearer.

At the end, I managed to write a kernel driver that receives input through a character device and sends raw input events, without ever knowing the existence of evdev. It still need a lot of tweaking regarding resolution and which events I should send and which not. (e.g. should I communicate the pressure if my data does not contain information about it? What about tool_width/major-axis and such?)

Anyway, with some trial and error the driver kinda works and I got to see 1:1 multitouch gesture on GNOME 40 :)

Regarding performance: I use a userspace process to write to a character device which talks to my kernelspace code, maybe using evdev directly avoids some layers of abstraction? And in this way I don’t have to write any kernelspace code right?

Repo with my code:

Thank you so much,
Il 11 mag 2021, 03:09 +0200, Peter Hutterer <peter.hutterer at>, ha scritto:
> On Sat, May 08, 2021 at 12:45:24PM +0200, Andrea Somaini wrote:
> > Hello,
> > I was thinking about creating a virtual touchpad device for Linux
> > I never worked on such low level software, so I feel kinda lost
> > Can someone please point me where should I start?
> The best option you have at this point is to emulate an evdev node that
> behaves like a touchpad. That's both straightforward and complicated at the
> same time. The code itself is trivial (use python-libevdev, check the
> examples directory) but getting touchpads right in evdev can be a bit
> tricky - you really need to know the details of the evdev protocol.
> If you look at the libinput test devices (e.g.
> test/litest-device-synaptics-rmi4.c) you get a **rough** idea of the events
> you need to send for a finger down event and a finger move event.
> You still need to handle BTN_TOOL_DOUBLETAP, etc.
> What I recommend is: use libinput record to record 1, 2, 3... finger
> interactions on your normal touchpad to get the set of data sent, then
> emulate that device. Axis ranges and coordinates can generally be changed
> at-will, but the set of events within each frame has to be correct (or
> correct enough) to be processed as expected.
> has some
> explanations too.
> Cheers,
> Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the wayland-devel mailing list