[Bug 244339] x11-servers/xorg-server: Some keys not working (1.20.7 regression)

[email protected]
Newsgroups gmane.os.freebsd.devel.x11
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244339

--- Comment #6 from Michael Gmelin <[email protected]> ---
(In reply to Jan Beich from comment #5)

Here is a good howto describing how to use usbhidaction(1),
which is part of base.

https://forums.freebsd.org/threads/howto-using-multimedia-keys-from-uhid-4-devices.24069/

I followed it to construct a little test case on a little Cherry keyboard
(vendor 0x046a product 0x0023) that provides media keys over uhid,
unfortunately this didn't just work out of the box with this keyboard:


  # usbhidctl -f /dev/uhid1 -r
  Report descriptor:
  Collection type=Application page=Consumer usage=Consumer_Control
  Input   rid=1 pos=0 size=16 count=1 page=Consumer usage=Unassigned Array,
logical range 0..1023
  End collection
  Collection type=Application page=Generic_Desktop usage=System_Control
  Input   rid=2 pos=0 size=1 count=1 page=Generic_Desktop
usage=System_Power_Down, logical range 0..1
  Input   rid=2 pos=1 size=1 count=1 page=Generic_Desktop usage=System_Sleep,
logical range 0..1
  Input   rid=2 pos=2 size=1 count=1 page=Generic_Desktop usage=System_Wake_Up,
logical range 0..1
  End collection
  Total   input size 3 bytes
  Total  output size 0 bytes
  Total feature size 0 bytes

Reading keys is possible, but it's all part of that Unassigned Array above:

  # usbhidctl -f /dev/uhid1 -r -a -l
  Report descriptor:
  Collection type=Application page=Consumer usage=Consumer_Control
  Input   rid=1 pos=0 size=16 count=1 page=Consumer usage=Unassigned Array, 
  logical range 0..1023
  End collection
  Collection type=Application page=Generic_Desktop usage=System_Control
  Input   rid=2 pos=0 size=1 count=1 page=Generic_Desktop
usage=System_Power_Down, logical range 0..1
  Input   rid=2 pos=1 size=1 count=1 page=Generic_Desktop usage=System_Sleep,
logical range 0..1
  Input   rid=2 pos=2 size=1 count=1 page=Generic_Desktop usage=System_Wake_Up,
logical range 0..1
  End collection
  Total   input size 3 bytes
  Total  output size 0 bytes
  Total feature size 0 bytes
  usbhidctl: hid_get_report(rid 1): Device not configured
  Consumer:Consumer_Control.Consumer:Unassigned=

  Generic_Desktop:System_Control.Generic_Desktop:System_Power_Down=
  Generic_Desktop:System_Control.Generic_Desktop:System_Sleep=
  Generic_Desktop:System_Control.Generic_Desktop:System_Wake_Up=

  Consumer:Consumer_Control.Consumer:Unassigned=0

  Consumer:Consumer_Control.Consumer:Unassigned=234

  Consumer:Consumer_Control.Consumer:Unassigned=0

  Consumer:Consumer_Control.Consumer:Unassigned=233

  Consumer:Consumer_Control.Consumer:Unassigned=0


As you can see, there's a problem getting the hid_report for rid 1. 

Good news is, that it still reports key events (234 and 233 are
"vol down/vol up").

In theory, writing rules should be possible, e.g.

  # cat myconfig
  Consumer:Consumer_Control.Consumer:Unassigned 234 0 mixer vol -10
  Consumer:Consumer_Control.Consumer:Unassigned 233 0 mixer vol +10

In practice this doesn't work, as the range is limited by usbhidaction:

  # usbhidaction -f /dev/uhid1 -c myconfig -v
  PARSE:1 Consumer:Consumer_Control.Consumer:Unassigned, -1, 'mixer vol -10'
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, -1, 'mixer vol +10'
  report size 3
  system 'mixer vol +10'
  Setting the mixer vol from 75:75 to 85:85.
  system 'mixer vol -10'
  Setting the mixer vol from 85:85 to 75:75.

The values are cut to -1. So pressing media keys always executes
both actions, not useful (in the example pressing any of the
media keys will issues both commands).

Looking at the code, I hacked in a workaround:

  # cat /usr/src/usr.bin/usbhidaction/usbhidaction.c | \
    sed "s/range = 1/range = 0/g" >myhidaction.c
  # cc -o myhidaction myhidaction.c -lusbhid

With this patch we can now configure actions. In this example, very basic
volume control and controlling audio/cmus (this all runs as root,
not ideal, but left out for simplicity):

  # cat myconfig

  # voldown
  Consumer:Consumer_Control.Consumer:Unassigned 234 0 mixer vol -10
  # poor man's mute
  Consumer:Consumer_Control.Consumer:Unassigned 226 0 mixer vol 0
  # volup
  Consumer:Consumer_Control.Consumer:Unassigned 233 0 mixer vol +10
  # prev
  Consumer:Consumer_Control.Consumer:Unassigned 182 0 cmus-remote --prev
  # play/pause
  Consumer:Consumer_Control.Consumer:Unassigned 205 0 cmus-remote --pause
  # next
  Consumer:Consumer_Control.Consumer:Unassigned 181 0 cmus-remote --next

  # ./myhidaction  -c myconfig -f /dev/uhid1 -v
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, 234, 'mixer vol -10'
  PARSE:4 Consumer:Consumer_Control.Consumer:Unassigned, 226, 'mixer vol 0'
  PARSE:6 Consumer:Consumer_Control.Consumer:Unassigned, 233, 'mixer vol +10'
  PARSE:8 Consumer:Consumer_Control.Consumer:Unassigned, 182, 'cmus-remote
--prev'
  PARSE:10 Consumer:Consumer_Control.Consumer:Unassigned, 205, 'cmus-remote
--pause'
  PARSE:12 Consumer:Consumer_Control.Consumer:Unassigned, 181, 'cmus-remote
--next'
  report size 3
  system 'cmus-remote --pause'
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, 234, 'mixer vol -10'
  PARSE:4 Consumer:Consumer_Control.Consumer:Unassigned, 226, 'mixer vol 0'
  PARSE:6 Consumer:Consumer_Control.Consumer:Unassigned, 233, 'mixer vol +10'
  PARSE:8 Consumer:Consumer_Control.Consumer:Unassigned, 182, 'cmus-remote
--prev'
  PARSE:10 Consumer:Consumer_Control.Consumer:Unassigned, 205, 'cmus-remote
--pause'
  PARSE:12 Consumer:Consumer_Control.Consumer:Unassigned, 181, 'cmus-remote
--next'
  system 'mixer vol +10'
  Setting the mixer vol from 20:20 to 30:30.
  system 'mixer vol +10'
  Setting the mixer vol from 30:30 to 40:40.
  system 'mixer vol +10'
  Setting the mixer vol from 40:40 to 50:50.
  system 'mixer vol +10'
  Setting the mixer vol from 50:50 to 60:60.
  system 'mixer vol +10'
  Setting the mixer vol from 60:60 to 70:70.
  system 'mixer vol +10'
  Setting the mixer vol from 70:70 to 80:80.
  system 'mixer vol +10'
  Setting the mixer vol from 80:80 to 90:90.
  system 'cmus-remote --pause'
  system 'cmus-remote --pause'

So that's good enough for me for demonstration purposes. I hardly
ever use that keyboard, but I thought leaving this here still might
be useful.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-x11
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.