# hid_get_item: HID_ITEM_MAXUSAGE should be increased up to 31 to parse the HID report descriptor



## twoface (Feb 19, 2022)

I have a ~16 years old Logitech USB keyboard that I use since today. Media keys are not recognize properly, and it is pretty buggy.

`# usbconfig -d ugen0.4
ugen0.4: <Logitech Logitech USB Keyboard> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)`

It currently works with Windows and Linux, and used to work with FreeBSD from 6.2 to 8.

I tried it on two 13.0-RELEASE-p7 setups, but found that it works erratically. It randomly lags and doubles some keystrokes.

Moreover, with Gnome, <super> + <l> does not lock the screen, and media keys do not work.

I tried to catch some input with xev(1) in vain, as these media keys are not "displayed". The same applies with `libinput debug-events`, media keys are not catch.

Not sure if it is normal, but I have noticed that my keyboard is detected as two devices:


```
event4   DEVICE_ADDED            Logitech Logitech USB Keyboard, class 0/0, rev 1.10/23.00, addr 3 seat0 default group5  cap:k
event6   DEVICE_ADDED            Logitech Logitech USB Keyboard System Control seat0 default group7  cap:k
```

As expected, `gsettings` value for these media keys are static (meaning not working):


```
org.gnome.settings-daemon.plugins.media-keys stop-static ['XF86AudioStop']
org.gnome.settings-daemon.plugins.media-keys eject-static ['XF86Eject']
org.gnome.settings-daemon.plugins.media-keys rotate-video-lock-static ['<Super>o', 'XF86RotationLockToggle']
org.gnome.settings-daemon.plugins.media-keys battery-status-static ['XF86Battery']
org.gnome.settings-daemon.plugins.media-keys touchpad-toggle-static ['XF86TouchpadToggle', '<Ctrl><Super>XF86TouchpadToggle']
org.gnome.settings-daemon.plugins.media-keys screen-brightness-up-static ['XF86MonBrightnessUp']
org.gnome.settings-daemon.plugins.media-keys play-static ['XF86AudioPlay', '<Ctrl>XF86AudioPlay']
org.gnome.settings-daemon.plugins.media-keys search-static ['XF86Search']
org.gnome.settings-daemon.plugins.media-keys rfkill-static ['XF86WLAN', 'XF86UWB', 'XF86RFKill']
org.gnome.settings-daemon.plugins.media-keys pause-static ['XF86AudioPause']
org.gnome.settings-daemon.plugins.media-keys volume-mute-static ['XF86AudioMute']
org.gnome.settings-daemon.plugins.media-keys volume-up-static ['XF86AudioRaiseVolume', '<Ctrl>XF86AudioRaiseVolume']
org.gnome.settings-daemon.plugins.media-keys calculator-static ['XF86Calculator']
org.gnome.settings-daemon.plugins.media-keys home-static ['XF86Explorer']
org.gnome.settings-daemon.plugins.media-keys www-static ['XF86WWW']
org.gnome.settings-daemon.plugins.media-keys volume-mute-quiet-static ['<Alt>XF86AudioMute']
org.gnome.settings-daemon.plugins.media-keys volume-down-quiet-static ['<Alt>XF86AudioLowerVolume', '<Alt><Ctrl>XF86AudioLowerVolume']
org.gnome.settings-daemon.plugins.media-keys power-static ['XF86PowerOff']
org.gnome.settings-daemon.plugins.media-keys volume-down-static ['XF86AudioLowerVolume', '<Ctrl>XF86AudioLowerVolume']
org.gnome.settings-daemon.plugins.media-keys playback-random-static ['XF86AudioRandomPlay']
org.gnome.settings-daemon.plugins.media-keys screen-brightness-cycle-static ['XF86MonBrightnessCycle']
org.gnome.settings-daemon.plugins.media-keys media-static ['XF86AudioMedia']
org.gnome.settings-daemon.plugins.media-keys hibernate-static ['XF86Suspend', 'XF86Hibernate']
org.gnome.settings-daemon.plugins.media-keys email-static ['XF86Mail']
org.gnome.settings-daemon.plugins.media-keys volume-up-quiet-static ['<Alt>XF86AudioRaiseVolume', '<Alt><Ctrl>XF86AudioRaiseVolume']
org.gnome.settings-daemon.plugins.media-keys screensaver-static ['XF86ScreenSaver']
org.gnome.settings-daemon.plugins.media-keys screen-brightness-down-static ['XF86MonBrightnessDown']
org.gnome.settings-daemon.plugins.media-keys touchpad-off-static ['XF86TouchpadOff']
org.gnome.settings-daemon.plugins.media-keys playback-rewind-static ['XF86AudioRewind']
org.gnome.settings-daemon.plugins.media-keys playback-repeat-static ['XF86AudioRepeat']
org.gnome.settings-daemon.plugins.media-keys suspend-static ['XF86Sleep']
org.gnome.settings-daemon.plugins.media-keys keyboard-brightness-toggle-static ['XF86KbdLightOnOff']
org.gnome.settings-daemon.plugins.media-keys mic-mute-static ['XF86AudioMicMute']
org.gnome.settings-daemon.plugins.media-keys volume-up-precise-static ['<Shift>XF86AudioRaiseVolume', '<Ctrl><Shift>XF86AudioRaiseVolume']
org.gnome.settings-daemon.plugins.media-keys keyboard-brightness-up-static ['XF86KbdBrightnessUp']
org.gnome.settings-daemon.plugins.media-keys playback-forward-static ['XF86AudioForward']
org.gnome.settings-daemon.plugins.media-keys rfkill-bluetooth-static ['XF86Bluetooth']
org.gnome.settings-daemon.plugins.media-keys control-center-static ['XF86Tools']
org.gnome.settings-daemon.plugins.media-keys touchpad-on-static ['XF86TouchpadOn']
org.gnome.settings-daemon.plugins.media-keys next-static ['XF86AudioNext', '<Ctrl>XF86AudioNext']
org.gnome.settings-daemon.plugins.media-keys previous-static ['XF86AudioPrev', '<Ctrl>XF86AudioPrev']
org.gnome.settings-daemon.plugins.media-keys keyboard-brightness-down-static ['XF86KbdBrightnessDown']
org.gnome.settings-daemon.plugins.media-keys volume-down-precise-static ['<Shift>XF86AudioLowerVolume', '<Ctrl><Shift>XF86AudioLowerVolume']
```


