From owner-freebsd-usb@FreeBSD.ORG Mon Jun 4 08:21:20 2012 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D92B1106564A for ; Mon, 4 Jun 2012 08:21:20 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 608638FC14 for ; Mon, 4 Jun 2012 08:21:20 +0000 (UTC) Received: by eeke49 with SMTP id e49so1550256eek.13 for ; Mon, 04 Jun 2012 01:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=nZ7KufHiiHOhdboExwW1Ac1qRf5JNONghT6iMU+Wjc8=; b=MLUbAUNhVJwidcZNxGFFIO9Q3wLNH96Zou1NaR4E9hg5bLCZugrAPwC6pQ1Mf0ZyOA tsdLCG3k9eV/nn623lQ0uMd86PM1Hzu1PGr6QD87NmWF/ogYS0PaETHRZxzwov45qX/J Y0P5+F8KxDFCz/RqlQK4GeAX5YVgYJIw3uq6vfAM0uN8ZSbl/wc0QCajEy+VzBYGeYRW qFiL68JTTRNgUfiUzwCkEccRwimSi1IAqFIPiuiZJWbIm3G7n6dZjnqHvQVzD/g5sN8W l3Tz/1Ua4kvW35oDMaFt+x7VXf9ygE080J+1LWIUKF6FH+k8X50RcwOUITOZzZjSYkSU 6DEA== Received: by 10.14.48.8 with SMTP id u8mr5078736eeb.128.1338798079320; Mon, 04 Jun 2012 01:21:19 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id p41sm34497453eef.5.2012.06.04.01.21.15 (version=SSLv3 cipher=OTHER); Mon, 04 Jun 2012 01:21:18 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FCC6FFA.3010904@FreeBSD.org> Date: Mon, 04 Jun 2012 11:21:14 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:10.0.3) Gecko/20120328 Thunderbird/10.0.3 MIME-Version: 1.0 To: Engineering References: <201205280640.q4S6e6L0035127@freefall.freebsd.org> <201206011730.31081.hselasky@c2i.net> <027901cd4011$53ec4ff0$fbc4efd0$@com> <201206011823.30527.hselasky@c2i.net> <028301cd4019$69eafba0$3dc0f2e0$@com> <4FC9B8C9.9060103@FreeBSD.org> <03ae01cd41d8$47569390$d603bab0$@com> In-Reply-To: <03ae01cd41d8$47569390$d603bab0$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-usb@freebsd.org Subject: Re: Recommendations for programming HID in FreeBSD 9 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jun 2012 08:21:20 -0000 On 06/04/12 01:29, Engineering wrote: >>> if (id != 0) >>> copyin(ugd->ugd_data,&id, 1); >>> error = uhid_set_report(sc, ugd->ugd_report_type, id, >>> NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); >> >> Hans is right. That code should do the trick. Last year I've fixed uhid >> driver to handle multiple report IDs. Even user-level tools are able to >> do it now. "id != 0" should be correct condition. According to HID spec, >> if device has at least one non-zero report ID, report ID should be >> included into any transfer. So now uhid driver assumes that report ID >> should be in the first byte of request, if it found some non-zero ID in >> descriptor. > > Thanks to all for your help, I have it working, and am very happy to be up > to date in BSD. > > For the record, one of my HID had different report IDs AND different report > sizes, so I had to add my hack to send the size for it to work correctly. That should also work fine now. uhid driver only enforces maximal transfer sizes calculated from the descriptor. User can request smaller transfers, specifying size in ugd.ugd_maxlen field. Look at hid_(get|set)_report() functions in lib/libusbhid sources. > The bonus with that is that my touchscreen, which has badly ported HID code > from the original USB firmware, and does not correctly report its report > sizes, can also work with uhid. -- Alexander Motin