USB device stack that isn't working

Dependents:   SDVXcontroller

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
lukeoftheaura
Date:
Fri Jan 12 19:11:17 2018 +0000
Parent:
71:53949e6131f6
Child:
73:6fb59df5258d
Commit message:
Unworking USB Device lib isn't working

Changed in this revision

USBHID/USBKeyboard.cpp Show annotated file Show diff for this revision Revisions of this file
USBHID/USBKeyboard.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBHID/USBKeyboard.cpp	Thu Jul 27 12:14:04 2017 +0100
+++ b/USBHID/USBKeyboard.cpp	Fri Jan 12 19:11:17 2018 +0000
@@ -442,10 +442,10 @@
     return keyCode(c, keymap[c].modifier);
 }
 
+
 bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) {
-    // Send a simulated keyboard keypress. Returns true if successful.
     HID_REPORT report;
-
+    
     report.data[0] = REPORT_ID_KEYBOARD;
     report.data[1] = modifier;
     report.data[2] = 0;
@@ -455,23 +455,51 @@
     report.data[6] = 0;
     report.data[7] = 0;
     report.data[8] = 0;
-
+    
     report.length = 9;
-
+    
     if (!send(&report)) {
         return false;
     }
-
+    
     report.data[1] = 0;
     report.data[3] = 0;
+    
+    return send(&report);
+}
 
-    if (!send(&report)) {
-        return false;
-    }
+bool USBKeyboard::keyPress(uint8_t key, uint8_t modifier) {
+    HID_REPORT report;
+    
+    report.data[0] = REPORT_ID_KEYBOARD;
+    report.data[1] = modifier;
+    report.data[2] = 0;
+    report.data[3] = keymap[key].usage;
+    report.data[4] = 0;
+    report.data[5] = 0;
+    report.data[6] = 0;
+    report.data[7] = 0;
+    report.data[8] = 0;
+    
+    return send(&report);
+}
 
-    return true;
+bool USBKeyboard::keyRelease() {
+    HID_REPORT report;
+    
+    report.data[0] = REPORT_ID_KEYBOARD;
+    report.data[1] = 0;
+    report.data[2] = 0;
+    report.data[3] = 0;
+    report.data[4] = 0;
+    report.data[5] = 0;
+    report.data[6] = 0;
+    report.data[7] = 0;
+    report.data[8] = 0;
+    
+    return send(&report);
+}
 
-}
 
 
 bool USBKeyboard::mediaControl(MEDIA_KEY key) {
--- a/USBHID/USBKeyboard.h	Thu Jul 27 12:14:04 2017 +0100
+++ b/USBHID/USBKeyboard.h	Fri Jan 12 19:11:17 2018 +0000
@@ -126,6 +126,8 @@
     * @returns true if there is no error, false otherwise
     */
     bool keyCode(uint8_t key, uint8_t modifier = 0);
+    bool keyPress(uint8_t key, uint8_t modifier = 0);
+    bool keyRelease();    
 
     /**
     * Send a character