USB/HID stack for the loststone project
Fork of USBDevice by
USBHID/USBMouse.cpp@11:7c95a42cf9f6, 2013-03-14 (annotated)
- Committer:
- xxann5
- Date:
- Thu Mar 14 13:53:16 2013 +0000
- Revision:
- 11:7c95a42cf9f6
- Parent:
- 8:4f27799a971d
pulled and merged with the main dev repo.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 1:80ab0d068708 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
samux | 1:80ab0d068708 | 2 | * |
samux | 1:80ab0d068708 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
samux | 1:80ab0d068708 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
samux | 1:80ab0d068708 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
samux | 1:80ab0d068708 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
samux | 1:80ab0d068708 | 7 | * Software is furnished to do so, subject to the following conditions: |
samux | 1:80ab0d068708 | 8 | * |
samux | 1:80ab0d068708 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
samux | 1:80ab0d068708 | 10 | * substantial portions of the Software. |
samux | 1:80ab0d068708 | 11 | * |
samux | 1:80ab0d068708 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
samux | 1:80ab0d068708 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
samux | 1:80ab0d068708 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
samux | 1:80ab0d068708 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
samux | 1:80ab0d068708 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
samux | 1:80ab0d068708 | 17 | */ |
samux | 1:80ab0d068708 | 18 | |
samux | 1:80ab0d068708 | 19 | #include "stdint.h" |
samux | 1:80ab0d068708 | 20 | #include "USBMouse.h" |
samux | 1:80ab0d068708 | 21 | |
xxann5 | 8:4f27799a971d | 22 | bool USBMouse::update(int16_t x, int16_t y, uint8_t button, int8_t z, int8_t h) { |
samux | 1:80ab0d068708 | 23 | switch (mouse_type) { |
samux | 1:80ab0d068708 | 24 | case REL_MOUSE: |
xxann5 | 8:4f27799a971d | 25 | return mouseSend(x, y, button, z, h); |
samux | 1:80ab0d068708 | 26 | case ABS_MOUSE: |
samux | 1:80ab0d068708 | 27 | HID_REPORT report; |
samux | 1:80ab0d068708 | 28 | |
samux | 1:80ab0d068708 | 29 | report.data[0] = x & 0xff; |
samux | 1:80ab0d068708 | 30 | report.data[1] = (x >> 8) & 0xff; |
samux | 1:80ab0d068708 | 31 | report.data[2] = y & 0xff; |
samux | 1:80ab0d068708 | 32 | report.data[3] = (y >> 8) & 0xff; |
samux | 1:80ab0d068708 | 33 | report.data[4] = -z; |
samux | 1:80ab0d068708 | 34 | report.data[5] = button & 0x07; |
samux | 1:80ab0d068708 | 35 | |
samux | 1:80ab0d068708 | 36 | report.length = 6; |
samux | 1:80ab0d068708 | 37 | |
samux | 1:80ab0d068708 | 38 | return send(&report); |
samux | 1:80ab0d068708 | 39 | default: |
samux | 1:80ab0d068708 | 40 | return false; |
samux | 1:80ab0d068708 | 41 | } |
samux | 1:80ab0d068708 | 42 | } |
samux | 1:80ab0d068708 | 43 | |
xxann5 | 8:4f27799a971d | 44 | bool USBMouse::mouseSend(int16_t x, int16_t y, uint8_t buttons, int8_t z, int8_t h) { |
samux | 1:80ab0d068708 | 45 | HID_REPORT report; |
xxann5 | 8:4f27799a971d | 46 | |
xxann5 | 8:4f27799a971d | 47 | report.data[0] = buttons;// & 0x07; |
samux | 1:80ab0d068708 | 48 | |
xxann5 | 8:4f27799a971d | 49 | report.data[1] = (unsigned int) x & 0x00FF; |
xxann5 | 8:4f27799a971d | 50 | report.data[2] = (unsigned int) x >> 8; |
xxann5 | 8:4f27799a971d | 51 | report.data[3] = (unsigned int) y & 0x00FF; |
xxann5 | 8:4f27799a971d | 52 | report.data[4] = (unsigned int) y >> 8; |
xxann5 | 8:4f27799a971d | 53 | report.data[5] = -z; // >0 to scroll down, <0 to scroll up |
xxann5 | 8:4f27799a971d | 54 | report.data[6] = h; |
xxann5 | 8:4f27799a971d | 55 | |
xxann5 | 8:4f27799a971d | 56 | report.length = 7; |
samux | 1:80ab0d068708 | 57 | |
samux | 1:80ab0d068708 | 58 | return send(&report); |
samux | 1:80ab0d068708 | 59 | } |
samux | 1:80ab0d068708 | 60 | |
samux | 1:80ab0d068708 | 61 | bool USBMouse::move(int16_t x, int16_t y) { |
xxann5 | 8:4f27799a971d | 62 | return update(x, y, button, 0, 0); |
samux | 1:80ab0d068708 | 63 | } |
samux | 1:80ab0d068708 | 64 | |
xxann5 | 8:4f27799a971d | 65 | bool USBMouse::scroll(int8_t z, int8_t h) { |
xxann5 | 8:4f27799a971d | 66 | return update(0, 0, button, z, h); |
samux | 1:80ab0d068708 | 67 | } |
samux | 1:80ab0d068708 | 68 | |
samux | 1:80ab0d068708 | 69 | |
samux | 1:80ab0d068708 | 70 | bool USBMouse::doubleClick() { |
samux | 1:80ab0d068708 | 71 | if (!click(MOUSE_LEFT)) |
samux | 1:80ab0d068708 | 72 | return false; |
samux | 1:80ab0d068708 | 73 | wait(0.1); |
samux | 1:80ab0d068708 | 74 | return click(MOUSE_LEFT); |
samux | 1:80ab0d068708 | 75 | } |
samux | 1:80ab0d068708 | 76 | |
samux | 1:80ab0d068708 | 77 | bool USBMouse::click(uint8_t button) { |
xxann5 | 8:4f27799a971d | 78 | if (!update(0, 0, button, 0, 0)) |
samux | 1:80ab0d068708 | 79 | return false; |
samux | 1:80ab0d068708 | 80 | wait(0.01); |
xxann5 | 8:4f27799a971d | 81 | return update(0, 0, 0, 0, 0); |
samux | 1:80ab0d068708 | 82 | } |
samux | 1:80ab0d068708 | 83 | |
samux | 1:80ab0d068708 | 84 | bool USBMouse::press(uint8_t button_) { |
xxann5 | 8:4f27799a971d | 85 | printf("btn_press\n\r"); |
samux | 1:80ab0d068708 | 86 | button = button_ & 0x07; |
xxann5 | 8:4f27799a971d | 87 | return update(0, 0, button, 0, 0); |
samux | 1:80ab0d068708 | 88 | } |
samux | 1:80ab0d068708 | 89 | |
samux | 1:80ab0d068708 | 90 | bool USBMouse::release(uint8_t button_) { |
xxann5 | 8:4f27799a971d | 91 | printf("btn_release\n\r"); |
samux | 1:80ab0d068708 | 92 | button = (button & (~button_)) & 0x07; |
xxann5 | 8:4f27799a971d | 93 | return update(0, 0, button, 0, 0); |
samux | 1:80ab0d068708 | 94 | } |
samux | 1:80ab0d068708 | 95 | |
samux | 1:80ab0d068708 | 96 | |
samux | 1:80ab0d068708 | 97 | uint8_t * USBMouse::reportDesc() { |
samux | 1:80ab0d068708 | 98 | |
samux | 1:80ab0d068708 | 99 | if (mouse_type == REL_MOUSE) { |
xxann5 | 8:4f27799a971d | 100 | // |
xxann5 | 8:4f27799a971d | 101 | // Wheel Mouse - simplified version - 5 button, vertical and horizontal wheel |
xxann5 | 8:4f27799a971d | 102 | // |
xxann5 | 8:4f27799a971d | 103 | // Input report - 5 bytes |
xxann5 | 8:4f27799a971d | 104 | // |
xxann5 | 8:4f27799a971d | 105 | // Byte | D7 D6 D5 D4 D3 D2 D1 D0 |
xxann5 | 8:4f27799a971d | 106 | // ------+--------------------------------------------------------------------- |
xxann5 | 8:4f27799a971d | 107 | // 0 | 0 0 0 Forward Back Middle Right Left (Buttons) |
xxann5 | 8:4f27799a971d | 108 | // 1 | X High |
xxann5 | 8:4f27799a971d | 109 | // 2 | X Low |
xxann5 | 8:4f27799a971d | 110 | // 3 | Y High |
xxann5 | 8:4f27799a971d | 111 | // 4 | Y Low |
xxann5 | 8:4f27799a971d | 112 | // 5 | Vertical Wheel |
xxann5 | 8:4f27799a971d | 113 | // 6 | Horizontal (Tilt) Wheel |
xxann5 | 8:4f27799a971d | 114 | // |
xxann5 | 8:4f27799a971d | 115 | // Feature report - 1 byte |
xxann5 | 8:4f27799a971d | 116 | // |
xxann5 | 8:4f27799a971d | 117 | // Byte | D7 D6 D5 D4 | D3 D2 | D1 D0 |
xxann5 | 8:4f27799a971d | 118 | // ------+------------------------------+--------------+---------------- |
xxann5 | 8:4f27799a971d | 119 | // 0 | 0 0 0 0 | Horizontal | Vertical |
xxann5 | 8:4f27799a971d | 120 | // (Resolution multiplier) |
xxann5 | 8:4f27799a971d | 121 | // |
xxann5 | 8:4f27799a971d | 122 | // Reference |
xxann5 | 8:4f27799a971d | 123 | // Wheel.docx in "Enhanced Wheel Support in Windows Vista" on MS WHDC |
xxann5 | 8:4f27799a971d | 124 | // http://www.microsoft.com/whdc/device/input/wheel.mspx |
xxann5 | 8:4f27799a971d | 125 | // |
samux | 1:80ab0d068708 | 126 | static uint8_t reportDescriptor[] = { |
xxann5 | 8:4f27799a971d | 127 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) |
xxann5 | 8:4f27799a971d | 128 | 0x09, 0x02, // USAGE (Mouse) |
xxann5 | 8:4f27799a971d | 129 | 0xa1, 0x01, // COLLECTION (Application) |
xxann5 | 8:4f27799a971d | 130 | 0x09, 0x02, // USAGE (Mouse) |
xxann5 | 8:4f27799a971d | 131 | 0xa1, 0x02, // COLLECTION (Logical) |
xxann5 | 8:4f27799a971d | 132 | 0x09, 0x01, // USAGE (Pointer) |
xxann5 | 8:4f27799a971d | 133 | 0xa1, 0x00, // COLLECTION (Physical) |
xxann5 | 8:4f27799a971d | 134 | // ------------------------------ Buttons |
xxann5 | 8:4f27799a971d | 135 | 0x05, 0x09, // USAGE_PAGE (Button) |
xxann5 | 8:4f27799a971d | 136 | 0x19, 0x01, // USAGE_MINIMUM (Button 1) |
xxann5 | 8:4f27799a971d | 137 | 0x29, 0x05, // USAGE_MAXIMUM (Button 5) |
xxann5 | 8:4f27799a971d | 138 | 0x15, 0x00, // LOGICAL_MINIMUM (0) |
xxann5 | 8:4f27799a971d | 139 | 0x25, 0x01, // LOGICAL_MAXIMUM (1) |
xxann5 | 8:4f27799a971d | 140 | 0x75, 0x01, // REPORT_SIZE (1) |
xxann5 | 8:4f27799a971d | 141 | 0x95, 0x05, // REPORT_COUNT (5) |
xxann5 | 8:4f27799a971d | 142 | 0x81, 0x02, // INPUT (Data,Var,Abs) |
xxann5 | 8:4f27799a971d | 143 | // ------------------------------ Padding |
xxann5 | 8:4f27799a971d | 144 | 0x75, 0x03, // REPORT_SIZE (3) |
xxann5 | 8:4f27799a971d | 145 | 0x95, 0x01, // REPORT_COUNT (1) |
xxann5 | 8:4f27799a971d | 146 | 0x81, 0x03, // INPUT (Cnst,Var,Abs) |
xxann5 | 8:4f27799a971d | 147 | // ------------------------------ X,Y position |
xxann5 | 8:4f27799a971d | 148 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) |
xxann5 | 8:4f27799a971d | 149 | 0x09, 0x30, // USAGE (X) |
xxann5 | 8:4f27799a971d | 150 | 0x09, 0x31, // USAGE (Y) |
xxann5 | 8:4f27799a971d | 151 | 0x16, 0x00, 0x81, // LOGICAL_MINIMUM (-32768) |
xxann5 | 8:4f27799a971d | 152 | 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767) |
xxann5 | 8:4f27799a971d | 153 | 0x75, 0x10, // REPORT_SIZE (16) |
xxann5 | 8:4f27799a971d | 154 | 0x95, 0x02, // REPORT_COUNT (2) |
xxann5 | 8:4f27799a971d | 155 | 0x81, 0x06, // INPUT (Data,Var,Rel) |
xxann5 | 8:4f27799a971d | 156 | 0xa1, 0x02, // COLLECTION (Logical) |
xxann5 | 8:4f27799a971d | 157 | // ------------------------------ Vertical wheel res multiplier |
xxann5 | 8:4f27799a971d | 158 | 0x09, 0x48, // USAGE (Resolution Multiplier) |
xxann5 | 8:4f27799a971d | 159 | 0x15, 0x00, // LOGICAL_MINIMUM (0) |
xxann5 | 8:4f27799a971d | 160 | 0x25, 0x01, // LOGICAL_MAXIMUM (1) |
xxann5 | 8:4f27799a971d | 161 | 0x35, 0x01, // PHYSICAL_MINIMUM (1) |
xxann5 | 8:4f27799a971d | 162 | 0x45, 0x04, // PHYSICAL_MAXIMUM (4) |
xxann5 | 8:4f27799a971d | 163 | 0x75, 0x02, // REPORT_SIZE (2) |
xxann5 | 8:4f27799a971d | 164 | 0x95, 0x01, // REPORT_COUNT (1) |
xxann5 | 8:4f27799a971d | 165 | 0xa4, // PUSH |
xxann5 | 8:4f27799a971d | 166 | 0xb1, 0x02, // FEATURE (Data,Var,Abs) |
xxann5 | 8:4f27799a971d | 167 | // ------------------------------ Vertical wheel |
xxann5 | 8:4f27799a971d | 168 | 0x09, 0x38, // USAGE (Wheel) |
xxann5 | 8:4f27799a971d | 169 | 0x15, 0x81, // LOGICAL_MINIMUM (-127) |
xxann5 | 8:4f27799a971d | 170 | 0x25, 0x7f, // LOGICAL_MAXIMUM (127) |
xxann5 | 8:4f27799a971d | 171 | 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical |
xxann5 | 8:4f27799a971d | 172 | 0x45, 0x00, // PHYSICAL_MAXIMUM (0) |
xxann5 | 8:4f27799a971d | 173 | 0x75, 0x08, // REPORT_SIZE (8) |
xxann5 | 8:4f27799a971d | 174 | 0x81, 0x06, // INPUT (Data,Var,Rel) |
xxann5 | 8:4f27799a971d | 175 | 0xc0, // END_COLLECTION |
xxann5 | 8:4f27799a971d | 176 | 0xa1, 0x02, // COLLECTION (Logical) |
xxann5 | 8:4f27799a971d | 177 | // ------------------------------ Horizontal wheel res multiplier |
xxann5 | 8:4f27799a971d | 178 | 0x09, 0x48, // USAGE (Resolution Multiplier) |
xxann5 | 8:4f27799a971d | 179 | 0xb4, // POP |
xxann5 | 8:4f27799a971d | 180 | 0xb1, 0x02, // FEATURE (Data,Var,Abs) |
xxann5 | 8:4f27799a971d | 181 | // ------------------------------ Padding for Feature report |
xxann5 | 8:4f27799a971d | 182 | 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical |
xxann5 | 8:4f27799a971d | 183 | 0x45, 0x00, // PHYSICAL_MAXIMUM (0) |
xxann5 | 8:4f27799a971d | 184 | 0x75, 0x04, // REPORT_SIZE (4) |
xxann5 | 8:4f27799a971d | 185 | 0xb1, 0x03, // FEATURE (Cnst,Var,Abs) |
xxann5 | 8:4f27799a971d | 186 | // ------------------------------ Horizontal wheel |
xxann5 | 8:4f27799a971d | 187 | 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) |
xxann5 | 8:4f27799a971d | 188 | 0x0a, 0x38, 0x02, // USAGE (AC Pan) |
xxann5 | 8:4f27799a971d | 189 | 0x15, 0x81, // LOGICAL_MINIMUM (-127) |
xxann5 | 8:4f27799a971d | 190 | 0x25, 0x7f, // LOGICAL_MAXIMUM (127) |
xxann5 | 8:4f27799a971d | 191 | 0x75, 0x08, // REPORT_SIZE (8) |
xxann5 | 8:4f27799a971d | 192 | 0x81, 0x06, // INPUT (Data,Var,Rel) |
xxann5 | 8:4f27799a971d | 193 | 0xc0, // END_COLLECTION |
xxann5 | 8:4f27799a971d | 194 | 0xc0, // END_COLLECTION |
xxann5 | 8:4f27799a971d | 195 | 0xc0, // END_COLLECTION |
xxann5 | 8:4f27799a971d | 196 | 0xc0 // END_COLLECTION |
xxann5 | 8:4f27799a971d | 197 | }; |
samux | 1:80ab0d068708 | 198 | |
samux | 1:80ab0d068708 | 199 | reportLength = sizeof(reportDescriptor); |
samux | 1:80ab0d068708 | 200 | return reportDescriptor; |
samux | 1:80ab0d068708 | 201 | } else if (mouse_type == ABS_MOUSE) { |
samux | 1:80ab0d068708 | 202 | static uint8_t reportDescriptor[] = { |
samux | 1:80ab0d068708 | 203 | |
samux | 1:80ab0d068708 | 204 | USAGE_PAGE(1), 0x01, // Generic Desktop |
samux | 1:80ab0d068708 | 205 | USAGE(1), 0x02, // Mouse |
samux | 1:80ab0d068708 | 206 | COLLECTION(1), 0x01, // Application |
samux | 1:80ab0d068708 | 207 | USAGE(1), 0x01, // Pointer |
samux | 1:80ab0d068708 | 208 | COLLECTION(1), 0x00, // Physical |
samux | 1:80ab0d068708 | 209 | |
samux | 1:80ab0d068708 | 210 | USAGE_PAGE(1), 0x01, // Generic Desktop |
samux | 1:80ab0d068708 | 211 | USAGE(1), 0x30, // X |
samux | 1:80ab0d068708 | 212 | USAGE(1), 0x31, // Y |
samux | 1:80ab0d068708 | 213 | LOGICAL_MINIMUM(1), 0x00, // 0 |
samux | 1:80ab0d068708 | 214 | LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767 |
samux | 1:80ab0d068708 | 215 | REPORT_SIZE(1), 0x10, |
samux | 1:80ab0d068708 | 216 | REPORT_COUNT(1), 0x02, |
samux | 1:80ab0d068708 | 217 | INPUT(1), 0x02, // Data, Variable, Absolute |
samux | 1:80ab0d068708 | 218 | |
samux | 1:80ab0d068708 | 219 | USAGE_PAGE(1), 0x01, // Generic Desktop |
samux | 1:80ab0d068708 | 220 | USAGE(1), 0x38, // scroll |
samux | 1:80ab0d068708 | 221 | LOGICAL_MINIMUM(1), 0x81, // -127 |
samux | 1:80ab0d068708 | 222 | LOGICAL_MAXIMUM(1), 0x7f, // 127 |
samux | 1:80ab0d068708 | 223 | REPORT_SIZE(1), 0x08, |
samux | 1:80ab0d068708 | 224 | REPORT_COUNT(1), 0x01, |
samux | 1:80ab0d068708 | 225 | INPUT(1), 0x06, // Data, Variable, Relative |
samux | 1:80ab0d068708 | 226 | |
samux | 1:80ab0d068708 | 227 | USAGE_PAGE(1), 0x09, // Buttons |
samux | 1:80ab0d068708 | 228 | USAGE_MINIMUM(1), 0x01, |
samux | 1:80ab0d068708 | 229 | USAGE_MAXIMUM(1), 0x03, |
samux | 1:80ab0d068708 | 230 | LOGICAL_MINIMUM(1), 0x00, // 0 |
samux | 1:80ab0d068708 | 231 | LOGICAL_MAXIMUM(1), 0x01, // 1 |
samux | 1:80ab0d068708 | 232 | REPORT_COUNT(1), 0x03, |
samux | 1:80ab0d068708 | 233 | REPORT_SIZE(1), 0x01, |
samux | 1:80ab0d068708 | 234 | INPUT(1), 0x02, // Data, Variable, Absolute |
samux | 1:80ab0d068708 | 235 | REPORT_COUNT(1), 0x01, |
samux | 1:80ab0d068708 | 236 | REPORT_SIZE(1), 0x05, |
samux | 1:80ab0d068708 | 237 | INPUT(1), 0x01, // Constant |
samux | 1:80ab0d068708 | 238 | |
samux | 1:80ab0d068708 | 239 | END_COLLECTION(0), |
samux | 1:80ab0d068708 | 240 | END_COLLECTION(0) |
samux | 1:80ab0d068708 | 241 | }; |
samux | 1:80ab0d068708 | 242 | reportLength = sizeof(reportDescriptor); |
samux | 1:80ab0d068708 | 243 | return reportDescriptor; |
samux | 1:80ab0d068708 | 244 | } |
samux | 1:80ab0d068708 | 245 | return NULL; |
samux | 1:80ab0d068708 | 246 | } |
samux | 1:80ab0d068708 | 247 | |
samux | 1:80ab0d068708 | 248 | #define DEFAULT_CONFIGURATION (1) |
samux | 1:80ab0d068708 | 249 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ |
samux | 1:80ab0d068708 | 250 | + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ |
samux | 1:80ab0d068708 | 251 | + (1 * HID_DESCRIPTOR_LENGTH) \ |
samux | 1:80ab0d068708 | 252 | + (2 * ENDPOINT_DESCRIPTOR_LENGTH)) |
samux | 1:80ab0d068708 | 253 | |
samux | 1:80ab0d068708 | 254 | uint8_t * USBMouse::configurationDesc() { |
samux | 1:80ab0d068708 | 255 | static uint8_t configurationDescriptor[] = { |
samux | 1:80ab0d068708 | 256 | CONFIGURATION_DESCRIPTOR_LENGTH,// bLength |
samux | 1:80ab0d068708 | 257 | CONFIGURATION_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 258 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) |
samux | 1:80ab0d068708 | 259 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) |
samux | 1:80ab0d068708 | 260 | 0x01, // bNumInterfaces |
samux | 1:80ab0d068708 | 261 | DEFAULT_CONFIGURATION, // bConfigurationValue |
samux | 1:80ab0d068708 | 262 | 0x00, // iConfiguration |
samux | 1:80ab0d068708 | 263 | C_RESERVED | C_SELF_POWERED, // bmAttributes |
samux | 1:80ab0d068708 | 264 | C_POWER(0), // bMaxPowerHello World from Mbed |
samux | 1:80ab0d068708 | 265 | |
samux | 1:80ab0d068708 | 266 | INTERFACE_DESCRIPTOR_LENGTH, // bLength |
samux | 1:80ab0d068708 | 267 | INTERFACE_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 268 | 0x00, // bInterfaceNumber |
samux | 1:80ab0d068708 | 269 | 0x00, // bAlternateSetting |
samux | 1:80ab0d068708 | 270 | 0x02, // bNumEndpoints |
samux | 1:80ab0d068708 | 271 | HID_CLASS, // bInterfaceClass |
samux | 1:80ab0d068708 | 272 | 1, // bInterfaceSubClass |
samux | 1:80ab0d068708 | 273 | 2, // bInterfaceProtocol (mouse) |
samux | 1:80ab0d068708 | 274 | 0x00, // iInterface |
samux | 1:80ab0d068708 | 275 | |
samux | 1:80ab0d068708 | 276 | HID_DESCRIPTOR_LENGTH, // bLength |
samux | 1:80ab0d068708 | 277 | HID_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 278 | LSB(HID_VERSION_1_11), // bcdHID (LSB) |
samux | 1:80ab0d068708 | 279 | MSB(HID_VERSION_1_11), // bcdHID (MSB) |
samux | 1:80ab0d068708 | 280 | 0x00, // bCountryCode |
samux | 1:80ab0d068708 | 281 | 0x01, // bNumDescriptors |
samux | 1:80ab0d068708 | 282 | REPORT_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 283 | LSB(reportDescLength()), // wDescriptorLength (LSB) |
samux | 1:80ab0d068708 | 284 | MSB(reportDescLength()), // wDescriptorLength (MSB) |
samux | 1:80ab0d068708 | 285 | |
samux | 1:80ab0d068708 | 286 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
samux | 1:80ab0d068708 | 287 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 288 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
samux | 1:80ab0d068708 | 289 | E_INTERRUPT, // bmAttributes |
samux | 1:80ab0d068708 | 290 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
samux | 1:80ab0d068708 | 291 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
samux | 1:80ab0d068708 | 292 | 1, // bInterval (milliseconds) |
samux | 1:80ab0d068708 | 293 | |
samux | 1:80ab0d068708 | 294 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
samux | 1:80ab0d068708 | 295 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
samux | 1:80ab0d068708 | 296 | PHY_TO_DESC(EPINT_OUT), // bEndpointAddress |
samux | 1:80ab0d068708 | 297 | E_INTERRUPT, // bmAttributes |
samux | 1:80ab0d068708 | 298 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
samux | 1:80ab0d068708 | 299 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
samux | 1:80ab0d068708 | 300 | 1, // bInterval (milliseconds) |
samux | 1:80ab0d068708 | 301 | }; |
samux | 1:80ab0d068708 | 302 | return configurationDescriptor; |
samux | 1:80ab0d068708 | 303 | } |