Skip to content

Commit

Permalink
add SetStringFeature to HID library
Browse files Browse the repository at this point in the history
  • Loading branch information
abratchik committed Feb 19, 2021
1 parent d9b18f4 commit fd6a1ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libraries/HID/src/HID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ int HID_::SetFeature(uint16_t id, const void* data, int len)
return reportCount;
}

int HID_::SetStringFeature(uint8_t id, const uint8_t* index, const char* data) {

int res = SetFeature(id, index, 1);

if(res == 0) return 0;

res += SetFeature(0xFF00 | *index , data, strlen_P(data));

return res;
}

bool HID_::LockFeature(uint16_t id, bool lock) {
if(rootReport) {
HIDReport* current;
Expand Down
1 change: 1 addition & 0 deletions libraries/HID/src/HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class HID_ : public PluggableUSBModule
int begin(void);
int SendReport(uint16_t id, const void* data, int len);
int SetFeature(uint16_t id, const void* data, int len);
int SetStringFeature(uint8_t id, const uint8_t* index, const char* data);
bool LockFeature(uint16_t id, bool lock);

void AppendDescriptor(HIDSubDescriptor* node);
Expand Down

0 comments on commit fd6a1ec

Please sign in to comment.