![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Kalibriersoftware Stromwerte
USBHID/USBKeyboard.cpp@1:ea5f520dcdc1, 2015-11-28 (annotated)
- Committer:
- Racer01014
- Date:
- Sat Nov 28 13:50:31 2015 +0000
- Revision:
- 1:ea5f520dcdc1
- Parent:
- 0:5e35c180ed4a
-
Who changed what in which revision?
User | Revision | Line number | New 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 | |
Racer01014 | 0:5e35c180ed4a | 21 | #include "USBKeyboard.h" |
Racer01014 | 0:5e35c180ed4a | 22 | |
Racer01014 | 0:5e35c180ed4a | 23 | #define REPORT_ID_KEYBOARD 1 |
Racer01014 | 0:5e35c180ed4a | 24 | #define REPORT_ID_VOLUME 3 |
Racer01014 | 0:5e35c180ed4a | 25 | |
Racer01014 | 0:5e35c180ed4a | 26 | |
Racer01014 | 0:5e35c180ed4a | 27 | typedef struct { |
Racer01014 | 0:5e35c180ed4a | 28 | unsigned char usage; |
Racer01014 | 0:5e35c180ed4a | 29 | unsigned char modifier; |
Racer01014 | 0:5e35c180ed4a | 30 | } KEYMAP; |
Racer01014 | 0:5e35c180ed4a | 31 | |
Racer01014 | 0:5e35c180ed4a | 32 | #ifdef US_KEYBOARD |
Racer01014 | 0:5e35c180ed4a | 33 | /* US keyboard (as HID standard) */ |
Racer01014 | 0:5e35c180ed4a | 34 | #define KEYMAP_SIZE (152) |
Racer01014 | 0:5e35c180ed4a | 35 | const KEYMAP keymap[KEYMAP_SIZE] = { |
Racer01014 | 0:5e35c180ed4a | 36 | {0, 0}, /* NUL */ |
Racer01014 | 0:5e35c180ed4a | 37 | {0, 0}, /* SOH */ |
Racer01014 | 0:5e35c180ed4a | 38 | {0, 0}, /* STX */ |
Racer01014 | 0:5e35c180ed4a | 39 | {0, 0}, /* ETX */ |
Racer01014 | 0:5e35c180ed4a | 40 | {0, 0}, /* EOT */ |
Racer01014 | 0:5e35c180ed4a | 41 | {0, 0}, /* ENQ */ |
Racer01014 | 0:5e35c180ed4a | 42 | {0, 0}, /* ACK */ |
Racer01014 | 0:5e35c180ed4a | 43 | {0, 0}, /* BEL */ |
Racer01014 | 0:5e35c180ed4a | 44 | {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */ |
Racer01014 | 0:5e35c180ed4a | 45 | {0x2b, 0}, /* TAB */ /* Keyboard Tab */ |
Racer01014 | 0:5e35c180ed4a | 46 | {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */ |
Racer01014 | 0:5e35c180ed4a | 47 | {0, 0}, /* VT */ |
Racer01014 | 0:5e35c180ed4a | 48 | {0, 0}, /* FF */ |
Racer01014 | 0:5e35c180ed4a | 49 | {0, 0}, /* CR */ |
Racer01014 | 0:5e35c180ed4a | 50 | {0, 0}, /* SO */ |
Racer01014 | 0:5e35c180ed4a | 51 | {0, 0}, /* SI */ |
Racer01014 | 0:5e35c180ed4a | 52 | {0, 0}, /* DEL */ |
Racer01014 | 0:5e35c180ed4a | 53 | {0, 0}, /* DC1 */ |
Racer01014 | 0:5e35c180ed4a | 54 | {0, 0}, /* DC2 */ |
Racer01014 | 0:5e35c180ed4a | 55 | {0, 0}, /* DC3 */ |
Racer01014 | 0:5e35c180ed4a | 56 | {0, 0}, /* DC4 */ |
Racer01014 | 0:5e35c180ed4a | 57 | {0, 0}, /* NAK */ |
Racer01014 | 0:5e35c180ed4a | 58 | {0, 0}, /* SYN */ |
Racer01014 | 0:5e35c180ed4a | 59 | {0, 0}, /* ETB */ |
Racer01014 | 0:5e35c180ed4a | 60 | {0, 0}, /* CAN */ |
Racer01014 | 0:5e35c180ed4a | 61 | {0, 0}, /* EM */ |
Racer01014 | 0:5e35c180ed4a | 62 | {0, 0}, /* SUB */ |
Racer01014 | 0:5e35c180ed4a | 63 | {0, 0}, /* ESC */ |
Racer01014 | 0:5e35c180ed4a | 64 | {0, 0}, /* FS */ |
Racer01014 | 0:5e35c180ed4a | 65 | {0, 0}, /* GS */ |
Racer01014 | 0:5e35c180ed4a | 66 | {0, 0}, /* RS */ |
Racer01014 | 0:5e35c180ed4a | 67 | {0, 0}, /* US */ |
Racer01014 | 0:5e35c180ed4a | 68 | {0x2c, 0}, /* */ |
Racer01014 | 0:5e35c180ed4a | 69 | {0x1e, KEY_SHIFT}, /* ! */ |
Racer01014 | 0:5e35c180ed4a | 70 | {0x34, KEY_SHIFT}, /* " */ |
Racer01014 | 0:5e35c180ed4a | 71 | {0x20, KEY_SHIFT}, /* # */ |
Racer01014 | 0:5e35c180ed4a | 72 | {0x21, KEY_SHIFT}, /* $ */ |
Racer01014 | 0:5e35c180ed4a | 73 | {0x22, KEY_SHIFT}, /* % */ |
Racer01014 | 0:5e35c180ed4a | 74 | {0x24, KEY_SHIFT}, /* & */ |
Racer01014 | 0:5e35c180ed4a | 75 | {0x34, 0}, /* ' */ |
Racer01014 | 0:5e35c180ed4a | 76 | {0x26, KEY_SHIFT}, /* ( */ |
Racer01014 | 0:5e35c180ed4a | 77 | {0x27, KEY_SHIFT}, /* ) */ |
Racer01014 | 0:5e35c180ed4a | 78 | {0x25, KEY_SHIFT}, /* * */ |
Racer01014 | 0:5e35c180ed4a | 79 | {0x2e, KEY_SHIFT}, /* + */ |
Racer01014 | 0:5e35c180ed4a | 80 | {0x36, 0}, /* , */ |
Racer01014 | 0:5e35c180ed4a | 81 | {0x2d, 0}, /* - */ |
Racer01014 | 0:5e35c180ed4a | 82 | {0x37, 0}, /* . */ |
Racer01014 | 0:5e35c180ed4a | 83 | {0x38, 0}, /* / */ |
Racer01014 | 0:5e35c180ed4a | 84 | {0x27, 0}, /* 0 */ |
Racer01014 | 0:5e35c180ed4a | 85 | {0x1e, 0}, /* 1 */ |
Racer01014 | 0:5e35c180ed4a | 86 | {0x1f, 0}, /* 2 */ |
Racer01014 | 0:5e35c180ed4a | 87 | {0x20, 0}, /* 3 */ |
Racer01014 | 0:5e35c180ed4a | 88 | {0x21, 0}, /* 4 */ |
Racer01014 | 0:5e35c180ed4a | 89 | {0x22, 0}, /* 5 */ |
Racer01014 | 0:5e35c180ed4a | 90 | {0x23, 0}, /* 6 */ |
Racer01014 | 0:5e35c180ed4a | 91 | {0x24, 0}, /* 7 */ |
Racer01014 | 0:5e35c180ed4a | 92 | {0x25, 0}, /* 8 */ |
Racer01014 | 0:5e35c180ed4a | 93 | {0x26, 0}, /* 9 */ |
Racer01014 | 0:5e35c180ed4a | 94 | {0x33, KEY_SHIFT}, /* : */ |
Racer01014 | 0:5e35c180ed4a | 95 | {0x33, 0}, /* ; */ |
Racer01014 | 0:5e35c180ed4a | 96 | {0x36, KEY_SHIFT}, /* < */ |
Racer01014 | 0:5e35c180ed4a | 97 | {0x2e, 0}, /* = */ |
Racer01014 | 0:5e35c180ed4a | 98 | {0x37, KEY_SHIFT}, /* > */ |
Racer01014 | 0:5e35c180ed4a | 99 | {0x38, KEY_SHIFT}, /* ? */ |
Racer01014 | 0:5e35c180ed4a | 100 | {0x1f, KEY_SHIFT}, /* @ */ |
Racer01014 | 0:5e35c180ed4a | 101 | {0x04, KEY_SHIFT}, /* A */ |
Racer01014 | 0:5e35c180ed4a | 102 | {0x05, KEY_SHIFT}, /* B */ |
Racer01014 | 0:5e35c180ed4a | 103 | {0x06, KEY_SHIFT}, /* C */ |
Racer01014 | 0:5e35c180ed4a | 104 | {0x07, KEY_SHIFT}, /* D */ |
Racer01014 | 0:5e35c180ed4a | 105 | {0x08, KEY_SHIFT}, /* E */ |
Racer01014 | 0:5e35c180ed4a | 106 | {0x09, KEY_SHIFT}, /* F */ |
Racer01014 | 0:5e35c180ed4a | 107 | {0x0a, KEY_SHIFT}, /* G */ |
Racer01014 | 0:5e35c180ed4a | 108 | {0x0b, KEY_SHIFT}, /* H */ |
Racer01014 | 0:5e35c180ed4a | 109 | {0x0c, KEY_SHIFT}, /* I */ |
Racer01014 | 0:5e35c180ed4a | 110 | {0x0d, KEY_SHIFT}, /* J */ |
Racer01014 | 0:5e35c180ed4a | 111 | {0x0e, KEY_SHIFT}, /* K */ |
Racer01014 | 0:5e35c180ed4a | 112 | {0x0f, KEY_SHIFT}, /* L */ |
Racer01014 | 0:5e35c180ed4a | 113 | {0x10, KEY_SHIFT}, /* M */ |
Racer01014 | 0:5e35c180ed4a | 114 | {0x11, KEY_SHIFT}, /* N */ |
Racer01014 | 0:5e35c180ed4a | 115 | {0x12, KEY_SHIFT}, /* O */ |
Racer01014 | 0:5e35c180ed4a | 116 | {0x13, KEY_SHIFT}, /* P */ |
Racer01014 | 0:5e35c180ed4a | 117 | {0x14, KEY_SHIFT}, /* Q */ |
Racer01014 | 0:5e35c180ed4a | 118 | {0x15, KEY_SHIFT}, /* R */ |
Racer01014 | 0:5e35c180ed4a | 119 | {0x16, KEY_SHIFT}, /* S */ |
Racer01014 | 0:5e35c180ed4a | 120 | {0x17, KEY_SHIFT}, /* T */ |
Racer01014 | 0:5e35c180ed4a | 121 | {0x18, KEY_SHIFT}, /* U */ |
Racer01014 | 0:5e35c180ed4a | 122 | {0x19, KEY_SHIFT}, /* V */ |
Racer01014 | 0:5e35c180ed4a | 123 | {0x1a, KEY_SHIFT}, /* W */ |
Racer01014 | 0:5e35c180ed4a | 124 | {0x1b, KEY_SHIFT}, /* X */ |
Racer01014 | 0:5e35c180ed4a | 125 | {0x1c, KEY_SHIFT}, /* Y */ |
Racer01014 | 0:5e35c180ed4a | 126 | {0x1d, KEY_SHIFT}, /* Z */ |
Racer01014 | 0:5e35c180ed4a | 127 | {0x2f, 0}, /* [ */ |
Racer01014 | 0:5e35c180ed4a | 128 | {0x31, 0}, /* \ */ |
Racer01014 | 0:5e35c180ed4a | 129 | {0x30, 0}, /* ] */ |
Racer01014 | 0:5e35c180ed4a | 130 | {0x23, KEY_SHIFT}, /* ^ */ |
Racer01014 | 0:5e35c180ed4a | 131 | {0x2d, KEY_SHIFT}, /* _ */ |
Racer01014 | 0:5e35c180ed4a | 132 | {0x35, 0}, /* ` */ |
Racer01014 | 0:5e35c180ed4a | 133 | {0x04, 0}, /* a */ |
Racer01014 | 0:5e35c180ed4a | 134 | {0x05, 0}, /* b */ |
Racer01014 | 0:5e35c180ed4a | 135 | {0x06, 0}, /* c */ |
Racer01014 | 0:5e35c180ed4a | 136 | {0x07, 0}, /* d */ |
Racer01014 | 0:5e35c180ed4a | 137 | {0x08, 0}, /* e */ |
Racer01014 | 0:5e35c180ed4a | 138 | {0x09, 0}, /* f */ |
Racer01014 | 0:5e35c180ed4a | 139 | {0x0a, 0}, /* g */ |
Racer01014 | 0:5e35c180ed4a | 140 | {0x0b, 0}, /* h */ |
Racer01014 | 0:5e35c180ed4a | 141 | {0x0c, 0}, /* i */ |
Racer01014 | 0:5e35c180ed4a | 142 | {0x0d, 0}, /* j */ |
Racer01014 | 0:5e35c180ed4a | 143 | {0x0e, 0}, /* k */ |
Racer01014 | 0:5e35c180ed4a | 144 | {0x0f, 0}, /* l */ |
Racer01014 | 0:5e35c180ed4a | 145 | {0x10, 0}, /* m */ |
Racer01014 | 0:5e35c180ed4a | 146 | {0x11, 0}, /* n */ |
Racer01014 | 0:5e35c180ed4a | 147 | {0x12, 0}, /* o */ |
Racer01014 | 0:5e35c180ed4a | 148 | {0x13, 0}, /* p */ |
Racer01014 | 0:5e35c180ed4a | 149 | {0x14, 0}, /* q */ |
Racer01014 | 0:5e35c180ed4a | 150 | {0x15, 0}, /* r */ |
Racer01014 | 0:5e35c180ed4a | 151 | {0x16, 0}, /* s */ |
Racer01014 | 0:5e35c180ed4a | 152 | {0x17, 0}, /* t */ |
Racer01014 | 0:5e35c180ed4a | 153 | {0x18, 0}, /* u */ |
Racer01014 | 0:5e35c180ed4a | 154 | {0x19, 0}, /* v */ |
Racer01014 | 0:5e35c180ed4a | 155 | {0x1a, 0}, /* w */ |
Racer01014 | 0:5e35c180ed4a | 156 | {0x1b, 0}, /* x */ |
Racer01014 | 0:5e35c180ed4a | 157 | {0x1c, 0}, /* y */ |
Racer01014 | 0:5e35c180ed4a | 158 | {0x1d, 0}, /* z */ |
Racer01014 | 0:5e35c180ed4a | 159 | {0x2f, KEY_SHIFT}, /* { */ |
Racer01014 | 0:5e35c180ed4a | 160 | {0x31, KEY_SHIFT}, /* | */ |
Racer01014 | 0:5e35c180ed4a | 161 | {0x30, KEY_SHIFT}, /* } */ |
Racer01014 | 0:5e35c180ed4a | 162 | {0x35, KEY_SHIFT}, /* ~ */ |
Racer01014 | 0:5e35c180ed4a | 163 | {0,0}, /* DEL */ |
Racer01014 | 0:5e35c180ed4a | 164 | |
Racer01014 | 0:5e35c180ed4a | 165 | {0x3a, 0}, /* F1 */ |
Racer01014 | 0:5e35c180ed4a | 166 | {0x3b, 0}, /* F2 */ |
Racer01014 | 0:5e35c180ed4a | 167 | {0x3c, 0}, /* F3 */ |
Racer01014 | 0:5e35c180ed4a | 168 | {0x3d, 0}, /* F4 */ |
Racer01014 | 0:5e35c180ed4a | 169 | {0x3e, 0}, /* F5 */ |
Racer01014 | 0:5e35c180ed4a | 170 | {0x3f, 0}, /* F6 */ |
Racer01014 | 0:5e35c180ed4a | 171 | {0x40, 0}, /* F7 */ |
Racer01014 | 0:5e35c180ed4a | 172 | {0x41, 0}, /* F8 */ |
Racer01014 | 0:5e35c180ed4a | 173 | {0x42, 0}, /* F9 */ |
Racer01014 | 0:5e35c180ed4a | 174 | {0x43, 0}, /* F10 */ |
Racer01014 | 0:5e35c180ed4a | 175 | {0x44, 0}, /* F11 */ |
Racer01014 | 0:5e35c180ed4a | 176 | {0x45, 0}, /* F12 */ |
Racer01014 | 0:5e35c180ed4a | 177 | |
Racer01014 | 0:5e35c180ed4a | 178 | {0x46, 0}, /* PRINT_SCREEN */ |
Racer01014 | 0:5e35c180ed4a | 179 | {0x47, 0}, /* SCROLL_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 180 | {0x39, 0}, /* CAPS_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 181 | {0x53, 0}, /* NUM_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 182 | {0x49, 0}, /* INSERT */ |
Racer01014 | 0:5e35c180ed4a | 183 | {0x4a, 0}, /* HOME */ |
Racer01014 | 0:5e35c180ed4a | 184 | {0x4b, 0}, /* PAGE_UP */ |
Racer01014 | 0:5e35c180ed4a | 185 | {0x4e, 0}, /* PAGE_DOWN */ |
Racer01014 | 0:5e35c180ed4a | 186 | |
Racer01014 | 0:5e35c180ed4a | 187 | {0x4f, 0}, /* RIGHT_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 188 | {0x50, 0}, /* LEFT_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 189 | {0x51, 0}, /* DOWN_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 190 | {0x52, 0}, /* UP_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 191 | }; |
Racer01014 | 0:5e35c180ed4a | 192 | |
Racer01014 | 0:5e35c180ed4a | 193 | #else |
Racer01014 | 0:5e35c180ed4a | 194 | /* UK keyboard */ |
Racer01014 | 0:5e35c180ed4a | 195 | #define KEYMAP_SIZE (152) |
Racer01014 | 0:5e35c180ed4a | 196 | const KEYMAP keymap[KEYMAP_SIZE] = { |
Racer01014 | 0:5e35c180ed4a | 197 | {0, 0}, /* NUL */ |
Racer01014 | 0:5e35c180ed4a | 198 | {0, 0}, /* SOH */ |
Racer01014 | 0:5e35c180ed4a | 199 | {0, 0}, /* STX */ |
Racer01014 | 0:5e35c180ed4a | 200 | {0, 0}, /* ETX */ |
Racer01014 | 0:5e35c180ed4a | 201 | {0, 0}, /* EOT */ |
Racer01014 | 0:5e35c180ed4a | 202 | {0, 0}, /* ENQ */ |
Racer01014 | 0:5e35c180ed4a | 203 | {0, 0}, /* ACK */ |
Racer01014 | 0:5e35c180ed4a | 204 | {0, 0}, /* BEL */ |
Racer01014 | 0:5e35c180ed4a | 205 | {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */ |
Racer01014 | 0:5e35c180ed4a | 206 | {0x2b, 0}, /* TAB */ /* Keyboard Tab */ |
Racer01014 | 0:5e35c180ed4a | 207 | {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */ |
Racer01014 | 0:5e35c180ed4a | 208 | {0, 0}, /* VT */ |
Racer01014 | 0:5e35c180ed4a | 209 | {0, 0}, /* FF */ |
Racer01014 | 0:5e35c180ed4a | 210 | {0, 0}, /* CR */ |
Racer01014 | 0:5e35c180ed4a | 211 | {0, 0}, /* SO */ |
Racer01014 | 0:5e35c180ed4a | 212 | {0, 0}, /* SI */ |
Racer01014 | 0:5e35c180ed4a | 213 | {0, 0}, /* DEL */ |
Racer01014 | 0:5e35c180ed4a | 214 | {0, 0}, /* DC1 */ |
Racer01014 | 0:5e35c180ed4a | 215 | {0, 0}, /* DC2 */ |
Racer01014 | 0:5e35c180ed4a | 216 | {0, 0}, /* DC3 */ |
Racer01014 | 0:5e35c180ed4a | 217 | {0, 0}, /* DC4 */ |
Racer01014 | 0:5e35c180ed4a | 218 | {0, 0}, /* NAK */ |
Racer01014 | 0:5e35c180ed4a | 219 | {0, 0}, /* SYN */ |
Racer01014 | 0:5e35c180ed4a | 220 | {0, 0}, /* ETB */ |
Racer01014 | 0:5e35c180ed4a | 221 | {0, 0}, /* CAN */ |
Racer01014 | 0:5e35c180ed4a | 222 | {0, 0}, /* EM */ |
Racer01014 | 0:5e35c180ed4a | 223 | {0, 0}, /* SUB */ |
Racer01014 | 0:5e35c180ed4a | 224 | {0, 0}, /* ESC */ |
Racer01014 | 0:5e35c180ed4a | 225 | {0, 0}, /* FS */ |
Racer01014 | 0:5e35c180ed4a | 226 | {0, 0}, /* GS */ |
Racer01014 | 0:5e35c180ed4a | 227 | {0, 0}, /* RS */ |
Racer01014 | 0:5e35c180ed4a | 228 | {0, 0}, /* US */ |
Racer01014 | 0:5e35c180ed4a | 229 | {0x2c, 0}, /* */ |
Racer01014 | 0:5e35c180ed4a | 230 | {0x1e, KEY_SHIFT}, /* ! */ |
Racer01014 | 0:5e35c180ed4a | 231 | {0x1f, KEY_SHIFT}, /* " */ |
Racer01014 | 0:5e35c180ed4a | 232 | {0x32, 0}, /* # */ |
Racer01014 | 0:5e35c180ed4a | 233 | {0x21, KEY_SHIFT}, /* $ */ |
Racer01014 | 0:5e35c180ed4a | 234 | {0x22, KEY_SHIFT}, /* % */ |
Racer01014 | 0:5e35c180ed4a | 235 | {0x24, KEY_SHIFT}, /* & */ |
Racer01014 | 0:5e35c180ed4a | 236 | {0x34, 0}, /* ' */ |
Racer01014 | 0:5e35c180ed4a | 237 | {0x26, KEY_SHIFT}, /* ( */ |
Racer01014 | 0:5e35c180ed4a | 238 | {0x27, KEY_SHIFT}, /* ) */ |
Racer01014 | 0:5e35c180ed4a | 239 | {0x25, KEY_SHIFT}, /* * */ |
Racer01014 | 0:5e35c180ed4a | 240 | {0x2e, KEY_SHIFT}, /* + */ |
Racer01014 | 0:5e35c180ed4a | 241 | {0x36, 0}, /* , */ |
Racer01014 | 0:5e35c180ed4a | 242 | {0x2d, 0}, /* - */ |
Racer01014 | 0:5e35c180ed4a | 243 | {0x37, 0}, /* . */ |
Racer01014 | 0:5e35c180ed4a | 244 | {0x38, 0}, /* / */ |
Racer01014 | 0:5e35c180ed4a | 245 | {0x27, 0}, /* 0 */ |
Racer01014 | 0:5e35c180ed4a | 246 | {0x1e, 0}, /* 1 */ |
Racer01014 | 0:5e35c180ed4a | 247 | {0x1f, 0}, /* 2 */ |
Racer01014 | 0:5e35c180ed4a | 248 | {0x20, 0}, /* 3 */ |
Racer01014 | 0:5e35c180ed4a | 249 | {0x21, 0}, /* 4 */ |
Racer01014 | 0:5e35c180ed4a | 250 | {0x22, 0}, /* 5 */ |
Racer01014 | 0:5e35c180ed4a | 251 | {0x23, 0}, /* 6 */ |
Racer01014 | 0:5e35c180ed4a | 252 | {0x24, 0}, /* 7 */ |
Racer01014 | 0:5e35c180ed4a | 253 | {0x25, 0}, /* 8 */ |
Racer01014 | 0:5e35c180ed4a | 254 | {0x26, 0}, /* 9 */ |
Racer01014 | 0:5e35c180ed4a | 255 | {0x33, KEY_SHIFT}, /* : */ |
Racer01014 | 0:5e35c180ed4a | 256 | {0x33, 0}, /* ; */ |
Racer01014 | 0:5e35c180ed4a | 257 | {0x36, KEY_SHIFT}, /* < */ |
Racer01014 | 0:5e35c180ed4a | 258 | {0x2e, 0}, /* = */ |
Racer01014 | 0:5e35c180ed4a | 259 | {0x37, KEY_SHIFT}, /* > */ |
Racer01014 | 0:5e35c180ed4a | 260 | {0x38, KEY_SHIFT}, /* ? */ |
Racer01014 | 0:5e35c180ed4a | 261 | {0x34, KEY_SHIFT}, /* @ */ |
Racer01014 | 0:5e35c180ed4a | 262 | {0x04, KEY_SHIFT}, /* A */ |
Racer01014 | 0:5e35c180ed4a | 263 | {0x05, KEY_SHIFT}, /* B */ |
Racer01014 | 0:5e35c180ed4a | 264 | {0x06, KEY_SHIFT}, /* C */ |
Racer01014 | 0:5e35c180ed4a | 265 | {0x07, KEY_SHIFT}, /* D */ |
Racer01014 | 0:5e35c180ed4a | 266 | {0x08, KEY_SHIFT}, /* E */ |
Racer01014 | 0:5e35c180ed4a | 267 | {0x09, KEY_SHIFT}, /* F */ |
Racer01014 | 0:5e35c180ed4a | 268 | {0x0a, KEY_SHIFT}, /* G */ |
Racer01014 | 0:5e35c180ed4a | 269 | {0x0b, KEY_SHIFT}, /* H */ |
Racer01014 | 0:5e35c180ed4a | 270 | {0x0c, KEY_SHIFT}, /* I */ |
Racer01014 | 0:5e35c180ed4a | 271 | {0x0d, KEY_SHIFT}, /* J */ |
Racer01014 | 0:5e35c180ed4a | 272 | {0x0e, KEY_SHIFT}, /* K */ |
Racer01014 | 0:5e35c180ed4a | 273 | {0x0f, KEY_SHIFT}, /* L */ |
Racer01014 | 0:5e35c180ed4a | 274 | {0x10, KEY_SHIFT}, /* M */ |
Racer01014 | 0:5e35c180ed4a | 275 | {0x11, KEY_SHIFT}, /* N */ |
Racer01014 | 0:5e35c180ed4a | 276 | {0x12, KEY_SHIFT}, /* O */ |
Racer01014 | 0:5e35c180ed4a | 277 | {0x13, KEY_SHIFT}, /* P */ |
Racer01014 | 0:5e35c180ed4a | 278 | {0x14, KEY_SHIFT}, /* Q */ |
Racer01014 | 0:5e35c180ed4a | 279 | {0x15, KEY_SHIFT}, /* R */ |
Racer01014 | 0:5e35c180ed4a | 280 | {0x16, KEY_SHIFT}, /* S */ |
Racer01014 | 0:5e35c180ed4a | 281 | {0x17, KEY_SHIFT}, /* T */ |
Racer01014 | 0:5e35c180ed4a | 282 | {0x18, KEY_SHIFT}, /* U */ |
Racer01014 | 0:5e35c180ed4a | 283 | {0x19, KEY_SHIFT}, /* V */ |
Racer01014 | 0:5e35c180ed4a | 284 | {0x1a, KEY_SHIFT}, /* W */ |
Racer01014 | 0:5e35c180ed4a | 285 | {0x1b, KEY_SHIFT}, /* X */ |
Racer01014 | 0:5e35c180ed4a | 286 | {0x1c, KEY_SHIFT}, /* Y */ |
Racer01014 | 0:5e35c180ed4a | 287 | {0x1d, KEY_SHIFT}, /* Z */ |
Racer01014 | 0:5e35c180ed4a | 288 | {0x2f, 0}, /* [ */ |
Racer01014 | 0:5e35c180ed4a | 289 | {0x64, 0}, /* \ */ |
Racer01014 | 0:5e35c180ed4a | 290 | {0x30, 0}, /* ] */ |
Racer01014 | 0:5e35c180ed4a | 291 | {0x23, KEY_SHIFT}, /* ^ */ |
Racer01014 | 0:5e35c180ed4a | 292 | {0x2d, KEY_SHIFT}, /* _ */ |
Racer01014 | 0:5e35c180ed4a | 293 | {0x35, 0}, /* ` */ |
Racer01014 | 0:5e35c180ed4a | 294 | {0x04, 0}, /* a */ |
Racer01014 | 0:5e35c180ed4a | 295 | {0x05, 0}, /* b */ |
Racer01014 | 0:5e35c180ed4a | 296 | {0x06, 0}, /* c */ |
Racer01014 | 0:5e35c180ed4a | 297 | {0x07, 0}, /* d */ |
Racer01014 | 0:5e35c180ed4a | 298 | {0x08, 0}, /* e */ |
Racer01014 | 0:5e35c180ed4a | 299 | {0x09, 0}, /* f */ |
Racer01014 | 0:5e35c180ed4a | 300 | {0x0a, 0}, /* g */ |
Racer01014 | 0:5e35c180ed4a | 301 | {0x0b, 0}, /* h */ |
Racer01014 | 0:5e35c180ed4a | 302 | {0x0c, 0}, /* i */ |
Racer01014 | 0:5e35c180ed4a | 303 | {0x0d, 0}, /* j */ |
Racer01014 | 0:5e35c180ed4a | 304 | {0x0e, 0}, /* k */ |
Racer01014 | 0:5e35c180ed4a | 305 | {0x0f, 0}, /* l */ |
Racer01014 | 0:5e35c180ed4a | 306 | {0x10, 0}, /* m */ |
Racer01014 | 0:5e35c180ed4a | 307 | {0x11, 0}, /* n */ |
Racer01014 | 0:5e35c180ed4a | 308 | {0x12, 0}, /* o */ |
Racer01014 | 0:5e35c180ed4a | 309 | {0x13, 0}, /* p */ |
Racer01014 | 0:5e35c180ed4a | 310 | {0x14, 0}, /* q */ |
Racer01014 | 0:5e35c180ed4a | 311 | {0x15, 0}, /* r */ |
Racer01014 | 0:5e35c180ed4a | 312 | {0x16, 0}, /* s */ |
Racer01014 | 0:5e35c180ed4a | 313 | {0x17, 0}, /* t */ |
Racer01014 | 0:5e35c180ed4a | 314 | {0x18, 0}, /* u */ |
Racer01014 | 0:5e35c180ed4a | 315 | {0x19, 0}, /* v */ |
Racer01014 | 0:5e35c180ed4a | 316 | {0x1a, 0}, /* w */ |
Racer01014 | 0:5e35c180ed4a | 317 | {0x1b, 0}, /* x */ |
Racer01014 | 0:5e35c180ed4a | 318 | {0x1c, 0}, /* y */ |
Racer01014 | 0:5e35c180ed4a | 319 | {0x1d, 0}, /* z */ |
Racer01014 | 0:5e35c180ed4a | 320 | {0x2f, KEY_SHIFT}, /* { */ |
Racer01014 | 0:5e35c180ed4a | 321 | {0x64, KEY_SHIFT}, /* | */ |
Racer01014 | 0:5e35c180ed4a | 322 | {0x30, KEY_SHIFT}, /* } */ |
Racer01014 | 0:5e35c180ed4a | 323 | {0x32, KEY_SHIFT}, /* ~ */ |
Racer01014 | 0:5e35c180ed4a | 324 | {0,0}, /* DEL */ |
Racer01014 | 0:5e35c180ed4a | 325 | |
Racer01014 | 0:5e35c180ed4a | 326 | {0x3a, 0}, /* F1 */ |
Racer01014 | 0:5e35c180ed4a | 327 | {0x3b, 0}, /* F2 */ |
Racer01014 | 0:5e35c180ed4a | 328 | {0x3c, 0}, /* F3 */ |
Racer01014 | 0:5e35c180ed4a | 329 | {0x3d, 0}, /* F4 */ |
Racer01014 | 0:5e35c180ed4a | 330 | {0x3e, 0}, /* F5 */ |
Racer01014 | 0:5e35c180ed4a | 331 | {0x3f, 0}, /* F6 */ |
Racer01014 | 0:5e35c180ed4a | 332 | {0x40, 0}, /* F7 */ |
Racer01014 | 0:5e35c180ed4a | 333 | {0x41, 0}, /* F8 */ |
Racer01014 | 0:5e35c180ed4a | 334 | {0x42, 0}, /* F9 */ |
Racer01014 | 0:5e35c180ed4a | 335 | {0x43, 0}, /* F10 */ |
Racer01014 | 0:5e35c180ed4a | 336 | {0x44, 0}, /* F11 */ |
Racer01014 | 0:5e35c180ed4a | 337 | {0x45, 0}, /* F12 */ |
Racer01014 | 0:5e35c180ed4a | 338 | |
Racer01014 | 0:5e35c180ed4a | 339 | {0x46, 0}, /* PRINT_SCREEN */ |
Racer01014 | 0:5e35c180ed4a | 340 | {0x47, 0}, /* SCROLL_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 341 | {0x39, 0}, /* CAPS_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 342 | {0x53, 0}, /* NUM_LOCK */ |
Racer01014 | 0:5e35c180ed4a | 343 | {0x49, 0}, /* INSERT */ |
Racer01014 | 0:5e35c180ed4a | 344 | {0x4a, 0}, /* HOME */ |
Racer01014 | 0:5e35c180ed4a | 345 | {0x4b, 0}, /* PAGE_UP */ |
Racer01014 | 0:5e35c180ed4a | 346 | {0x4e, 0}, /* PAGE_DOWN */ |
Racer01014 | 0:5e35c180ed4a | 347 | |
Racer01014 | 0:5e35c180ed4a | 348 | {0x4f, 0}, /* RIGHT_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 349 | {0x50, 0}, /* LEFT_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 350 | {0x51, 0}, /* DOWN_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 351 | {0x52, 0}, /* UP_ARROW */ |
Racer01014 | 0:5e35c180ed4a | 352 | }; |
Racer01014 | 0:5e35c180ed4a | 353 | #endif |
Racer01014 | 0:5e35c180ed4a | 354 | |
Racer01014 | 0:5e35c180ed4a | 355 | uint8_t * USBKeyboard::reportDesc() { |
Racer01014 | 0:5e35c180ed4a | 356 | static uint8_t reportDescriptor[] = { |
Racer01014 | 0:5e35c180ed4a | 357 | USAGE_PAGE(1), 0x01, // Generic Desktop |
Racer01014 | 0:5e35c180ed4a | 358 | USAGE(1), 0x06, // Keyboard |
Racer01014 | 0:5e35c180ed4a | 359 | COLLECTION(1), 0x01, // Application |
Racer01014 | 0:5e35c180ed4a | 360 | REPORT_ID(1), REPORT_ID_KEYBOARD, |
Racer01014 | 0:5e35c180ed4a | 361 | |
Racer01014 | 0:5e35c180ed4a | 362 | USAGE_PAGE(1), 0x07, // Key Codes |
Racer01014 | 0:5e35c180ed4a | 363 | USAGE_MINIMUM(1), 0xE0, |
Racer01014 | 0:5e35c180ed4a | 364 | USAGE_MAXIMUM(1), 0xE7, |
Racer01014 | 0:5e35c180ed4a | 365 | LOGICAL_MINIMUM(1), 0x00, |
Racer01014 | 0:5e35c180ed4a | 366 | LOGICAL_MAXIMUM(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 367 | REPORT_SIZE(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 368 | REPORT_COUNT(1), 0x08, |
Racer01014 | 0:5e35c180ed4a | 369 | INPUT(1), 0x02, // Data, Variable, Absolute |
Racer01014 | 0:5e35c180ed4a | 370 | REPORT_COUNT(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 371 | REPORT_SIZE(1), 0x08, |
Racer01014 | 0:5e35c180ed4a | 372 | INPUT(1), 0x01, // Constant |
Racer01014 | 0:5e35c180ed4a | 373 | |
Racer01014 | 0:5e35c180ed4a | 374 | |
Racer01014 | 0:5e35c180ed4a | 375 | REPORT_COUNT(1), 0x05, |
Racer01014 | 0:5e35c180ed4a | 376 | REPORT_SIZE(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 377 | USAGE_PAGE(1), 0x08, // LEDs |
Racer01014 | 0:5e35c180ed4a | 378 | USAGE_MINIMUM(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 379 | USAGE_MAXIMUM(1), 0x05, |
Racer01014 | 0:5e35c180ed4a | 380 | OUTPUT(1), 0x02, // Data, Variable, Absolute |
Racer01014 | 0:5e35c180ed4a | 381 | REPORT_COUNT(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 382 | REPORT_SIZE(1), 0x03, |
Racer01014 | 0:5e35c180ed4a | 383 | OUTPUT(1), 0x01, // Constant |
Racer01014 | 0:5e35c180ed4a | 384 | |
Racer01014 | 0:5e35c180ed4a | 385 | |
Racer01014 | 0:5e35c180ed4a | 386 | REPORT_COUNT(1), 0x06, |
Racer01014 | 0:5e35c180ed4a | 387 | REPORT_SIZE(1), 0x08, |
Racer01014 | 0:5e35c180ed4a | 388 | LOGICAL_MINIMUM(1), 0x00, |
Racer01014 | 0:5e35c180ed4a | 389 | LOGICAL_MAXIMUM(1), 0x65, |
Racer01014 | 0:5e35c180ed4a | 390 | USAGE_PAGE(1), 0x07, // Key Codes |
Racer01014 | 0:5e35c180ed4a | 391 | USAGE_MINIMUM(1), 0x00, |
Racer01014 | 0:5e35c180ed4a | 392 | USAGE_MAXIMUM(1), 0x65, |
Racer01014 | 0:5e35c180ed4a | 393 | INPUT(1), 0x00, // Data, Array |
Racer01014 | 0:5e35c180ed4a | 394 | END_COLLECTION(0), |
Racer01014 | 0:5e35c180ed4a | 395 | |
Racer01014 | 0:5e35c180ed4a | 396 | // Media Control |
Racer01014 | 0:5e35c180ed4a | 397 | USAGE_PAGE(1), 0x0C, |
Racer01014 | 0:5e35c180ed4a | 398 | USAGE(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 399 | COLLECTION(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 400 | REPORT_ID(1), REPORT_ID_VOLUME, |
Racer01014 | 0:5e35c180ed4a | 401 | USAGE_PAGE(1), 0x0C, |
Racer01014 | 0:5e35c180ed4a | 402 | LOGICAL_MINIMUM(1), 0x00, |
Racer01014 | 0:5e35c180ed4a | 403 | LOGICAL_MAXIMUM(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 404 | REPORT_SIZE(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 405 | REPORT_COUNT(1), 0x07, |
Racer01014 | 0:5e35c180ed4a | 406 | USAGE(1), 0xB5, // Next Track |
Racer01014 | 0:5e35c180ed4a | 407 | USAGE(1), 0xB6, // Previous Track |
Racer01014 | 0:5e35c180ed4a | 408 | USAGE(1), 0xB7, // Stop |
Racer01014 | 0:5e35c180ed4a | 409 | USAGE(1), 0xCD, // Play / Pause |
Racer01014 | 0:5e35c180ed4a | 410 | USAGE(1), 0xE2, // Mute |
Racer01014 | 0:5e35c180ed4a | 411 | USAGE(1), 0xE9, // Volume Up |
Racer01014 | 0:5e35c180ed4a | 412 | USAGE(1), 0xEA, // Volume Down |
Racer01014 | 0:5e35c180ed4a | 413 | INPUT(1), 0x02, // Input (Data, Variable, Absolute) |
Racer01014 | 0:5e35c180ed4a | 414 | REPORT_COUNT(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 415 | INPUT(1), 0x01, |
Racer01014 | 0:5e35c180ed4a | 416 | END_COLLECTION(0), |
Racer01014 | 0:5e35c180ed4a | 417 | }; |
Racer01014 | 0:5e35c180ed4a | 418 | reportLength = sizeof(reportDescriptor); |
Racer01014 | 0:5e35c180ed4a | 419 | return reportDescriptor; |
Racer01014 | 0:5e35c180ed4a | 420 | } |
Racer01014 | 0:5e35c180ed4a | 421 | |
Racer01014 | 0:5e35c180ed4a | 422 | |
Racer01014 | 0:5e35c180ed4a | 423 | bool USBKeyboard::EP1_OUT_callback() { |
Racer01014 | 0:5e35c180ed4a | 424 | uint32_t bytesRead = 0; |
Racer01014 | 0:5e35c180ed4a | 425 | uint8_t led[65]; |
Racer01014 | 0:5e35c180ed4a | 426 | USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE); |
Racer01014 | 0:5e35c180ed4a | 427 | |
Racer01014 | 0:5e35c180ed4a | 428 | // we take led[1] because led[0] is the report ID |
Racer01014 | 0:5e35c180ed4a | 429 | lock_status = led[1] & 0x07; |
Racer01014 | 0:5e35c180ed4a | 430 | |
Racer01014 | 0:5e35c180ed4a | 431 | // We activate the endpoint to be able to recceive data |
Racer01014 | 0:5e35c180ed4a | 432 | if (!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE)) |
Racer01014 | 0:5e35c180ed4a | 433 | return false; |
Racer01014 | 0:5e35c180ed4a | 434 | return true; |
Racer01014 | 0:5e35c180ed4a | 435 | } |
Racer01014 | 0:5e35c180ed4a | 436 | |
Racer01014 | 0:5e35c180ed4a | 437 | uint8_t USBKeyboard::lockStatus() { |
Racer01014 | 0:5e35c180ed4a | 438 | return lock_status; |
Racer01014 | 0:5e35c180ed4a | 439 | } |
Racer01014 | 0:5e35c180ed4a | 440 | |
Racer01014 | 0:5e35c180ed4a | 441 | int USBKeyboard::_putc(int c) { |
Racer01014 | 0:5e35c180ed4a | 442 | return keyCode(c, keymap[c].modifier); |
Racer01014 | 0:5e35c180ed4a | 443 | } |
Racer01014 | 0:5e35c180ed4a | 444 | |
Racer01014 | 0:5e35c180ed4a | 445 | bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) { |
Racer01014 | 0:5e35c180ed4a | 446 | // Send a simulated keyboard keypress. Returns true if successful. |
Racer01014 | 0:5e35c180ed4a | 447 | HID_REPORT report; |
Racer01014 | 0:5e35c180ed4a | 448 | |
Racer01014 | 0:5e35c180ed4a | 449 | report.data[0] = REPORT_ID_KEYBOARD; |
Racer01014 | 0:5e35c180ed4a | 450 | report.data[1] = modifier; |
Racer01014 | 0:5e35c180ed4a | 451 | report.data[2] = 0; |
Racer01014 | 0:5e35c180ed4a | 452 | report.data[3] = keymap[key].usage; |
Racer01014 | 0:5e35c180ed4a | 453 | report.data[4] = 0; |
Racer01014 | 0:5e35c180ed4a | 454 | report.data[5] = 0; |
Racer01014 | 0:5e35c180ed4a | 455 | report.data[6] = 0; |
Racer01014 | 0:5e35c180ed4a | 456 | report.data[7] = 0; |
Racer01014 | 0:5e35c180ed4a | 457 | report.data[8] = 0; |
Racer01014 | 0:5e35c180ed4a | 458 | |
Racer01014 | 0:5e35c180ed4a | 459 | report.length = 9; |
Racer01014 | 0:5e35c180ed4a | 460 | |
Racer01014 | 0:5e35c180ed4a | 461 | if (!send(&report)) { |
Racer01014 | 0:5e35c180ed4a | 462 | return false; |
Racer01014 | 0:5e35c180ed4a | 463 | } |
Racer01014 | 0:5e35c180ed4a | 464 | |
Racer01014 | 0:5e35c180ed4a | 465 | report.data[1] = 0; |
Racer01014 | 0:5e35c180ed4a | 466 | report.data[3] = 0; |
Racer01014 | 0:5e35c180ed4a | 467 | |
Racer01014 | 0:5e35c180ed4a | 468 | if (!send(&report)) { |
Racer01014 | 0:5e35c180ed4a | 469 | return false; |
Racer01014 | 0:5e35c180ed4a | 470 | } |
Racer01014 | 0:5e35c180ed4a | 471 | |
Racer01014 | 0:5e35c180ed4a | 472 | return true; |
Racer01014 | 0:5e35c180ed4a | 473 | |
Racer01014 | 0:5e35c180ed4a | 474 | } |
Racer01014 | 0:5e35c180ed4a | 475 | |
Racer01014 | 0:5e35c180ed4a | 476 | |
Racer01014 | 0:5e35c180ed4a | 477 | bool USBKeyboard::mediaControl(MEDIA_KEY key) { |
Racer01014 | 0:5e35c180ed4a | 478 | HID_REPORT report; |
Racer01014 | 0:5e35c180ed4a | 479 | |
Racer01014 | 0:5e35c180ed4a | 480 | report.data[0] = REPORT_ID_VOLUME; |
Racer01014 | 0:5e35c180ed4a | 481 | report.data[1] = (1 << key) & 0x7f; |
Racer01014 | 0:5e35c180ed4a | 482 | |
Racer01014 | 0:5e35c180ed4a | 483 | report.length = 2; |
Racer01014 | 0:5e35c180ed4a | 484 | |
Racer01014 | 0:5e35c180ed4a | 485 | if (!send(&report)) { |
Racer01014 | 0:5e35c180ed4a | 486 | return false; |
Racer01014 | 0:5e35c180ed4a | 487 | } |
Racer01014 | 0:5e35c180ed4a | 488 | |
Racer01014 | 0:5e35c180ed4a | 489 | report.data[0] = REPORT_ID_VOLUME; |
Racer01014 | 0:5e35c180ed4a | 490 | report.data[1] = 0; |
Racer01014 | 0:5e35c180ed4a | 491 | |
Racer01014 | 0:5e35c180ed4a | 492 | report.length = 2; |
Racer01014 | 0:5e35c180ed4a | 493 | |
Racer01014 | 0:5e35c180ed4a | 494 | return send(&report); |
Racer01014 | 0:5e35c180ed4a | 495 | } |
Racer01014 | 0:5e35c180ed4a | 496 | |
Racer01014 | 0:5e35c180ed4a | 497 | |
Racer01014 | 0:5e35c180ed4a | 498 | #define DEFAULT_CONFIGURATION (1) |
Racer01014 | 0:5e35c180ed4a | 499 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ |
Racer01014 | 0:5e35c180ed4a | 500 | + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ |
Racer01014 | 0:5e35c180ed4a | 501 | + (1 * HID_DESCRIPTOR_LENGTH) \ |
Racer01014 | 0:5e35c180ed4a | 502 | + (2 * ENDPOINT_DESCRIPTOR_LENGTH)) |
Racer01014 | 0:5e35c180ed4a | 503 | |
Racer01014 | 0:5e35c180ed4a | 504 | uint8_t * USBKeyboard::configurationDesc() { |
Racer01014 | 0:5e35c180ed4a | 505 | static uint8_t configurationDescriptor[] = { |
Racer01014 | 0:5e35c180ed4a | 506 | CONFIGURATION_DESCRIPTOR_LENGTH,// bLength |
Racer01014 | 0:5e35c180ed4a | 507 | CONFIGURATION_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 508 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) |
Racer01014 | 0:5e35c180ed4a | 509 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) |
Racer01014 | 0:5e35c180ed4a | 510 | 0x01, // bNumInterfaces |
Racer01014 | 0:5e35c180ed4a | 511 | DEFAULT_CONFIGURATION, // bConfigurationValue |
Racer01014 | 0:5e35c180ed4a | 512 | 0x00, // iConfiguration |
Racer01014 | 0:5e35c180ed4a | 513 | C_RESERVED | C_SELF_POWERED, // bmAttributes |
Racer01014 | 0:5e35c180ed4a | 514 | C_POWER(0), // bMaxPowerHello World from Mbed |
Racer01014 | 0:5e35c180ed4a | 515 | |
Racer01014 | 0:5e35c180ed4a | 516 | INTERFACE_DESCRIPTOR_LENGTH, // bLength |
Racer01014 | 0:5e35c180ed4a | 517 | INTERFACE_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 518 | 0x00, // bInterfaceNumber |
Racer01014 | 0:5e35c180ed4a | 519 | 0x00, // bAlternateSetting |
Racer01014 | 0:5e35c180ed4a | 520 | 0x02, // bNumEndpoints |
Racer01014 | 0:5e35c180ed4a | 521 | HID_CLASS, // bInterfaceClass |
Racer01014 | 0:5e35c180ed4a | 522 | 1, // bInterfaceSubClass |
Racer01014 | 0:5e35c180ed4a | 523 | 1, // bInterfaceProtocol (keyboard) |
Racer01014 | 0:5e35c180ed4a | 524 | 0x00, // iInterface |
Racer01014 | 0:5e35c180ed4a | 525 | |
Racer01014 | 0:5e35c180ed4a | 526 | HID_DESCRIPTOR_LENGTH, // bLength |
Racer01014 | 0:5e35c180ed4a | 527 | HID_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 528 | LSB(HID_VERSION_1_11), // bcdHID (LSB) |
Racer01014 | 0:5e35c180ed4a | 529 | MSB(HID_VERSION_1_11), // bcdHID (MSB) |
Racer01014 | 0:5e35c180ed4a | 530 | 0x00, // bCountryCode |
Racer01014 | 0:5e35c180ed4a | 531 | 0x01, // bNumDescriptors |
Racer01014 | 0:5e35c180ed4a | 532 | REPORT_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 533 | LSB(reportDescLength()), // wDescriptorLength (LSB) |
Racer01014 | 0:5e35c180ed4a | 534 | MSB(reportDescLength()), // wDescriptorLength (MSB) |
Racer01014 | 0:5e35c180ed4a | 535 | |
Racer01014 | 0:5e35c180ed4a | 536 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
Racer01014 | 0:5e35c180ed4a | 537 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 538 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
Racer01014 | 0:5e35c180ed4a | 539 | E_INTERRUPT, // bmAttributes |
Racer01014 | 0:5e35c180ed4a | 540 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
Racer01014 | 0:5e35c180ed4a | 541 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
Racer01014 | 0:5e35c180ed4a | 542 | 1, // bInterval (milliseconds) |
Racer01014 | 0:5e35c180ed4a | 543 | |
Racer01014 | 0:5e35c180ed4a | 544 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
Racer01014 | 0:5e35c180ed4a | 545 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
Racer01014 | 0:5e35c180ed4a | 546 | PHY_TO_DESC(EPINT_OUT), // bEndpointAddress |
Racer01014 | 0:5e35c180ed4a | 547 | E_INTERRUPT, // bmAttributes |
Racer01014 | 0:5e35c180ed4a | 548 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
Racer01014 | 0:5e35c180ed4a | 549 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
Racer01014 | 0:5e35c180ed4a | 550 | 1, // bInterval (milliseconds) |
Racer01014 | 0:5e35c180ed4a | 551 | }; |
Racer01014 | 0:5e35c180ed4a | 552 | return configurationDescriptor; |
Racer01014 | 0:5e35c180ed4a | 553 | } |