Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HttpServer_snapshot_mbed-os
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 #if defined(TARGET_RZ_A2XX) 00037 ~USBHostMouse(); 00038 #endif 00039 00040 /** 00041 * Try to connect a mouse device 00042 * 00043 * @return true if connection was successful 00044 */ 00045 bool connect(); 00046 00047 /** 00048 * Check if a mouse is connected 00049 * 00050 * @returns true if a mouse is connected 00051 */ 00052 bool connected(); 00053 00054 /** 00055 * Attach a callback called when a mouse event is received 00056 * 00057 * @param ptr function pointer 00058 */ 00059 inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) { 00060 if (ptr != NULL) { 00061 onUpdate = ptr; 00062 } 00063 } 00064 00065 /** 00066 * Attach a callback called when the button state changes 00067 * 00068 * @param ptr function pointer 00069 */ 00070 inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) { 00071 if (ptr != NULL) { 00072 onButtonUpdate = ptr; 00073 } 00074 } 00075 00076 /** 00077 * Attach a callback called when the X axis value changes 00078 * 00079 * @param ptr function pointer 00080 */ 00081 inline void attachXEvent(void (*ptr)(int8_t x)) { 00082 if (ptr != NULL) { 00083 onXUpdate = ptr; 00084 } 00085 } 00086 00087 /** 00088 * Attach a callback called when the Y axis value changes 00089 * 00090 * @param ptr function pointer 00091 */ 00092 inline void attachYEvent(void (*ptr)(int8_t y)) { 00093 if (ptr != NULL) { 00094 onYUpdate = ptr; 00095 } 00096 } 00097 00098 /** 00099 * Attach a callback called when the Z axis value changes (scrolling) 00100 * 00101 * @param ptr function pointer 00102 */ 00103 inline void attachZEvent(void (*ptr)(int8_t z)) { 00104 if (ptr != NULL) { 00105 onZUpdate = ptr; 00106 } 00107 } 00108 00109 protected: 00110 //From IUSBEnumerator 00111 virtual void setVidPid(uint16_t vid, uint16_t pid); 00112 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 00113 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00114 00115 private: 00116 USBHost * host; 00117 USBDeviceConnected * dev; 00118 USBEndpoint * int_in; 00119 #if defined(TARGET_RZ_A2XX) 00120 uint8_t * report; 00121 #else 00122 uint8_t report[8]; 00123 #endif 00124 00125 bool dev_connected; 00126 bool mouse_device_found; 00127 int mouse_intf; 00128 00129 uint8_t buttons; 00130 int8_t x; 00131 int8_t y; 00132 int8_t z; 00133 00134 void rxHandler(); 00135 void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z); 00136 void (*onButtonUpdate)(uint8_t buttons); 00137 void (*onXUpdate)(int8_t x); 00138 void (*onYUpdate)(int8_t y); 00139 void (*onZUpdate)(int8_t z); 00140 int report_id; 00141 void init(); 00142 }; 00143 00144 #endif 00145 00146 #endif
Generated on Wed Jul 13 2022 05:33:37 by
