Committer:
chris
Date:
Thu Oct 20 14:07:30 2011 +0000
Revision:
0:e98d1c2b16c6

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:e98d1c2b16c6 1 /* USBMouseKeyboard.h */
chris 0:e98d1c2b16c6 2 /* USB device example: Keyboard with a relative mouse */
chris 0:e98d1c2b16c6 3 /* Copyright (c) 2011 ARM Limited. All rights reserved. */
chris 0:e98d1c2b16c6 4
chris 0:e98d1c2b16c6 5 #ifndef _USB_KEYBOARD_REL_MOUSE_
chris 0:e98d1c2b16c6 6 #define _USB_KEYBOARD_REL_MOUSE_
chris 0:e98d1c2b16c6 7
chris 0:e98d1c2b16c6 8 #include "GenericMouse.h"
chris 0:e98d1c2b16c6 9 #include "GenericKeyboard.h"
chris 0:e98d1c2b16c6 10 #include "USBHID.h"
chris 0:e98d1c2b16c6 11
chris 0:e98d1c2b16c6 12 /** USB device: a keyboard and a relative mouse
chris 0:e98d1c2b16c6 13 *
chris 0:e98d1c2b16c6 14 * Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard.
chris 0:e98d1c2b16c6 15 *
chris 0:e98d1c2b16c6 16 * Example:
chris 0:e98d1c2b16c6 17 * @code
chris 0:e98d1c2b16c6 18 *
chris 0:e98d1c2b16c6 19 * #include "mbed.h"
chris 0:e98d1c2b16c6 20 * #include "USBMouseKeyboard.h"
chris 0:e98d1c2b16c6 21 *
chris 0:e98d1c2b16c6 22 * USBMouseKeyboard key_mouse;
chris 0:e98d1c2b16c6 23 *
chris 0:e98d1c2b16c6 24 * int main(void)
chris 0:e98d1c2b16c6 25 * {
chris 0:e98d1c2b16c6 26 * while(1)
chris 0:e98d1c2b16c6 27 * {
chris 0:e98d1c2b16c6 28 * key_mouse.move(20, 0);
chris 0:e98d1c2b16c6 29 * key_mouse.puts("Hello World\r\n");
chris 0:e98d1c2b16c6 30 * wait(2);
chris 0:e98d1c2b16c6 31 * }
chris 0:e98d1c2b16c6 32 * }
chris 0:e98d1c2b16c6 33 * @endcode
chris 0:e98d1c2b16c6 34 */
chris 0:e98d1c2b16c6 35 class USBMouseKeyboard: public GenericMouse, public GenericKeyboard, public USBHID
chris 0:e98d1c2b16c6 36 {
chris 0:e98d1c2b16c6 37 public:
chris 0:e98d1c2b16c6 38
chris 0:e98d1c2b16c6 39 /**
chris 0:e98d1c2b16c6 40 * Constructor for a relative mouse and a keyboard
chris 0:e98d1c2b16c6 41 *
chris 0:e98d1c2b16c6 42 */
chris 0:e98d1c2b16c6 43 USBMouseKeyboard(){};
chris 0:e98d1c2b16c6 44
chris 0:e98d1c2b16c6 45 /**
chris 0:e98d1c2b16c6 46 * Write a state of the mouse
chris 0:e98d1c2b16c6 47 *
chris 0:e98d1c2b16c6 48 * @param x x relative position
chris 0:e98d1c2b16c6 49 * @param y y relative position
chris 0:e98d1c2b16c6 50 * @param buttons buttons state (first bit represents MOUSE_LEFT, second bit MOUSE_RIGHT and third bit MOUSE_MIDDLE)
chris 0:e98d1c2b16c6 51 * @param z wheel state (>0 to scroll down, <0 to scroll up)
chris 0:e98d1c2b16c6 52 * @return true if there is no error, false otherwise
chris 0:e98d1c2b16c6 53 */
chris 0:e98d1c2b16c6 54 virtual bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z);
chris 0:e98d1c2b16c6 55
chris 0:e98d1c2b16c6 56 virtual uint8_t * ReportDesc();
chris 0:e98d1c2b16c6 57
chris 0:e98d1c2b16c6 58
chris 0:e98d1c2b16c6 59 private:
chris 0:e98d1c2b16c6 60 bool mouseWrite(int8_t x, int8_t y, uint8_t buttons, int8_t z);
chris 0:e98d1c2b16c6 61 };
chris 0:e98d1c2b16c6 62
chris 0:e98d1c2b16c6 63 #endif