TEAMUSB_SLAVE

Dependencies:   USBHost mbed

Fork of USBHostKeyboard_HelloWorld by TEAMUSB

Revision:
8:f8122ca2f58f
Parent:
7:be82ac3c4821
Child:
9:8bcd70b26084
--- a/main.cpp	Fri Mar 27 11:34:07 2015 +0000
+++ b/main.cpp	Fri Mar 27 14:44:09 2015 +0000
@@ -8,28 +8,48 @@
     printf("Key: %c\r\n", key);
 }
 
+void onKeyMod(uint8_t key, uint8_t modifier) {
+    printf("Key: %c\r\n", key);
+}
+
+
 void keyboard_task(void const *) {
     
     USBHostKeyboard keyboard;
     
     while(1) {
+        
+        printf("trying to connect\r\n");
+        
         // try to connect a USB keyboard
-        while(!keyboard.connect())
+        while(!keyboard.connect()) {
             Thread::wait(500);
+        }
+
+        printf("connected\r\n");
+
     
         // when connected, attach handler called on keyboard event
         keyboard.attach(onKey);
+        keyboard.attach(onKeyMod);
+        
+        printf("eventhandler attached\r\n");
         
         // wait until the keyboard is disconnected
-        while(keyboard.connected())
-            Thread::wait(500);
+        while(keyboard.connected()) {
+            USBHost::poll();
+        }
+            
+        printf("disconnected\r\n");
+        
     }
 }
 
 int main() {
     Thread keyboardTask(keyboard_task, NULL, osPriorityNormal, 256 * 4);
+    
     while(1) {
         led=!led;
-        Thread::wait(500);
+        Thread::wait(2000); 
     }
 }