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