arduino / arduino/ArduinoCore-avr
Add string descriptor and string feature support to HID library
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
String features are important for complete support of HID protocol, however they are not handled as regular features, according to USB HID specification. Any string feature stores only integer index of the string, which is the identification of the string descriptor.
Suggested enhancement allows to hide the complexity of handling string descriptors. The sketch code can look as follows:
```
// SomeHIDDevice can be Mouse, Keyboard, PowerDevice etc and usually is the place where we define the
// HID device descriptor.
#include
// we store string descriptor index in the var, which will be reported through Feature
const byte bSomeStringFeature = 10;
// the string is stored in PROGMEM to save memory
const char STRING_SOMESTRING[] PROGMEM = "My cool device";
void setup() {
SomeHIDDevice.begin();
// here we call the wrapper of the SetStringFeature method defined in the SomeHIDDevice and pass the
// address of the variable, which will hold the value of the feature, to the HID library
// HID_SOME_STRING corresponds to the HID Report ID and is to be defined in the SomeHIDDevice.h
SomeHIDDevice.SetStringFeature(HID_SOME_STRING, &bSomeStringFeature, STRING_SOMESTRING);
}
void loop() {
//...
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by examining the HID library's existing feature handling and the USB HID specification, focusing on how string descriptors are identified by integer indexes rather than handled as regular features. Compare the requested SetStringFeature flow with current device descriptor definitions. Done means string features can expose the descriptor index while hiding string-descriptor handling from sketch code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100