From owner-freebsd-x11@FreeBSD.ORG Tue Jul 19 11:09:43 2011 Return-Path: Delivered-To: freebsd-x11@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53C6E106566B; Tue, 19 Jul 2011 11:09:43 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ey0-f176.google.com (mail-ey0-f176.google.com [209.85.215.176]) by mx1.freebsd.org (Postfix) with ESMTP id B1D2B8FC15; Tue, 19 Jul 2011 11:09:42 +0000 (UTC) Received: by eya28 with SMTP id 28so3270496eya.21 for ; Tue, 19 Jul 2011 04:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :x-enigmail-version:content-type:content-transfer-encoding; bh=ogeys0ACoNWb1A63Q/MHA0QDxApdmwdksGdw19t8bcw=; b=HuGL6NsYhQJTkpn4LIi++wfzTH3RUbDEO5THcfdopMyH5oL8GtB9mnRrT5FiQdkMtx KXuMUtCJ8/4rzeeljgDITWjMxC43Mizdd9RWKoAuFNk7vU1R8BI8UUNaFS+X1t9h/mOx yb+ZokixfPH1qt0I4WKloPbINNTXTAgYZNkmQ= Received: by 10.213.9.145 with SMTP id l17mr2626779ebl.10.1311072205366; Tue, 19 Jul 2011 03:43:25 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id w9sm2644827eej.19.2011.07.19.03.43.23 (version=SSLv3 cipher=OTHER); Tue, 19 Jul 2011 03:43:24 -0700 (PDT) Sender: Alexander Motin Message-ID: <4E255F64.30608@FreeBSD.org> Date: Tue, 19 Jul 2011 13:41:40 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.23 (X11/20091212) MIME-Version: 1.0 To: freebsd-x11@freebsd.org X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Cc: freebsd-hardware@freebsd.org Subject: USB HID support for xf86-input-mouse (including digitizers and touchscreens) X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2011 11:09:43 -0000 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