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