Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1626 lines
74KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2017 PJRC.COM, LLC.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * 1. The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * 2. If the Software is incorporated into a build system that allows
  17. * selection among a list of target devices, then similar target
  18. * devices manufactured by PJRC.COM must be included in the list of
  19. * target devices and selectable in the same manner.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. //#if F_CPU >= 20000000
  31. #define USB_DESC_LIST_DEFINE
  32. #include "usb_desc.h"
  33. #ifdef NUM_ENDPOINTS
  34. #include "usb_names.h"
  35. #include "imxrt.h"
  36. #include "avr_functions.h"
  37. // USB Descriptors are binary data which the USB host reads to
  38. // automatically detect a USB device's capabilities. The format
  39. // and meaning of every field is documented in numerous USB
  40. // standards. When working with USB descriptors, despite the
  41. // complexity of the standards and poor writing quality in many
  42. // of those documents, remember descriptors are nothing more
  43. // than constant binary data that tells the USB host what the
  44. // device can do. Computers will load drivers based on this data.
  45. // Those drivers then communicate on the endpoints specified by
  46. // the descriptors.
  47. // To configure a new combination of interfaces or make minor
  48. // changes to existing configuration (eg, change the name or ID
  49. // numbers), usually you would edit "usb_desc.h". This file
  50. // is meant to be configured by the header, so generally it is
  51. // only edited to add completely new USB interfaces or features.
  52. // **************************************************************
  53. // USB Device
  54. // **************************************************************
  55. #define LSB(n) ((n) & 255)
  56. #define MSB(n) (((n) >> 8) & 255)
  57. // USB Device Descriptor. The USB host reads this first, to learn
  58. // what type of device is connected.
  59. static uint8_t device_descriptor[] = {
  60. 18, // bLength
  61. 1, // bDescriptorType
  62. 0x00, 0x02, // bcdUSB
  63. #ifdef DEVICE_CLASS
  64. DEVICE_CLASS, // bDeviceClass
  65. #else
  66. 0,
  67. #endif
  68. #ifdef DEVICE_SUBCLASS
  69. DEVICE_SUBCLASS, // bDeviceSubClass
  70. #else
  71. 0,
  72. #endif
  73. #ifdef DEVICE_PROTOCOL
  74. DEVICE_PROTOCOL, // bDeviceProtocol
  75. #else
  76. 0,
  77. #endif
  78. EP0_SIZE, // bMaxPacketSize0
  79. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  80. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  81. #ifdef BCD_DEVICE
  82. LSB(BCD_DEVICE), MSB(BCD_DEVICE), // bcdDevice
  83. #else
  84. // For USB types that don't explicitly define BCD_DEVICE,
  85. // use the minor version number to help teensy_ports
  86. // identify which Teensy model is used.
  87. #if defined(__MKL26Z64__)
  88. 0x73, 0x02,
  89. #elif defined(__MK20DX128__)
  90. 0x74, 0x02,
  91. #elif defined(__MK20DX256__)
  92. 0x75, 0x02,
  93. #elif defined(__MK64FX512__)
  94. 0x76, 0x02,
  95. #elif defined(__MK66FX1M0__)
  96. 0x77, 0x02,
  97. #elif defined(__IMXRT1052__)
  98. 0x78, 0x02, // Teensy 4.0 Beta #1
  99. #else
  100. 0x79, 0x02, // Teensy 4.0 Beta #2
  101. //0x00, 0x02,
  102. #endif
  103. #endif
  104. 1, // iManufacturer
  105. 2, // iProduct
  106. 3, // iSerialNumber
  107. 1 // bNumConfigurations
  108. };
  109. static uint8_t qualifier_descriptor[] = { // 9.6.2 Device_Qualifier, page 264
  110. 10, // bLength
  111. 6, // bDescriptorType
  112. 0x00, 0x02, // bcdUSB
  113. #ifdef DEVICE_CLASS
  114. DEVICE_CLASS, // bDeviceClass
  115. #else
  116. 0,
  117. #endif
  118. #ifdef DEVICE_SUBCLASS
  119. DEVICE_SUBCLASS, // bDeviceSubClass
  120. #else
  121. 0,
  122. #endif
  123. #ifdef DEVICE_PROTOCOL
  124. DEVICE_PROTOCOL, // bDeviceProtocol
  125. #else
  126. 0,
  127. #endif
  128. EP0_SIZE, // bMaxPacketSize0
  129. 1, // bNumConfigurations
  130. 0 // bReserved
  131. };
  132. // These descriptors must NOT be "const", because the USB DMA
  133. // has trouble accessing flash memory with enough bandwidth
  134. // while the processor is executing from flash.
  135. // **************************************************************
  136. // HID Report Descriptors
  137. // **************************************************************
  138. // Each HID interface needs a special report descriptor that tells
  139. // the meaning and format of the data.
  140. #ifdef KEYBOARD_INTERFACE
  141. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  142. static uint8_t keyboard_report_desc[] = {
  143. 0x05, 0x01, // Usage Page (Generic Desktop),
  144. 0x09, 0x06, // Usage (Keyboard),
  145. 0xA1, 0x01, // Collection (Application),
  146. 0x75, 0x01, // Report Size (1),
  147. 0x95, 0x08, // Report Count (8),
  148. 0x05, 0x07, // Usage Page (Key Codes),
  149. 0x19, 0xE0, // Usage Minimum (224),
  150. 0x29, 0xE7, // Usage Maximum (231),
  151. 0x15, 0x00, // Logical Minimum (0),
  152. 0x25, 0x01, // Logical Maximum (1),
  153. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  154. 0x95, 0x01, // Report Count (1),
  155. 0x75, 0x08, // Report Size (8),
  156. 0x81, 0x03, // Input (Constant), ;Reserved byte
  157. 0x95, 0x05, // Report Count (5),
  158. 0x75, 0x01, // Report Size (1),
  159. 0x05, 0x08, // Usage Page (LEDs),
  160. 0x19, 0x01, // Usage Minimum (1),
  161. 0x29, 0x05, // Usage Maximum (5),
  162. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  163. 0x95, 0x01, // Report Count (1),
  164. 0x75, 0x03, // Report Size (3),
  165. 0x91, 0x03, // Output (Constant), ;LED report padding
  166. 0x95, 0x06, // Report Count (6),
  167. 0x75, 0x08, // Report Size (8),
  168. 0x15, 0x00, // Logical Minimum (0),
  169. 0x25, 0x7F, // Logical Maximum(104),
  170. 0x05, 0x07, // Usage Page (Key Codes),
  171. 0x19, 0x00, // Usage Minimum (0),
  172. 0x29, 0x7F, // Usage Maximum (104),
  173. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  174. 0xC0 // End Collection
  175. };
  176. #endif
  177. #ifdef KEYMEDIA_INTERFACE
  178. static uint8_t keymedia_report_desc[] = {
  179. 0x05, 0x0C, // Usage Page (Consumer)
  180. 0x09, 0x01, // Usage (Consumer Controls)
  181. 0xA1, 0x01, // Collection (Application)
  182. 0x75, 0x0A, // Report Size (10)
  183. 0x95, 0x04, // Report Count (4)
  184. 0x19, 0x00, // Usage Minimum (0)
  185. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  186. 0x15, 0x00, // Logical Minimum (0)
  187. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  188. 0x81, 0x00, // Input (Data, Array)
  189. 0x05, 0x01, // Usage Page (Generic Desktop)
  190. 0x75, 0x08, // Report Size (8)
  191. 0x95, 0x03, // Report Count (3)
  192. 0x19, 0x00, // Usage Minimum (0)
  193. 0x29, 0xB7, // Usage Maximum (0xB7)
  194. 0x15, 0x00, // Logical Minimum (0)
  195. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  196. 0x81, 0x00, // Input (Data, Array)
  197. 0xC0 // End Collection
  198. };
  199. #endif
  200. #ifdef MOUSE_INTERFACE
  201. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  202. static uint8_t mouse_report_desc[] = {
  203. 0x05, 0x01, // Usage Page (Generic Desktop)
  204. 0x09, 0x02, // Usage (Mouse)
  205. 0xA1, 0x01, // Collection (Application)
  206. 0x85, 0x01, // REPORT_ID (1)
  207. 0x05, 0x09, // Usage Page (Button)
  208. 0x19, 0x01, // Usage Minimum (Button #1)
  209. 0x29, 0x08, // Usage Maximum (Button #8)
  210. 0x15, 0x00, // Logical Minimum (0)
  211. 0x25, 0x01, // Logical Maximum (1)
  212. 0x95, 0x08, // Report Count (8)
  213. 0x75, 0x01, // Report Size (1)
  214. 0x81, 0x02, // Input (Data, Variable, Absolute)
  215. 0x05, 0x01, // Usage Page (Generic Desktop)
  216. 0x09, 0x30, // Usage (X)
  217. 0x09, 0x31, // Usage (Y)
  218. 0x09, 0x38, // Usage (Wheel)
  219. 0x15, 0x81, // Logical Minimum (-127)
  220. 0x25, 0x7F, // Logical Maximum (127)
  221. 0x75, 0x08, // Report Size (8),
  222. 0x95, 0x03, // Report Count (3),
  223. 0x81, 0x06, // Input (Data, Variable, Relative)
  224. 0x05, 0x0C, // Usage Page (Consumer)
  225. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  226. 0x15, 0x81, // Logical Minimum (-127)
  227. 0x25, 0x7F, // Logical Maximum (127)
  228. 0x75, 0x08, // Report Size (8),
  229. 0x95, 0x01, // Report Count (1),
  230. 0x81, 0x06, // Input (Data, Variable, Relative)
  231. 0xC0, // End Collection
  232. 0x05, 0x01, // Usage Page (Generic Desktop)
  233. 0x09, 0x02, // Usage (Mouse)
  234. 0xA1, 0x01, // Collection (Application)
  235. 0x85, 0x02, // REPORT_ID (2)
  236. 0x05, 0x01, // Usage Page (Generic Desktop)
  237. 0x09, 0x30, // Usage (X)
  238. 0x09, 0x31, // Usage (Y)
  239. 0x15, 0x00, // Logical Minimum (0)
  240. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  241. 0x75, 0x10, // Report Size (16),
  242. 0x95, 0x02, // Report Count (2),
  243. 0x81, 0x02, // Input (Data, Variable, Absolute)
  244. 0xC0 // End Collection
  245. };
  246. #endif
  247. #ifdef JOYSTICK_INTERFACE
  248. #if JOYSTICK_SIZE == 12
  249. static uint8_t joystick_report_desc[] = {
  250. 0x05, 0x01, // Usage Page (Generic Desktop)
  251. 0x09, 0x04, // Usage (Joystick)
  252. 0xA1, 0x01, // Collection (Application)
  253. 0x15, 0x00, // Logical Minimum (0)
  254. 0x25, 0x01, // Logical Maximum (1)
  255. 0x75, 0x01, // Report Size (1)
  256. 0x95, 0x20, // Report Count (32)
  257. 0x05, 0x09, // Usage Page (Button)
  258. 0x19, 0x01, // Usage Minimum (Button #1)
  259. 0x29, 0x20, // Usage Maximum (Button #32)
  260. 0x81, 0x02, // Input (variable,absolute)
  261. 0x15, 0x00, // Logical Minimum (0)
  262. 0x25, 0x07, // Logical Maximum (7)
  263. 0x35, 0x00, // Physical Minimum (0)
  264. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  265. 0x75, 0x04, // Report Size (4)
  266. 0x95, 0x01, // Report Count (1)
  267. 0x65, 0x14, // Unit (20)
  268. 0x05, 0x01, // Usage Page (Generic Desktop)
  269. 0x09, 0x39, // Usage (Hat switch)
  270. 0x81, 0x42, // Input (variable,absolute,null_state)
  271. 0x05, 0x01, // Usage Page (Generic Desktop)
  272. 0x09, 0x01, // Usage (Pointer)
  273. 0xA1, 0x00, // Collection ()
  274. 0x15, 0x00, // Logical Minimum (0)
  275. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  276. 0x75, 0x0A, // Report Size (10)
  277. 0x95, 0x04, // Report Count (4)
  278. 0x09, 0x30, // Usage (X)
  279. 0x09, 0x31, // Usage (Y)
  280. 0x09, 0x32, // Usage (Z)
  281. 0x09, 0x35, // Usage (Rz)
  282. 0x81, 0x02, // Input (variable,absolute)
  283. 0xC0, // End Collection
  284. 0x15, 0x00, // Logical Minimum (0)
  285. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  286. 0x75, 0x0A, // Report Size (10)
  287. 0x95, 0x02, // Report Count (2)
  288. 0x09, 0x36, // Usage (Slider)
  289. 0x09, 0x36, // Usage (Slider)
  290. 0x81, 0x02, // Input (variable,absolute)
  291. 0xC0 // End Collection
  292. };
  293. #elif JOYSTICK_SIZE == 64
  294. // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
  295. // 128 buttons 16
  296. // 6 axes 12
  297. // 17 sliders 34
  298. // 4 pov 2
  299. static uint8_t joystick_report_desc[] = {
  300. 0x05, 0x01, // Usage Page (Generic Desktop)
  301. 0x09, 0x04, // Usage (Joystick)
  302. 0xA1, 0x01, // Collection (Application)
  303. 0x15, 0x00, // Logical Minimum (0)
  304. 0x25, 0x01, // Logical Maximum (1)
  305. 0x75, 0x01, // Report Size (1)
  306. 0x95, 0x80, // Report Count (128)
  307. 0x05, 0x09, // Usage Page (Button)
  308. 0x19, 0x01, // Usage Minimum (Button #1)
  309. 0x29, 0x80, // Usage Maximum (Button #128)
  310. 0x81, 0x02, // Input (variable,absolute)
  311. 0x05, 0x01, // Usage Page (Generic Desktop)
  312. 0x09, 0x01, // Usage (Pointer)
  313. 0xA1, 0x00, // Collection ()
  314. 0x15, 0x00, // Logical Minimum (0)
  315. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  316. 0x75, 0x10, // Report Size (16)
  317. 0x95, 23, // Report Count (23)
  318. 0x09, 0x30, // Usage (X)
  319. 0x09, 0x31, // Usage (Y)
  320. 0x09, 0x32, // Usage (Z)
  321. 0x09, 0x33, // Usage (Rx)
  322. 0x09, 0x34, // Usage (Ry)
  323. 0x09, 0x35, // Usage (Rz)
  324. 0x09, 0x36, // Usage (Slider)
  325. 0x09, 0x36, // Usage (Slider)
  326. 0x09, 0x36, // Usage (Slider)
  327. 0x09, 0x36, // Usage (Slider)
  328. 0x09, 0x36, // Usage (Slider)
  329. 0x09, 0x36, // Usage (Slider)
  330. 0x09, 0x36, // Usage (Slider)
  331. 0x09, 0x36, // Usage (Slider)
  332. 0x09, 0x36, // Usage (Slider)
  333. 0x09, 0x36, // Usage (Slider)
  334. 0x09, 0x36, // Usage (Slider)
  335. 0x09, 0x36, // Usage (Slider)
  336. 0x09, 0x36, // Usage (Slider)
  337. 0x09, 0x36, // Usage (Slider)
  338. 0x09, 0x36, // Usage (Slider)
  339. 0x09, 0x36, // Usage (Slider)
  340. 0x09, 0x36, // Usage (Slider)
  341. 0x81, 0x02, // Input (variable,absolute)
  342. 0xC0, // End Collection
  343. 0x15, 0x00, // Logical Minimum (0)
  344. 0x25, 0x07, // Logical Maximum (7)
  345. 0x35, 0x00, // Physical Minimum (0)
  346. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  347. 0x75, 0x04, // Report Size (4)
  348. 0x95, 0x04, // Report Count (4)
  349. 0x65, 0x14, // Unit (20)
  350. 0x05, 0x01, // Usage Page (Generic Desktop)
  351. 0x09, 0x39, // Usage (Hat switch)
  352. 0x09, 0x39, // Usage (Hat switch)
  353. 0x09, 0x39, // Usage (Hat switch)
  354. 0x09, 0x39, // Usage (Hat switch)
  355. 0x81, 0x42, // Input (variable,absolute,null_state)
  356. 0xC0 // End Collection
  357. };
  358. #endif // JOYSTICK_SIZE
  359. #endif // JOYSTICK_INTERFACE
  360. #ifdef MULTITOUCH_INTERFACE
  361. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  362. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  363. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  364. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  365. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  366. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  367. static uint8_t multitouch_report_desc[] = {
  368. 0x05, 0x0D, // Usage Page (Digitizer)
  369. 0x09, 0x04, // Usage (Touch Screen)
  370. 0xa1, 0x01, // Collection (Application)
  371. 0x09, 0x22, // Usage (Finger)
  372. 0xA1, 0x02, // Collection (Logical)
  373. 0x09, 0x42, // Usage (Tip Switch)
  374. 0x15, 0x00, // Logical Minimum (0)
  375. 0x25, 0x01, // Logical Maximum (1)
  376. 0x75, 0x01, // Report Size (1)
  377. 0x95, 0x01, // Report Count (1)
  378. 0x81, 0x02, // Input (variable,absolute)
  379. 0x09, 0x51, // Usage (Contact Identifier)
  380. 0x25, 0x7F, // Logical Maximum (127)
  381. 0x75, 0x07, // Report Size (7)
  382. 0x95, 0x01, // Report Count (1)
  383. 0x81, 0x02, // Input (variable,absolute)
  384. 0x09, 0x30, // Usage (Pressure)
  385. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  386. 0x75, 0x08, // Report Size (8)
  387. 0x95, 0x01, // Report Count (1)
  388. 0x81, 0x02, // Input (variable,absolute)
  389. 0x05, 0x01, // Usage Page (Generic Desktop)
  390. 0x09, 0x30, // Usage (X)
  391. 0x09, 0x31, // Usage (Y)
  392. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  393. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  394. 0x75, 0x10, // Report Size (16)
  395. 0x95, 0x02, // Report Count (2)
  396. 0x81, 0x02, // Input (variable,absolute)
  397. 0xC0, // End Collection
  398. 0x05, 0x0D, // Usage Page (Digitizer)
  399. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  400. 0x75, 0x10, // Report Size (16)
  401. 0x95, 0x01, // Report Count (1)
  402. 0x09, 0x56, // Usage (Scan Time)
  403. 0x81, 0x02, // Input (variable,absolute)
  404. 0x05, 0x0D, // Usage Page (Digitizers)
  405. 0x09, 0x55, // Usage (Contact Count Maximum)
  406. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  407. 0x75, 0x08, // Report Size (8)
  408. 0x95, 0x01, // Report Count (1)
  409. 0xB1, 0x02, // Feature (variable,absolute)
  410. 0xC0 // End Collection
  411. };
  412. #endif
  413. #ifdef SEREMU_INTERFACE
  414. static uint8_t seremu_report_desc[] = {
  415. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  416. 0x09, 0x04, // Usage 0x04
  417. 0xA1, 0x5C, // Collection 0x5C
  418. 0x75, 0x08, // report size = 8 bits (global)
  419. 0x15, 0x00, // logical minimum = 0 (global)
  420. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  421. 0x95, SEREMU_TX_SIZE, // report count (global)
  422. 0x09, 0x75, // usage (local)
  423. 0x81, 0x02, // Input
  424. 0x95, SEREMU_RX_SIZE, // report count (global)
  425. 0x09, 0x76, // usage (local)
  426. 0x91, 0x02, // Output
  427. 0x95, 0x04, // report count (global)
  428. 0x09, 0x76, // usage (local)
  429. 0xB1, 0x02, // Feature
  430. 0xC0 // end collection
  431. };
  432. #endif
  433. #ifdef RAWHID_INTERFACE
  434. static uint8_t rawhid_report_desc[] = {
  435. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  436. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  437. 0xA1, 0x01, // Collection 0x01
  438. 0x75, 0x08, // report size = 8 bits
  439. 0x15, 0x00, // logical minimum = 0
  440. 0x26, 0xFF, 0x00, // logical maximum = 255
  441. 0x95, RAWHID_TX_SIZE, // report count
  442. 0x09, 0x01, // usage
  443. 0x81, 0x02, // Input (array)
  444. 0x95, RAWHID_RX_SIZE, // report count
  445. 0x09, 0x02, // usage
  446. 0x91, 0x02, // Output (array)
  447. 0xC0 // end collection
  448. };
  449. #endif
  450. #ifdef FLIGHTSIM_INTERFACE
  451. static uint8_t flightsim_report_desc[] = {
  452. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  453. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  454. 0xA1, 0x01, // Collection 0x01
  455. 0x75, 0x08, // report size = 8 bits
  456. 0x15, 0x00, // logical minimum = 0
  457. 0x26, 0xFF, 0x00, // logical maximum = 255
  458. 0x95, FLIGHTSIM_TX_SIZE, // report count
  459. 0x09, 0x01, // usage
  460. 0x81, 0x02, // Input (array)
  461. 0x95, FLIGHTSIM_RX_SIZE, // report count
  462. 0x09, 0x02, // usage
  463. 0x91, 0x02, // Output (array)
  464. 0xC0 // end collection
  465. };
  466. #endif
  467. // **************************************************************
  468. // USB Descriptor Sizes
  469. // **************************************************************
  470. // pre-compute the size and position of everything in the config descriptor
  471. //
  472. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  473. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  474. #ifdef CDC_IAD_DESCRIPTOR
  475. #define CDC_IAD_DESCRIPTOR_SIZE 8
  476. #else
  477. #define CDC_IAD_DESCRIPTOR_SIZE 0
  478. #endif
  479. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  480. #ifdef CDC_DATA_INTERFACE
  481. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  482. #else
  483. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  484. #endif
  485. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  486. #ifdef MIDI_INTERFACE
  487. #if !defined(MIDI_NUM_CABLES) || MIDI_NUM_CABLES < 1 || MIDI_NUM_CABLES > 16
  488. #error "MIDI_NUM_CABLES must be defined between 1 to 16"
  489. #endif
  490. #define MIDI_INTERFACE_DESC_SIZE 9+7+((6+6+9+9)*MIDI_NUM_CABLES)+(9+4+MIDI_NUM_CABLES)*2
  491. #else
  492. #define MIDI_INTERFACE_DESC_SIZE 0
  493. #endif
  494. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  495. #ifdef KEYBOARD_INTERFACE
  496. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  497. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  498. #else
  499. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  500. #endif
  501. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  502. #ifdef MOUSE_INTERFACE
  503. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  504. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  505. #else
  506. #define MOUSE_INTERFACE_DESC_SIZE 0
  507. #endif
  508. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  509. #ifdef RAWHID_INTERFACE
  510. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  511. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  512. #else
  513. #define RAWHID_INTERFACE_DESC_SIZE 0
  514. #endif
  515. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  516. #ifdef FLIGHTSIM_INTERFACE
  517. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  518. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  519. #else
  520. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  521. #endif
  522. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  523. #ifdef SEREMU_INTERFACE
  524. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  525. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  526. #else
  527. #define SEREMU_INTERFACE_DESC_SIZE 0
  528. #endif
  529. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  530. #ifdef JOYSTICK_INTERFACE
  531. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  532. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  533. #else
  534. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  535. #endif
  536. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  537. #ifdef MTP_INTERFACE
  538. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  539. #else
  540. #define MTP_INTERFACE_DESC_SIZE 0
  541. #endif
  542. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  543. #ifdef KEYMEDIA_INTERFACE
  544. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  545. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  546. #else
  547. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  548. #endif
  549. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  550. #ifdef AUDIO_INTERFACE
  551. #define AUDIO_INTERFACE_DESC_SIZE 8 + 9+10+12+9+12+10+9 + 9+9+7+11+9+7 + 9+9+7+11+9+7+9
  552. #else
  553. #define AUDIO_INTERFACE_DESC_SIZE 0
  554. #endif
  555. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  556. #ifdef MULTITOUCH_INTERFACE
  557. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  558. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  559. #else
  560. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  561. #endif
  562. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  563. // **************************************************************
  564. // USB Configuration
  565. // **************************************************************
  566. // USB Configuration Descriptor. This huge descriptor tells all
  567. // of the devices capbilities.
  568. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  569. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  570. 9, // bLength;
  571. 2, // bDescriptorType;
  572. LSB(CONFIG_DESC_SIZE), // wTotalLength
  573. MSB(CONFIG_DESC_SIZE),
  574. NUM_INTERFACE, // bNumInterfaces
  575. 1, // bConfigurationValue
  576. 0, // iConfiguration
  577. 0xC0, // bmAttributes
  578. 50, // bMaxPower
  579. #ifdef CDC_IAD_DESCRIPTOR
  580. // interface association descriptor, USB ECN, Table 9-Z
  581. 8, // bLength
  582. 11, // bDescriptorType
  583. CDC_STATUS_INTERFACE, // bFirstInterface
  584. 2, // bInterfaceCount
  585. 0x02, // bFunctionClass
  586. 0x02, // bFunctionSubClass
  587. 0x01, // bFunctionProtocol
  588. 4, // iFunction
  589. #endif
  590. #ifdef CDC_DATA_INTERFACE
  591. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  592. 9, // bLength
  593. 4, // bDescriptorType
  594. CDC_STATUS_INTERFACE, // bInterfaceNumber
  595. 0, // bAlternateSetting
  596. 1, // bNumEndpoints
  597. 0x02, // bInterfaceClass
  598. 0x02, // bInterfaceSubClass
  599. 0x01, // bInterfaceProtocol
  600. 0, // iInterface
  601. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  602. 5, // bFunctionLength
  603. 0x24, // bDescriptorType
  604. 0x00, // bDescriptorSubtype
  605. 0x10, 0x01, // bcdCDC
  606. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  607. 5, // bFunctionLength
  608. 0x24, // bDescriptorType
  609. 0x01, // bDescriptorSubtype
  610. 0x01, // bmCapabilities
  611. 1, // bDataInterface
  612. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  613. 4, // bFunctionLength
  614. 0x24, // bDescriptorType
  615. 0x02, // bDescriptorSubtype
  616. 0x06, // bmCapabilities
  617. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  618. 5, // bFunctionLength
  619. 0x24, // bDescriptorType
  620. 0x06, // bDescriptorSubtype
  621. CDC_STATUS_INTERFACE, // bMasterInterface
  622. CDC_DATA_INTERFACE, // bSlaveInterface0
  623. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  624. 7, // bLength
  625. 5, // bDescriptorType
  626. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  627. 0x03, // bmAttributes (0x03=intr)
  628. CDC_ACM_SIZE, 0, // wMaxPacketSize
  629. 16, // bInterval
  630. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  631. 9, // bLength
  632. 4, // bDescriptorType
  633. CDC_DATA_INTERFACE, // bInterfaceNumber
  634. 0, // bAlternateSetting
  635. 2, // bNumEndpoints
  636. 0x0A, // bInterfaceClass
  637. 0x00, // bInterfaceSubClass
  638. 0x00, // bInterfaceProtocol
  639. 0, // iInterface
  640. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  641. 7, // bLength
  642. 5, // bDescriptorType
  643. CDC_RX_ENDPOINT, // bEndpointAddress
  644. 0x02, // bmAttributes (0x02=bulk)
  645. CDC_RX_SIZE, 0, // wMaxPacketSize
  646. 0, // bInterval
  647. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  648. 7, // bLength
  649. 5, // bDescriptorType
  650. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  651. 0x02, // bmAttributes (0x02=bulk)
  652. CDC_TX_SIZE, 0, // wMaxPacketSize
  653. 0, // bInterval
  654. #endif // CDC_DATA_INTERFACE
  655. #ifdef MIDI_INTERFACE
  656. // Standard MS Interface Descriptor,
  657. 9, // bLength
  658. 4, // bDescriptorType
  659. MIDI_INTERFACE, // bInterfaceNumber
  660. 0, // bAlternateSetting
  661. 2, // bNumEndpoints
  662. 0x01, // bInterfaceClass (0x01 = Audio)
  663. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  664. 0x00, // bInterfaceProtocol (unused for MIDI)
  665. 0, // iInterface
  666. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  667. 7, // bLength
  668. 0x24, // bDescriptorType = CS_INTERFACE
  669. 0x01, // bDescriptorSubtype = MS_HEADER
  670. 0x00, 0x01, // bcdMSC = revision 01.00
  671. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  672. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  673. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  674. 6, // bLength
  675. 0x24, // bDescriptorType = CS_INTERFACE
  676. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  677. 0x01, // bJackType = EMBEDDED
  678. 1, // bJackID, ID = 1
  679. 0, // iJack
  680. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  681. 6, // bLength
  682. 0x24, // bDescriptorType = CS_INTERFACE
  683. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  684. 0x02, // bJackType = EXTERNAL
  685. 2, // bJackID, ID = 2
  686. 0, // iJack
  687. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  688. 9,
  689. 0x24, // bDescriptorType = CS_INTERFACE
  690. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  691. 0x01, // bJackType = EMBEDDED
  692. 3, // bJackID, ID = 3
  693. 1, // bNrInputPins = 1 pin
  694. 2, // BaSourceID(1) = 2
  695. 1, // BaSourcePin(1) = first pin
  696. 0, // iJack
  697. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  698. 9,
  699. 0x24, // bDescriptorType = CS_INTERFACE
  700. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  701. 0x02, // bJackType = EXTERNAL
  702. 4, // bJackID, ID = 4
  703. 1, // bNrInputPins = 1 pin
  704. 1, // BaSourceID(1) = 1
  705. 1, // BaSourcePin(1) = first pin
  706. 0, // iJack
  707. #if MIDI_NUM_CABLES >= 2
  708. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
  709. 6, 0x24, 0x02, 0x01, (a), 0, \
  710. 6, 0x24, 0x02, 0x02, (b), 0, \
  711. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
  712. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
  713. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  714. #endif
  715. #if MIDI_NUM_CABLES >= 3
  716. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  717. #endif
  718. #if MIDI_NUM_CABLES >= 4
  719. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  720. #endif
  721. #if MIDI_NUM_CABLES >= 5
  722. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
  723. #endif
  724. #if MIDI_NUM_CABLES >= 6
  725. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
  726. #endif
  727. #if MIDI_NUM_CABLES >= 7
  728. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
  729. #endif
  730. #if MIDI_NUM_CABLES >= 8
  731. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
  732. #endif
  733. #if MIDI_NUM_CABLES >= 9
  734. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
  735. #endif
  736. #if MIDI_NUM_CABLES >= 10
  737. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
  738. #endif
  739. #if MIDI_NUM_CABLES >= 11
  740. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
  741. #endif
  742. #if MIDI_NUM_CABLES >= 12
  743. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
  744. #endif
  745. #if MIDI_NUM_CABLES >= 13
  746. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
  747. #endif
  748. #if MIDI_NUM_CABLES >= 14
  749. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
  750. #endif
  751. #if MIDI_NUM_CABLES >= 15
  752. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
  753. #endif
  754. #if MIDI_NUM_CABLES >= 16
  755. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
  756. #endif
  757. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  758. 9, // bLength
  759. 5, // bDescriptorType = ENDPOINT
  760. MIDI_RX_ENDPOINT, // bEndpointAddress
  761. 0x02, // bmAttributes (0x02=bulk)
  762. MIDI_RX_SIZE, 0, // wMaxPacketSize
  763. 0, // bInterval
  764. 0, // bRefresh
  765. 0, // bSynchAddress
  766. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  767. 4+MIDI_NUM_CABLES, // bLength
  768. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  769. 0x01, // bJackType = MS_GENERAL
  770. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  771. 1, // BaAssocJackID(1) = jack ID #1
  772. #if MIDI_NUM_CABLES >= 2
  773. 5,
  774. #endif
  775. #if MIDI_NUM_CABLES >= 3
  776. 9,
  777. #endif
  778. #if MIDI_NUM_CABLES >= 4
  779. 13,
  780. #endif
  781. #if MIDI_NUM_CABLES >= 5
  782. 17,
  783. #endif
  784. #if MIDI_NUM_CABLES >= 6
  785. 21,
  786. #endif
  787. #if MIDI_NUM_CABLES >= 7
  788. 25,
  789. #endif
  790. #if MIDI_NUM_CABLES >= 8
  791. 29,
  792. #endif
  793. #if MIDI_NUM_CABLES >= 9
  794. 33,
  795. #endif
  796. #if MIDI_NUM_CABLES >= 10
  797. 37,
  798. #endif
  799. #if MIDI_NUM_CABLES >= 11
  800. 41,
  801. #endif
  802. #if MIDI_NUM_CABLES >= 12
  803. 45,
  804. #endif
  805. #if MIDI_NUM_CABLES >= 13
  806. 49,
  807. #endif
  808. #if MIDI_NUM_CABLES >= 14
  809. 53,
  810. #endif
  811. #if MIDI_NUM_CABLES >= 15
  812. 57,
  813. #endif
  814. #if MIDI_NUM_CABLES >= 16
  815. 61,
  816. #endif
  817. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  818. 9, // bLength
  819. 5, // bDescriptorType = ENDPOINT
  820. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  821. 0x02, // bmAttributes (0x02=bulk)
  822. MIDI_TX_SIZE, 0, // wMaxPacketSize
  823. 0, // bInterval
  824. 0, // bRefresh
  825. 0, // bSynchAddress
  826. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  827. 4+MIDI_NUM_CABLES, // bLength
  828. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  829. 0x01, // bJackType = MS_GENERAL
  830. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  831. 3, // BaAssocJackID(1) = jack ID #3
  832. #if MIDI_NUM_CABLES >= 2
  833. 7,
  834. #endif
  835. #if MIDI_NUM_CABLES >= 3
  836. 11,
  837. #endif
  838. #if MIDI_NUM_CABLES >= 4
  839. 15,
  840. #endif
  841. #if MIDI_NUM_CABLES >= 5
  842. 19,
  843. #endif
  844. #if MIDI_NUM_CABLES >= 6
  845. 23,
  846. #endif
  847. #if MIDI_NUM_CABLES >= 7
  848. 27,
  849. #endif
  850. #if MIDI_NUM_CABLES >= 8
  851. 31,
  852. #endif
  853. #if MIDI_NUM_CABLES >= 9
  854. 35,
  855. #endif
  856. #if MIDI_NUM_CABLES >= 10
  857. 39,
  858. #endif
  859. #if MIDI_NUM_CABLES >= 11
  860. 43,
  861. #endif
  862. #if MIDI_NUM_CABLES >= 12
  863. 47,
  864. #endif
  865. #if MIDI_NUM_CABLES >= 13
  866. 51,
  867. #endif
  868. #if MIDI_NUM_CABLES >= 14
  869. 55,
  870. #endif
  871. #if MIDI_NUM_CABLES >= 15
  872. 59,
  873. #endif
  874. #if MIDI_NUM_CABLES >= 16
  875. 63,
  876. #endif
  877. #endif // MIDI_INTERFACE
  878. #ifdef KEYBOARD_INTERFACE
  879. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  880. 9, // bLength
  881. 4, // bDescriptorType
  882. KEYBOARD_INTERFACE, // bInterfaceNumber
  883. 0, // bAlternateSetting
  884. 1, // bNumEndpoints
  885. 0x03, // bInterfaceClass (0x03 = HID)
  886. 0x01, // bInterfaceSubClass (0x01 = Boot)
  887. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  888. 0, // iInterface
  889. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  890. 9, // bLength
  891. 0x21, // bDescriptorType
  892. 0x11, 0x01, // bcdHID
  893. 0, // bCountryCode
  894. 1, // bNumDescriptors
  895. 0x22, // bDescriptorType
  896. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  897. MSB(sizeof(keyboard_report_desc)),
  898. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  899. 7, // bLength
  900. 5, // bDescriptorType
  901. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  902. 0x03, // bmAttributes (0x03=intr)
  903. KEYBOARD_SIZE, 0, // wMaxPacketSize
  904. KEYBOARD_INTERVAL, // bInterval
  905. #endif // KEYBOARD_INTERFACE
  906. #ifdef MOUSE_INTERFACE
  907. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  908. 9, // bLength
  909. 4, // bDescriptorType
  910. MOUSE_INTERFACE, // bInterfaceNumber
  911. 0, // bAlternateSetting
  912. 1, // bNumEndpoints
  913. 0x03, // bInterfaceClass (0x03 = HID)
  914. 0x00, // bInterfaceSubClass (0x01 = Boot)
  915. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  916. 0, // iInterface
  917. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  918. 9, // bLength
  919. 0x21, // bDescriptorType
  920. 0x11, 0x01, // bcdHID
  921. 0, // bCountryCode
  922. 1, // bNumDescriptors
  923. 0x22, // bDescriptorType
  924. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  925. MSB(sizeof(mouse_report_desc)),
  926. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  927. 7, // bLength
  928. 5, // bDescriptorType
  929. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  930. 0x03, // bmAttributes (0x03=intr)
  931. MOUSE_SIZE, 0, // wMaxPacketSize
  932. MOUSE_INTERVAL, // bInterval
  933. #endif // MOUSE_INTERFACE
  934. #ifdef RAWHID_INTERFACE
  935. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  936. 9, // bLength
  937. 4, // bDescriptorType
  938. RAWHID_INTERFACE, // bInterfaceNumber
  939. 0, // bAlternateSetting
  940. 2, // bNumEndpoints
  941. 0x03, // bInterfaceClass (0x03 = HID)
  942. 0x00, // bInterfaceSubClass
  943. 0x00, // bInterfaceProtocol
  944. 0, // iInterface
  945. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  946. 9, // bLength
  947. 0x21, // bDescriptorType
  948. 0x11, 0x01, // bcdHID
  949. 0, // bCountryCode
  950. 1, // bNumDescriptors
  951. 0x22, // bDescriptorType
  952. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  953. MSB(sizeof(rawhid_report_desc)),
  954. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  955. 7, // bLength
  956. 5, // bDescriptorType
  957. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  958. 0x03, // bmAttributes (0x03=intr)
  959. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  960. RAWHID_TX_INTERVAL, // bInterval
  961. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  962. 7, // bLength
  963. 5, // bDescriptorType
  964. RAWHID_RX_ENDPOINT, // bEndpointAddress
  965. 0x03, // bmAttributes (0x03=intr)
  966. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  967. RAWHID_RX_INTERVAL, // bInterval
  968. #endif // RAWHID_INTERFACE
  969. #ifdef FLIGHTSIM_INTERFACE
  970. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  971. 9, // bLength
  972. 4, // bDescriptorType
  973. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  974. 0, // bAlternateSetting
  975. 2, // bNumEndpoints
  976. 0x03, // bInterfaceClass (0x03 = HID)
  977. 0x00, // bInterfaceSubClass
  978. 0x00, // bInterfaceProtocol
  979. 0, // iInterface
  980. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  981. 9, // bLength
  982. 0x21, // bDescriptorType
  983. 0x11, 0x01, // bcdHID
  984. 0, // bCountryCode
  985. 1, // bNumDescriptors
  986. 0x22, // bDescriptorType
  987. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  988. MSB(sizeof(flightsim_report_desc)),
  989. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  990. 7, // bLength
  991. 5, // bDescriptorType
  992. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  993. 0x03, // bmAttributes (0x03=intr)
  994. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  995. FLIGHTSIM_TX_INTERVAL, // bInterval
  996. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  997. 7, // bLength
  998. 5, // bDescriptorType
  999. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  1000. 0x03, // bmAttributes (0x03=intr)
  1001. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  1002. FLIGHTSIM_RX_INTERVAL, // bInterval
  1003. #endif // FLIGHTSIM_INTERFACE
  1004. #ifdef SEREMU_INTERFACE
  1005. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1006. 9, // bLength
  1007. 4, // bDescriptorType
  1008. SEREMU_INTERFACE, // bInterfaceNumber
  1009. 0, // bAlternateSetting
  1010. 2, // bNumEndpoints
  1011. 0x03, // bInterfaceClass (0x03 = HID)
  1012. 0x00, // bInterfaceSubClass
  1013. 0x00, // bInterfaceProtocol
  1014. 0, // iInterface
  1015. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1016. 9, // bLength
  1017. 0x21, // bDescriptorType
  1018. 0x11, 0x01, // bcdHID
  1019. 0, // bCountryCode
  1020. 1, // bNumDescriptors
  1021. 0x22, // bDescriptorType
  1022. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  1023. MSB(sizeof(seremu_report_desc)),
  1024. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1025. 7, // bLength
  1026. 5, // bDescriptorType
  1027. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  1028. 0x03, // bmAttributes (0x03=intr)
  1029. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  1030. SEREMU_TX_INTERVAL, // bInterval
  1031. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1032. 7, // bLength
  1033. 5, // bDescriptorType
  1034. SEREMU_RX_ENDPOINT, // bEndpointAddress
  1035. 0x03, // bmAttributes (0x03=intr)
  1036. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  1037. SEREMU_RX_INTERVAL, // bInterval
  1038. #endif // SEREMU_INTERFACE
  1039. #ifdef JOYSTICK_INTERFACE
  1040. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1041. 9, // bLength
  1042. 4, // bDescriptorType
  1043. JOYSTICK_INTERFACE, // bInterfaceNumber
  1044. 0, // bAlternateSetting
  1045. 1, // bNumEndpoints
  1046. 0x03, // bInterfaceClass (0x03 = HID)
  1047. 0x00, // bInterfaceSubClass
  1048. 0x00, // bInterfaceProtocol
  1049. 0, // iInterface
  1050. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1051. 9, // bLength
  1052. 0x21, // bDescriptorType
  1053. 0x11, 0x01, // bcdHID
  1054. 0, // bCountryCode
  1055. 1, // bNumDescriptors
  1056. 0x22, // bDescriptorType
  1057. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  1058. MSB(sizeof(joystick_report_desc)),
  1059. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1060. 7, // bLength
  1061. 5, // bDescriptorType
  1062. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  1063. 0x03, // bmAttributes (0x03=intr)
  1064. JOYSTICK_SIZE, 0, // wMaxPacketSize
  1065. JOYSTICK_INTERVAL, // bInterval
  1066. #endif // JOYSTICK_INTERFACE
  1067. #ifdef MTP_INTERFACE
  1068. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1069. 9, // bLength
  1070. 4, // bDescriptorType
  1071. MTP_INTERFACE, // bInterfaceNumber
  1072. 0, // bAlternateSetting
  1073. 3, // bNumEndpoints
  1074. 0x06, // bInterfaceClass (0x06 = still image)
  1075. 0x01, // bInterfaceSubClass
  1076. 0x01, // bInterfaceProtocol
  1077. 4, // iInterface
  1078. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1079. 7, // bLength
  1080. 5, // bDescriptorType
  1081. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  1082. 0x02, // bmAttributes (0x02=bulk)
  1083. MTP_TX_SIZE, 0, // wMaxPacketSize
  1084. 0, // bInterval
  1085. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1086. 7, // bLength
  1087. 5, // bDescriptorType
  1088. MTP_RX_ENDPOINT, // bEndpointAddress
  1089. 0x02, // bmAttributes (0x02=bulk)
  1090. MTP_RX_SIZE, 0, // wMaxPacketSize
  1091. 0, // bInterval
  1092. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1093. 7, // bLength
  1094. 5, // bDescriptorType
  1095. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  1096. 0x03, // bmAttributes (0x03=intr)
  1097. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  1098. MTP_EVENT_INTERVAL, // bInterval
  1099. #endif // MTP_INTERFACE
  1100. #ifdef KEYMEDIA_INTERFACE
  1101. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1102. 9, // bLength
  1103. 4, // bDescriptorType
  1104. KEYMEDIA_INTERFACE, // bInterfaceNumber
  1105. 0, // bAlternateSetting
  1106. 1, // bNumEndpoints
  1107. 0x03, // bInterfaceClass (0x03 = HID)
  1108. 0x00, // bInterfaceSubClass
  1109. 0x00, // bInterfaceProtocol
  1110. 0, // iInterface
  1111. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1112. 9, // bLength
  1113. 0x21, // bDescriptorType
  1114. 0x11, 0x01, // bcdHID
  1115. 0, // bCountryCode
  1116. 1, // bNumDescriptors
  1117. 0x22, // bDescriptorType
  1118. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  1119. MSB(sizeof(keymedia_report_desc)),
  1120. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1121. 7, // bLength
  1122. 5, // bDescriptorType
  1123. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  1124. 0x03, // bmAttributes (0x03=intr)
  1125. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  1126. KEYMEDIA_INTERVAL, // bInterval
  1127. #endif // KEYMEDIA_INTERFACE
  1128. #ifdef AUDIO_INTERFACE
  1129. // interface association descriptor, USB ECN, Table 9-Z
  1130. 8, // bLength
  1131. 11, // bDescriptorType
  1132. AUDIO_INTERFACE, // bFirstInterface
  1133. 3, // bInterfaceCount
  1134. 0x01, // bFunctionClass
  1135. 0x01, // bFunctionSubClass
  1136. 0x00, // bFunctionProtocol
  1137. 0, // iFunction
  1138. // Standard AudioControl (AC) Interface Descriptor
  1139. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  1140. 9, // bLength
  1141. 4, // bDescriptorType, 4 = INTERFACE
  1142. AUDIO_INTERFACE, // bInterfaceNumber
  1143. 0, // bAlternateSetting
  1144. 0, // bNumEndpoints
  1145. 1, // bInterfaceClass, 1 = AUDIO
  1146. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  1147. 0, // bInterfaceProtocol
  1148. 0, // iInterface
  1149. // Class-specific AC Interface Header Descriptor
  1150. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  1151. 10, // bLength
  1152. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1153. 0x01, // bDescriptorSubtype, 1 = HEADER
  1154. 0x00, 0x01, // bcdADC (version 1.0)
  1155. LSB(62), MSB(62), // wTotalLength
  1156. 2, // bInCollection
  1157. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  1158. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  1159. // Input Terminal Descriptor
  1160. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1161. 12, // bLength
  1162. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1163. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1164. 1, // bTerminalID
  1165. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  1166. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  1167. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1168. 0, // bAssocTerminal, 0 = unidirectional
  1169. 2, // bNrChannels
  1170. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1171. 0, // iChannelNames
  1172. 0, // iTerminal
  1173. // Output Terminal Descriptor
  1174. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1175. 9, // bLength
  1176. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1177. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1178. 2, // bTerminalID
  1179. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1180. 0, // bAssocTerminal, 0 = unidirectional
  1181. 1, // bCSourceID, connected to input terminal, ID=1
  1182. 0, // iTerminal
  1183. // Input Terminal Descriptor
  1184. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1185. 12, // bLength
  1186. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1187. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1188. 3, // bTerminalID
  1189. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1190. 0, // bAssocTerminal, 0 = unidirectional
  1191. 2, // bNrChannels
  1192. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1193. 0, // iChannelNames
  1194. 0, // iTerminal
  1195. // Volume feature descriptor
  1196. 10, // bLength
  1197. 0x24, // bDescriptorType = CS_INTERFACE
  1198. 0x06, // bDescriptorSubType = FEATURE_UNIT
  1199. 0x31, // bUnitID
  1200. 0x03, // bSourceID (Input Terminal)
  1201. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  1202. 0x01, // bmaControls(0) Master: Mute
  1203. 0x02, // bmaControls(1) Left: Volume
  1204. 0x02, // bmaControls(2) Right: Volume
  1205. 0x00, // iFeature
  1206. // Output Terminal Descriptor
  1207. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1208. 9, // bLength
  1209. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1210. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1211. 4, // bTerminalID
  1212. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  1213. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1214. 0, // bAssocTerminal, 0 = unidirectional
  1215. 0x31, // bCSourceID, connected to feature, ID=31
  1216. 0, // iTerminal
  1217. // Standard AS Interface Descriptor
  1218. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1219. // Alternate 0: default setting, disabled zero bandwidth
  1220. 9, // bLenght
  1221. 4, // bDescriptorType = INTERFACE
  1222. AUDIO_INTERFACE+1, // bInterfaceNumber
  1223. 0, // bAlternateSetting
  1224. 0, // bNumEndpoints
  1225. 1, // bInterfaceClass, 1 = AUDIO
  1226. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1227. 0, // bInterfaceProtocol
  1228. 0, // iInterface
  1229. // Alternate 1: streaming data
  1230. 9, // bLenght
  1231. 4, // bDescriptorType = INTERFACE
  1232. AUDIO_INTERFACE+1, // bInterfaceNumber
  1233. 1, // bAlternateSetting
  1234. 1, // bNumEndpoints
  1235. 1, // bInterfaceClass, 1 = AUDIO
  1236. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1237. 0, // bInterfaceProtocol
  1238. 0, // iInterface
  1239. // Class-Specific AS Interface Descriptor
  1240. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1241. 7, // bLength
  1242. 0x24, // bDescriptorType = CS_INTERFACE
  1243. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1244. 2, // bTerminalLink: Terminal ID = 2
  1245. 3, // bDelay (approx 3ms delay, audio lib updates)
  1246. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1247. // Type I Format Descriptor
  1248. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1249. 11, // bLength
  1250. 0x24, // bDescriptorType = CS_INTERFACE
  1251. 2, // bDescriptorSubtype = FORMAT_TYPE
  1252. 1, // bFormatType = FORMAT_TYPE_I
  1253. 2, // bNrChannels = 2
  1254. 2, // bSubFrameSize = 2 byte
  1255. 16, // bBitResolution = 16 bits
  1256. 1, // bSamFreqType = 1 frequency
  1257. LSB(44100), MSB(44100), 0, // tSamFreq
  1258. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1259. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1260. 9, // bLength
  1261. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1262. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1263. 0x09, // bmAttributes = isochronous, adaptive
  1264. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1265. 1, // bInterval, 1 = every frame
  1266. 0, // bRefresh
  1267. 0, // bSynchAddress
  1268. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1269. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1270. 7, // bLength
  1271. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1272. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1273. 0x00, // bmAttributes
  1274. 0, // bLockDelayUnits, 1 = ms
  1275. 0x00, 0x00, // wLockDelay
  1276. // Standard AS Interface Descriptor
  1277. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1278. // Alternate 0: default setting, disabled zero bandwidth
  1279. 9, // bLenght
  1280. 4, // bDescriptorType = INTERFACE
  1281. AUDIO_INTERFACE+2, // bInterfaceNumber
  1282. 0, // bAlternateSetting
  1283. 0, // bNumEndpoints
  1284. 1, // bInterfaceClass, 1 = AUDIO
  1285. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1286. 0, // bInterfaceProtocol
  1287. 0, // iInterface
  1288. // Alternate 1: streaming data
  1289. 9, // bLenght
  1290. 4, // bDescriptorType = INTERFACE
  1291. AUDIO_INTERFACE+2, // bInterfaceNumber
  1292. 1, // bAlternateSetting
  1293. 2, // bNumEndpoints
  1294. 1, // bInterfaceClass, 1 = AUDIO
  1295. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1296. 0, // bInterfaceProtocol
  1297. 0, // iInterface
  1298. // Class-Specific AS Interface Descriptor
  1299. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1300. 7, // bLength
  1301. 0x24, // bDescriptorType = CS_INTERFACE
  1302. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1303. 3, // bTerminalLink: Terminal ID = 3
  1304. 3, // bDelay (approx 3ms delay, audio lib updates)
  1305. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1306. // Type I Format Descriptor
  1307. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1308. 11, // bLength
  1309. 0x24, // bDescriptorType = CS_INTERFACE
  1310. 2, // bDescriptorSubtype = FORMAT_TYPE
  1311. 1, // bFormatType = FORMAT_TYPE_I
  1312. 2, // bNrChannels = 2
  1313. 2, // bSubFrameSize = 2 byte
  1314. 16, // bBitResolution = 16 bits
  1315. 1, // bSamFreqType = 1 frequency
  1316. LSB(44100), MSB(44100), 0, // tSamFreq
  1317. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1318. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1319. 9, // bLength
  1320. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1321. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1322. 0x05, // bmAttributes = isochronous, asynchronous
  1323. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1324. 1, // bInterval, 1 = every frame
  1325. 0, // bRefresh
  1326. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1327. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1328. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1329. 7, // bLength
  1330. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1331. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1332. 0x00, // bmAttributes
  1333. 0, // bLockDelayUnits, 1 = ms
  1334. 0x00, 0x00, // wLockDelay
  1335. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1336. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1337. 9, // bLength
  1338. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1339. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1340. 0x11, // bmAttributes = isochronous, feedback
  1341. 3, 0, // wMaxPacketSize, 3 bytes
  1342. 1, // bInterval, 1 = every frame
  1343. 5, // bRefresh, 5 = 32ms
  1344. 0, // bSynchAddress
  1345. #endif
  1346. #ifdef MULTITOUCH_INTERFACE
  1347. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1348. 9, // bLength
  1349. 4, // bDescriptorType
  1350. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1351. 0, // bAlternateSetting
  1352. 1, // bNumEndpoints
  1353. 0x03, // bInterfaceClass (0x03 = HID)
  1354. 0x00, // bInterfaceSubClass
  1355. 0x00, // bInterfaceProtocol
  1356. 0, // iInterface
  1357. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1358. 9, // bLength
  1359. 0x21, // bDescriptorType
  1360. 0x11, 0x01, // bcdHID
  1361. 0, // bCountryCode
  1362. 1, // bNumDescriptors
  1363. 0x22, // bDescriptorType
  1364. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1365. MSB(sizeof(multitouch_report_desc)),
  1366. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1367. 7, // bLength
  1368. 5, // bDescriptorType
  1369. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1370. 0x03, // bmAttributes (0x03=intr)
  1371. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1372. 1, // bInterval
  1373. #endif // KEYMEDIA_INTERFACE
  1374. };
  1375. // **************************************************************
  1376. // String Descriptors
  1377. // **************************************************************
  1378. // The descriptors above can provide human readable strings,
  1379. // referenced by index numbers. These descriptors are the
  1380. // actual string data
  1381. /* defined in usb_names.h
  1382. struct usb_string_descriptor_struct {
  1383. uint8_t bLength;
  1384. uint8_t bDescriptorType;
  1385. uint16_t wString[];
  1386. };
  1387. */
  1388. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  1389. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  1390. extern struct usb_string_descriptor_struct usb_string_product_name
  1391. __attribute__ ((weak, alias("usb_string_product_name_default")));
  1392. extern struct usb_string_descriptor_struct usb_string_serial_number
  1393. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  1394. struct usb_string_descriptor_struct string0 = {
  1395. 4,
  1396. 3,
  1397. {0x0409}
  1398. };
  1399. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  1400. 2 + MANUFACTURER_NAME_LEN * 2,
  1401. 3,
  1402. MANUFACTURER_NAME
  1403. };
  1404. struct usb_string_descriptor_struct usb_string_product_name_default = {
  1405. 2 + PRODUCT_NAME_LEN * 2,
  1406. 3,
  1407. PRODUCT_NAME
  1408. };
  1409. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  1410. 12,
  1411. 3,
  1412. {0,0,0,0,0,0,0,0,0,0}
  1413. };
  1414. #ifdef MTP_INTERFACE
  1415. struct usb_string_descriptor_struct usb_string_mtp = {
  1416. 2 + 3 * 2,
  1417. 3,
  1418. {'M','T','P'}
  1419. };
  1420. #endif
  1421. void usb_init_serialnumber(void)
  1422. {
  1423. #if 1
  1424. char buf[11];
  1425. uint32_t i, num;
  1426. num = HW_OCOTP_MAC0 & 0xFFFFFF;
  1427. // add extra zero to work around OS-X CDC-ACM driver bug
  1428. if (num < 10000000) num = num * 10;
  1429. ultoa(num, buf, 10);
  1430. for (i=0; i<10; i++) {
  1431. char c = buf[i];
  1432. if (!c) break;
  1433. usb_string_serial_number_default.wString[i] = c;
  1434. }
  1435. usb_string_serial_number_default.bLength = i * 2 + 2;
  1436. #else
  1437. usb_string_serial_number_default.wString[0] = '1';
  1438. usb_string_serial_number_default.wString[1] = '2';
  1439. usb_string_serial_number_default.wString[2] = '3';
  1440. usb_string_serial_number_default.bLength = 3 * 2 + 2;
  1441. #endif
  1442. }
  1443. // **************************************************************
  1444. // Descriptors List
  1445. // **************************************************************
  1446. // This table provides access to all the descriptor data above.
  1447. const usb_descriptor_list_t usb_descriptor_list[] = {
  1448. //wValue, wIndex, address, length
  1449. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  1450. {0x0600, 0x0000, qualifier_descriptor, sizeof(qualifier_descriptor)},
  1451. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  1452. {0x0700, 0x0000, config_descriptor, sizeof(config_descriptor)},
  1453. #ifdef SEREMU_INTERFACE
  1454. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  1455. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  1456. #endif
  1457. #ifdef KEYBOARD_INTERFACE
  1458. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  1459. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  1460. #endif
  1461. #ifdef MOUSE_INTERFACE
  1462. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  1463. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  1464. #endif
  1465. #ifdef JOYSTICK_INTERFACE
  1466. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  1467. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  1468. #endif
  1469. #ifdef RAWHID_INTERFACE
  1470. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  1471. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  1472. #endif
  1473. #ifdef FLIGHTSIM_INTERFACE
  1474. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  1475. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  1476. #endif
  1477. #ifdef KEYMEDIA_INTERFACE
  1478. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  1479. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  1480. #endif
  1481. #ifdef MULTITOUCH_INTERFACE
  1482. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  1483. {0x2100, MULTITOUCH_INTERFACE, config_descriptor+MULTITOUCH_HID_DESC_OFFSET, 9},
  1484. #endif
  1485. #ifdef MTP_INTERFACE
  1486. {0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
  1487. #endif
  1488. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  1489. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  1490. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  1491. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  1492. {0, 0, NULL, 0}
  1493. };
  1494. // **************************************************************
  1495. // Endpoint Configuration
  1496. // **************************************************************
  1497. #if 0
  1498. // 0x00 = not used
  1499. // 0x19 = Recieve only
  1500. // 0x15 = Transmit only
  1501. // 0x1D = Transmit & Recieve
  1502. //
  1503. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1504. {
  1505. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  1506. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1507. };
  1508. #endif
  1509. const uint32_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1510. {
  1511. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  1512. ENDPOINT1_CONFIG,
  1513. #elif (NUM_ENDPOINTS >= 1)
  1514. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1515. #endif
  1516. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  1517. ENDPOINT2_CONFIG,
  1518. #elif (NUM_ENDPOINTS >= 2)
  1519. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1520. #endif
  1521. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  1522. ENDPOINT3_CONFIG,
  1523. #elif (NUM_ENDPOINTS >= 3)
  1524. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1525. #endif
  1526. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  1527. ENDPOINT4_CONFIG,
  1528. #elif (NUM_ENDPOINTS >= 4)
  1529. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1530. #endif
  1531. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  1532. ENDPOINT5_CONFIG,
  1533. #elif (NUM_ENDPOINTS >= 5)
  1534. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1535. #endif
  1536. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  1537. ENDPOINT6_CONFIG,
  1538. #elif (NUM_ENDPOINTS >= 6)
  1539. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1540. #endif
  1541. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  1542. ENDPOINT7_CONFIG,
  1543. #elif (NUM_ENDPOINTS >= 7)
  1544. ENDPOINT_TRANSMIT_UNUSED + ENDPOINT_RECEIVE_UNUSED,
  1545. #endif
  1546. };
  1547. #endif // NUM_ENDPOINTS
  1548. //#endif // F_CPU >= 20 MHz