USBMOUSE
Dependents: ESD_Project_USBMouse
USBMouse.h
00001 #ifndef USBMOUSE_H 00002 #define USBMOUSE_H 00003 #include "USBHID.h" 00004 #define REPORT_ID_MOUSE 2 00005 00006 #define X_MIN_REL (-127) /*!< The maximum value that we can move to the left on the x-axis */ 00007 #define Y_MIN_REL (-127) /*!< The maximum value that we can move up on the y-axis */ 00008 #define X_MAX_REL (127) /*!< The maximum value that we can move to the right on the x-axis */ 00009 #define Y_MAX_REL (127) /*!< The maximum value that we can move down on the y-axis */ 00010 00011 enum MOUSE_BUTTON 00012 { 00013 MOUSE_LEFT = 1, 00014 MOUSE_RIGHT = 2, 00015 MOUSE_MIDDLE = 4, 00016 }; 00017 enum MOUSE_TYPE 00018 { 00019 REL_MOUSE, 00020 ABS_MOUSE 00021 }; 00022 00023 class USBMouse: public USBHID 00024 { 00025 public: 00026 USBMouse(MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0001, uint16_t product_release = 0x0001): 00027 USBHID(0, 0, vendor_id, product_id, product_release, false) 00028 { 00029 button = 0; 00030 this->mouse_type = mouse_type; 00031 connect(); 00032 }; 00033 bool update(int16_t x, int16_t y, uint8_t buttons, int8_t z); 00034 bool move(int16_t x, int16_t y); 00035 bool press(uint8_t button); 00036 bool release(uint8_t button); 00037 bool doubleClick(); 00038 bool click(uint8_t button); 00039 bool scroll(int8_t z); 00040 virtual uint8_t * reportDesc(); 00041 00042 protected: 00043 virtual uint8_t * configurationDesc(); 00044 00045 private: 00046 MOUSE_TYPE mouse_type; 00047 uint8_t button; 00048 bool mouseSend(int8_t x, int8_t y, uint8_t buttons, int8_t z); 00049 }; 00050 00051 #endif
Generated on Sat Jul 16 2022 01:37:14 by
1.7.2