aboutsummaryrefslogtreecommitdiff
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)
downloadqmk_firmware-b4a91ecf4e46ee533563fd759e26dd249bf6b4de.tar.gz
qmk_firmware-b4a91ecf4e46ee533563fd759e26dd249bf6b4de.zip
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 f40c2d2f2..947077cd2 100644
--- a/protocol/mbed/HIDKeyboard.cpp
+++ b/protocol/mbed/HIDKeyboard.cpp
@@ -17,6 +17,10 @@ bool HIDKeyboard::sendReport(report_keyboard_t report) {
17 return true; 17 return true;
18} 18}
19 19
20uint8_t HIDKeyboard::leds() {
21 return led_state;
22}
23
20bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { 24bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) {
21 if (configuration != DEFAULT_CONFIGURATION) { 25 if (configuration != DEFAULT_CONFIGURATION) {
22 return false; 26 return false;
@@ -228,29 +232,40 @@ bool HIDKeyboard::USBCallback_request() {
228 } 232 }
229 233
230 // Process class-specific requests 234 // Process class-specific requests
231/*
232 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) 235 if (transfer->setup.bmRequestType.Type == CLASS_TYPE)
233 { 236 {
234 switch (transfer->setup.bRequest) 237 switch (transfer->setup.bRequest) {
235 { 238 case SET_REPORT:
236 case SET_REPORT: 239 // LED indicator
237 // First byte will be used for report ID 240 // TODO: check Interface and Report length?
238 //outputReport.data[0] = transfer->setup.wValue & 0xff; 241 // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { }
239 //outputReport.length = transfer->setup.wLength + 1; 242 // if (transfer->setup.wLength == 1)
240 outputReport.length = transfer->setup.wLength; 243
241 244 transfer->remaining = 1;
242 //transfer->remaining = sizeof(outputReport.data) - 1; 245 //transfer->ptr = ?? what ptr should be set when OUT(not used?)
243 //transfer->ptr = &outputReport.data[1];
244 transfer->remaining = sizeof(outputReport.data);
245 transfer->ptr = &outputReport.data[0];
246 transfer->direction = HOST_TO_DEVICE; 246 transfer->direction = HOST_TO_DEVICE;
247 transfer->notify = true; 247 transfer->notify = true; /* notify with USBCallback_requestCompleted */
248 success = true; 248 success = true;
249 default: 249 default:
250 break; 250 break;
251 } 251 }
252 } 252 }
253*/
254 253
255 return success; 254 return success;
256} 255}
256
257void HIDKeyboard::USBCallback_requestCompleted(uint8_t * buf, uint32_t length)
258{
259 if (length > 0) {
260 CONTROL_TRANSFER *transfer = getTransferPtr();
261 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
262 switch (transfer->setup.bRequest) {
263 case SET_REPORT:
264 led_state = buf[0];
265 break;
266 default:
267 break;
268 }
269 }
270 }
271}