Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string descriptor and string feature support to HID library #393

Open
abratchik opened this issue Feb 19, 2021 · 0 comments · May be fixed by #387
Open

Add string descriptor and string feature support to HID library #393

abratchik opened this issue Feb 19, 2021 · 0 comments · May be fixed by #387

Comments

@abratchik
Copy link

abratchik commented Feb 19, 2021

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 <SomeHIDDevice.h>

// 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() {
 //...
}
@abratchik abratchik changed the title Add string descriptor and feature suypport to HID library Add string descriptor and string feature support to HID library Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant