USBMouseKeyboard

mbed OS 2

This is the handbook for mbed OS 2.

The USBMouseKeyboard interface is used to emulate a mouse and a keyboard at the same time over the USB port.

The USB connector should be attached to

  • p31 (D+), p32 (D-) and GND for the LPC1768 and the LPC11U24
  • The on-board USB connector of the FRDM-KL25Z

Hello World

Import program

00001 #include "mbed.h"
00002 #include "USBMouseKeyboard.h"
00003  
00004 //LED1: NUM_LOCK
00005 //LED2: CAPS_LOCK
00006 //LED3: SCROLL_LOCK
00007 BusOut leds(LED1, LED2, LED3);
00008  
00009 //USBMouseKeyboard
00010 USBMouseKeyboard key_mouse;
00011  
00012 int main(void) {
00013     while (1) {
00014         key_mouse.mediaControl(KEY_VOLUME_DOWN);
00015         key_mouse.printf("Hello World from Mbed\r\n");
00016         key_mouse.keyCode('s', KEY_CTRL);
00017         key_mouse.move(20, 0);
00018         key_mouse.keyCode(KEY_SCROLL_LOCK);
00019         wait(1);
00020         leds = key_mouse.lockStatus();
00021     }
00022 }

API

[Not found]

Details

You can choose either a relative mouse or an absolute mouse with the keyboard. By default, a USBMouseKeyboard is a relative mouse and a keyboard