USBMOUSE
Dependents: ESD_Project_USBMouse
USBHID/USBMouse.h@0:78a4faee5b0f, 2015-12-13 (annotated)
- Committer:
- priyankapashte
- Date:
- Sun Dec 13 10:04:36 2015 +0000
- Revision:
- 0:78a4faee5b0f
USBMouse File has been modified;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
priyankapashte | 0:78a4faee5b0f | 1 | #ifndef USBMOUSE_H |
priyankapashte | 0:78a4faee5b0f | 2 | #define USBMOUSE_H |
priyankapashte | 0:78a4faee5b0f | 3 | #include "USBHID.h" |
priyankapashte | 0:78a4faee5b0f | 4 | #define REPORT_ID_MOUSE 2 |
priyankapashte | 0:78a4faee5b0f | 5 | |
priyankapashte | 0:78a4faee5b0f | 6 | #define X_MIN_REL (-127) /*!< The maximum value that we can move to the left on the x-axis */ |
priyankapashte | 0:78a4faee5b0f | 7 | #define Y_MIN_REL (-127) /*!< The maximum value that we can move up on the y-axis */ |
priyankapashte | 0:78a4faee5b0f | 8 | #define X_MAX_REL (127) /*!< The maximum value that we can move to the right on the x-axis */ |
priyankapashte | 0:78a4faee5b0f | 9 | #define Y_MAX_REL (127) /*!< The maximum value that we can move down on the y-axis */ |
priyankapashte | 0:78a4faee5b0f | 10 | |
priyankapashte | 0:78a4faee5b0f | 11 | enum MOUSE_BUTTON |
priyankapashte | 0:78a4faee5b0f | 12 | { |
priyankapashte | 0:78a4faee5b0f | 13 | MOUSE_LEFT = 1, |
priyankapashte | 0:78a4faee5b0f | 14 | MOUSE_RIGHT = 2, |
priyankapashte | 0:78a4faee5b0f | 15 | MOUSE_MIDDLE = 4, |
priyankapashte | 0:78a4faee5b0f | 16 | }; |
priyankapashte | 0:78a4faee5b0f | 17 | enum MOUSE_TYPE |
priyankapashte | 0:78a4faee5b0f | 18 | { |
priyankapashte | 0:78a4faee5b0f | 19 | REL_MOUSE, |
priyankapashte | 0:78a4faee5b0f | 20 | ABS_MOUSE |
priyankapashte | 0:78a4faee5b0f | 21 | }; |
priyankapashte | 0:78a4faee5b0f | 22 | |
priyankapashte | 0:78a4faee5b0f | 23 | class USBMouse: public USBHID |
priyankapashte | 0:78a4faee5b0f | 24 | { |
priyankapashte | 0:78a4faee5b0f | 25 | public: |
priyankapashte | 0:78a4faee5b0f | 26 | USBMouse(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0001, uint16_t product_release = 0x0001): |
priyankapashte | 0:78a4faee5b0f | 27 | USBHID(0, 0, vendor_id, product_id, product_release, false) |
priyankapashte | 0:78a4faee5b0f | 28 | { |
priyankapashte | 0:78a4faee5b0f | 29 | button = 0; |
priyankapashte | 0:78a4faee5b0f | 30 | this->mouse_type = mouse_type; |
priyankapashte | 0:78a4faee5b0f | 31 | connect(); |
priyankapashte | 0:78a4faee5b0f | 32 | }; |
priyankapashte | 0:78a4faee5b0f | 33 | bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z); |
priyankapashte | 0:78a4faee5b0f | 34 | bool move(int16_t x, int16_t y); |
priyankapashte | 0:78a4faee5b0f | 35 | bool press(uint8_t button); |
priyankapashte | 0:78a4faee5b0f | 36 | bool release(uint8_t button); |
priyankapashte | 0:78a4faee5b0f | 37 | bool doubleClick(); |
priyankapashte | 0:78a4faee5b0f | 38 | bool click(uint8_t button); |
priyankapashte | 0:78a4faee5b0f | 39 | bool scroll(int8_t z); |
priyankapashte | 0:78a4faee5b0f | 40 | virtual uint8_t * reportDesc(); |
priyankapashte | 0:78a4faee5b0f | 41 | |
priyankapashte | 0:78a4faee5b0f | 42 | protected: |
priyankapashte | 0:78a4faee5b0f | 43 | virtual uint8_t * configurationDesc(); |
priyankapashte | 0:78a4faee5b0f | 44 | |
priyankapashte | 0:78a4faee5b0f | 45 | private: |
priyankapashte | 0:78a4faee5b0f | 46 | MOUSE_TYPE mouse_type; |
priyankapashte | 0:78a4faee5b0f | 47 | uint8_t button; |
priyankapashte | 0:78a4faee5b0f | 48 | bool mouseSend(int8_t x, int8_t y, uint8_t buttons, int8_t z); |
priyankapashte | 0:78a4faee5b0f | 49 | }; |
priyankapashte | 0:78a4faee5b0f | 50 | |
priyankapashte | 0:78a4faee5b0f | 51 | #endif |