Embed: (wiki syntax)

« Back to documentation index

USBMouseKeyboard Class Reference

USBMouseKeyboard Class Reference

USB device: a keyboard and a relative mouse. More...

#include <USBMouseKeyboard.h>

Inherits GenericMouse, GenericKeyboard, and USBHID.

Public Member Functions

 USBMouseKeyboard ()
 Constructor for a relative mouse and a keyboard.
virtual bool update (int16_t x, int16_t y, uint8_t buttons, int8_t z)
 Write a state of the mouse.
bool move (int16_t x, int16_t y)
 Move the cursor to (x, y)
bool press (uint8_t button)
 Press one or several buttons.
bool release (uint8_t button)
 Release one or several buttons.
bool doubleClick ()
 Double click (MOUSE_LEFT)
bool click (uint8_t button)
 Click.
bool scroll (int8_t z)
 Scrolling.
bool keyCode (uint8_t modifier, uint8_t key)
 Send all kinds of characters (ctrl + key, ...).
virtual int _putc (int c)
 Send a character.
bool mediaControl (MEDIA_KEY key)
 Control media keys.

Detailed Description

USB device: a keyboard and a relative mouse.

Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard.

Example:

 #include "mbed.h"
 #include "USBMouseKeyboard.h"

 USBMouseKeyboard key_mouse;

 int main(void)
 {
   while(1)
   {
       key_mouse.move(20, 0);
       key_mouse.puts("Hello World\r\n");
       wait(2);
   }
 }

Definition at line 35 of file USBMouseKeyboard.h.


Constructor & Destructor Documentation

Constructor for a relative mouse and a keyboard.

Definition at line 43 of file USBMouseKeyboard.h.


Member Function Documentation

int _putc ( int  c ) [virtual, inherited]

Send a character.

Parameters:
ccharacter to be sent
Returns:
true if there is no error, false otherwise

Definition at line 10 of file GenericKeyboard.c.

bool click ( uint8_t  button ) [inherited]

Click.

Parameters:
buttonstate of the buttons ( ex: clic(MOUSE_LEFT))
Returns:
true if there is no error, false otherwise

Definition at line 26 of file GenericMouse.c.

bool doubleClick (  ) [inherited]

Double click (MOUSE_LEFT)

Returns:
true if there is no error, false otherwise

Definition at line 19 of file GenericMouse.c.

bool keyCode ( uint8_t  modifier,
uint8_t  key 
) [inherited]

Send all kinds of characters (ctrl + key, ...).

 //To send CTRL + s (save)
  keyboard.keyCode(CTRL, 's');
Parameters:
modifierbit 0: CTRL, bit 1: SHIFT, bit 2: ALT
keycharacter to send
Returns:
true if there is no error, false otherwise

Definition at line 14 of file GenericKeyboard.c.

bool mediaControl ( MEDIA_KEY  key ) [inherited]

Control media keys.

Parameters:
keymedia key pressed (KEY_NEXT_TRACK, KEY_PREVIOUS_TRACK, KEY_STOP, KEY_PLAY_PAUSE, KEY_MUTE, KEY_VOLUME_UP, KEY_VOLUME_DOWN)
Returns:
true if there is no error, false otherwise

Definition at line 47 of file GenericKeyboard.c.

bool move ( int16_t  x,
int16_t  y 
) [inherited]

Move the cursor to (x, y)

Parameters:
xx-axis position (can be absolute or relative)
yy-axis position (can be absolute or relative)
Returns:
true if there is no error, false otherwise

Definition at line 10 of file GenericMouse.c.

bool press ( uint8_t  button ) [inherited]

Press one or several buttons.

Parameters:
buttonbutton state (ex: press(MOUSE_LEFT))
Returns:
true if there is no error, false otherwise

Definition at line 33 of file GenericMouse.c.

bool release ( uint8_t  button ) [inherited]

Release one or several buttons.

Parameters:
buttonbutton state (ex: release(MOUSE_LEFT))
Returns:
true if there is no error, false otherwise

Definition at line 38 of file GenericMouse.c.

bool scroll ( int8_t  z ) [inherited]

Scrolling.

Parameters:
zvalue of the wheel (>0 to go down, <0 to go up)
Returns:
true if there is no error, false otherwise

Definition at line 14 of file GenericMouse.c.

bool update ( int16_t  x,
int16_t  y,
uint8_t  buttons,
int8_t  z 
) [virtual]

Write a state of the mouse.

Parameters:
xx relative position
yy relative position
buttonsbuttons state (first bit represents MOUSE_LEFT, second bit MOUSE_RIGHT and third bit MOUSE_MIDDLE)
zwheel state (>0 to scroll down, <0 to scroll up)
Returns:
true if there is no error, false otherwise

Reimplemented from GenericMouse.

Definition at line 101 of file USBMouseKeyboard.c.