diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2013-11-05 19:16:15 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2013-11-05 19:16:15 +0100 |
commit | b1362aa792552373a6a2c028aefcc8a0878f09c6 (patch) | |
tree | dce80ade24b4b4687fabccf8d7607af26aa7424b /usb | |
parent | b4a27cc8e6a5eb91266cc515cef0b63e7e20db2b (diff) |
HID: added set_feature_report().
Diffstat (limited to 'usb')
-rw-r--r-- | usb/hid.h | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -233,6 +233,7 @@ class USB_HID : public USB_class_driver { enum ControlState { None, SetOutputReport, + SetFeatureReport, }; const uint8_t interface_num; @@ -278,6 +279,12 @@ class USB_HID : public USB_class_driver { return SetupStatus::Ok; } + // Set feature report. + if(bmRequestType == 0x21 && wIndex == interface_num && bRequest == 0x09 && (wValue & 0xff00) == 0x0300) { + controlstate = SetFeatureReport; + return SetupStatus::Ok; + } + return SetupStatus::Unhandled; } @@ -292,21 +299,36 @@ class USB_HID : public USB_class_driver { return; } + bool res = false; + switch(controlstate) { case SetOutputReport: usb.read(ep, buf, len); - set_output_report(buf, len); + res = set_output_report(buf, len); + break; + + case SetFeatureReport: + usb.read(ep, buf, len); + res = set_feature_report(buf, len); break; + default: break; } - - usb.write(0, nullptr, 0); + if(res) { + usb.write(0, nullptr, 0); + } else { + usb.hw_set_stall(0); + } } virtual bool set_output_report(uint32_t* buf, uint32_t len) { return false; } + + virtual bool set_feature_report(uint32_t* buf, uint32_t len) { + return false; + } }; #endif |