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