Adaptation of the official mbed USBHost repository to work with the LPC4088 Display Module
Dependents: DMSupport DMSupport DMSupport DMSupport
Fork of DM_USBHost by
USBHostKeyboard.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 USBHOSTKEYBOARD_H 00018 #define USBHOSTKEYBOARD_H 00019 00020 #include "USBHostConf.h" 00021 00022 #if USBHOST_KEYBOARD 00023 00024 #include "USBHost.h" 00025 00026 /** 00027 * A class to communicate a USB keyboard 00028 */ 00029 class USBHostKeyboard : public IUSBEnumerator { 00030 public: 00031 00032 /** 00033 * Constructor 00034 */ 00035 USBHostKeyboard(); 00036 virtual ~USBHostKeyboard(); 00037 00038 /** 00039 * Try to connect a keyboard device 00040 * 00041 * @return true if connection was successful 00042 */ 00043 bool connect(); 00044 00045 /** 00046 * Check if a keyboard is connected 00047 * 00048 * @returns true if a keyboard is connected 00049 */ 00050 bool connected(); 00051 00052 /** 00053 * Attach a callback called when a keyboard event is received 00054 * 00055 * @param ptr function pointer 00056 */ 00057 inline void attach(void (*ptr)(uint8_t key)) { 00058 if (ptr != NULL) { 00059 onKey = ptr; 00060 } 00061 } 00062 00063 /** 00064 * Attach a callback called when a keyboard event is received 00065 * 00066 * @param ptr function pointer 00067 */ 00068 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier)) { 00069 if (ptr != NULL) { 00070 onKeyCode = ptr; 00071 } 00072 } 00073 00074 protected: 00075 //From IUSBEnumerator 00076 virtual void setVidPid(uint16_t vid, uint16_t pid); 00077 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 00078 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00079 00080 private: 00081 USBHost * host; 00082 USBDeviceConnected * dev; 00083 USBEndpoint * int_in; 00084 uint8_t* report; 00085 int keyboard_intf; 00086 bool keyboard_device_found; 00087 00088 bool dev_connected; 00089 00090 void rxHandler(); 00091 00092 void (*onKey)(uint8_t key); 00093 void (*onKeyCode)(uint8_t key, uint8_t modifier); 00094 00095 int report_id; 00096 00097 void init(); 00098 00099 }; 00100 00101 #endif 00102 00103 #endif
Generated on Tue Jul 12 2022 21:45:29 by
