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