X-TOUCH to djay bridge

Dependencies:   mbed mbed-rtos FATFileSystem

Committer:
okini3939
Date:
Wed Jun 05 04:54:37 2019 +0000
Revision:
1:0dac72ab5910
sample

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 1:0dac72ab5910 1 /* mbed USBHost Library
okini3939 1:0dac72ab5910 2 * Copyright (c) 2006-2013 ARM Limited
okini3939 1:0dac72ab5910 3 *
okini3939 1:0dac72ab5910 4 * Licensed under the Apache License, Version 2.0 (the "License");
okini3939 1:0dac72ab5910 5 * you may not use this file except in compliance with the License.
okini3939 1:0dac72ab5910 6 * You may obtain a copy of the License at
okini3939 1:0dac72ab5910 7 *
okini3939 1:0dac72ab5910 8 * http://www.apache.org/licenses/LICENSE-2.0
okini3939 1:0dac72ab5910 9 *
okini3939 1:0dac72ab5910 10 * Unless required by applicable law or agreed to in writing, software
okini3939 1:0dac72ab5910 11 * distributed under the License is distributed on an "AS IS" BASIS,
okini3939 1:0dac72ab5910 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
okini3939 1:0dac72ab5910 13 * See the License for the specific language governing permissions and
okini3939 1:0dac72ab5910 14 * limitations under the License.
okini3939 1:0dac72ab5910 15 */
okini3939 1:0dac72ab5910 16
okini3939 1:0dac72ab5910 17 #ifndef USBHOSTKEYBOARD_H
okini3939 1:0dac72ab5910 18 #define USBHOSTKEYBOARD_H
okini3939 1:0dac72ab5910 19
okini3939 1:0dac72ab5910 20 #include "USBHostConf.h"
okini3939 1:0dac72ab5910 21
okini3939 1:0dac72ab5910 22 #if USBHOST_KEYBOARD
okini3939 1:0dac72ab5910 23
okini3939 1:0dac72ab5910 24 #include "USBHost.h"
okini3939 1:0dac72ab5910 25
okini3939 1:0dac72ab5910 26 /**
okini3939 1:0dac72ab5910 27 * A class to communicate a USB keyboard
okini3939 1:0dac72ab5910 28 */
okini3939 1:0dac72ab5910 29 class USBHostKeyboard : public IUSBEnumerator
okini3939 1:0dac72ab5910 30 {
okini3939 1:0dac72ab5910 31 public:
okini3939 1:0dac72ab5910 32
okini3939 1:0dac72ab5910 33 /**
okini3939 1:0dac72ab5910 34 * Constructor
okini3939 1:0dac72ab5910 35 */
okini3939 1:0dac72ab5910 36 USBHostKeyboard();
okini3939 1:0dac72ab5910 37
okini3939 1:0dac72ab5910 38 /**
okini3939 1:0dac72ab5910 39 * Try to connect a keyboard device
okini3939 1:0dac72ab5910 40 *
okini3939 1:0dac72ab5910 41 * @return true if connection was successful
okini3939 1:0dac72ab5910 42 */
okini3939 1:0dac72ab5910 43 bool connect();
okini3939 1:0dac72ab5910 44
okini3939 1:0dac72ab5910 45 /**
okini3939 1:0dac72ab5910 46 * Check if a keyboard is connected
okini3939 1:0dac72ab5910 47 *
okini3939 1:0dac72ab5910 48 * @returns true if a keyboard is connected
okini3939 1:0dac72ab5910 49 */
okini3939 1:0dac72ab5910 50 bool connected();
okini3939 1:0dac72ab5910 51
okini3939 1:0dac72ab5910 52 /**
okini3939 1:0dac72ab5910 53 * Attach a callback called when a keyboard event is received
okini3939 1:0dac72ab5910 54 *
okini3939 1:0dac72ab5910 55 * @param ptr function pointer
okini3939 1:0dac72ab5910 56 */
okini3939 1:0dac72ab5910 57 inline void attach(void (*ptr)(uint8_t key))
okini3939 1:0dac72ab5910 58 {
okini3939 1:0dac72ab5910 59 if (ptr != NULL) {
okini3939 1:0dac72ab5910 60 onKey = ptr;
okini3939 1:0dac72ab5910 61 }
okini3939 1:0dac72ab5910 62 }
okini3939 1:0dac72ab5910 63
okini3939 1:0dac72ab5910 64 /**
okini3939 1:0dac72ab5910 65 * Attach a callback called when a keyboard event is received
okini3939 1:0dac72ab5910 66 *
okini3939 1:0dac72ab5910 67 * @param ptr function pointer
okini3939 1:0dac72ab5910 68 */
okini3939 1:0dac72ab5910 69 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier))
okini3939 1:0dac72ab5910 70 {
okini3939 1:0dac72ab5910 71 if (ptr != NULL) {
okini3939 1:0dac72ab5910 72 onKeyCode = ptr;
okini3939 1:0dac72ab5910 73 }
okini3939 1:0dac72ab5910 74 }
okini3939 1:0dac72ab5910 75
okini3939 1:0dac72ab5910 76 protected:
okini3939 1:0dac72ab5910 77 //From IUSBEnumerator
okini3939 1:0dac72ab5910 78 virtual void setVidPid(uint16_t vid, uint16_t pid);
okini3939 1:0dac72ab5910 79 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
okini3939 1:0dac72ab5910 80 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
okini3939 1:0dac72ab5910 81
okini3939 1:0dac72ab5910 82 private:
okini3939 1:0dac72ab5910 83 USBHost * host;
okini3939 1:0dac72ab5910 84 USBDeviceConnected * dev;
okini3939 1:0dac72ab5910 85 USBEndpoint * int_in;
okini3939 1:0dac72ab5910 86 uint8_t report[9];
okini3939 1:0dac72ab5910 87 int keyboard_intf;
okini3939 1:0dac72ab5910 88 bool keyboard_device_found;
okini3939 1:0dac72ab5910 89
okini3939 1:0dac72ab5910 90 bool dev_connected;
okini3939 1:0dac72ab5910 91
okini3939 1:0dac72ab5910 92 void rxHandler();
okini3939 1:0dac72ab5910 93
okini3939 1:0dac72ab5910 94 void (*onKey)(uint8_t key);
okini3939 1:0dac72ab5910 95 void (*onKeyCode)(uint8_t key, uint8_t modifier);
okini3939 1:0dac72ab5910 96
okini3939 1:0dac72ab5910 97 int report_id;
okini3939 1:0dac72ab5910 98
okini3939 1:0dac72ab5910 99 void init();
okini3939 1:0dac72ab5910 100
okini3939 1:0dac72ab5910 101 };
okini3939 1:0dac72ab5910 102
okini3939 1:0dac72ab5910 103 #endif
okini3939 1:0dac72ab5910 104
okini3939 1:0dac72ab5910 105 #endif