keycode2 add USBKeyboard

Dependencies:   USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
yueee_yt
Date:
Fri Oct 05 11:58:23 2012 +0000
Parent:
4:f0df6aae7147
Commit message:
Keycode2 Sample
;

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	Wed Nov 30 11:04:28 2011 +0000
+++ b/USBDevice.lib	Fri Oct 05 11:58:23 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/samux/code/USBDevice/#65a34d6b5e22
+http://mbed.org/users/yueee_yt/code/USBDevice/#4c0daa716c71
--- a/main.cpp	Wed Nov 30 11:04:28 2011 +0000
+++ b/main.cpp	Fri Oct 05 11:58:23 2012 +0000
@@ -5,17 +5,33 @@
 //LED2: CAPS_LOCK
 //LED3: SCROLL_LOCK
 BusOut leds(LED1, LED2, LED3);
-
+DigitalIn key1(p17);
+DigitalIn key2(p18);
 //USBKeyboard
 USBKeyboard keyboard;
-
-int main(void) {
+void key1_on(void)
+{
+    //Ctrl+Alt+Del
+    keyboard.keyCode2(0x4c,0,0,0,0,0, KEY_CTRL|KEY_ALT);
+    wait(1);
+}
+void key2_on(void)
+{
+    //ESC
+    keyboard.keyCode2(0x29);
+    wait(1);
+}
+int main(void)
+{
+    bool k1,k2;
+    k1=true;k2=true;
+    key1.mode(PullUp);
+    key2.mode(PullUp);
     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);
+        if (key1==0&&k1==1)key1_on();
+        if (key2==0&&k2==1)key2_on();
+        k1=key1;
+        k2=key2;
         leds = keyboard.lockStatus();
     }
 }
\ No newline at end of file