Where do I lookup values for building a USB HID descriptor?
The USB documentation is pretty terrible. It suffers from excessive genericization, where they're trying to make everything so generic and general that it's hard to get from the docs to any specific application.

The descriptor format is located in the document called "Device Class Definition for HID" at the link to usb.org you provide.

The critical thing you're missing is that the various segments (such as 0x05) is not documented with the prefix 0x. In fact, they generally describe them in raw binary.

For example, with regard to the 0xA1:


You can see that the binary prefix 1010_00nn indicates that is is a collection, and the postfix nnnn_nn01 indicates it is 1 byte long. Then subsequent byte is then interpreted as the collection type, in this case of type Application. This then sets the context in which the further bytes are interpreted, untill the HID descriptor parser either sees another collection tag, or an end collection marker.

You can see that END COLLECTION is specified as 0b1100_00nn, with nn being ignored. This is where the 0xC0 is coming from.

You can also start to see how the other arguments are constructed. For example, LOGICAL MINIMUM is 0x25, or 0b0010_0101. From that, we can see that we have a data-length of 0bnnnn_nn01, or one byte, and the specifier for LOGICAL MINIMUM is 0b0010_01nn



The structure for the USAGE PAGE descriptor is the same. The command to select the usage page is 0000_01nn, and nnnn_nn01 indicates it is 1 byte long. I would guess that, since the documentation states that usage-pages are 32 bits, the upper bits are assumed to be zero, or inferred from another part of the documentation. I actually don't know how they're specified.

There is a good page of the various HID constants here.

And a more recent version from the BSD sources here (Thanks, @crazysim!) (latest HEAD, may not last).