USBDevice for STM support
Dependents: Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more
This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).
USBHID/USBMouse.cpp@4:50ec00aa4515, 2017-03-28 (annotated)
- Committer:
- frq08711@LMECWL0871.LME.ST.COM
- Date:
- Tue Mar 28 11:00:57 2017 +0200
- Branch:
- master
- Revision:
- 4:50ec00aa4515
- Parent:
- 1:2a3ae13b45ef
update for 5.4.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 2 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 7 | * Software is furnished to do so, subject to the following conditions: |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 8 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 10 | * substantial portions of the Software. |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 11 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 17 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 18 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 19 | #include "stdint.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 20 | #include "USBMouse.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 21 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 22 | bool USBMouse::update(int16_t x, int16_t y, uint8_t button, int8_t z) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 23 | switch (mouse_type) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 24 | case REL_MOUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 25 | while (x > 127) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 26 | if (!mouseSend(127, 0, button, z)) return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 27 | x = x - 127; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 28 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 29 | while (x < -128) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 30 | if (!mouseSend(-128, 0, button, z)) return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 31 | x = x + 128; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 32 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 33 | while (y > 127) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 34 | if (!mouseSend(0, 127, button, z)) return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 35 | y = y - 127; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 36 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 37 | while (y < -128) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 38 | if (!mouseSend(0, -128, button, z)) return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 39 | y = y + 128; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 40 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 41 | return mouseSend(x, y, button, z); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 42 | case ABS_MOUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 43 | HID_REPORT report; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 44 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 45 | report.data[0] = x & 0xff; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 46 | report.data[1] = (x >> 8) & 0xff; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 47 | report.data[2] = y & 0xff; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 48 | report.data[3] = (y >> 8) & 0xff; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 49 | report.data[4] = -z; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 50 | report.data[5] = button & 0x07; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 51 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 52 | report.length = 6; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 53 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 54 | return send(&report); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 55 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 56 | return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 57 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 58 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 59 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 60 | bool USBMouse::mouseSend(int8_t x, int8_t y, uint8_t buttons, int8_t z) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 61 | HID_REPORT report; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 62 | report.data[0] = buttons & 0x07; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 63 | report.data[1] = x; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 64 | report.data[2] = y; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 65 | report.data[3] = -z; // >0 to scroll down, <0 to scroll up |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 66 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 67 | report.length = 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 68 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 69 | return send(&report); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 70 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 71 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 72 | bool USBMouse::move(int16_t x, int16_t y) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 73 | return update(x, y, button, 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 74 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 75 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 76 | bool USBMouse::scroll(int8_t z) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 77 | return update(0, 0, button, z); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 78 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 79 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 80 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 81 | bool USBMouse::doubleClick() { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 82 | if (!click(MOUSE_LEFT)) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 83 | return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 84 | wait(0.1); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 85 | return click(MOUSE_LEFT); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 86 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 87 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 88 | bool USBMouse::click(uint8_t button) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 89 | if (!update(0, 0, button, 0)) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 90 | return false; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 91 | wait(0.01); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 92 | return update(0, 0, 0, 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 93 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 94 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 95 | bool USBMouse::press(uint8_t button_) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 96 | button = button_ & 0x07; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 97 | return update(0, 0, button, 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 98 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 99 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 100 | bool USBMouse::release(uint8_t button_) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 101 | button = (button & (~button_)) & 0x07; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 102 | return update(0, 0, button, 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 103 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 104 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 105 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 106 | uint8_t * USBMouse::reportDesc() { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 107 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 108 | if (mouse_type == REL_MOUSE) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 109 | static uint8_t reportDescriptor[] = { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 110 | USAGE_PAGE(1), 0x01, // Genric Desktop |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 111 | USAGE(1), 0x02, // Mouse |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 112 | COLLECTION(1), 0x01, // Application |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 113 | USAGE(1), 0x01, // Pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 114 | COLLECTION(1), 0x00, // Physical |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 115 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 116 | REPORT_COUNT(1), 0x03, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 117 | REPORT_SIZE(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 118 | USAGE_PAGE(1), 0x09, // Buttons |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 119 | USAGE_MINIMUM(1), 0x1, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 120 | USAGE_MAXIMUM(1), 0x3, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 121 | LOGICAL_MINIMUM(1), 0x00, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 122 | LOGICAL_MAXIMUM(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 123 | INPUT(1), 0x02, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 124 | REPORT_COUNT(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 125 | REPORT_SIZE(1), 0x05, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 126 | INPUT(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 127 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 128 | REPORT_COUNT(1), 0x03, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 129 | REPORT_SIZE(1), 0x08, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 130 | USAGE_PAGE(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 131 | USAGE(1), 0x30, // X |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 132 | USAGE(1), 0x31, // Y |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 133 | USAGE(1), 0x38, // scroll |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 134 | LOGICAL_MINIMUM(1), 0x81, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 135 | LOGICAL_MAXIMUM(1), 0x7f, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 136 | INPUT(1), 0x06, // Relative data |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 137 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 138 | END_COLLECTION(0), |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 139 | END_COLLECTION(0), |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 140 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 141 | reportLength = sizeof(reportDescriptor); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 142 | return reportDescriptor; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 143 | } else if (mouse_type == ABS_MOUSE) { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 144 | static uint8_t reportDescriptor[] = { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 145 | USAGE_PAGE(1), 0x01, // Generic Desktop |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 146 | USAGE(1), 0x02, // Mouse |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 147 | COLLECTION(1), 0x01, // Application |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 148 | USAGE(1), 0x01, // Pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 149 | COLLECTION(1), 0x00, // Physical |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 150 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 151 | USAGE_PAGE(1), 0x01, // Generic Desktop |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 152 | USAGE(1), 0x30, // X |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 153 | USAGE(1), 0x31, // Y |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 154 | LOGICAL_MINIMUM(1), 0x00, // 0 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 155 | LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 156 | REPORT_SIZE(1), 0x10, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 157 | REPORT_COUNT(1), 0x02, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 158 | INPUT(1), 0x02, // Data, Variable, Absolute |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 159 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 160 | USAGE_PAGE(1), 0x01, // Generic Desktop |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 161 | USAGE(1), 0x38, // scroll |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 162 | LOGICAL_MINIMUM(1), 0x81, // -127 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 163 | LOGICAL_MAXIMUM(1), 0x7f, // 127 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 164 | REPORT_SIZE(1), 0x08, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 165 | REPORT_COUNT(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 166 | INPUT(1), 0x06, // Data, Variable, Relative |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 167 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 168 | USAGE_PAGE(1), 0x09, // Buttons |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 169 | USAGE_MINIMUM(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 170 | USAGE_MAXIMUM(1), 0x03, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 171 | LOGICAL_MINIMUM(1), 0x00, // 0 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 172 | LOGICAL_MAXIMUM(1), 0x01, // 1 |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 173 | REPORT_COUNT(1), 0x03, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 174 | REPORT_SIZE(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 175 | INPUT(1), 0x02, // Data, Variable, Absolute |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 176 | REPORT_COUNT(1), 0x01, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 177 | REPORT_SIZE(1), 0x05, |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 178 | INPUT(1), 0x01, // Constant |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 179 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 180 | END_COLLECTION(0), |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 181 | END_COLLECTION(0) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 182 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 183 | reportLength = sizeof(reportDescriptor); |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 184 | return reportDescriptor; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 185 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 186 | return NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 187 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 188 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 189 | #define DEFAULT_CONFIGURATION (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 190 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 191 | + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 192 | + (1 * HID_DESCRIPTOR_LENGTH) \ |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 193 | + (2 * ENDPOINT_DESCRIPTOR_LENGTH)) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 194 | |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 195 | uint8_t * USBMouse::configurationDesc() { |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 196 | static uint8_t configurationDescriptor[] = { |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 197 | CONFIGURATION_DESCRIPTOR_LENGTH, // bLength |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 198 | CONFIGURATION_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 199 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 200 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 201 | 0x01, // bNumInterfaces |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 202 | DEFAULT_CONFIGURATION, // bConfigurationValue |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 203 | 0x00, // iConfiguration |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 204 | C_RESERVED | C_SELF_POWERED, // bmAttributes |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 205 | C_POWER(0), // bMaxPower |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 206 | |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 207 | INTERFACE_DESCRIPTOR_LENGTH, // bLength |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 208 | INTERFACE_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 209 | 0x00, // bInterfaceNumber |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 210 | 0x00, // bAlternateSetting |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 211 | 0x02, // bNumEndpoints |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 212 | HID_CLASS, // bInterfaceClass |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 213 | HID_SUBCLASS_BOOT, // bInterfaceSubClass |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 214 | HID_PROTOCOL_MOUSE, // bInterfaceProtocol |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 215 | 0x00, // iInterface |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 216 | |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 217 | HID_DESCRIPTOR_LENGTH, // bLength |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 218 | HID_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 219 | LSB(HID_VERSION_1_11), // bcdHID (LSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 220 | MSB(HID_VERSION_1_11), // bcdHID (MSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 221 | 0x00, // bCountryCode |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 222 | 0x01, // bNumDescriptors |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 223 | REPORT_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 224 | (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 225 | (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 226 | |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 227 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 228 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 229 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 230 | E_INTERRUPT, // bmAttributes |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 231 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 232 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 233 | 1, // bInterval (milliseconds) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 234 | |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 235 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 236 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 237 | PHY_TO_DESC(EPINT_OUT), // bEndpointAddress |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 238 | E_INTERRUPT, // bmAttributes |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 239 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 240 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
frq08711@LMECWL0871.LME.ST.COM | 4:50ec00aa4515 | 241 | 1, // bInterval (milliseconds) |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 242 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 243 | return configurationDescriptor; |
frq08711@LMECWL0871.LME.ST.COM | 1:2a3ae13b45ef | 244 | } |