Re: g_hid and hid-multitouch compatibility?
From: Benjamin Tissoires <hidden>
Date: 2011-05-31 16:55:19
On Tue, May 31, 2011 at 18:03, Pablo Cases [off-list ref] wrote:
Hi Benjamin, I've attached some logs (rdesc.txt, events.txt and evtest.txt) showing a simulated 2-touch sequence spanning over four frames (last frame is a "untouch" event). Looking at the logs I'd say that I have a problem with the MIN/MAX limit decoding as evtest says limits are -127/127 but that is not what we're reporting according to rdesc.
Indeed, there are troubles with ranges of X and Y. The good point is
that besides that, hid-multitouch seems to work well.
However, what strikes me is that the values are not clamped by the input layer.
The problems comes from your mouse emulation, here:
INPUT(4)[INPUT]
Field(0)
....
Field(1)
Physical(GenericDesktop.Pointer)
Usage(3)
GenericDesktop.X
GenericDesktop.Y
GenericDesktop.Wheel
Logical Minimum(-127) <---------
Logical Maximum(127) <---------
Report Size(8)
Report Count(3)
Report Offset(8)
Flags( Variable Relative )
the values are not coherent with the one reported above. Maybe we
should patch hid-multitouch to ignore non mt inputs... ;-) but I
really don"t have the time to do it right now.
Maybe you don't need to introduce this mouse emulation at all in your
device (it depends if your "firmware" will support it or not).
There is also a problem with the feature
Digitizers.ContactMaximumNumber. Apparently, I would say that you put
the initial value is at 2 instead of 10 as your maximum value
suggests. If it's intentional, it's fine, but you won't be able to
send more than two touches, even by changing this number later...
(just saw the question after)
While we're at it I have some more questions: Q: Do we need to acknowledge the Device Configuration Feature Report sent from the host to the device (instructing the device to report "multi-touch" events)?
If you are talking about the "Digitizers.InputMode" setting, then, we just send the signal and we don't wait for an answer. My memory is quite confusing here, but again, if you don't intend to support mouse emulation, dropping this input in the reports will ease things.
Q: Do we need to send the ContactCountMaximum Feature Report as described in the Windows 7 specification? Because I can see that these values are hardcoded (or just initialized?) in hid-multitouch for each supported device.
So, the first implementation of hid-multitouch did not care about this feature. Now, I tried to use it for devices that send it correctly. As I did not asked all the owners of the devices to redo the tests, some device still got .maxcontact I'd rather not have this thing hardcoded in order to be able to reuse the different classes with a lot of devices. Cheers, Benjamin
Regards, Pabloquoted
-----Original Message----- From: Benjamin Tissoires [mailto:benjamin.tissoires@gmail.com] Sent: den 31 maj 2011 13:19 To: Pablo Cases Cc: Stéphane Chatty; Henrik Rydberg; Jiri Kosina; linux- input@vger.kernel.org Subject: Re: g_hid and hid-multitouch compatibility? Hi Pablo, On Mon, May 30, 2011 at 18:11, Pablo Cases [off-list ref] wrote:quoted
Hi Benjamin, Now things seem to work a lot better thanks to your input :) I'mstill on the 2.6.38 version of the multitouch code, but static registering works after adding our faked USB VIP/PID to hid.ids.c, hid- core.c and hid-multitouch.c:quoted
Digitizers.TipSwitch ---> Key.Touch Digitizers.InRange ---> Sync.Report Digitizers.ContactID ---> Sync.Report GenericDesktop.X ---> Absolute.MTPositionX GenericDesktop.Y ---> Absolute.MTPositionY Digitizers.TipSwitch ---> Key.Touch Digitizers.InRange ---> Sync.Report Digitizers.ContactID ---> Sync.Report GenericDesktop.X ---> Absolute.MTPositionX GenericDesktop.Y ---> Absolute.MTPositionY Digitizers.ContactCount ---> Sync.Report Button.0001 ---> Key.LeftBtn Button.0002 ---> Key.RightBtn Button.0003 ---> Key.MiddleBtn GenericDesktop.X ---> Absolute.MTPositionX GenericDesktop.Y ---> Absolute.MTPositionY GenericDesktop.Wheel ---> Relative.Wheel Running some diagnostics: workstation$ sudo python eviocg.py /dev/input/event3 the device '/dev/input/event3' is multitouch enabled with theprotocol B. Can you send me the output of the command "evtest /dev/input/event3" while moving/releasing fingers? I'm particularly interested in the headers of this output (with the maximum of the ABS_MT_SLOTS). Can you also send the full reports descriptor from /sys/kernel/debug/hid/0003:xxxx:yyyy.0002/rdescquoted
An unmodified version of mtdiag now discovers our multitouch device,but I cannot get any valid touch output in the "drawing surface" of the application. You mentioned that I could optimize things by using some of the quirk defined, but is this necessary or optional? purely optional. (normally)quoted
If I'm reporting as the Windows 7 specification describes do I stillneed to use any of the quirks? the point is that many hardware makers interpreted differently this documentation (that's why we have those quirks). I'm not sure how Microsoft handles this mess, but it may be even more complicated than our hid-multitouch... So I can not guarantee that it will work out of the box. The big point lies in the understanding of the different significations of the fields during a touch life time.quoted
Specially I'm wondering about the quirks that relate to contactid/contact number and slots. Do I really need to think about slots at all if I have valid ContactIDs in my reports? Well it's optimization, so it's optional (though I prefer, because it avoids finding elements in lists). Cheers, Benjaminquoted
Regards, Pabloquoted
-----Original Message----- From: Benjamin Tissoires [mailto:benjamin.tissoires@gmail.com] Sent: den 28 maj 2011 00:42 To: Pablo Cases Cc: Stéphane Chatty; Henrik Rydberg; Jiri Kosina; linux- input@vger.kernel.org Subject: Re: g_hid and hid-multitouch compatibility? Hi Pablo On Sat, May 28, 2011 at 00:08, Pablo Cases[off-list ref]quoted
quoted
wrote:quoted
Hi Benjamin, Thanks for the response. It is my ignorance that should be excusedasquoted
quoted
I have shown/will show that I am the novice with regards to USB HIDandquoted
quoted
multitouch in this forum :)quoted
I´ll continue interleaving additional comments below. -Pabloquoted
-----Original Message----- From: Benjamin Tissoires [mailto:benjamin.tissoires@gmail.com] Sent: den 27 maj 2011 18:10 To: Pablo Cases Cc: Stéphane Chatty; Henrik Rydberg; Jiri Kosina; linux- input@vger.kernel.org Subject: Re: g_hid and hid-multitouch compatibility? Hi Pablo, Adding Stéphane, Henrik and Jiri in CC. On Fri, May 27, 2011 at 17:33, Pablo Cases[off-list ref]quoted
quoted
wrote:quoted
Hi all, I have searched the net and the archives of linux-input forinformation on how to use the Linux g_hid kernel module on adevicequoted
quoted
andquoted
quoted
the hid-multitouch kernel module on a host to communicatemultitouchquoted
quoted
quoted
quoted
events. But unfortunately I can only get single touch working. Excuse my ignorance, I didn't know g_hid existed before yourmail.quoted
quoted
Ifquoted
quoted
I understand it well enough, it's an hid emulation from user-space.quoted
quoted
quoted
quoted
Are you trying to inject events from a device in user-space tothequoted
quoted
quoted
quoted
kernel? If so, I think it would be easier to use uinput. And thefunnyquoted
quoted
think was that I'm currently writing a small lib to injectmulitouchquoted
quoted
quoted
quoted
events in a uinput device in an easier way.Maybe I misunderstand your explanation above but we´re not runningg_hid and hid-multitouch on the same system. We have a separate hardware USB device running Linux with the g_hid kernel moduleloaded.quoted
quoted
On this device we then have (thanks to g_hid) a userspace filecalledquoted
quoted
/dev/hidg0 that we can write USB HID input reports to, which thenwillquoted
quoted
be sent through the device's gadget usb framework, through anphysicalquoted
quoted
USB cable, to a separate PC host running hid-multitouch. Thanks for the explaination. I didn't knew that it was possible todoquoted
quoted
such things. Linux is really a wonderful world ;-)quoted
quoted
quoted
Q: Has anyone successfully completed a g_hid <-> hid-multitouchsetup? And is there a description somewhere of such setup? I don't think so, hid-multitouch is really new (since 2.6.38, andwasquoted
quoted
not very generic at this time).quoted
Q: Is the Windows 7 multitouch USB HID descriptor the correctonequoted
quoted
toquoted
quoted
use also for Linux hid-multitouch? Or is some tweaking necessary? Normally, any valid Windows 7 multitouch USB HID descriptor canbequoted
quoted
quoted
quoted
handled by hid-multitouch. But it's more the events that are sent to hid-multitouch thatwillquoted
quoted
quoted
quoted
tell if your device is compatible or not.quoted
DETAILED DESCRIPTION BELOW The device is a Linux device that uses g_hid (currently 2.6.37kernel) and a USB HID Report Descriptor for multitouch using two-touchquoted
quoted
parallel mode according to Microsoft document http://msdn.microsoft.com/en-us/windows/hardware/gg487437.quoted
On the host (ubuntu 11.04, 2.6.38 kernel) I registerdynamicallyquoted
quoted
quoted
quoted
according to the description at http://lii- enac.fr/en/architecture/linux-input/multitouch-ubuntu-howto.html.Usingquoted
quoted
the events/rdesc files in debugfs on Ubuntu 11.04 I havevalidatedquoted
quoted
thequoted
quoted
parsing of the report descriptor and the input reports. This is really a bad idea to use these howto with ubuntu 11.04ATM.quoted
quoted
Iquoted
quoted
didn't found the time to update this stuff, and this branch cannotquoted
quoted
bequoted
quoted
used in ubuntu 11.04 (it contains code for 2.6.35 only, and therewerequoted
quoted
changes in the hid layer after). If you only used the part "Howtoquoted
quoted
addquoted
quoted
your device to hid-multitouch from the user space" withoutupdatingquoted
quoted
quoted
quoted
your hid module, then it's as if you have'nt done anything (the generic hid module can not autodetect multitouch devices).Currently I am using the hid-multitouch code as existing in thesource distribution of a 2.6.38 Ubuntu 11.04 fetched through apt-get.quoted
quoted
In the page referred to above I have only used the "How to add your device to hid-multitouch from the user space", and not the 2.6.35 related parts. So there are no autodetection in your kernel.quoted
Ok, so for autodetection of multitouch devices to work I need toupdate the hid-multitouch module to a newer version (than wasavailablequoted
quoted
in 2.6.38), preferably head on a git master branch somewhere?Anotherquoted
quoted
option is to add a static configuration field in hid-multitouch and hid-ids.h for my USB device's VID/PID. But then again, maybe it's better to do that on the latest available code as well? Autodetection is not available upstream too, sorry. The latest available code is on Jiri's tree. I'll try to maintain a bunch of patches to backport the work done on hid-multitouch since 2.6.35 on http://lii-enac.fr/en/architecture/linux-input/multitouch- howto.html#hid-multitouch but I'm a little late for the backports right now. Jiri's tree is at http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=summaryquoted
quoted
quoted
Example multitouch input report from/sys/kernel/debug/hid/0003:xxxx:yyyy.0002/events looks correct:quoted
report (size 14) (numbered) = 05 03 00 a5 12 32 0e 03 01 99 1432quoted
quoted
0equoted
quoted
02quoted
Digitizers.TipSwitch = 1 Digitizers.InRange = 1 Digitizers.ContactID = 0 GenericDesktop.X = 4773 GenericDesktop.Y = 3634 Digitizers.TipSwitch = 1 Digitizers.InRange = 1 Digitizers.ContactID = 1 GenericDesktop.X = 5273 GenericDesktop.Y = 3634 Digitizers.ContactCount = 2Most of the time, the problematic part comes from the releases.Butquoted
quoted
quoted
quoted
it's a good start.With "releases" I assume you mean the finger removal from thetouchquoted
quoted
surface, like a "touch-up" event? I have not implemented that partyet,quoted
quoted
but our Microsoft contact informed us that for Windows 7compatibilityquoted
quoted
it should be reported as a final touch report withquoted
TipSwitch = 0 InRange = 1 Is this applicable to hid-multitouch too?Exactly, I meant touch-up. Your behavior is applicable to hid- multitouch. Once registering your device with hid-multitouch, you can choose a class that controls how optimized your driver will be. Normally, the MT_CLS_DEFAULT class will work with any Win 7 compliant device (crossing fingers). Then, you can optimize it by looking for the classes that have MT_QUIRK_VALID_IS_INRANGE (or adding a new one). In the same time,youquoted
quoted
can also optimize the way your device actually does the matchbetweenquoted
quoted
slots (from 0 to N-1 with N the maximum contact count of yourdevice)quoted
quoted
and the tracking_id reported by the device (or the position in thehidquoted
quoted
report). For dual touches only devices, the differences are not big, but we prefer to optimize things all the time ;-)quoted
quoted
quoted
The first touch in the report is correctly presented both onWindowsquoted
quoted
and on Ubuntu 11.04 (using ENAC's mtdiag tool with a minor tweaktoquoted
quoted
quoted
quoted
display data from all devices not just multitouch ones). I canseequoted
quoted
inquoted
quoted
the debugfs files that the data for the second touch data iscorrectlyquoted
quoted
transferred and interpreted (see above), but the mapping to thelinuxquoted
quoted
input system seems a bit strange though (see below). My guess isthat Iquoted
quoted
have not been correctly registered as a multitouch device. I'massumingquoted
quoted
this also because I cannot see any activity from the hid-multitouchquoted
quoted
quoted
quoted
module other than it being initialized when I connect my device (probably another reason for the needed tweak in mtdiag above).quoted
Example mapping from/sys/kernel/debug/hid/0003:xxxx:yyyy.0002/rdescquoted
quoted
that does not look entirely correct for the second touch:quoted
Digitizers.TipSwitch ---> Key.Touch Digitizers.InRange ---> Key.ToolPen Digitizers.ContactID ---> Absolute.Misc GenericDesktop.X ---> Absolute.X GenericDesktop.Y ---> Absolute.Y Digitizers.TipSwitch ---> Key.Touch Digitizers.InRange ---> Key.ToolRubber Digitizers.ContactID ---> Absolute.? GenericDesktop.X ---> Absolute.Z GenericDesktop.Y ---> Absolute.RxThis means that your device is handled by the generic usbhid andnotquoted
quoted
quoted
quoted
hid-multitouch.That is what troubles me. I can see in the host's dmesg that"generic-usb" seems to be the driver chosen for my device when it is connected to the host. And according to your comment above I mightnotquoted
quoted
have correctly registered my device in hid-multitouch which would be the source of the problem...quoted
As a side note; I have sprinkled printk() here and there hid-multitouch.c and hid-core.c. While running the code I can only seethatquoted
quoted
mt_init() and mt_exit() are called during module loading/unloading; never do I see any evidence of that the probing or mapping functionsinquoted
quoted
hid-multitouch are used, only the generic usb parts are used for parsing the report descriptors and input reports. Yep, hid-multitouch does not handle your device. There is currentlynoquoted
quoted
user-space way to tell usbhid (the generic) not to handle a device. You'll have to add your VID-PID to the hid_have_special_driver list (in hid-core.c) to disable generic usb hid handling for your device. You can check the latest patches adding a specific device to hid-multitouch to have some examples.quoted
Could you point me to the location in the code where the decisionisquoted
quoted
taken to use the hid-multitouch driver for a hid-multitouchsupportedquoted
quoted
device? I'm guessing it is somewhere in hid-core.c but I have notbeenquoted
quoted
able to pinpoint the location exactly. I could use this location asaquoted
quoted
start point to backtrace why we're not considered as a hid-multitouchquoted
quoted
supported device. it's just above ;-) hid_have_special_driver in hid-core.c Cheers, Benjaminquoted
quoted
If you are trying to inject events from the user space, Istronglyquoted
quoted
quoted
quoted
recommend to use uinput instead. Let me know if you want to havemyquoted
quoted
quoted
quoted
little uinput-multitouch lib. Cheers, Benjaminquoted
Digitizers.ContactCount ---> Absolute.? Button.0001 ---> Key.LeftBtn Button.0002 ---> Key.RightBtn Button.0003 ---> Key.MiddleBtn GenericDesktop.X ---> Relative.X GenericDesktop.Y ---> Relative.Y GenericDesktop.Wheel ---> Relative.Wheel Regards, Pablo Cases ------------------------- Pablo Cases, M.Sc. Development Engineer Software FlatFrog Laboratories AB Magistratsvägen 10 22643 Lund Sweden Tel: +46 708 393816 Mail: pc@flatfrog.com Web: www.flatfrog.com -- To unsubscribe from this list: send the line "unsubscribelinux-quoted
quoted
quoted
quoted
input" inquoted
the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlquoted
quoted
quoted
quoted
quoted
-- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html