Question: What is HID_MAX_USAGES? What is it used for? And why is the value so small?


#define HID_MAX_USAGES                        12288



Background info: I need to set the value to 32k and rekompile the kernel. Otherwise my gaming-mouse is not recognized by ubuntu. So I want to know what this value is good for, before changing my system.

1 Answer 1


I think the HID_MAX_USAGES is so "small" cause a HID-device report descriptor in cases where the hid-devices report the right size, the size is way smaller, and in that case it's descriptor won't exceed the hard coded HID_MAX_USAGES limit.

When you get the issue of your keyboard or mice not working, and after a recompile of the kernel with the increased HID_MAX_USES your device start working. Is that most likely because the lower limit would reject parsing the reported descriptor.

After reading and googling some did I inspect some Linux drivers that seemed to override what the device reported itself. Eg. if the device reported it had 2^15 the driver could override it to the maximum allowed by the HID_MAX_USAGES, or with the device usages actually size.

So short summed, basically what happens, the hid-device report descriptor specifies an excessively large number of consumer usages (eg. 2^15 ), which is more than HID_MAX_USAGES. This prevents proper parsing of the reported descriptor and most likely the device or parts of it won't work.

I have been using the dirty hack of increment the HID_MAX_USAGES myself in a production environment. How dirty it is have I asked with no good answers. But with my knowledge I can see that the hack leaves a bigger memory-footprint, I have not looked into if it might be able to slightly hurt performance a bit. I could not see the hack pose any security risk. (Please correct me if I am wrong.)

I believe incrementing the HID_MAX_USAGES in a bug-report is out of the question for any mainline kernel, it is no optimal solution. Rater I would suggest you to submit a detailed bug-report about your hid- keyboard\mice not working. You can also buzz the manufacture of your product to add proper support in a driver.

Extended (source):

On Tue, 21 May 2013, Christian Ohm wrote:

> Is there any reason why HID_MAX_USAGES shouldn't be more than 12288?  

Well, the reasoning is a mixture of current implementation, and 

- we currently have statically allocated arrays on a per-parser basis, for 
  parsing usages and collection indices. If the number of max usages is 
  going to grow in an uncontrolled manner, we'll have to change the way 
  our parser works (which is not impossible, of course).

- most of the ocurences of huge max usages being presented by the devices 
  have actually turned out to be bogus and could have been fixed by 
  patching the report descriptor in order to reflect the real behavior of 
  the device


Jiri Kosina

The above snippet is from the hid subsystem kernel mantainer.

  • Thank you for your answer. Because the mouse was supported by the next later version of ubuntu I did't tracked that issue. This explanation supports my gut feeling, that this was a bug somewhere else. Mar 2, 2021 at 14:37
  • @sergejWerfel Just out of curiosity, which mouse was it? Mar 3, 2021 at 17:49
  • 1
    a little bit late... i think it was sharkoon drakonia, but I'm not sure anymore ;) Oct 7, 2021 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .