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