From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 6 00:02:36 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 381F086B for ; Tue, 6 Jan 2015 00:02:36 +0000 (UTC) Received: from phlegethon.blisses.org (phlegethon.blisses.org [50.56.97.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED1CD25AB for ; Tue, 6 Jan 2015 00:02:21 +0000 (UTC) Received: from blisses.org (cocytus.blisses.org [23.25.209.73]) by phlegethon.blisses.org (Postfix) with ESMTPSA id 85D92148A99 for ; Mon, 5 Jan 2015 19:02:15 -0500 (EST) Date: Mon, 5 Jan 2015 19:02:13 -0500 From: Mason Loring Bliss To: freebsd-hackers@freebsd.org Subject: usbhidctl / Logitech Message-ID: <20150106000213.GT4187@blisses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jan 2015 00:02:36 -0000 Hi all. I'm tracking a problem and I'd love some advice. In short, I've got a Logitech Illuminated Keyboard, and I'm trying to support the media keys with usbhidaction. So far, it seems that the uhid the Logitech gives me is presenting a value range, 786432..787199, but here's where I'm confused. Note: Comments are against usbhidaction.c 227195 from 10.1. So, since we're give a range when we look at the result of hid_get_item, we set range = 1 on line 382. Because of this, when we get to line 450, during config parsing, cmd->value is thrown away and becomes either "u - lo" or "-1". The trouble is, the actual value we want is found in cmd->value, and it's not 1, so it's smashed to -1 on line 454. Here's the config for usbhidaction to support my media keys: Consumer:Consumer_Control.Consumer:Unassigned 226 0 mixer vol 0 Consumer:Consumer_Control.Consumer:Unassigned 234 0 mixer vol -1 Consumer:Consumer_Control.Consumer:Unassigned 233 0 mixer vol +1 I guess my question is, is it inappropriate/wrong for the Logitech keyboard to be reporting a range? The three media keys are all on that one "Consumer:Consumer_Control.Consumer:Unassigned" control and I can only differentiate between them by value, but because the keyboard says it has a range of values (which these aren't in obviously) we smash that value. The man page for usbhidaction talks about "Consumer:Volume_Down" and "Consumer:Volume_Up" as two seperate controls, but that's now how this Logitech device is evidently doing it. Right now I'm doing the following to make usbhidaction work for me, but I'm wondering what the right fix is for FreeBSD. --- usbhidaction.c.orig 2015-01-05 15:42:51.340151502 -0500 +++ usbhidaction.c 2015-01-05 18:38:20.618456979 -0500 @@ -447,7 +447,7 @@ cmd->item = h; cmd->name = strdup(name); cmd->action = strdup(action); - if (range) { + if (range && 0) { if (cmd->value == 1) cmd->value = u - lo; else >From a perusal of their source tree, it looks like NetBSD, the source of the code in question, would have the same issue with this keyboard. If the Logitech is doing something improper by specifying a range, we should still be able to work around that. If it's normal for it to specify a range, then it seems like we don't want to smash the values it's providing when we ask. Thanks in advance for clues. -- Mason Loring Bliss (( If I have not seen as far as others, it is because mason@blisses.org )) giants were standing on my shoulders. - Hal Abelson