From owner-freebsd-current@FreeBSD.ORG Thu Sep 9 14:07:47 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 529A010656E0 for ; Thu, 9 Sep 2010 14:07:47 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id DE86C8FC1E for ; Thu, 9 Sep 2010 14:07:46 +0000 (UTC) Received: by wyb33 with SMTP id 33so1707170wyb.13 for ; Thu, 09 Sep 2010 07:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=u+pka04t0k0RV3ETCK9lSGQEA2abZdjqlxzxctfJpFg=; b=ujUnkAwTnJBdogbSX2MQsnx8R2hU/WoBILE4tcsW1gkBGMYgWPQN6rKRBkQd9JsOiK lbSv710Nm3j8uUtOSafg7vfDTTTlUIrakRa7RKKDXrfuJsifnvsNPUtFY7xPnWBi50so oAem9nIWHDKzTXnAVE/5yuEWs3ST2SUqaveHw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=YHldiIQuvOpTT7waqy0YkT8zeHK1l9mkxvXbvibFPzG4jCZwg2NJImhef0PF83JLba VpM+Kc6SXP+0eaKr0kaLyxiHU8vwU0mwLUycjjGQwKXotaP069aEIdfQgdQcWstmp/6F O2gkbhKJMA9klun10fp/V4DnML5JYxANbV0vA= MIME-Version: 1.0 Received: by 10.227.72.213 with SMTP id n21mr37997wbj.66.1284041265768; Thu, 09 Sep 2010 07:07:45 -0700 (PDT) Received: by 10.216.27.204 with HTTP; Thu, 9 Sep 2010 07:07:45 -0700 (PDT) In-Reply-To: <201009090859.50251.hselasky@c2i.net> References: <201009090859.50251.hselasky@c2i.net> Date: Thu, 9 Sep 2010 07:07:45 -0700 Message-ID: From: Maksim Yevmenkin To: Hans Petter Selasky Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-current@freebsd.org Subject: Re: silly libusbhid question X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2010 14:07:47 -0000 On Wed, Sep 8, 2010 at 11:59 PM, Hans Petter Selasky wrote: > >> In kernel and userspace this is currently a feature in the HID libraries. > > And I agree that maybe this should be changed. Before changing anything please > grep the kernel sources for this function and check that no callers are using > this feature, or add this missing 1 << hid_collection mask. thanks for the answer! i was not going to change anything, not immediately at least :) someone pointed me at a bluetooth mouse with a somewhat "interesting" hid descriptor, i.e. hid descriptor = { 0x05 0x01 0x09 0x02 0xa1 0x01 0x85 0x03 0x09 0x01 0xa1 0x00 0x05 0x09 0x19 0x01 0x29 0x05 0x15 0x00 0x25 0x01 0x75 0x01 0x95 0x05 0x81 0x02 0x75 0x03 0x95 0x01 0x81 0x01 0x05 0x01 0x09 0x30 0x09 0x31 0x16 0x00 0x80 0x26 0xff 0x7f 0x75 0x10 0x95 0x02 0x81 0x06 0xa1 0x02 0x85 0x03 0x05 0x01 0x09 0x38 0x15 0x81 0x25 0x7f 0x75 0x08 0x95 0x01 0x81 0x06 0xc0 0xa1 0x02 0x85 0x03 0x05 0x0c 0x0a 0x38 0x02 0x15 0x81 0x25 0x7f 0x75 0x08 0x95 0x01 0x81 0x06 0xc0 0xc0 0xc0 } which (if i did everything right) decodes to Collection page=Generic_Desktop usage=Mouse Collection page=Generic_Desktop usage=Pointer Input id=3 size=1 count=1 page=Button usage=Button_1 Variable, logical range 0..1 Input id=3 size=1 count=1 page=Button usage=Button_2 Variable, logical range 0..1 Input id=3 size=1 count=1 page=Button usage=Button_3 Variable, logical range 0..1 Input id=3 size=1 count=1 page=Button usage=Button_4 Variable, logical range 0..1 Input id=3 size=1 count=1 page=Button usage=Button_5 Variable, logical range 0..1 Input id=3 size=16 count=1 page=Generic_Desktop usage=X Variable Relative, logical range -32768..32767 Input id=3 size=16 count=1 page=Generic_Desktop usage=Y Variable Relative, logical range -32768..32767 Collection page=Generic_Desktop usage=Y Input id=3 size=8 count=1 page=Generic_Desktop usage=Wheel Variable Relative, logical range -127..127 End collection Collection page=Generic_Desktop usage=Wheel Input id=3 size=8 count=1 page=Consumer usage=AC_Pan Variable Relative, logical range -127..127 End collection End collection End collection please notice two nested collections one with usage "Y" and another with usage "Wheel". the problem is that when for (d = hid_start_parse(desc, 1 << hid_input, -1); hid_get_item(d, &h) > 0; ) { switch(page) { case Generic_Desktop: switch(usage) { case X: break; case Y: break; case Wheel: break; } break; } } hid_end_parse(d); code used to parse the descriptor and extract data from input reports, "page" and "usage" on collection items override data from real input items :( so it looks like we are getting two "X" and two "Wheel" values -- one from real input item (which comes first) and then one from collection item (which comes after and has garbage value in it). in any case, workaround is quite simple (please see my latest commit to bthidd(8)), i.e. just check h.kind and make sure it set to hid_input. thanks, max