Base station firmware

Committer:
Perijah
Date:
Tue May 24 13:16:55 2016 +0000
Revision:
0:ecc3925d3f8c
Base station firmware

Who changed what in which revision?

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