abcminiuser / lufa

LUFA - the Lightweight USB Framework for AVRs.
http://www.lufa-lib.org
1.04k stars 325 forks source link

Add Physical Descriptor Support #85

Open NZSmartie opened 8 years ago

NZSmartie commented 8 years ago

There are two parts to this PR, the first being the support for physical descriptors by providing structs and a couple of macros in LUFA/Drivers/USB/Class/Common/HIDClassCommon.h

The second part is a copied and modified joystick demo which:

  1. Adds two example physical descriptor sets
  2. Reports the designator minimum and maximum in the report descriptor
  3. Returns the descriptor in CALLBACK_USB_GetDescriptor
abcminiuser commented 8 years ago

Wow, fantastic work! This is wonderful and I'm sure others will appreciate it.

There's a few minor things for me to fix up, which I'll do some time this week before merging it in (you've done the bulk of the work, I'm happy to tidy things up). Notes for myself:

NicoHood commented 8 years ago

May I ask why a physical descriptor is needed? I never used/saw that feature.

NZSmartie commented 8 years ago

@NicoHood May I ask why a physical descriptor is needed? I never used/saw that feature.

A lot of implementations of HID tend to use a fixed Report Descriptor that is well known to the end application. so all the reports a pre-mapped, or most likely hard coded.

There are multiple uses for Physical Descriptors. One case is with the Virtual Reality usage page (0x03), a Glove requires the inputs to have designators mapping to the physical descriptor so that the application can automatically map to.

An example I can think of is a generic game controller where the game can use the right hand thumb with 0 effort as the primary button, and a effort of 1 to be the secondary button. it seems like a weird concept. But from a game's perspective, it could help when a unknown controller is plugged in for the first time and needing to automatically map as many actions as possible that the user is familiar with. So they have minimal setup time and less effort adjusting to the new controller.

abcminiuser commented 7 years ago

Well I feel like a right muppet for completely forgetting about this; I'll look at it Saturday along with #91.