How to support wl_touch input? (when developing clients)

Peter Hutterer peter.hutterer at who-t.net
Wed May 8 22:57:18 UTC 2024


On Wed, May 08, 2024 at 11:19:56AM +1000, Peter Hutterer wrote:
> On Tue, May 07, 2024 at 09:27:36PM +1000, Campbell Barton wrote:
> > Hi, what are some ways to test "wl_touch" events?
> > 
> > - Is it possible to make track-pads use the wl_touch interface?
> 
> generally - no. most general-purpose compositors use libinput which
> converts the touch points on touchpads into pointer movement and thus
> compositors forward those as wl_pointer events.
> 
> > - Is there a way to emulate touch input using a mouse?
> > - If specific hardware is needed, any suggestions?
> 
> A few options:
> 
> you can emulate any device with uinput (or uhid if you want to also
> test the kernel). the simplest way is to get a recording from a device
> with libinput record and then replay that locally with libinput replay.
> that requires that you find a touchscreen and execute the sequence
> though. I have one, so here's a gist I recorded:
> https://gist.github.com/whot/8000f803836db1425a7a1e920c10cf85
> 
> Alternatively, you can create a uinput device that attaches to your
> touchpad, sets INPUT_PROP_DIRECT and otherwise forwards event 1:1.
> https://python-libevdev.readthedocs.io/en/latest/examples.html
> should help with that.
> 
> finally, you can put a quirk with
> AttrInputProp=+INPUT_PROP_DIRECT;-INPUT_PROP_BUTTONPAD
> that should make libinput treat your device like a touchscreen (though
> you'll also need a udev rule to remove ID_INPUT_TOUCHPAD and instead set
> ID_INPUT_TOUCHSCREEN, or hack that into libinput's evdev.c).
> https://wayland.freedesktop.org/libinput/doc/latest/device-quirks.html
> 
> I'd personally go with the record/replay approach, it's the simplest one and
> you can re-play that exact same sequence until whatever bug you're
> seeing is fixed. docs on record/replay are here:
> https://wayland.freedesktop.org/libinput/doc/latest/tools.html

Follow-up:

Another one I wrote (apparently):
https://gitlab.freedesktop.org/whot/touchmouse
I don't remember much about this (last commit 3 years ago) but it still
works. This may be the easiest one for quick testing if no specific
event sequences are required.

There's also this repo here which is useful to emulate a Wacom tablet:
https://github.com/whot/wacom-recordings
That one uses hid-replay but uses the same principle.

Cheers,
  Peter

> > For context, recently a user reported a bug where touch events aren't
> > supported (wl_touch), see: https://wayland-book.com/seat/touch.html
> > 
> > While it seems fairly straightforward to support, I don't think I have any
> > hardware that uses this interface & buying a Wacom touch-screen just to add
> > support for wl_touch seems excessive (I already have a touch-pad &
> > wacom-tablet, even though both support "touch" it it seems neither active
> > the wl_touch API).
> > 
> > Any suggestions for how to test that wl_touch support is working for
> > application/toolkit developers?
> > 
> > 
> > 


More information about the wayland-devel mailing list