Embed:
(wiki syntax)
Show/hide line numbers
USBMouseKeyboard.h
00001 /* USBMouseKeyboard.h */ 00002 /* USB device example: Keyboard with a relative mouse */ 00003 /* Copyright (c) 2011 ARM Limited. All rights reserved. */ 00004 00005 #ifndef _USB_KEYBOARD_REL_MOUSE_ 00006 #define _USB_KEYBOARD_REL_MOUSE_ 00007 00008 #include "GenericMouse.h" 00009 #include "GenericKeyboard.h" 00010 #include "USBHID.h" 00011 00012 /** USB device: a keyboard and a relative mouse 00013 * 00014 * Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard. 00015 * 00016 * Example: 00017 * @code 00018 * 00019 * #include "mbed.h" 00020 * #include "USBMouseKeyboard.h" 00021 * 00022 * USBMouseKeyboard key_mouse; 00023 * 00024 * int main(void) 00025 * { 00026 * while(1) 00027 * { 00028 * key_mouse.move(20, 0); 00029 * key_mouse.puts("Hello World\r\n"); 00030 * wait(2); 00031 * } 00032 * } 00033 * @endcode 00034 */ 00035 class USBMouseKeyboard: public GenericMouse, public GenericKeyboard, public USBHID 00036 { 00037 public: 00038 00039 /** 00040 * Constructor for a relative mouse and a keyboard 00041 * 00042 */ 00043 USBMouseKeyboard(){}; 00044 00045 /** 00046 * Write a state of the mouse 00047 * 00048 * @param x x relative position 00049 * @param y y relative position 00050 * @param buttons buttons state (first bit represents MOUSE_LEFT, second bit MOUSE_RIGHT and third bit MOUSE_MIDDLE) 00051 * @param z wheel state (>0 to scroll down, <0 to scroll up) 00052 * @return true if there is no error, false otherwise 00053 */ 00054 virtual bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z); 00055 00056 virtual uint8_t * ReportDesc(); 00057 00058 00059 private: 00060 bool mouseWrite(int8_t x, int8_t y, uint8_t buttons, int8_t z); 00061 }; 00062 00063 #endif
Generated on Fri Jul 15 2022 02:22:27 by 1.7.2