1 /* mbed USBHost Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef USBHOSTKEYBOARD_H
18 #define USBHOSTKEYBOARD_H
20 #include "USBHostConf.h"
27 * A class to communicate a USB keyboard
29 class USBHostKeyboard : public IUSBEnumerator {
38 * Try to connect a keyboard device
40 * @return true if connection was successful
45 * Check if a keyboard is connected
47 * @returns true if a keyboard is connected
52 * Attach a callback called when a keyboard event is received
54 * @param ptr function pointer
56 inline void attach(void (*ptr)(uint8_t key)) {
63 * Attach a callback called when a keyboard event is received
65 * @param ptr function pointer
67 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier)) {
75 virtual void setVidPid(uint16_t vid, uint16_t pid);
76 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
77 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
81 USBDeviceConnected * dev;
85 bool keyboard_device_found;
91 void (*onKey)(uint8_t key);
92 void (*onKeyCode)(uint8_t key, uint8_t modifier);