auto input keyboard

Dependencies:   USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

main.cpp

Committer:
seeed
Date:
2013-07-31
Revision:
7:66c5fd43b19c
Parent:
5:03a4211d593a

File content as of revision 7:66c5fd43b19c:

#include "mbed.h"
#include "USBKeyboard.h"
 
//LED1: NUM_LOCK
//LED2: CAPS_LOCK
//LED3: SCROLL_LOCK
BusOut leds(LED1, LED2, LED3);
 
//USBKeyboard
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) {
        leds = keyboard.lockStatus();
    }
}