Adaptation of the official mbed USBHost repository to work with the LPC4088 Display Module
Dependents: DMSupport DMSupport DMSupport DMSupport
Fork of DM_USBHost by
USBHostMouse.h
00001 /* mbed USBHost Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef USBHOSTMOUSE_H 00018 #define USBHOSTMOUSE_H 00019 00020 #include "USBHostConf.h" 00021 00022 #if USBHOST_MOUSE 00023 00024 #include "USBHost.h" 00025 00026 /** 00027 * A class to communicate a USB mouse 00028 */ 00029 class USBHostMouse : public IUSBEnumerator { 00030 public: 00031 00032 /** 00033 * Constructor 00034 */ 00035 USBHostMouse(); 00036 virtual ~USBHostMouse(); 00037 00038 /** 00039 * Try to connect a mouse device 00040 * 00041 * @return true if connection was successful 00042 */ 00043 bool connect(); 00044 00045 /** 00046 * Check if a mouse is connected 00047 * 00048 * @returns true if a mouse is connected 00049 */ 00050 bool connected(); 00051 00052 /** 00053 * Attach a callback called when a mouse event is received 00054 * 00055 * @param ptr function pointer 00056 */ 00057 inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) { 00058 if (ptr != NULL) { 00059 onUpdate = ptr; 00060 } 00061 } 00062 00063 /** 00064 * Attach a callback called when the button state changes 00065 * 00066 * @param ptr function pointer 00067 */ 00068 inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) { 00069 if (ptr != NULL) { 00070 onButtonUpdate = ptr; 00071 } 00072 } 00073 00074 /** 00075 * Attach a callback called when the X axis value changes 00076 * 00077 * @param ptr function pointer 00078 */ 00079 inline void attachXEvent(void (*ptr)(int8_t x)) { 00080 if (ptr != NULL) { 00081 onXUpdate = ptr; 00082 } 00083 } 00084 00085 /** 00086 * Attach a callback called when the Y axis value changes 00087 * 00088 * @param ptr function pointer 00089 */ 00090 inline void attachYEvent(void (*ptr)(int8_t y)) { 00091 if (ptr != NULL) { 00092 onYUpdate = ptr; 00093 } 00094 } 00095 00096 /** 00097 * Attach a callback called when the Z axis value changes (scrolling) 00098 * 00099 * @param ptr function pointer 00100 */ 00101 inline void attachZEvent(void (*ptr)(int8_t z)) { 00102 if (ptr != NULL) { 00103 onZUpdate = ptr; 00104 } 00105 } 00106 00107 protected: 00108 //From IUSBEnumerator 00109 virtual void setVidPid(uint16_t vid, uint16_t pid); 00110 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed 00111 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00112 00113 private: 00114 USBHost * host; 00115 USBDeviceConnected * dev; 00116 USBEndpoint * int_in; 00117 uint8_t* report; 00118 00119 bool dev_connected; 00120 bool mouse_device_found; 00121 int mouse_intf; 00122 00123 uint8_t buttons; 00124 int8_t x; 00125 int8_t y; 00126 int8_t z; 00127 00128 void rxHandler(); 00129 void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z); 00130 void (*onButtonUpdate)(uint8_t buttons); 00131 void (*onXUpdate)(int8_t x); 00132 void (*onYUpdate)(int8_t y); 00133 void (*onZUpdate)(int8_t z); 00134 int report_id; 00135 void init(); 00136 }; 00137 00138 #endif 00139 00140 #endif
Generated on Tue Jul 12 2022 21:45:29 by 1.7.2