summaryrefslogtreecommitdiff
path: root/protocol/mbed/HIDKeyboard.cpp
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-20 14:39:49 +0900
committertmk <nobody@nowhere>2014-07-30 14:07:43 +0900
commitb4a91ecf4e46ee533563fd759e26dd249bf6b4de (patch)
treecc52fa874d471a3f15d5cdda64fc3e6232d88303 /protocol/mbed/HIDKeyboard.cpp
parent4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 (diff)
Add LED indicator support in mbed
Diffstat (limited to 'protocol/mbed/HIDKeyboard.cpp')
-rw-r--r--protocol/mbed/HIDKeyboard.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/protocol/mbed/HIDKeyboard.cpp b/protocol/mbed/HIDKeyboard.cpp
index f40c2d2f2a..947077cd24 100644
--- a/protocol/mbed/HIDKeyboard.cpp
+++ b/protocol/mbed/HIDKeyboard.cpp
@@ -17,6 +17,10 @@ bool HIDKeyboard::sendReport(report_keyboard_t report) {
return true;
}
+uint8_t HIDKeyboard::leds() {
+ return led_state;
+}
+
bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) {
if (configuration != DEFAULT_CONFIGURATION) {
return false;
@@ -228,29 +232,40 @@ bool HIDKeyboard::USBCallback_request() {
}
// Process class-specific requests
-/*
if (transfer->setup.bmRequestType.Type == CLASS_TYPE)
{
- switch (transfer->setup.bRequest)
- {
- case SET_REPORT:
- // First byte will be used for report ID
- //outputReport.data[0] = transfer->setup.wValue & 0xff;
- //outputReport.length = transfer->setup.wLength + 1;
- outputReport.length = transfer->setup.wLength;
-
- //transfer->remaining = sizeof(outputReport.data) - 1;
- //transfer->ptr = &outputReport.data[1];
- transfer->remaining = sizeof(outputReport.data);
- transfer->ptr = &outputReport.data[0];
+ switch (transfer->setup.bRequest) {
+ case SET_REPORT:
+ // LED indicator
+ // TODO: check Interface and Report length?
+ // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { }
+ // if (transfer->setup.wLength == 1)
+
+ transfer->remaining = 1;
+ //transfer->ptr = ?? what ptr should be set when OUT(not used?)
transfer->direction = HOST_TO_DEVICE;
- transfer->notify = true;
+ transfer->notify = true; /* notify with USBCallback_requestCompleted */
success = true;
default:
break;
}
}
-*/
return success;
}
+
+void HIDKeyboard::USBCallback_requestCompleted(uint8_t * buf, uint32_t length)
+{
+ if (length > 0) {
+ CONTROL_TRANSFER *transfer = getTransferPtr();
+ if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
+ switch (transfer->setup.bRequest) {
+ case SET_REPORT:
+ led_state = buf[0];
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}