partly working USB Device lib for STM32F746NG Discovery both Interface are working

Dependents:   DISCO-F746NG-USB_Device McLighTT project_Keyboard_to_the_Keyboard MIDIInstrumentPADProject ... more

Committer:
DieterGraef
Date:
Sun Jul 31 17:47:35 2016 +0000
Revision:
0:0a2eaa300982
partly working USB Device library - serial and MIDI is working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:0a2eaa300982 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
DieterGraef 0:0a2eaa300982 2 *
DieterGraef 0:0a2eaa300982 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
DieterGraef 0:0a2eaa300982 4 * and associated documentation files (the "Software"), to deal in the Software without
DieterGraef 0:0a2eaa300982 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
DieterGraef 0:0a2eaa300982 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
DieterGraef 0:0a2eaa300982 7 * Software is furnished to do so, subject to the following conditions:
DieterGraef 0:0a2eaa300982 8 *
DieterGraef 0:0a2eaa300982 9 * The above copyright notice and this permission notice shall be included in all copies or
DieterGraef 0:0a2eaa300982 10 * substantial portions of the Software.
DieterGraef 0:0a2eaa300982 11 *
DieterGraef 0:0a2eaa300982 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
DieterGraef 0:0a2eaa300982 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
DieterGraef 0:0a2eaa300982 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DieterGraef 0:0a2eaa300982 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DieterGraef 0:0a2eaa300982 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DieterGraef 0:0a2eaa300982 17 */
DieterGraef 0:0a2eaa300982 18
DieterGraef 0:0a2eaa300982 19 #include "stdint.h"
DieterGraef 0:0a2eaa300982 20 #include "USBMouseKeyboard.h"
DieterGraef 0:0a2eaa300982 21
DieterGraef 0:0a2eaa300982 22 typedef struct {
DieterGraef 0:0a2eaa300982 23 unsigned char usage;
DieterGraef 0:0a2eaa300982 24 unsigned char modifier;
DieterGraef 0:0a2eaa300982 25 } KEYMAP;
DieterGraef 0:0a2eaa300982 26
DieterGraef 0:0a2eaa300982 27 #ifdef US_KEYBOARD
DieterGraef 0:0a2eaa300982 28 /* US keyboard (as HID standard) */
DieterGraef 0:0a2eaa300982 29 #define KEYMAP_SIZE (152)
DieterGraef 0:0a2eaa300982 30 const KEYMAP keymap[KEYMAP_SIZE] = {
DieterGraef 0:0a2eaa300982 31 {0, 0}, /* NUL */
DieterGraef 0:0a2eaa300982 32 {0, 0}, /* SOH */
DieterGraef 0:0a2eaa300982 33 {0, 0}, /* STX */
DieterGraef 0:0a2eaa300982 34 {0, 0}, /* ETX */
DieterGraef 0:0a2eaa300982 35 {0, 0}, /* EOT */
DieterGraef 0:0a2eaa300982 36 {0, 0}, /* ENQ */
DieterGraef 0:0a2eaa300982 37 {0, 0}, /* ACK */
DieterGraef 0:0a2eaa300982 38 {0, 0}, /* BEL */
DieterGraef 0:0a2eaa300982 39 {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */
DieterGraef 0:0a2eaa300982 40 {0x2b, 0}, /* TAB */ /* Keyboard Tab */
DieterGraef 0:0a2eaa300982 41 {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */
DieterGraef 0:0a2eaa300982 42 {0, 0}, /* VT */
DieterGraef 0:0a2eaa300982 43 {0, 0}, /* FF */
DieterGraef 0:0a2eaa300982 44 {0, 0}, /* CR */
DieterGraef 0:0a2eaa300982 45 {0, 0}, /* SO */
DieterGraef 0:0a2eaa300982 46 {0, 0}, /* SI */
DieterGraef 0:0a2eaa300982 47 {0, 0}, /* DEL */
DieterGraef 0:0a2eaa300982 48 {0, 0}, /* DC1 */
DieterGraef 0:0a2eaa300982 49 {0, 0}, /* DC2 */
DieterGraef 0:0a2eaa300982 50 {0, 0}, /* DC3 */
DieterGraef 0:0a2eaa300982 51 {0, 0}, /* DC4 */
DieterGraef 0:0a2eaa300982 52 {0, 0}, /* NAK */
DieterGraef 0:0a2eaa300982 53 {0, 0}, /* SYN */
DieterGraef 0:0a2eaa300982 54 {0, 0}, /* ETB */
DieterGraef 0:0a2eaa300982 55 {0, 0}, /* CAN */
DieterGraef 0:0a2eaa300982 56 {0, 0}, /* EM */
DieterGraef 0:0a2eaa300982 57 {0, 0}, /* SUB */
DieterGraef 0:0a2eaa300982 58 {0, 0}, /* ESC */
DieterGraef 0:0a2eaa300982 59 {0, 0}, /* FS */
DieterGraef 0:0a2eaa300982 60 {0, 0}, /* GS */
DieterGraef 0:0a2eaa300982 61 {0, 0}, /* RS */
DieterGraef 0:0a2eaa300982 62 {0, 0}, /* US */
DieterGraef 0:0a2eaa300982 63 {0x2c, 0}, /* */
DieterGraef 0:0a2eaa300982 64 {0x1e, KEY_SHIFT}, /* ! */
DieterGraef 0:0a2eaa300982 65 {0x34, KEY_SHIFT}, /* " */
DieterGraef 0:0a2eaa300982 66 {0x20, KEY_SHIFT}, /* # */
DieterGraef 0:0a2eaa300982 67 {0x21, KEY_SHIFT}, /* $ */
DieterGraef 0:0a2eaa300982 68 {0x22, KEY_SHIFT}, /* % */
DieterGraef 0:0a2eaa300982 69 {0x24, KEY_SHIFT}, /* & */
DieterGraef 0:0a2eaa300982 70 {0x34, 0}, /* ' */
DieterGraef 0:0a2eaa300982 71 {0x26, KEY_SHIFT}, /* ( */
DieterGraef 0:0a2eaa300982 72 {0x27, KEY_SHIFT}, /* ) */
DieterGraef 0:0a2eaa300982 73 {0x25, KEY_SHIFT}, /* * */
DieterGraef 0:0a2eaa300982 74 {0x2e, KEY_SHIFT}, /* + */
DieterGraef 0:0a2eaa300982 75 {0x36, 0}, /* , */
DieterGraef 0:0a2eaa300982 76 {0x2d, 0}, /* - */
DieterGraef 0:0a2eaa300982 77 {0x37, 0}, /* . */
DieterGraef 0:0a2eaa300982 78 {0x38, 0}, /* / */
DieterGraef 0:0a2eaa300982 79 {0x27, 0}, /* 0 */
DieterGraef 0:0a2eaa300982 80 {0x1e, 0}, /* 1 */
DieterGraef 0:0a2eaa300982 81 {0x1f, 0}, /* 2 */
DieterGraef 0:0a2eaa300982 82 {0x20, 0}, /* 3 */
DieterGraef 0:0a2eaa300982 83 {0x21, 0}, /* 4 */
DieterGraef 0:0a2eaa300982 84 {0x22, 0}, /* 5 */
DieterGraef 0:0a2eaa300982 85 {0x23, 0}, /* 6 */
DieterGraef 0:0a2eaa300982 86 {0x24, 0}, /* 7 */
DieterGraef 0:0a2eaa300982 87 {0x25, 0}, /* 8 */
DieterGraef 0:0a2eaa300982 88 {0x26, 0}, /* 9 */
DieterGraef 0:0a2eaa300982 89 {0x33, KEY_SHIFT}, /* : */
DieterGraef 0:0a2eaa300982 90 {0x33, 0}, /* ; */
DieterGraef 0:0a2eaa300982 91 {0x36, KEY_SHIFT}, /* < */
DieterGraef 0:0a2eaa300982 92 {0x2e, 0}, /* = */
DieterGraef 0:0a2eaa300982 93 {0x37, KEY_SHIFT}, /* > */
DieterGraef 0:0a2eaa300982 94 {0x38, KEY_SHIFT}, /* ? */
DieterGraef 0:0a2eaa300982 95 {0x1f, KEY_SHIFT}, /* @ */
DieterGraef 0:0a2eaa300982 96 {0x04, KEY_SHIFT}, /* A */
DieterGraef 0:0a2eaa300982 97 {0x05, KEY_SHIFT}, /* B */
DieterGraef 0:0a2eaa300982 98 {0x06, KEY_SHIFT}, /* C */
DieterGraef 0:0a2eaa300982 99 {0x07, KEY_SHIFT}, /* D */
DieterGraef 0:0a2eaa300982 100 {0x08, KEY_SHIFT}, /* E */
DieterGraef 0:0a2eaa300982 101 {0x09, KEY_SHIFT}, /* F */
DieterGraef 0:0a2eaa300982 102 {0x0a, KEY_SHIFT}, /* G */
DieterGraef 0:0a2eaa300982 103 {0x0b, KEY_SHIFT}, /* H */
DieterGraef 0:0a2eaa300982 104 {0x0c, KEY_SHIFT}, /* I */
DieterGraef 0:0a2eaa300982 105 {0x0d, KEY_SHIFT}, /* J */
DieterGraef 0:0a2eaa300982 106 {0x0e, KEY_SHIFT}, /* K */
DieterGraef 0:0a2eaa300982 107 {0x0f, KEY_SHIFT}, /* L */
DieterGraef 0:0a2eaa300982 108 {0x10, KEY_SHIFT}, /* M */
DieterGraef 0:0a2eaa300982 109 {0x11, KEY_SHIFT}, /* N */
DieterGraef 0:0a2eaa300982 110 {0x12, KEY_SHIFT}, /* O */
DieterGraef 0:0a2eaa300982 111 {0x13, KEY_SHIFT}, /* P */
DieterGraef 0:0a2eaa300982 112 {0x14, KEY_SHIFT}, /* Q */
DieterGraef 0:0a2eaa300982 113 {0x15, KEY_SHIFT}, /* R */
DieterGraef 0:0a2eaa300982 114 {0x16, KEY_SHIFT}, /* S */
DieterGraef 0:0a2eaa300982 115 {0x17, KEY_SHIFT}, /* T */
DieterGraef 0:0a2eaa300982 116 {0x18, KEY_SHIFT}, /* U */
DieterGraef 0:0a2eaa300982 117 {0x19, KEY_SHIFT}, /* V */
DieterGraef 0:0a2eaa300982 118 {0x1a, KEY_SHIFT}, /* W */
DieterGraef 0:0a2eaa300982 119 {0x1b, KEY_SHIFT}, /* X */
DieterGraef 0:0a2eaa300982 120 {0x1c, KEY_SHIFT}, /* Y */
DieterGraef 0:0a2eaa300982 121 {0x1d, KEY_SHIFT}, /* Z */
DieterGraef 0:0a2eaa300982 122 {0x2f, 0}, /* [ */
DieterGraef 0:0a2eaa300982 123 {0x31, 0}, /* \ */
DieterGraef 0:0a2eaa300982 124 {0x30, 0}, /* ] */
DieterGraef 0:0a2eaa300982 125 {0x23, KEY_SHIFT}, /* ^ */
DieterGraef 0:0a2eaa300982 126 {0x2d, KEY_SHIFT}, /* _ */
DieterGraef 0:0a2eaa300982 127 {0x35, 0}, /* ` */
DieterGraef 0:0a2eaa300982 128 {0x04, 0}, /* a */
DieterGraef 0:0a2eaa300982 129 {0x05, 0}, /* b */
DieterGraef 0:0a2eaa300982 130 {0x06, 0}, /* c */
DieterGraef 0:0a2eaa300982 131 {0x07, 0}, /* d */
DieterGraef 0:0a2eaa300982 132 {0x08, 0}, /* e */
DieterGraef 0:0a2eaa300982 133 {0x09, 0}, /* f */
DieterGraef 0:0a2eaa300982 134 {0x0a, 0}, /* g */
DieterGraef 0:0a2eaa300982 135 {0x0b, 0}, /* h */
DieterGraef 0:0a2eaa300982 136 {0x0c, 0}, /* i */
DieterGraef 0:0a2eaa300982 137 {0x0d, 0}, /* j */
DieterGraef 0:0a2eaa300982 138 {0x0e, 0}, /* k */
DieterGraef 0:0a2eaa300982 139 {0x0f, 0}, /* l */
DieterGraef 0:0a2eaa300982 140 {0x10, 0}, /* m */
DieterGraef 0:0a2eaa300982 141 {0x11, 0}, /* n */
DieterGraef 0:0a2eaa300982 142 {0x12, 0}, /* o */
DieterGraef 0:0a2eaa300982 143 {0x13, 0}, /* p */
DieterGraef 0:0a2eaa300982 144 {0x14, 0}, /* q */
DieterGraef 0:0a2eaa300982 145 {0x15, 0}, /* r */
DieterGraef 0:0a2eaa300982 146 {0x16, 0}, /* s */
DieterGraef 0:0a2eaa300982 147 {0x17, 0}, /* t */
DieterGraef 0:0a2eaa300982 148 {0x18, 0}, /* u */
DieterGraef 0:0a2eaa300982 149 {0x19, 0}, /* v */
DieterGraef 0:0a2eaa300982 150 {0x1a, 0}, /* w */
DieterGraef 0:0a2eaa300982 151 {0x1b, 0}, /* x */
DieterGraef 0:0a2eaa300982 152 {0x1c, 0}, /* y */
DieterGraef 0:0a2eaa300982 153 {0x1d, 0}, /* z */
DieterGraef 0:0a2eaa300982 154 {0x2f, KEY_SHIFT}, /* { */
DieterGraef 0:0a2eaa300982 155 {0x31, KEY_SHIFT}, /* | */
DieterGraef 0:0a2eaa300982 156 {0x30, KEY_SHIFT}, /* } */
DieterGraef 0:0a2eaa300982 157 {0x35, KEY_SHIFT}, /* ~ */
DieterGraef 0:0a2eaa300982 158 {0,0}, /* DEL */
DieterGraef 0:0a2eaa300982 159
DieterGraef 0:0a2eaa300982 160 {0x3a, 0}, /* F1 */
DieterGraef 0:0a2eaa300982 161 {0x3b, 0}, /* F2 */
DieterGraef 0:0a2eaa300982 162 {0x3c, 0}, /* F3 */
DieterGraef 0:0a2eaa300982 163 {0x3d, 0}, /* F4 */
DieterGraef 0:0a2eaa300982 164 {0x3e, 0}, /* F5 */
DieterGraef 0:0a2eaa300982 165 {0x3f, 0}, /* F6 */
DieterGraef 0:0a2eaa300982 166 {0x40, 0}, /* F7 */
DieterGraef 0:0a2eaa300982 167 {0x41, 0}, /* F8 */
DieterGraef 0:0a2eaa300982 168 {0x42, 0}, /* F9 */
DieterGraef 0:0a2eaa300982 169 {0x43, 0}, /* F10 */
DieterGraef 0:0a2eaa300982 170 {0x44, 0}, /* F11 */
DieterGraef 0:0a2eaa300982 171 {0x45, 0}, /* F12 */
DieterGraef 0:0a2eaa300982 172
DieterGraef 0:0a2eaa300982 173 {0x46, 0}, /* PRINT_SCREEN */
DieterGraef 0:0a2eaa300982 174 {0x47, 0}, /* SCROLL_LOCK */
DieterGraef 0:0a2eaa300982 175 {0x39, 0}, /* CAPS_LOCK */
DieterGraef 0:0a2eaa300982 176 {0x53, 0}, /* NUM_LOCK */
DieterGraef 0:0a2eaa300982 177 {0x49, 0}, /* INSERT */
DieterGraef 0:0a2eaa300982 178 {0x4a, 0}, /* HOME */
DieterGraef 0:0a2eaa300982 179 {0x4b, 0}, /* PAGE_UP */
DieterGraef 0:0a2eaa300982 180 {0x4e, 0}, /* PAGE_DOWN */
DieterGraef 0:0a2eaa300982 181
DieterGraef 0:0a2eaa300982 182 {0x4f, 0}, /* RIGHT_ARROW */
DieterGraef 0:0a2eaa300982 183 {0x50, 0}, /* LEFT_ARROW */
DieterGraef 0:0a2eaa300982 184 {0x51, 0}, /* DOWN_ARROW */
DieterGraef 0:0a2eaa300982 185 {0x52, 0}, /* UP_ARROW */
DieterGraef 0:0a2eaa300982 186 };
DieterGraef 0:0a2eaa300982 187
DieterGraef 0:0a2eaa300982 188 #else
DieterGraef 0:0a2eaa300982 189 /* UK keyboard */
DieterGraef 0:0a2eaa300982 190 #define KEYMAP_SIZE (152)
DieterGraef 0:0a2eaa300982 191 const KEYMAP keymap[KEYMAP_SIZE] = {
DieterGraef 0:0a2eaa300982 192 {0, 0}, /* NUL */
DieterGraef 0:0a2eaa300982 193 {0, 0}, /* SOH */
DieterGraef 0:0a2eaa300982 194 {0, 0}, /* STX */
DieterGraef 0:0a2eaa300982 195 {0, 0}, /* ETX */
DieterGraef 0:0a2eaa300982 196 {0, 0}, /* EOT */
DieterGraef 0:0a2eaa300982 197 {0, 0}, /* ENQ */
DieterGraef 0:0a2eaa300982 198 {0, 0}, /* ACK */
DieterGraef 0:0a2eaa300982 199 {0, 0}, /* BEL */
DieterGraef 0:0a2eaa300982 200 {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */
DieterGraef 0:0a2eaa300982 201 {0x2b, 0}, /* TAB */ /* Keyboard Tab */
DieterGraef 0:0a2eaa300982 202 {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */
DieterGraef 0:0a2eaa300982 203 {0, 0}, /* VT */
DieterGraef 0:0a2eaa300982 204 {0, 0}, /* FF */
DieterGraef 0:0a2eaa300982 205 {0, 0}, /* CR */
DieterGraef 0:0a2eaa300982 206 {0, 0}, /* SO */
DieterGraef 0:0a2eaa300982 207 {0, 0}, /* SI */
DieterGraef 0:0a2eaa300982 208 {0, 0}, /* DEL */
DieterGraef 0:0a2eaa300982 209 {0, 0}, /* DC1 */
DieterGraef 0:0a2eaa300982 210 {0, 0}, /* DC2 */
DieterGraef 0:0a2eaa300982 211 {0, 0}, /* DC3 */
DieterGraef 0:0a2eaa300982 212 {0, 0}, /* DC4 */
DieterGraef 0:0a2eaa300982 213 {0, 0}, /* NAK */
DieterGraef 0:0a2eaa300982 214 {0, 0}, /* SYN */
DieterGraef 0:0a2eaa300982 215 {0, 0}, /* ETB */
DieterGraef 0:0a2eaa300982 216 {0, 0}, /* CAN */
DieterGraef 0:0a2eaa300982 217 {0, 0}, /* EM */
DieterGraef 0:0a2eaa300982 218 {0, 0}, /* SUB */
DieterGraef 0:0a2eaa300982 219 {0, 0}, /* ESC */
DieterGraef 0:0a2eaa300982 220 {0, 0}, /* FS */
DieterGraef 0:0a2eaa300982 221 {0, 0}, /* GS */
DieterGraef 0:0a2eaa300982 222 {0, 0}, /* RS */
DieterGraef 0:0a2eaa300982 223 {0, 0}, /* US */
DieterGraef 0:0a2eaa300982 224 {0x2c, 0}, /* */
DieterGraef 0:0a2eaa300982 225 {0x1e, KEY_SHIFT}, /* ! */
DieterGraef 0:0a2eaa300982 226 {0x1f, KEY_SHIFT}, /* " */
DieterGraef 0:0a2eaa300982 227 {0x32, 0}, /* # */
DieterGraef 0:0a2eaa300982 228 {0x21, KEY_SHIFT}, /* $ */
DieterGraef 0:0a2eaa300982 229 {0x22, KEY_SHIFT}, /* % */
DieterGraef 0:0a2eaa300982 230 {0x24, KEY_SHIFT}, /* & */
DieterGraef 0:0a2eaa300982 231 {0x34, 0}, /* ' */
DieterGraef 0:0a2eaa300982 232 {0x26, KEY_SHIFT}, /* ( */
DieterGraef 0:0a2eaa300982 233 {0x27, KEY_SHIFT}, /* ) */
DieterGraef 0:0a2eaa300982 234 {0x25, KEY_SHIFT}, /* * */
DieterGraef 0:0a2eaa300982 235 {0x2e, KEY_SHIFT}, /* + */
DieterGraef 0:0a2eaa300982 236 {0x36, 0}, /* , */
DieterGraef 0:0a2eaa300982 237 {0x2d, 0}, /* - */
DieterGraef 0:0a2eaa300982 238 {0x37, 0}, /* . */
DieterGraef 0:0a2eaa300982 239 {0x38, 0}, /* / */
DieterGraef 0:0a2eaa300982 240 {0x27, 0}, /* 0 */
DieterGraef 0:0a2eaa300982 241 {0x1e, 0}, /* 1 */
DieterGraef 0:0a2eaa300982 242 {0x1f, 0}, /* 2 */
DieterGraef 0:0a2eaa300982 243 {0x20, 0}, /* 3 */
DieterGraef 0:0a2eaa300982 244 {0x21, 0}, /* 4 */
DieterGraef 0:0a2eaa300982 245 {0x22, 0}, /* 5 */
DieterGraef 0:0a2eaa300982 246 {0x23, 0}, /* 6 */
DieterGraef 0:0a2eaa300982 247 {0x24, 0}, /* 7 */
DieterGraef 0:0a2eaa300982 248 {0x25, 0}, /* 8 */
DieterGraef 0:0a2eaa300982 249 {0x26, 0}, /* 9 */
DieterGraef 0:0a2eaa300982 250 {0x33, KEY_SHIFT}, /* : */
DieterGraef 0:0a2eaa300982 251 {0x33, 0}, /* ; */
DieterGraef 0:0a2eaa300982 252 {0x36, KEY_SHIFT}, /* < */
DieterGraef 0:0a2eaa300982 253 {0x2e, 0}, /* = */
DieterGraef 0:0a2eaa300982 254 {0x37, KEY_SHIFT}, /* > */
DieterGraef 0:0a2eaa300982 255 {0x38, KEY_SHIFT}, /* ? */
DieterGraef 0:0a2eaa300982 256 {0x34, KEY_SHIFT}, /* @ */
DieterGraef 0:0a2eaa300982 257 {0x04, KEY_SHIFT}, /* A */
DieterGraef 0:0a2eaa300982 258 {0x05, KEY_SHIFT}, /* B */
DieterGraef 0:0a2eaa300982 259 {0x06, KEY_SHIFT}, /* C */
DieterGraef 0:0a2eaa300982 260 {0x07, KEY_SHIFT}, /* D */
DieterGraef 0:0a2eaa300982 261 {0x08, KEY_SHIFT}, /* E */
DieterGraef 0:0a2eaa300982 262 {0x09, KEY_SHIFT}, /* F */
DieterGraef 0:0a2eaa300982 263 {0x0a, KEY_SHIFT}, /* G */
DieterGraef 0:0a2eaa300982 264 {0x0b, KEY_SHIFT}, /* H */
DieterGraef 0:0a2eaa300982 265 {0x0c, KEY_SHIFT}, /* I */
DieterGraef 0:0a2eaa300982 266 {0x0d, KEY_SHIFT}, /* J */
DieterGraef 0:0a2eaa300982 267 {0x0e, KEY_SHIFT}, /* K */
DieterGraef 0:0a2eaa300982 268 {0x0f, KEY_SHIFT}, /* L */
DieterGraef 0:0a2eaa300982 269 {0x10, KEY_SHIFT}, /* M */
DieterGraef 0:0a2eaa300982 270 {0x11, KEY_SHIFT}, /* N */
DieterGraef 0:0a2eaa300982 271 {0x12, KEY_SHIFT}, /* O */
DieterGraef 0:0a2eaa300982 272 {0x13, KEY_SHIFT}, /* P */
DieterGraef 0:0a2eaa300982 273 {0x14, KEY_SHIFT}, /* Q */
DieterGraef 0:0a2eaa300982 274 {0x15, KEY_SHIFT}, /* R */
DieterGraef 0:0a2eaa300982 275 {0x16, KEY_SHIFT}, /* S */
DieterGraef 0:0a2eaa300982 276 {0x17, KEY_SHIFT}, /* T */
DieterGraef 0:0a2eaa300982 277 {0x18, KEY_SHIFT}, /* U */
DieterGraef 0:0a2eaa300982 278 {0x19, KEY_SHIFT}, /* V */
DieterGraef 0:0a2eaa300982 279 {0x1a, KEY_SHIFT}, /* W */
DieterGraef 0:0a2eaa300982 280 {0x1b, KEY_SHIFT}, /* X */
DieterGraef 0:0a2eaa300982 281 {0x1c, KEY_SHIFT}, /* Y */
DieterGraef 0:0a2eaa300982 282 {0x1d, KEY_SHIFT}, /* Z */
DieterGraef 0:0a2eaa300982 283 {0x2f, 0}, /* [ */
DieterGraef 0:0a2eaa300982 284 {0x64, 0}, /* \ */
DieterGraef 0:0a2eaa300982 285 {0x30, 0}, /* ] */
DieterGraef 0:0a2eaa300982 286 {0x23, KEY_SHIFT}, /* ^ */
DieterGraef 0:0a2eaa300982 287 {0x2d, KEY_SHIFT}, /* _ */
DieterGraef 0:0a2eaa300982 288 {0x35, 0}, /* ` */
DieterGraef 0:0a2eaa300982 289 {0x04, 0}, /* a */
DieterGraef 0:0a2eaa300982 290 {0x05, 0}, /* b */
DieterGraef 0:0a2eaa300982 291 {0x06, 0}, /* c */
DieterGraef 0:0a2eaa300982 292 {0x07, 0}, /* d */
DieterGraef 0:0a2eaa300982 293 {0x08, 0}, /* e */
DieterGraef 0:0a2eaa300982 294 {0x09, 0}, /* f */
DieterGraef 0:0a2eaa300982 295 {0x0a, 0}, /* g */
DieterGraef 0:0a2eaa300982 296 {0x0b, 0}, /* h */
DieterGraef 0:0a2eaa300982 297 {0x0c, 0}, /* i */
DieterGraef 0:0a2eaa300982 298 {0x0d, 0}, /* j */
DieterGraef 0:0a2eaa300982 299 {0x0e, 0}, /* k */
DieterGraef 0:0a2eaa300982 300 {0x0f, 0}, /* l */
DieterGraef 0:0a2eaa300982 301 {0x10, 0}, /* m */
DieterGraef 0:0a2eaa300982 302 {0x11, 0}, /* n */
DieterGraef 0:0a2eaa300982 303 {0x12, 0}, /* o */
DieterGraef 0:0a2eaa300982 304 {0x13, 0}, /* p */
DieterGraef 0:0a2eaa300982 305 {0x14, 0}, /* q */
DieterGraef 0:0a2eaa300982 306 {0x15, 0}, /* r */
DieterGraef 0:0a2eaa300982 307 {0x16, 0}, /* s */
DieterGraef 0:0a2eaa300982 308 {0x17, 0}, /* t */
DieterGraef 0:0a2eaa300982 309 {0x18, 0}, /* u */
DieterGraef 0:0a2eaa300982 310 {0x19, 0}, /* v */
DieterGraef 0:0a2eaa300982 311 {0x1a, 0}, /* w */
DieterGraef 0:0a2eaa300982 312 {0x1b, 0}, /* x */
DieterGraef 0:0a2eaa300982 313 {0x1c, 0}, /* y */
DieterGraef 0:0a2eaa300982 314 {0x1d, 0}, /* z */
DieterGraef 0:0a2eaa300982 315 {0x2f, KEY_SHIFT}, /* { */
DieterGraef 0:0a2eaa300982 316 {0x64, KEY_SHIFT}, /* | */
DieterGraef 0:0a2eaa300982 317 {0x30, KEY_SHIFT}, /* } */
DieterGraef 0:0a2eaa300982 318 {0x32, KEY_SHIFT}, /* ~ */
DieterGraef 0:0a2eaa300982 319 {0,0}, /* DEL */
DieterGraef 0:0a2eaa300982 320
DieterGraef 0:0a2eaa300982 321 {0x3a, 0}, /* F1 */
DieterGraef 0:0a2eaa300982 322 {0x3b, 0}, /* F2 */
DieterGraef 0:0a2eaa300982 323 {0x3c, 0}, /* F3 */
DieterGraef 0:0a2eaa300982 324 {0x3d, 0}, /* F4 */
DieterGraef 0:0a2eaa300982 325 {0x3e, 0}, /* F5 */
DieterGraef 0:0a2eaa300982 326 {0x3f, 0}, /* F6 */
DieterGraef 0:0a2eaa300982 327 {0x40, 0}, /* F7 */
DieterGraef 0:0a2eaa300982 328 {0x41, 0}, /* F8 */
DieterGraef 0:0a2eaa300982 329 {0x42, 0}, /* F9 */
DieterGraef 0:0a2eaa300982 330 {0x43, 0}, /* F10 */
DieterGraef 0:0a2eaa300982 331 {0x44, 0}, /* F11 */
DieterGraef 0:0a2eaa300982 332 {0x45, 0}, /* F12 */
DieterGraef 0:0a2eaa300982 333
DieterGraef 0:0a2eaa300982 334 {0x46, 0}, /* PRINT_SCREEN */
DieterGraef 0:0a2eaa300982 335 {0x47, 0}, /* SCROLL_LOCK */
DieterGraef 0:0a2eaa300982 336 {0x39, 0}, /* CAPS_LOCK */
DieterGraef 0:0a2eaa300982 337 {0x53, 0}, /* NUM_LOCK */
DieterGraef 0:0a2eaa300982 338 {0x49, 0}, /* INSERT */
DieterGraef 0:0a2eaa300982 339 {0x4a, 0}, /* HOME */
DieterGraef 0:0a2eaa300982 340 {0x4b, 0}, /* PAGE_UP */
DieterGraef 0:0a2eaa300982 341 {0x4e, 0}, /* PAGE_DOWN */
DieterGraef 0:0a2eaa300982 342
DieterGraef 0:0a2eaa300982 343 {0x4f, 0}, /* RIGHT_ARROW */
DieterGraef 0:0a2eaa300982 344 {0x50, 0}, /* LEFT_ARROW */
DieterGraef 0:0a2eaa300982 345 {0x51, 0}, /* DOWN_ARROW */
DieterGraef 0:0a2eaa300982 346 {0x52, 0}, /* UP_ARROW */
DieterGraef 0:0a2eaa300982 347 };
DieterGraef 0:0a2eaa300982 348 #endif
DieterGraef 0:0a2eaa300982 349
DieterGraef 0:0a2eaa300982 350
DieterGraef 0:0a2eaa300982 351 uint8_t * USBMouseKeyboard::reportDesc() {
DieterGraef 0:0a2eaa300982 352 if (mouse_type == REL_MOUSE) {
DieterGraef 0:0a2eaa300982 353 static uint8_t reportDescriptor[] = {
DieterGraef 0:0a2eaa300982 354 // Keyboard
DieterGraef 0:0a2eaa300982 355 USAGE_PAGE(1), 0x01,
DieterGraef 0:0a2eaa300982 356 USAGE(1), 0x06,
DieterGraef 0:0a2eaa300982 357 COLLECTION(1), 0x01,
DieterGraef 0:0a2eaa300982 358 REPORT_ID(1), REPORT_ID_KEYBOARD,
DieterGraef 0:0a2eaa300982 359 USAGE_PAGE(1), 0x07,
DieterGraef 0:0a2eaa300982 360 USAGE_MINIMUM(1), 0xE0,
DieterGraef 0:0a2eaa300982 361 USAGE_MAXIMUM(1), 0xE7,
DieterGraef 0:0a2eaa300982 362 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 363 LOGICAL_MAXIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 364 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 365 REPORT_COUNT(1), 0x08,
DieterGraef 0:0a2eaa300982 366 INPUT(1), 0x02,
DieterGraef 0:0a2eaa300982 367 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 368 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 369 INPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 370 REPORT_COUNT(1), 0x05,
DieterGraef 0:0a2eaa300982 371 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 372 USAGE_PAGE(1), 0x08,
DieterGraef 0:0a2eaa300982 373 USAGE_MINIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 374 USAGE_MAXIMUM(1), 0x05,
DieterGraef 0:0a2eaa300982 375 OUTPUT(1), 0x02,
DieterGraef 0:0a2eaa300982 376 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 377 REPORT_SIZE(1), 0x03,
DieterGraef 0:0a2eaa300982 378 OUTPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 379 REPORT_COUNT(1), 0x06,
DieterGraef 0:0a2eaa300982 380 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 381 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 382 LOGICAL_MAXIMUM(2), 0xff, 0x00,
DieterGraef 0:0a2eaa300982 383 USAGE_PAGE(1), 0x07,
DieterGraef 0:0a2eaa300982 384 USAGE_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 385 USAGE_MAXIMUM(2), 0xff, 0x00,
DieterGraef 0:0a2eaa300982 386 INPUT(1), 0x00,
DieterGraef 0:0a2eaa300982 387 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 388
DieterGraef 0:0a2eaa300982 389 // Mouse
DieterGraef 0:0a2eaa300982 390 USAGE_PAGE(1), 0x01, // Generic Desktop
DieterGraef 0:0a2eaa300982 391 USAGE(1), 0x02, // Mouse
DieterGraef 0:0a2eaa300982 392 COLLECTION(1), 0x01, // Application
DieterGraef 0:0a2eaa300982 393 USAGE(1), 0x01, // Pointer
DieterGraef 0:0a2eaa300982 394 COLLECTION(1), 0x00, // Physical
DieterGraef 0:0a2eaa300982 395 REPORT_ID(1), REPORT_ID_MOUSE,
DieterGraef 0:0a2eaa300982 396 REPORT_COUNT(1), 0x03,
DieterGraef 0:0a2eaa300982 397 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 398 USAGE_PAGE(1), 0x09, // Buttons
DieterGraef 0:0a2eaa300982 399 USAGE_MINIMUM(1), 0x1,
DieterGraef 0:0a2eaa300982 400 USAGE_MAXIMUM(1), 0x3,
DieterGraef 0:0a2eaa300982 401 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 402 LOGICAL_MAXIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 403 INPUT(1), 0x02,
DieterGraef 0:0a2eaa300982 404 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 405 REPORT_SIZE(1), 0x05,
DieterGraef 0:0a2eaa300982 406 INPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 407 REPORT_COUNT(1), 0x03,
DieterGraef 0:0a2eaa300982 408 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 409 USAGE_PAGE(1), 0x01,
DieterGraef 0:0a2eaa300982 410 USAGE(1), 0x30, // X
DieterGraef 0:0a2eaa300982 411 USAGE(1), 0x31, // Y
DieterGraef 0:0a2eaa300982 412 USAGE(1), 0x38, // scroll
DieterGraef 0:0a2eaa300982 413 LOGICAL_MINIMUM(1), 0x81,
DieterGraef 0:0a2eaa300982 414 LOGICAL_MAXIMUM(1), 0x7f,
DieterGraef 0:0a2eaa300982 415 INPUT(1), 0x06,
DieterGraef 0:0a2eaa300982 416 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 417 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 418
DieterGraef 0:0a2eaa300982 419
DieterGraef 0:0a2eaa300982 420 // Media Control
DieterGraef 0:0a2eaa300982 421 USAGE_PAGE(1), 0x0C,
DieterGraef 0:0a2eaa300982 422 USAGE(1), 0x01,
DieterGraef 0:0a2eaa300982 423 COLLECTION(1), 0x01,
DieterGraef 0:0a2eaa300982 424 REPORT_ID(1), REPORT_ID_VOLUME,
DieterGraef 0:0a2eaa300982 425 USAGE_PAGE(1), 0x0C,
DieterGraef 0:0a2eaa300982 426 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 427 LOGICAL_MAXIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 428 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 429 REPORT_COUNT(1), 0x07,
DieterGraef 0:0a2eaa300982 430 USAGE(1), 0xB5, // Next Track
DieterGraef 0:0a2eaa300982 431 USAGE(1), 0xB6, // Previous Track
DieterGraef 0:0a2eaa300982 432 USAGE(1), 0xB7, // Stop
DieterGraef 0:0a2eaa300982 433 USAGE(1), 0xCD, // Play / Pause
DieterGraef 0:0a2eaa300982 434 USAGE(1), 0xE2, // Mute
DieterGraef 0:0a2eaa300982 435 USAGE(1), 0xE9, // Volume Up
DieterGraef 0:0a2eaa300982 436 USAGE(1), 0xEA, // Volume Down
DieterGraef 0:0a2eaa300982 437 INPUT(1), 0x02, // Input (Data, Variable, Absolute)
DieterGraef 0:0a2eaa300982 438 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 439 INPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 440 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 441 };
DieterGraef 0:0a2eaa300982 442 reportLength = sizeof(reportDescriptor);
DieterGraef 0:0a2eaa300982 443 return reportDescriptor;
DieterGraef 0:0a2eaa300982 444 } else if (mouse_type == ABS_MOUSE) {
DieterGraef 0:0a2eaa300982 445 static uint8_t reportDescriptor[] = {
DieterGraef 0:0a2eaa300982 446
DieterGraef 0:0a2eaa300982 447 // Keyboard
DieterGraef 0:0a2eaa300982 448 USAGE_PAGE(1), 0x01,
DieterGraef 0:0a2eaa300982 449 USAGE(1), 0x06,
DieterGraef 0:0a2eaa300982 450 COLLECTION(1), 0x01,
DieterGraef 0:0a2eaa300982 451 REPORT_ID(1), REPORT_ID_KEYBOARD,
DieterGraef 0:0a2eaa300982 452 USAGE_PAGE(1), 0x07,
DieterGraef 0:0a2eaa300982 453 USAGE_MINIMUM(1), 0xE0,
DieterGraef 0:0a2eaa300982 454 USAGE_MAXIMUM(1), 0xE7,
DieterGraef 0:0a2eaa300982 455 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 456 LOGICAL_MAXIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 457 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 458 REPORT_COUNT(1), 0x08,
DieterGraef 0:0a2eaa300982 459 INPUT(1), 0x02,
DieterGraef 0:0a2eaa300982 460 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 461 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 462 INPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 463 REPORT_COUNT(1), 0x05,
DieterGraef 0:0a2eaa300982 464 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 465 USAGE_PAGE(1), 0x08,
DieterGraef 0:0a2eaa300982 466 USAGE_MINIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 467 USAGE_MAXIMUM(1), 0x05,
DieterGraef 0:0a2eaa300982 468 OUTPUT(1), 0x02,
DieterGraef 0:0a2eaa300982 469 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 470 REPORT_SIZE(1), 0x03,
DieterGraef 0:0a2eaa300982 471 OUTPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 472 REPORT_COUNT(1), 0x06,
DieterGraef 0:0a2eaa300982 473 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 474 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 475 LOGICAL_MAXIMUM(2), 0xff, 0x00,
DieterGraef 0:0a2eaa300982 476 USAGE_PAGE(1), 0x07,
DieterGraef 0:0a2eaa300982 477 USAGE_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 478 USAGE_MAXIMUM(2), 0xff, 0x00,
DieterGraef 0:0a2eaa300982 479 INPUT(1), 0x00,
DieterGraef 0:0a2eaa300982 480 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 481
DieterGraef 0:0a2eaa300982 482 // Mouse
DieterGraef 0:0a2eaa300982 483 USAGE_PAGE(1), 0x01, // Generic Desktop
DieterGraef 0:0a2eaa300982 484 USAGE(1), 0x02, // Mouse
DieterGraef 0:0a2eaa300982 485 COLLECTION(1), 0x01, // Application
DieterGraef 0:0a2eaa300982 486 USAGE(1), 0x01, // Pointer
DieterGraef 0:0a2eaa300982 487 COLLECTION(1), 0x00, // Physical
DieterGraef 0:0a2eaa300982 488 REPORT_ID(1), REPORT_ID_MOUSE,
DieterGraef 0:0a2eaa300982 489
DieterGraef 0:0a2eaa300982 490 USAGE_PAGE(1), 0x01, // Generic Desktop
DieterGraef 0:0a2eaa300982 491 USAGE(1), 0x30, // X
DieterGraef 0:0a2eaa300982 492 USAGE(1), 0x31, // Y
DieterGraef 0:0a2eaa300982 493 LOGICAL_MINIMUM(1), 0x00, // 0
DieterGraef 0:0a2eaa300982 494 LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767
DieterGraef 0:0a2eaa300982 495 REPORT_SIZE(1), 0x10,
DieterGraef 0:0a2eaa300982 496 REPORT_COUNT(1), 0x02,
DieterGraef 0:0a2eaa300982 497 INPUT(1), 0x02, // Data, Variable, Absolute
DieterGraef 0:0a2eaa300982 498
DieterGraef 0:0a2eaa300982 499 USAGE_PAGE(1), 0x01, // Generic Desktop
DieterGraef 0:0a2eaa300982 500 USAGE(1), 0x38, // scroll
DieterGraef 0:0a2eaa300982 501 LOGICAL_MINIMUM(1), 0x81, // -127
DieterGraef 0:0a2eaa300982 502 LOGICAL_MAXIMUM(1), 0x7f, // 127
DieterGraef 0:0a2eaa300982 503 REPORT_SIZE(1), 0x08,
DieterGraef 0:0a2eaa300982 504 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 505 INPUT(1), 0x06, // Data, Variable, Relative
DieterGraef 0:0a2eaa300982 506
DieterGraef 0:0a2eaa300982 507 USAGE_PAGE(1), 0x09, // Buttons
DieterGraef 0:0a2eaa300982 508 USAGE_MINIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 509 USAGE_MAXIMUM(1), 0x03,
DieterGraef 0:0a2eaa300982 510 LOGICAL_MINIMUM(1), 0x00, // 0
DieterGraef 0:0a2eaa300982 511 LOGICAL_MAXIMUM(1), 0x01, // 1
DieterGraef 0:0a2eaa300982 512 REPORT_COUNT(1), 0x03,
DieterGraef 0:0a2eaa300982 513 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 514 INPUT(1), 0x02, // Data, Variable, Absolute
DieterGraef 0:0a2eaa300982 515 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 516 REPORT_SIZE(1), 0x05,
DieterGraef 0:0a2eaa300982 517 INPUT(1), 0x01, // Constant
DieterGraef 0:0a2eaa300982 518
DieterGraef 0:0a2eaa300982 519 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 520 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 521
DieterGraef 0:0a2eaa300982 522 // Media Control
DieterGraef 0:0a2eaa300982 523 USAGE_PAGE(1), 0x0C,
DieterGraef 0:0a2eaa300982 524 USAGE(1), 0x01,
DieterGraef 0:0a2eaa300982 525 COLLECTION(1), 0x01,
DieterGraef 0:0a2eaa300982 526 REPORT_ID(1), REPORT_ID_VOLUME,
DieterGraef 0:0a2eaa300982 527 USAGE_PAGE(1), 0x0C,
DieterGraef 0:0a2eaa300982 528 LOGICAL_MINIMUM(1), 0x00,
DieterGraef 0:0a2eaa300982 529 LOGICAL_MAXIMUM(1), 0x01,
DieterGraef 0:0a2eaa300982 530 REPORT_SIZE(1), 0x01,
DieterGraef 0:0a2eaa300982 531 REPORT_COUNT(1), 0x07,
DieterGraef 0:0a2eaa300982 532 USAGE(1), 0xB5, // Next Track
DieterGraef 0:0a2eaa300982 533 USAGE(1), 0xB6, // Previous Track
DieterGraef 0:0a2eaa300982 534 USAGE(1), 0xB7, // Stop
DieterGraef 0:0a2eaa300982 535 USAGE(1), 0xCD, // Play / Pause
DieterGraef 0:0a2eaa300982 536 USAGE(1), 0xE2, // Mute
DieterGraef 0:0a2eaa300982 537 USAGE(1), 0xE9, // Volume Up
DieterGraef 0:0a2eaa300982 538 USAGE(1), 0xEA, // Volume Down
DieterGraef 0:0a2eaa300982 539 INPUT(1), 0x02, // Input (Data, Variable, Absolute)
DieterGraef 0:0a2eaa300982 540 REPORT_COUNT(1), 0x01,
DieterGraef 0:0a2eaa300982 541 INPUT(1), 0x01,
DieterGraef 0:0a2eaa300982 542 END_COLLECTION(0),
DieterGraef 0:0a2eaa300982 543 };
DieterGraef 0:0a2eaa300982 544 reportLength = sizeof(reportDescriptor);
DieterGraef 0:0a2eaa300982 545 return reportDescriptor;
DieterGraef 0:0a2eaa300982 546 }
DieterGraef 0:0a2eaa300982 547
DieterGraef 0:0a2eaa300982 548 return NULL;
DieterGraef 0:0a2eaa300982 549 }
DieterGraef 0:0a2eaa300982 550
DieterGraef 0:0a2eaa300982 551 bool USBMouseKeyboard::EPINT_OUT_callback() {
DieterGraef 0:0a2eaa300982 552 uint32_t bytesRead = 0;
DieterGraef 0:0a2eaa300982 553 uint8_t led[65];
DieterGraef 0:0a2eaa300982 554 USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE);
DieterGraef 0:0a2eaa300982 555
DieterGraef 0:0a2eaa300982 556 // we take led[1] because led[0] is the report ID
DieterGraef 0:0a2eaa300982 557 lock_status = led[1] & 0x07;
DieterGraef 0:0a2eaa300982 558
DieterGraef 0:0a2eaa300982 559 // We activate the endpoint to be able to recceive data
DieterGraef 0:0a2eaa300982 560 if (!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE))
DieterGraef 0:0a2eaa300982 561 return false;
DieterGraef 0:0a2eaa300982 562 return true;
DieterGraef 0:0a2eaa300982 563 }
DieterGraef 0:0a2eaa300982 564
DieterGraef 0:0a2eaa300982 565 uint8_t USBMouseKeyboard::lockStatus() {
DieterGraef 0:0a2eaa300982 566 return lock_status;
DieterGraef 0:0a2eaa300982 567 }
DieterGraef 0:0a2eaa300982 568
DieterGraef 0:0a2eaa300982 569 bool USBMouseKeyboard::update(int16_t x, int16_t y, uint8_t button, int8_t z) {
DieterGraef 0:0a2eaa300982 570 switch (mouse_type) {
DieterGraef 0:0a2eaa300982 571 case REL_MOUSE:
DieterGraef 0:0a2eaa300982 572 while (x > 127) {
DieterGraef 0:0a2eaa300982 573 if (!mouseSend(127, 0, button, z)) return false;
DieterGraef 0:0a2eaa300982 574 x = x - 127;
DieterGraef 0:0a2eaa300982 575 }
DieterGraef 0:0a2eaa300982 576 while (x < -128) {
DieterGraef 0:0a2eaa300982 577 if (!mouseSend(-128, 0, button, z)) return false;
DieterGraef 0:0a2eaa300982 578 x = x + 128;
DieterGraef 0:0a2eaa300982 579 }
DieterGraef 0:0a2eaa300982 580 while (y > 127) {
DieterGraef 0:0a2eaa300982 581 if (!mouseSend(0, 127, button, z)) return false;
DieterGraef 0:0a2eaa300982 582 y = y - 127;
DieterGraef 0:0a2eaa300982 583 }
DieterGraef 0:0a2eaa300982 584 while (y < -128) {
DieterGraef 0:0a2eaa300982 585 if (!mouseSend(0, -128, button, z)) return false;
DieterGraef 0:0a2eaa300982 586 y = y + 128;
DieterGraef 0:0a2eaa300982 587 }
DieterGraef 0:0a2eaa300982 588 return mouseSend(x, y, button, z);
DieterGraef 0:0a2eaa300982 589 case ABS_MOUSE:
DieterGraef 0:0a2eaa300982 590 HID_REPORT report;
DieterGraef 0:0a2eaa300982 591
DieterGraef 0:0a2eaa300982 592 report.data[0] = REPORT_ID_MOUSE;
DieterGraef 0:0a2eaa300982 593 report.data[1] = x & 0xff;
DieterGraef 0:0a2eaa300982 594 report.data[2] = (x >> 8) & 0xff;
DieterGraef 0:0a2eaa300982 595 report.data[3] = y & 0xff;
DieterGraef 0:0a2eaa300982 596 report.data[4] = (y >> 8) & 0xff;
DieterGraef 0:0a2eaa300982 597 report.data[5] = -z;
DieterGraef 0:0a2eaa300982 598 report.data[6] = button & 0x07;
DieterGraef 0:0a2eaa300982 599
DieterGraef 0:0a2eaa300982 600 report.length = 7;
DieterGraef 0:0a2eaa300982 601
DieterGraef 0:0a2eaa300982 602 return send(&report);
DieterGraef 0:0a2eaa300982 603 default:
DieterGraef 0:0a2eaa300982 604 return false;
DieterGraef 0:0a2eaa300982 605 }
DieterGraef 0:0a2eaa300982 606 }
DieterGraef 0:0a2eaa300982 607
DieterGraef 0:0a2eaa300982 608 bool USBMouseKeyboard::mouseSend(int8_t x, int8_t y, uint8_t buttons, int8_t z) {
DieterGraef 0:0a2eaa300982 609 HID_REPORT report;
DieterGraef 0:0a2eaa300982 610 report.data[0] = REPORT_ID_MOUSE;
DieterGraef 0:0a2eaa300982 611 report.data[1] = buttons & 0x07;
DieterGraef 0:0a2eaa300982 612 report.data[2] = x;
DieterGraef 0:0a2eaa300982 613 report.data[3] = y;
DieterGraef 0:0a2eaa300982 614 report.data[4] = -z; // >0 to scroll down, <0 to scroll up
DieterGraef 0:0a2eaa300982 615
DieterGraef 0:0a2eaa300982 616 report.length = 5;
DieterGraef 0:0a2eaa300982 617
DieterGraef 0:0a2eaa300982 618 return send(&report);
DieterGraef 0:0a2eaa300982 619 }
DieterGraef 0:0a2eaa300982 620
DieterGraef 0:0a2eaa300982 621 bool USBMouseKeyboard::move(int16_t x, int16_t y) {
DieterGraef 0:0a2eaa300982 622 return update(x, y, button, 0);
DieterGraef 0:0a2eaa300982 623 }
DieterGraef 0:0a2eaa300982 624
DieterGraef 0:0a2eaa300982 625 bool USBMouseKeyboard::scroll(int8_t z) {
DieterGraef 0:0a2eaa300982 626 return update(0, 0, button, z);
DieterGraef 0:0a2eaa300982 627 }
DieterGraef 0:0a2eaa300982 628
DieterGraef 0:0a2eaa300982 629 bool USBMouseKeyboard::doubleClick() {
DieterGraef 0:0a2eaa300982 630 if (!click(MOUSE_LEFT))
DieterGraef 0:0a2eaa300982 631 return false;
DieterGraef 0:0a2eaa300982 632 wait(0.1);
DieterGraef 0:0a2eaa300982 633 return click(MOUSE_LEFT);
DieterGraef 0:0a2eaa300982 634 }
DieterGraef 0:0a2eaa300982 635
DieterGraef 0:0a2eaa300982 636 bool USBMouseKeyboard::click(uint8_t button) {
DieterGraef 0:0a2eaa300982 637 if (!update(0, 0, button, 0))
DieterGraef 0:0a2eaa300982 638 return false;
DieterGraef 0:0a2eaa300982 639 wait(0.01);
DieterGraef 0:0a2eaa300982 640 return update(0, 0, 0, 0);
DieterGraef 0:0a2eaa300982 641 }
DieterGraef 0:0a2eaa300982 642
DieterGraef 0:0a2eaa300982 643 bool USBMouseKeyboard::press(uint8_t button_) {
DieterGraef 0:0a2eaa300982 644 button = button_ & 0x07;
DieterGraef 0:0a2eaa300982 645 return update(0, 0, button, 0);
DieterGraef 0:0a2eaa300982 646 }
DieterGraef 0:0a2eaa300982 647
DieterGraef 0:0a2eaa300982 648 bool USBMouseKeyboard::release(uint8_t button_) {
DieterGraef 0:0a2eaa300982 649 button = (button & (~button_)) & 0x07;
DieterGraef 0:0a2eaa300982 650 return update(0, 0, button, 0);
DieterGraef 0:0a2eaa300982 651 }
DieterGraef 0:0a2eaa300982 652
DieterGraef 0:0a2eaa300982 653 int USBMouseKeyboard::_putc(int c) {
DieterGraef 0:0a2eaa300982 654 return keyCode(c, keymap[c].modifier);
DieterGraef 0:0a2eaa300982 655 }
DieterGraef 0:0a2eaa300982 656
DieterGraef 0:0a2eaa300982 657 bool USBMouseKeyboard::keyCode(uint8_t key, uint8_t modifier) {
DieterGraef 0:0a2eaa300982 658 // Send a simulated keyboard keypress. Returns true if successful.
DieterGraef 0:0a2eaa300982 659
DieterGraef 0:0a2eaa300982 660 HID_REPORT report;
DieterGraef 0:0a2eaa300982 661
DieterGraef 0:0a2eaa300982 662 report.data[0] = REPORT_ID_KEYBOARD;
DieterGraef 0:0a2eaa300982 663 report.data[1] = modifier;
DieterGraef 0:0a2eaa300982 664 report.data[2] = 0;
DieterGraef 0:0a2eaa300982 665 report.data[3] = keymap[key].usage;
DieterGraef 0:0a2eaa300982 666 report.data[4] = 0;
DieterGraef 0:0a2eaa300982 667 report.data[5] = 0;
DieterGraef 0:0a2eaa300982 668 report.data[6] = 0;
DieterGraef 0:0a2eaa300982 669 report.data[7] = 0;
DieterGraef 0:0a2eaa300982 670 report.data[8] = 0;
DieterGraef 0:0a2eaa300982 671
DieterGraef 0:0a2eaa300982 672 report.length = 9;
DieterGraef 0:0a2eaa300982 673
DieterGraef 0:0a2eaa300982 674 if (!send(&report)) {
DieterGraef 0:0a2eaa300982 675 return false;
DieterGraef 0:0a2eaa300982 676 }
DieterGraef 0:0a2eaa300982 677
DieterGraef 0:0a2eaa300982 678 report.data[1] = 0;
DieterGraef 0:0a2eaa300982 679 report.data[3] = 0;
DieterGraef 0:0a2eaa300982 680
DieterGraef 0:0a2eaa300982 681 if (!send(&report)) {
DieterGraef 0:0a2eaa300982 682 return false;
DieterGraef 0:0a2eaa300982 683 }
DieterGraef 0:0a2eaa300982 684
DieterGraef 0:0a2eaa300982 685 return true;
DieterGraef 0:0a2eaa300982 686
DieterGraef 0:0a2eaa300982 687 }
DieterGraef 0:0a2eaa300982 688
DieterGraef 0:0a2eaa300982 689
DieterGraef 0:0a2eaa300982 690 bool USBMouseKeyboard::mediaControl(MEDIA_KEY key) {
DieterGraef 0:0a2eaa300982 691 HID_REPORT report;
DieterGraef 0:0a2eaa300982 692
DieterGraef 0:0a2eaa300982 693 report.data[0] = REPORT_ID_VOLUME;
DieterGraef 0:0a2eaa300982 694 report.data[1] = (1 << key) & 0x7f;
DieterGraef 0:0a2eaa300982 695
DieterGraef 0:0a2eaa300982 696 report.length = 2;
DieterGraef 0:0a2eaa300982 697
DieterGraef 0:0a2eaa300982 698 send(&report);
DieterGraef 0:0a2eaa300982 699
DieterGraef 0:0a2eaa300982 700 report.data[0] = REPORT_ID_VOLUME;
DieterGraef 0:0a2eaa300982 701 report.data[1] = 0;
DieterGraef 0:0a2eaa300982 702
DieterGraef 0:0a2eaa300982 703 report.length = 2;
DieterGraef 0:0a2eaa300982 704
DieterGraef 0:0a2eaa300982 705 return send(&report);
DieterGraef 0:0a2eaa300982 706 }