USBDevice Library for QSB_Scancode_USB

Dependents:   QSB_Scandcode_USB

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
ThomasSonderDesign
Date:
Thu Feb 25 00:44:29 2016 +0000
Parent:
31:5bf05f9b3c7b
Commit message:
Test Sending scan codes over usb

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
diff -r 5bf05f9b3c7b -r 4888faad7a73 USBHID/USBKeyboard.cpp
--- a/USBHID/USBKeyboard.cpp	Thu Aug 21 15:00:37 2014 +0100
+++ b/USBHID/USBKeyboard.cpp	Thu Feb 25 00:44:29 2016 +0000
@@ -472,6 +472,40 @@
     return true;
 
 }
+/*Modified keyCode comand that takes 7 arguments
+**used to simulate unicode input on windows machines
+*/
+bool USBKeyboard::keyCode(uint8_t key0,uint8_t key1,uint8_t key2,uint8_t key3,uint8_t key4,uint8_t key5, 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;
+    report.data[3] = keymap[key0].usage;
+    report.data[4] = keymap[key1].usage;
+    report.data[5] = keymap[key2].usage;
+    report.data[6] = keymap[key3].usage;
+    report.data[7] = keymap[key4].usage;
+    report.data[8] = 0;
+
+    report.length = 9;
+
+    if (!send(&report)) {
+        return false;
+    }
+
+    report.data[1] = 0;
+    report.data[3] = 0;
+
+    if (!send(&report)) {
+        return false;
+    }
+
+    return true;
+
+}
+
 
 
 bool USBKeyboard::mediaControl(MEDIA_KEY key) {
diff -r 5bf05f9b3c7b -r 4888faad7a73 USBHID/USBKeyboard.h
--- a/USBHID/USBKeyboard.h	Thu Aug 21 15:00:37 2014 +0100
+++ b/USBHID/USBKeyboard.h	Thu Feb 25 00:44:29 2016 +0000
@@ -121,6 +121,8 @@
     * @returns true if there is no error, false otherwise
     */
     bool keyCode(uint8_t key, uint8_t modifier = 0);
+    
+    bool keyCode(uint8_t key0,uint8_t key1,uint8_t key2,uint8_t key3,uint8_t key4,uint8_t key5, uint8_t modifier);
 
     /**
     * Send a character