auto input keyboard

Dependencies:   USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
seeed
Date:
Wed Jul 31 01:15:29 2013 +0000
Parent:
6:17871da2a7e4
Commit message:
auto input keyboard

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice.lib	Fri Mar 01 13:23:58 2013 +0000
+++ b/USBDevice.lib	Wed Jul 31 01:15:29 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
+http://mbed.org/users/seeed/code/USBDevice/#5592a5e874fe
--- a/main.cpp	Fri Mar 01 13:23:58 2013 +0000
+++ b/main.cpp	Wed Jul 31 01:15:29 2013 +0000
@@ -10,12 +10,36 @@
 USBKeyboard keyboard;
  
 int main(void) {
+    unsigned int lock;  // Original status of caps lock
+    
+    while (!keyboard.configured()) {
+    }
+    wait(3);
+    
+    // Enable caps lock to bypass input method
+    lock = 0;
+    keyboard.keyCode(KEY_CAPS_LOCK);
+    wait(0.1);
+    if (0 == (keyboard.lockStatus() & 2)) {
+       keyboard.keyCode(KEY_CAPS_LOCK);
+       lock = 1;
+    }
+
+    wait(0.1);
+    keyboard.keyCode('r', KEY_META);
+    wait(0.1);
+    keyboard.puts("iexplore  http://seeedstudio.com\n\n");
+    wait(0.1);
+    keyboard.keyCode('r', KEY_META);
+    wait(0.1);
+    keyboard.puts("msg  *  have fun!\n\n");
+    
+    // recover the original status of caps lock
+    if (0 == lock) {
+        keyboard.keyCode(KEY_CAPS_LOCK);  
+    }
+    
     while (1) {
-        keyboard.mediaControl(KEY_VOLUME_DOWN);
-        keyboard.printf("Hello World from Mbed\r\n");
-        keyboard.keyCode('s', KEY_CTRL);
-        keyboard.keyCode(KEY_CAPS_LOCK);
-        wait(1);
         leds = keyboard.lockStatus();
     }
 }
\ No newline at end of file