USBDevice library with modifications required to work with Semtech GUI App for SX1276.

Fork of USBDevice by mbed official

Committer:
modtronix
Date:
Mon Feb 16 02:10:27 2015 +0000
Revision:
42:7e7597ba0fac
Parent:
25:7c72828865f3
USBDevice library with modifications required to work with Semtech GUI App for SX1276.

Who changed what in which revision?

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