Kalibriersoftware Stromwerte

Dependencies:   Matrix mbed

Committer:
Racer01014
Date:
Sat Nov 28 13:50:31 2015 +0000
Revision:
1:ea5f520dcdc1
Parent:
0:5e35c180ed4a
-

Who changed what in which revision?

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