summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2013-11-05 19:16:15 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2013-11-05 19:16:15 +0100
commitb1362aa792552373a6a2c028aefcc8a0878f09c6 (patch)
treedce80ade24b4b4687fabccf8d7607af26aa7424b
parentb4a27cc8e6a5eb91266cc515cef0b63e7e20db2b (diff)
HID: added set_feature_report().
-rw-r--r--usb/hid.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/usb/hid.h b/usb/hid.h
index 5e3447e..bb5b9d7 100644
--- a/usb/hid.h
+++ b/usb/hid.h
@@ -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