Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jan 2015 19:02:13 -0500
From:      Mason Loring Bliss <mason@blisses.org>
To:        freebsd-hackers@freebsd.org
Subject:   usbhidctl / Logitech
Message-ID:  <20150106000213.GT4187@blisses.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150106000213.GT4187>