Acts a USB HID keyboard, and socket server. Forwards characters from TCP ip socket to keyboard
Dependencies: mbed EthernetNetIf
USBKeyboardMouse/USBMouse.h@0:beb124b81ef5, 2011-08-02 (annotated)
- Committer:
- henryeherman
- Date:
- Tue Aug 02 02:58:40 2011 +0000
- Revision:
- 0:beb124b81ef5
Just barley work
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
henryeherman | 0:beb124b81ef5 | 1 | #include "usbhid.h" |
henryeherman | 0:beb124b81ef5 | 2 | |
henryeherman | 0:beb124b81ef5 | 3 | #ifndef MBED_USBMOUSE_H |
henryeherman | 0:beb124b81ef5 | 4 | #define MBED_USBMOUSE_H |
henryeherman | 0:beb124b81ef5 | 5 | |
henryeherman | 0:beb124b81ef5 | 6 | /* Class: USBMouse |
henryeherman | 0:beb124b81ef5 | 7 | * Emulate a USB Mouse HID device |
henryeherman | 0:beb124b81ef5 | 8 | * |
henryeherman | 0:beb124b81ef5 | 9 | * Example: |
henryeherman | 0:beb124b81ef5 | 10 | * > #include "mbed.h" |
henryeherman | 0:beb124b81ef5 | 11 | * > #include "USBMouse.h" |
henryeherman | 0:beb124b81ef5 | 12 | * > |
henryeherman | 0:beb124b81ef5 | 13 | * > USBMouse mouse; |
henryeherman | 0:beb124b81ef5 | 14 | * > |
henryeherman | 0:beb124b81ef5 | 15 | * > int main() { |
henryeherman | 0:beb124b81ef5 | 16 | * > while(1) { |
henryeherman | 0:beb124b81ef5 | 17 | * > mouse.move(10, 0); |
henryeherman | 0:beb124b81ef5 | 18 | * > wait(2); |
henryeherman | 0:beb124b81ef5 | 19 | * > } |
henryeherman | 0:beb124b81ef5 | 20 | * > } |
henryeherman | 0:beb124b81ef5 | 21 | */ |
henryeherman | 0:beb124b81ef5 | 22 | class USBMouse : private usbhid { |
henryeherman | 0:beb124b81ef5 | 23 | public: |
henryeherman | 0:beb124b81ef5 | 24 | /* Constructor: USBMouse |
henryeherman | 0:beb124b81ef5 | 25 | * Create a USB Mouse using the mbed USB Device interface |
henryeherman | 0:beb124b81ef5 | 26 | */ |
henryeherman | 0:beb124b81ef5 | 27 | USBMouse(); |
henryeherman | 0:beb124b81ef5 | 28 | |
henryeherman | 0:beb124b81ef5 | 29 | /* Function: move |
henryeherman | 0:beb124b81ef5 | 30 | * Move the mouse |
henryeherman | 0:beb124b81ef5 | 31 | * |
henryeherman | 0:beb124b81ef5 | 32 | * Variables: |
henryeherman | 0:beb124b81ef5 | 33 | * x - Distance to move in x-axis |
henryeherman | 0:beb124b81ef5 | 34 | * y - Distance to move in y-axis |
henryeherman | 0:beb124b81ef5 | 35 | */ |
henryeherman | 0:beb124b81ef5 | 36 | void move(int x, int y); |
henryeherman | 0:beb124b81ef5 | 37 | |
henryeherman | 0:beb124b81ef5 | 38 | /* Function: scroll |
henryeherman | 0:beb124b81ef5 | 39 | * Scroll the scroll wheel |
henryeherman | 0:beb124b81ef5 | 40 | * |
henryeherman | 0:beb124b81ef5 | 41 | * Variables: |
henryeherman | 0:beb124b81ef5 | 42 | * z - Distance to scroll scroll wheel |
henryeherman | 0:beb124b81ef5 | 43 | */ |
henryeherman | 0:beb124b81ef5 | 44 | void scroll(int z); |
henryeherman | 0:beb124b81ef5 | 45 | |
henryeherman | 0:beb124b81ef5 | 46 | /* Function: buttons |
henryeherman | 0:beb124b81ef5 | 47 | * Set the state of the buttons |
henryeherman | 0:beb124b81ef5 | 48 | * |
henryeherman | 0:beb124b81ef5 | 49 | * Variables: |
henryeherman | 0:beb124b81ef5 | 50 | * left - set the left button as down (1) or up (0) |
henryeherman | 0:beb124b81ef5 | 51 | * middle - set the middle button as down (1) or up (0) |
henryeherman | 0:beb124b81ef5 | 52 | * right - set the right button as down (1) or up (0) |
henryeherman | 0:beb124b81ef5 | 53 | */ |
henryeherman | 0:beb124b81ef5 | 54 | void buttons(int left, int middle, int right); |
henryeherman | 0:beb124b81ef5 | 55 | |
henryeherman | 0:beb124b81ef5 | 56 | private: |
henryeherman | 0:beb124b81ef5 | 57 | int _buttons; |
henryeherman | 0:beb124b81ef5 | 58 | }; |
henryeherman | 0:beb124b81ef5 | 59 | |
henryeherman | 0:beb124b81ef5 | 60 | #endif |