Skip to content

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

Open
@abratchik

Description

@abratchik

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() {
 //...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions