USB HID support for xf86-input-mouse (including digitizers and touchscreens)

Alexander Motin mav at FreeBSD.org
Tue Jul 19 11:09:43 UTC 2011


Hi.

Looking on xf86-input-mouse, I've found that it includes some code to
support USB HID pointing devices directly using libusbhid library. But
that code seemed like newer worked (at least on FreeBSD) and is quite
limited. Same time that approach would allow us to override different
limitation, now imposed by sysmouse protocol. For example, to support
absolute coordinates, pressure force, multiple touches, etc. I've made a
patch, rewriting it to support wide range of pointing devices. I've
tested it with few mouses, digitizer and two touchscreens.

To use it, you may:
1. Update installed packages to have x11-drivers/xf86-input-mouse of the
version 1.6.0.
2. Download patch http://people.freebsd.org/~mav/patch-zz-input-mouse8
and put it into /usr/ports/x11-drivers/xf86-input-mouse/files
3. Rebuild and reinstall the driver.
4. Release the pointing device of ums driver, if needed (build kernel
without ums). Device should be reported as uhidX.
5. Add to Xorg configuration:
Section "InputDevice"
    Identifier     "Panel1"
    Driver         "mouse"
    Option         "Protocol" "usb"
    Option         "Device" "/dev/uhidX"
EndSection
...
Section "ServerLayout"
...
	InputDevice "Panel1"
...
EndSection
Some HID devices provide several first-level logical collections
(subdevices), supported by the driver. In that case several of above
devices should be added with different Identifier but same
Device. For example, my Asus T101MT laptop's touchscreen has two usable
logical collections: multi-touch touchscreen and it's mouse emulation.
6. In different operation modes device may report events via different
of these collections. Due to present uhid(4) driver API limitation, it
is impossible for the driver to switch them now. The only way now is to
switch them directly via libusb with command line
usbconfig -u 1 -a 3 do_request 0x21 0x09 0x0305 0x0000 0x0002 0x05 0x0Z
where Z is value from 0 to 2, where 0 is a mouse emulation, 1 is a
single-touch touch-screen and 2 -- native mode. And 05 is a feature
report ID that includes the switch for my touchscreen.
7. Due to missing multitouch support in present Xorg (XInput 2.1
required), multiple touches are now mapped to right button press now. As
any other button, it can be mapped to mouse wheel emulation by adding
into the device section:
    Option         "EmulateWheel" "on"
    Option         "EmulateWheelButton" "3" <- right button
    Option         "EmulateWheelInertia" "500"  <- this may be tuned
    Option         "XAxisMapping" "7 6"
    Option         "YAxisMapping" "5 4"
It allows to scroll with two fingers.
8. I was experimenting with a hack, mapping multiple touches into
different pointers, using Multi-Pointer X technology, added from present
Xinput 2.0. I indeed successfully had several separate pointers on
screen, so multitouch touch screen itself is working fine. But I haven't
found any practical use for it. If somebody heard about any application
that has some useful support for MPX -- tell me please.

I am not sure it will be the permanent solution and what are the chances
to commit it upstream now. I am thinking about further changes at kernel
level to implement it other way. But for existing systems I think it is
an acceptable way to go.

On any problems, send me Xorg.0.log and `usbhidctl -f /dev/uhidX -r`
outputs.

Thank you. Comments welcome.

-- 
Alexander Motin


More information about the freebsd-hardware mailing list