I have tested another generic keyboard that works perfectly out of the box (included media keys), with all pc tested running FreeBSD 13.0-RELEASE-p7.

`dmesg -a` returns multiple times:


```
hid_get_item: HID_ITEM_MAXUSAGE should be increased up to 31 to parse the HID report descriptor
```

Maybe I am wrong, but seems a driver bug and my keyboard is not properly recognized as the report is cropped, being limited to 8 bytes?

Anyway, I tried to compile from sources the hid module to increase HID_ITEM_MAXUSAGE, but opt_hid.h seems missing.

I have also tested iichid driver and tried the HID driver hcons, but again in vain, as I get:


```
driver bug: Unable to set devclass (class: ppc devname: (unknown))
```

Now I am out of idea now.


----------



## Vladimir Kondratyev (Feb 19, 2022)

> Anyway, I tried to compile from sources the hid module to increase HID_ITEM_MAXUSAGE, but opt_hid.h seems missing.

what is exact error message?


----------



## twoface (Feb 21, 2022)

I cleaned the sources and managed to build the module.

```
git fetch origin
git reset --hard origin/stable/13
```

The good:

I do not see anymore complaint about HID_ITEM_MAXUSAGE size,
Maybe I am wrong, but at least for now, seems there is no more random lags and "double keystrokes" ;
The bad?

My keyboard is detected as two devices.
The ugly:

<super> + <l> does not lock the screen;
Still have this message when I try to enable iichid:


```
driver bug: Unable to set devclass (class: ppc devname: (unknown))
```

Unfortunately, media keys still not work (not showing in xev, libinput, nor in gsettings).


----------



## Vladimir Kondratyev (Feb 21, 2022)

twoface said:


> The bad?
> 
> My keyboard is detected as two devices.


Yes, the bad. There should be at least 3 devices.



twoface said:


> The ugly:
> 
> <super> + <l> does not lock the screen;
> Still have this message when I try to enable iichid:


It is not clear to me what "enable iichid" means but to get media keys working you should enable usbhid with adding of following lines to */boot/loader.conf*:
`hw.usb.usbhid.enable=1
usbhid_load="YES"`


----------



## twoface (Feb 21, 2022)

Of course, these are enable, yet media keys are not working (nor <ctrl> + <l> does work properly):

```
hw.usb.usbhid.enable=1
usbhid_load="YES"
```

Nevertheless, the first made the suspend button working again, even if it is yet marked as static in gsettings.

And "by enable iichid, I mean according to the iichid README". But seems that unloading and loading again the iichid module does no more trigger every time the message:


```
driver bug: Unable to set devclass (class: ppc devname: (unknown))
```


----------

