usb_descriptor.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /*
  2. * Copyright 2012 Jun Wako <wakojun@gmail.com>
  3. * This file is based on:
  4. * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
  5. * LUFA-120219/Demos/Device/Lowlevel/GenericHID
  6. */
  7. /*
  8. LUFA Library
  9. Copyright (C) Dean Camera, 2012.
  10. dean [at] fourwalledcubicle [dot] com
  11. www.lufa-lib.org
  12. */
  13. /*
  14. Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  15. Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
  16. Permission to use, copy, modify, distribute, and sell this
  17. software and its documentation for any purpose is hereby granted
  18. without fee, provided that the above copyright notice appear in
  19. all copies and that both that the copyright notice and this
  20. permission notice and warranty disclaimer appear in supporting
  21. documentation, and that the name of the author not be used in
  22. advertising or publicity pertaining to distribution of the
  23. software without specific, written prior permission.
  24. The author disclaim all warranties with regard to this
  25. software, including all implied warranties of merchantability
  26. and fitness. In no event shall the author be liable for any
  27. special, indirect or consequential damages or any damages
  28. whatsoever resulting from loss of use, data or profits, whether
  29. in an action of contract, negligence or other tortious action,
  30. arising out of or in connection with the use or performance of
  31. this software.
  32. */
  33. #include "util.h"
  34. #include "report.h"
  35. #include "usb_descriptor.h"
  36. /*
  37. * HID report descriptors
  38. */
  39. #ifdef KEYBOARD_SHARED_EP
  40. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  41. #define SHARED_REPORT_STARTED
  42. #else
  43. const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = {
  44. #endif
  45. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  46. HID_RI_USAGE(8, 0x06), // Keyboard
  47. HID_RI_COLLECTION(8, 0x01), // Application
  48. #ifdef KEYBOARD_SHARED_EP
  49. HID_RI_REPORT_ID(8, REPORT_ID_KEYBOARD),
  50. #endif
  51. // Modifiers (8 bits)
  52. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  53. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  54. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  55. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  56. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  57. HID_RI_REPORT_COUNT(8, 0x08),
  58. HID_RI_REPORT_SIZE(8, 0x01),
  59. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  60. // Reserved (1 byte)
  61. HID_RI_REPORT_COUNT(8, 0x01),
  62. HID_RI_REPORT_SIZE(8, 0x08),
  63. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  64. // Keycodes (6 bytes)
  65. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  66. HID_RI_USAGE_MINIMUM(8, 0x00),
  67. HID_RI_USAGE_MAXIMUM(8, 0xFF),
  68. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  69. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  70. HID_RI_REPORT_COUNT(8, 0x06),
  71. HID_RI_REPORT_SIZE(8, 0x08),
  72. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  73. // Status LEDs (5 bits)
  74. HID_RI_USAGE_PAGE(8, 0x08), // LED
  75. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  76. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  77. HID_RI_REPORT_COUNT(8, 0x05),
  78. HID_RI_REPORT_SIZE(8, 0x01),
  79. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  80. // LED padding (3 bits)
  81. HID_RI_REPORT_COUNT(8, 0x01),
  82. HID_RI_REPORT_SIZE(8, 0x03),
  83. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  84. HID_RI_END_COLLECTION(0),
  85. #ifndef KEYBOARD_SHARED_EP
  86. };
  87. #endif
  88. #ifdef MOUSE_ENABLE
  89. #ifndef MOUSE_SHARED_EP
  90. const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = {
  91. #elif !defined(SHARED_REPORT_STARTED)
  92. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  93. #define SHARED_REPORT_STARTED
  94. #endif
  95. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  96. HID_RI_USAGE(8, 0x02), // Mouse
  97. HID_RI_COLLECTION(8, 0x01), // Application
  98. #ifdef MOUSE_SHARED_EP
  99. HID_RI_REPORT_ID(8, REPORT_ID_MOUSE),
  100. #endif
  101. HID_RI_USAGE(8, 0x01), // Pointer
  102. HID_RI_COLLECTION(8, 0x00), // Physical
  103. // Buttons (5 bits)
  104. HID_RI_USAGE_PAGE(8, 0x09), // Button
  105. HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
  106. HID_RI_USAGE_MAXIMUM(8, 0x05), // Button 5
  107. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  108. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  109. HID_RI_REPORT_COUNT(8, 0x05),
  110. HID_RI_REPORT_SIZE(8, 0x01),
  111. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  112. // Button padding (3 bits)
  113. HID_RI_REPORT_COUNT(8, 0x01),
  114. HID_RI_REPORT_SIZE(8, 0x03),
  115. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  116. // X/Y position (2 bytes)
  117. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  118. HID_RI_USAGE(8, 0x30), // X
  119. HID_RI_USAGE(8, 0x31), // Y
  120. HID_RI_LOGICAL_MINIMUM(8, -127),
  121. HID_RI_LOGICAL_MAXIMUM(8, 127),
  122. HID_RI_REPORT_COUNT(8, 0x02),
  123. HID_RI_REPORT_SIZE(8, 0x08),
  124. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  125. // Vertical wheel (1 byte)
  126. HID_RI_USAGE(8, 0x38), // Wheel
  127. HID_RI_LOGICAL_MINIMUM(8, -127),
  128. HID_RI_LOGICAL_MAXIMUM(8, 127),
  129. HID_RI_REPORT_COUNT(8, 0x01),
  130. HID_RI_REPORT_SIZE(8, 0x08),
  131. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  132. // Horizontal wheel (1 byte)
  133. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  134. HID_RI_USAGE(16, 0x0238), // AC Pan
  135. HID_RI_LOGICAL_MINIMUM(8, -127),
  136. HID_RI_LOGICAL_MAXIMUM(8, 127),
  137. HID_RI_REPORT_COUNT(8, 0x01),
  138. HID_RI_REPORT_SIZE(8, 0x08),
  139. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  140. HID_RI_END_COLLECTION(0),
  141. HID_RI_END_COLLECTION(0),
  142. #ifndef MOUSE_SHARED_EP
  143. };
  144. #endif
  145. #endif
  146. #if defined(SHARED_EP_ENABLE) && !defined(SHARED_REPORT_STARTED)
  147. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  148. #endif
  149. #ifdef EXTRAKEY_ENABLE
  150. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  151. HID_RI_USAGE(8, 0x80), // System Control
  152. HID_RI_COLLECTION(8, 0x01), // Application
  153. HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
  154. HID_RI_USAGE_MINIMUM(16, 0x0081), // System Power Down
  155. HID_RI_USAGE_MAXIMUM(16, 0x0083), // System Wake Up
  156. HID_RI_LOGICAL_MINIMUM(16, 0x0001),
  157. HID_RI_LOGICAL_MAXIMUM(16, 0x0003),
  158. HID_RI_REPORT_COUNT(8, 1),
  159. HID_RI_REPORT_SIZE(8, 16),
  160. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  161. HID_RI_END_COLLECTION(0),
  162. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  163. HID_RI_USAGE(8, 0x01), // Consumer Control
  164. HID_RI_COLLECTION(8, 0x01), // Application
  165. HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
  166. HID_RI_USAGE_MINIMUM(16, 0x0001), // Consumer Control
  167. HID_RI_USAGE_MAXIMUM(16, 0x029C), // AC Distribute Vertically
  168. HID_RI_LOGICAL_MINIMUM(16, 0x0001),
  169. HID_RI_LOGICAL_MAXIMUM(16, 0x029C),
  170. HID_RI_REPORT_COUNT(8, 1),
  171. HID_RI_REPORT_SIZE(8, 16),
  172. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  173. HID_RI_END_COLLECTION(0),
  174. #endif
  175. #ifdef NKRO_ENABLE
  176. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  177. HID_RI_USAGE(8, 0x06), // Keyboard
  178. HID_RI_COLLECTION(8, 0x01), // Application
  179. HID_RI_REPORT_ID(8, REPORT_ID_NKRO),
  180. // Modifiers (8 bits)
  181. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  182. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  183. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  184. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  185. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  186. HID_RI_REPORT_COUNT(8, 0x08),
  187. HID_RI_REPORT_SIZE(8, 0x01),
  188. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  189. // Keycodes
  190. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  191. HID_RI_USAGE_MINIMUM(8, 0x00),
  192. HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1),
  193. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  194. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  195. HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8),
  196. HID_RI_REPORT_SIZE(8, 0x01),
  197. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  198. // Status LEDs (5 bits)
  199. HID_RI_USAGE_PAGE(8, 0x08), // LED
  200. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  201. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  202. HID_RI_REPORT_COUNT(8, 0x05),
  203. HID_RI_REPORT_SIZE(8, 0x01),
  204. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  205. // LED padding (3 bits)
  206. HID_RI_REPORT_COUNT(8, 0x01),
  207. HID_RI_REPORT_SIZE(8, 0x03),
  208. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  209. HID_RI_END_COLLECTION(0),
  210. #endif
  211. #ifdef SHARED_EP_ENABLE
  212. };
  213. #endif
  214. #ifdef RAW_ENABLE
  215. const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = {
  216. HID_RI_USAGE_PAGE(16, 0xFF60), // Vendor Defined
  217. HID_RI_USAGE(8, 0x61), // Vendor Defined
  218. HID_RI_COLLECTION(8, 0x01), // Application
  219. // Data to host
  220. HID_RI_USAGE(8, 0x62), // Vendor Defined
  221. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  222. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  223. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  224. HID_RI_REPORT_SIZE(8, 0x08),
  225. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  226. // Data from host
  227. HID_RI_USAGE(8, 0x63), // Vendor Defined
  228. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  229. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  230. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  231. HID_RI_REPORT_SIZE(8, 0x08),
  232. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  233. HID_RI_END_COLLECTION(0),
  234. };
  235. #endif
  236. #ifdef CONSOLE_ENABLE
  237. const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
  238. HID_RI_USAGE_PAGE(16, 0xFF31), // Vendor Defined (PJRC Teensy compatible)
  239. HID_RI_USAGE(8, 0x74), // Vendor Defined (PJRC Teensy compatible)
  240. HID_RI_COLLECTION(8, 0x01), // Application
  241. // Data to host
  242. HID_RI_USAGE(8, 0x75), // Vendor Defined
  243. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  244. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  245. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  246. HID_RI_REPORT_SIZE(8, 0x08),
  247. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  248. // Data from host
  249. HID_RI_USAGE(8, 0x76), // Vendor Defined
  250. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  251. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  252. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  253. HID_RI_REPORT_SIZE(8, 0x08),
  254. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  255. HID_RI_END_COLLECTION(0),
  256. };
  257. #endif
  258. /*
  259. * Device descriptor
  260. */
  261. const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
  262. .Header = {
  263. .Size = sizeof(USB_Descriptor_Device_t),
  264. .Type = DTYPE_Device
  265. },
  266. .USBSpecification = VERSION_BCD(1, 1, 0),
  267. #if VIRTSER_ENABLE
  268. .Class = USB_CSCP_IADDeviceClass,
  269. .SubClass = USB_CSCP_IADDeviceSubclass,
  270. .Protocol = USB_CSCP_IADDeviceProtocol,
  271. #else
  272. .Class = USB_CSCP_NoDeviceClass,
  273. .SubClass = USB_CSCP_NoDeviceSubclass,
  274. .Protocol = USB_CSCP_NoDeviceProtocol,
  275. #endif
  276. .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
  277. // Specified in config.h
  278. .VendorID = VENDOR_ID,
  279. .ProductID = PRODUCT_ID,
  280. .ReleaseNumber = DEVICE_VER,
  281. .ManufacturerStrIndex = 0x01,
  282. .ProductStrIndex = 0x02,
  283. .SerialNumStrIndex = 0x03,
  284. .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
  285. };
  286. #ifndef USB_MAX_POWER_CONSUMPTION
  287. #define USB_MAX_POWER_CONSUMPTION 500
  288. #endif
  289. /*
  290. * Configuration descriptors
  291. */
  292. const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
  293. .Config = {
  294. .Header = {
  295. .Size = sizeof(USB_Descriptor_Configuration_Header_t),
  296. .Type = DTYPE_Configuration
  297. },
  298. .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
  299. .TotalInterfaces = TOTAL_INTERFACES,
  300. .ConfigurationNumber = 1,
  301. .ConfigurationStrIndex = NO_DESCRIPTOR,
  302. .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP),
  303. .MaxPowerConsumption = USB_CONFIG_POWER_MA(USB_MAX_POWER_CONSUMPTION)
  304. },
  305. #ifndef KEYBOARD_SHARED_EP
  306. /*
  307. * Keyboard
  308. */
  309. .Keyboard_Interface = {
  310. .Header = {
  311. .Size = sizeof(USB_Descriptor_Interface_t),
  312. .Type = DTYPE_Interface
  313. },
  314. .InterfaceNumber = KEYBOARD_INTERFACE,
  315. .AlternateSetting = 0x00,
  316. .TotalEndpoints = 1,
  317. .Class = HID_CSCP_HIDClass,
  318. .SubClass = HID_CSCP_BootSubclass,
  319. .Protocol = HID_CSCP_KeyboardBootProtocol,
  320. .InterfaceStrIndex = NO_DESCRIPTOR
  321. },
  322. .Keyboard_HID = {
  323. .Header = {
  324. .Size = sizeof(USB_HID_Descriptor_HID_t),
  325. .Type = HID_DTYPE_HID
  326. },
  327. .HIDSpec = VERSION_BCD(1, 1, 1),
  328. .CountryCode = 0x00,
  329. .TotalReportDescriptors = 1,
  330. .HIDReportType = HID_DTYPE_Report,
  331. .HIDReportLength = sizeof(KeyboardReport)
  332. },
  333. .Keyboard_INEndpoint = {
  334. .Header = {
  335. .Size = sizeof(USB_Descriptor_Endpoint_t),
  336. .Type = DTYPE_Endpoint
  337. },
  338. .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
  339. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  340. .EndpointSize = KEYBOARD_EPSIZE,
  341. .PollingIntervalMS = 0x0A
  342. },
  343. #endif
  344. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  345. /*
  346. * Mouse
  347. */
  348. .Mouse_Interface = {
  349. .Header = {
  350. .Size = sizeof(USB_Descriptor_Interface_t),
  351. .Type = DTYPE_Interface
  352. },
  353. .InterfaceNumber = MOUSE_INTERFACE,
  354. .AlternateSetting = 0x00,
  355. .TotalEndpoints = 1,
  356. .Class = HID_CSCP_HIDClass,
  357. .SubClass = HID_CSCP_BootSubclass,
  358. .Protocol = HID_CSCP_MouseBootProtocol,
  359. .InterfaceStrIndex = NO_DESCRIPTOR
  360. },
  361. .Mouse_HID = {
  362. .Header = {
  363. .Size = sizeof(USB_HID_Descriptor_HID_t),
  364. .Type = HID_DTYPE_HID
  365. },
  366. .HIDSpec = VERSION_BCD(1, 1, 1),
  367. .CountryCode = 0x00,
  368. .TotalReportDescriptors = 1,
  369. .HIDReportType = HID_DTYPE_Report,
  370. .HIDReportLength = sizeof(MouseReport)
  371. },
  372. .Mouse_INEndpoint = {
  373. .Header = {
  374. .Size = sizeof(USB_Descriptor_Endpoint_t),
  375. .Type = DTYPE_Endpoint
  376. },
  377. .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
  378. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  379. .EndpointSize = MOUSE_EPSIZE,
  380. .PollingIntervalMS = 0x0A
  381. },
  382. #endif
  383. #ifdef SHARED_EP_ENABLE
  384. /*
  385. * Shared
  386. */
  387. .Shared_Interface = {
  388. .Header = {
  389. .Size = sizeof(USB_Descriptor_Interface_t),
  390. .Type = DTYPE_Interface
  391. },
  392. .InterfaceNumber = SHARED_INTERFACE,
  393. .AlternateSetting = 0x00,
  394. .TotalEndpoints = 1,
  395. .Class = HID_CSCP_HIDClass,
  396. #ifdef KEYBOARD_SHARED_EP
  397. .SubClass = HID_CSCP_BootSubclass,
  398. .Protocol = HID_CSCP_KeyboardBootProtocol,
  399. #else
  400. .SubClass = HID_CSCP_NonBootSubclass,
  401. .Protocol = HID_CSCP_NonBootProtocol,
  402. #endif
  403. .InterfaceStrIndex = NO_DESCRIPTOR
  404. },
  405. .Shared_HID = {
  406. .Header = {
  407. .Size = sizeof(USB_HID_Descriptor_HID_t),
  408. .Type = HID_DTYPE_HID
  409. },
  410. .HIDSpec = VERSION_BCD(1, 1, 1),
  411. .CountryCode = 0x00,
  412. .TotalReportDescriptors = 1,
  413. .HIDReportType = HID_DTYPE_Report,
  414. .HIDReportLength = sizeof(SharedReport)
  415. },
  416. .Shared_INEndpoint = {
  417. .Header = {
  418. .Size = sizeof(USB_Descriptor_Endpoint_t),
  419. .Type = DTYPE_Endpoint
  420. },
  421. .EndpointAddress = (ENDPOINT_DIR_IN | SHARED_IN_EPNUM),
  422. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  423. .EndpointSize = SHARED_EPSIZE,
  424. .PollingIntervalMS = 0x0A
  425. },
  426. #endif
  427. #ifdef RAW_ENABLE
  428. /*
  429. * Raw HID
  430. */
  431. .Raw_Interface = {
  432. .Header = {
  433. .Size = sizeof(USB_Descriptor_Interface_t),
  434. .Type = DTYPE_Interface
  435. },
  436. .InterfaceNumber = RAW_INTERFACE,
  437. .AlternateSetting = 0x00,
  438. .TotalEndpoints = 2,
  439. .Class = HID_CSCP_HIDClass,
  440. .SubClass = HID_CSCP_NonBootSubclass,
  441. .Protocol = HID_CSCP_NonBootProtocol,
  442. .InterfaceStrIndex = NO_DESCRIPTOR
  443. },
  444. .Raw_HID = {
  445. .Header = {
  446. .Size = sizeof(USB_HID_Descriptor_HID_t),
  447. .Type = HID_DTYPE_HID
  448. },
  449. .HIDSpec = VERSION_BCD(1, 1, 1),
  450. .CountryCode = 0x00,
  451. .TotalReportDescriptors = 1,
  452. .HIDReportType = HID_DTYPE_Report,
  453. .HIDReportLength = sizeof(RawReport)
  454. },
  455. .Raw_INEndpoint = {
  456. .Header = {
  457. .Size = sizeof(USB_Descriptor_Endpoint_t),
  458. .Type = DTYPE_Endpoint
  459. },
  460. .EndpointAddress = (ENDPOINT_DIR_IN | RAW_IN_EPNUM),
  461. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  462. .EndpointSize = RAW_EPSIZE,
  463. .PollingIntervalMS = 0x01
  464. },
  465. .Raw_OUTEndpoint = {
  466. .Header = {
  467. .Size = sizeof(USB_Descriptor_Endpoint_t),
  468. .Type = DTYPE_Endpoint
  469. },
  470. .EndpointAddress = (ENDPOINT_DIR_OUT | RAW_OUT_EPNUM),
  471. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  472. .EndpointSize = RAW_EPSIZE,
  473. .PollingIntervalMS = 0x01
  474. },
  475. #endif
  476. #ifdef CONSOLE_ENABLE
  477. /*
  478. * Console
  479. */
  480. .Console_Interface = {
  481. .Header = {
  482. .Size = sizeof(USB_Descriptor_Interface_t),
  483. .Type = DTYPE_Interface
  484. },
  485. .InterfaceNumber = CONSOLE_INTERFACE,
  486. .AlternateSetting = 0x00,
  487. .TotalEndpoints = 2,
  488. .Class = HID_CSCP_HIDClass,
  489. .SubClass = HID_CSCP_NonBootSubclass,
  490. .Protocol = HID_CSCP_NonBootProtocol,
  491. .InterfaceStrIndex = NO_DESCRIPTOR
  492. },
  493. .Console_HID = {
  494. .Header = {
  495. .Size = sizeof(USB_HID_Descriptor_HID_t),
  496. .Type = HID_DTYPE_HID
  497. },
  498. .HIDSpec = VERSION_BCD(1, 1, 1),
  499. .CountryCode = 0x00,
  500. .TotalReportDescriptors = 1,
  501. .HIDReportType = HID_DTYPE_Report,
  502. .HIDReportLength = sizeof(ConsoleReport)
  503. },
  504. .Console_INEndpoint = {
  505. .Header = {
  506. .Size = sizeof(USB_Descriptor_Endpoint_t),
  507. .Type = DTYPE_Endpoint
  508. },
  509. .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
  510. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  511. .EndpointSize = CONSOLE_EPSIZE,
  512. .PollingIntervalMS = 0x01
  513. },
  514. .Console_OUTEndpoint = {
  515. .Header = {
  516. .Size = sizeof(USB_Descriptor_Endpoint_t),
  517. .Type = DTYPE_Endpoint
  518. },
  519. .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
  520. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  521. .EndpointSize = CONSOLE_EPSIZE,
  522. .PollingIntervalMS = 0x01
  523. },
  524. #endif
  525. #ifdef MIDI_ENABLE
  526. /*
  527. * MIDI
  528. */
  529. .Audio_Interface_Association = {
  530. .Header = {
  531. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  532. .Type = DTYPE_InterfaceAssociation
  533. },
  534. .FirstInterfaceIndex = AC_INTERFACE,
  535. .TotalInterfaces = 2,
  536. .Class = AUDIO_CSCP_AudioClass,
  537. .SubClass = AUDIO_CSCP_ControlSubclass,
  538. .Protocol = AUDIO_CSCP_ControlProtocol,
  539. .IADStrIndex = NO_DESCRIPTOR,
  540. },
  541. .Audio_ControlInterface = {
  542. .Header = {
  543. .Size = sizeof(USB_Descriptor_Interface_t),
  544. .Type = DTYPE_Interface
  545. },
  546. .InterfaceNumber = AC_INTERFACE,
  547. .AlternateSetting = 0,
  548. .TotalEndpoints = 0,
  549. .Class = AUDIO_CSCP_AudioClass,
  550. .SubClass = AUDIO_CSCP_ControlSubclass,
  551. .Protocol = AUDIO_CSCP_ControlProtocol,
  552. .InterfaceStrIndex = NO_DESCRIPTOR
  553. },
  554. .Audio_ControlInterface_SPC = {
  555. .Header = {
  556. .Size = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  557. .Type = DTYPE_CSInterface
  558. },
  559. .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
  560. .ACSpecification = VERSION_BCD(1, 0, 0),
  561. .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  562. .InCollection = 1,
  563. .InterfaceNumber = AS_INTERFACE,
  564. },
  565. .Audio_StreamInterface = {
  566. .Header = {
  567. .Size = sizeof(USB_Descriptor_Interface_t),
  568. .Type = DTYPE_Interface
  569. },
  570. .InterfaceNumber = AS_INTERFACE,
  571. .AlternateSetting = 0,
  572. .TotalEndpoints = 2,
  573. .Class = AUDIO_CSCP_AudioClass,
  574. .SubClass = AUDIO_CSCP_MIDIStreamingSubclass,
  575. .Protocol = AUDIO_CSCP_StreamingProtocol,
  576. .InterfaceStrIndex = NO_DESCRIPTOR
  577. },
  578. .Audio_StreamInterface_SPC = {
  579. .Header = {
  580. .Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t),
  581. .Type = DTYPE_CSInterface
  582. },
  583. .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
  584. .AudioSpecification = VERSION_BCD(1, 0, 0),
  585. .TotalLength = offsetof(USB_Descriptor_Configuration_t, MIDI_Out_Jack_Endpoint_SPC) + sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t) - offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC)
  586. },
  587. .MIDI_In_Jack_Emb = {
  588. .Header = {
  589. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  590. .Type = DTYPE_CSInterface
  591. },
  592. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  593. .JackType = MIDI_JACKTYPE_Embedded,
  594. .JackID = 0x01,
  595. .JackStrIndex = NO_DESCRIPTOR
  596. },
  597. .MIDI_In_Jack_Ext = {
  598. .Header = {
  599. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  600. .Type = DTYPE_CSInterface
  601. },
  602. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  603. .JackType = MIDI_JACKTYPE_External,
  604. .JackID = 0x02,
  605. .JackStrIndex = NO_DESCRIPTOR
  606. },
  607. .MIDI_Out_Jack_Emb = {
  608. .Header = {
  609. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  610. .Type = DTYPE_CSInterface
  611. },
  612. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  613. .JackType = MIDI_JACKTYPE_Embedded,
  614. .JackID = 0x03,
  615. .NumberOfPins = 1,
  616. .SourceJackID = {0x02},
  617. .SourcePinID = {0x01},
  618. .JackStrIndex = NO_DESCRIPTOR
  619. },
  620. .MIDI_Out_Jack_Ext = {
  621. .Header = {
  622. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  623. .Type = DTYPE_CSInterface
  624. },
  625. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  626. .JackType = MIDI_JACKTYPE_External,
  627. .JackID = 0x04,
  628. .NumberOfPins = 1,
  629. .SourceJackID = {0x01},
  630. .SourcePinID = {0x01},
  631. .JackStrIndex = NO_DESCRIPTOR
  632. },
  633. .MIDI_In_Jack_Endpoint = {
  634. .Endpoint = {
  635. .Header = {
  636. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  637. .Type = DTYPE_Endpoint
  638. },
  639. .EndpointAddress = MIDI_STREAM_OUT_EPADDR,
  640. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  641. .EndpointSize = MIDI_STREAM_EPSIZE,
  642. .PollingIntervalMS = 0x05
  643. },
  644. .Refresh = 0,
  645. .SyncEndpointNumber = 0
  646. },
  647. .MIDI_In_Jack_Endpoint_SPC = {
  648. .Header = {
  649. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  650. .Type = DTYPE_CSEndpoint
  651. },
  652. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  653. .TotalEmbeddedJacks = 0x01,
  654. .AssociatedJackID = {0x01}
  655. },
  656. .MIDI_Out_Jack_Endpoint = {
  657. .Endpoint = {
  658. .Header = {
  659. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  660. .Type = DTYPE_Endpoint
  661. },
  662. .EndpointAddress = MIDI_STREAM_IN_EPADDR,
  663. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  664. .EndpointSize = MIDI_STREAM_EPSIZE,
  665. .PollingIntervalMS = 0x05
  666. },
  667. .Refresh = 0,
  668. .SyncEndpointNumber = 0
  669. },
  670. .MIDI_Out_Jack_Endpoint_SPC = {
  671. .Header = {
  672. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  673. .Type = DTYPE_CSEndpoint
  674. },
  675. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  676. .TotalEmbeddedJacks = 0x01,
  677. .AssociatedJackID = {0x03}
  678. },
  679. #endif
  680. #ifdef VIRTSER_ENABLE
  681. /*
  682. * Virtual Serial
  683. */
  684. .CDC_Interface_Association = {
  685. .Header = {
  686. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  687. .Type = DTYPE_InterfaceAssociation
  688. },
  689. .FirstInterfaceIndex = CCI_INTERFACE,
  690. .TotalInterfaces = 2,
  691. .Class = CDC_CSCP_CDCClass,
  692. .SubClass = CDC_CSCP_ACMSubclass,
  693. .Protocol = CDC_CSCP_ATCommandProtocol,
  694. .IADStrIndex = NO_DESCRIPTOR,
  695. },
  696. .CDC_CCI_Interface = {
  697. .Header = {
  698. .Size = sizeof(USB_Descriptor_Interface_t),
  699. .Type = DTYPE_Interface
  700. },
  701. .InterfaceNumber = CCI_INTERFACE,
  702. .AlternateSetting = 0,
  703. .TotalEndpoints = 1,
  704. .Class = CDC_CSCP_CDCClass,
  705. .SubClass = CDC_CSCP_ACMSubclass,
  706. .Protocol = CDC_CSCP_ATCommandProtocol,
  707. .InterfaceStrIndex = NO_DESCRIPTOR
  708. },
  709. .CDC_Functional_Header = {
  710. .Header = {
  711. .Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t),
  712. .Type = DTYPE_CSInterface
  713. },
  714. .Subtype = 0x00,
  715. .CDCSpecification = VERSION_BCD(1, 1, 0),
  716. },
  717. .CDC_Functional_ACM = {
  718. .Header = {
  719. .Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t),
  720. .Type = DTYPE_CSInterface
  721. },
  722. .Subtype = 0x02,
  723. .Capabilities = 0x02,
  724. },
  725. .CDC_Functional_Union = {
  726. .Header = {
  727. .Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t),
  728. .Type = DTYPE_CSInterface
  729. },
  730. .Subtype = 0x06,
  731. .MasterInterfaceNumber = CCI_INTERFACE,
  732. .SlaveInterfaceNumber = CDI_INTERFACE,
  733. },
  734. .CDC_NotificationEndpoint = {
  735. .Header = {
  736. .Size = sizeof(USB_Descriptor_Endpoint_t),
  737. .Type = DTYPE_Endpoint
  738. },
  739. .EndpointAddress = CDC_NOTIFICATION_EPADDR,
  740. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  741. .EndpointSize = CDC_NOTIFICATION_EPSIZE,
  742. .PollingIntervalMS = 0xFF
  743. },
  744. .CDC_DCI_Interface = {
  745. .Header = {
  746. .Size = sizeof(USB_Descriptor_Interface_t),
  747. .Type = DTYPE_Interface
  748. },
  749. .InterfaceNumber = CDI_INTERFACE,
  750. .AlternateSetting = 0,
  751. .TotalEndpoints = 2,
  752. .Class = CDC_CSCP_CDCDataClass,
  753. .SubClass = CDC_CSCP_NoDataSubclass,
  754. .Protocol = CDC_CSCP_NoDataProtocol,
  755. .InterfaceStrIndex = NO_DESCRIPTOR
  756. },
  757. .CDC_DataOutEndpoint = {
  758. .Header = {
  759. .Size = sizeof(USB_Descriptor_Endpoint_t),
  760. .Type = DTYPE_Endpoint
  761. },
  762. .EndpointAddress = CDC_OUT_EPADDR,
  763. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  764. .EndpointSize = CDC_EPSIZE,
  765. .PollingIntervalMS = 0x05
  766. },
  767. .CDC_DataInEndpoint = {
  768. .Header = {
  769. .Size = sizeof(USB_Descriptor_Endpoint_t),
  770. .Type = DTYPE_Endpoint
  771. },
  772. .EndpointAddress = CDC_IN_EPADDR,
  773. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  774. .EndpointSize = CDC_EPSIZE,
  775. .PollingIntervalMS = 0x05
  776. },
  777. #endif
  778. };
  779. /*
  780. * String descriptors
  781. */
  782. const USB_Descriptor_String_t PROGMEM LanguageString = {
  783. .Header = {
  784. .Size = USB_STRING_LEN(1),
  785. .Type = DTYPE_String
  786. },
  787. .UnicodeString = {LANGUAGE_ID_ENG}
  788. };
  789. const USB_Descriptor_String_t PROGMEM ManufacturerString = {
  790. .Header = {
  791. .Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), // Subtract 1 for null terminator
  792. .Type = DTYPE_String
  793. },
  794. .UnicodeString = LSTR(MANUFACTURER)
  795. };
  796. const USB_Descriptor_String_t PROGMEM ProductString = {
  797. .Header = {
  798. .Size = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), // Subtract 1 for null terminator
  799. .Type = DTYPE_String
  800. },
  801. .UnicodeString = LSTR(PRODUCT)
  802. };
  803. #ifndef SERIAL_NUMBER
  804. #define SERIAL_NUMBER 0
  805. #endif
  806. const USB_Descriptor_String_t PROGMEM SerialNumberString = {
  807. .Header = {
  808. .Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
  809. .Type = DTYPE_String
  810. },
  811. .UnicodeString = LSTR(SERIAL_NUMBER)
  812. };
  813. /**
  814. * This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  815. * documentation) by the application code so that the address and size of a requested descriptor can be given
  816. * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
  817. * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
  818. * USB host.
  819. */
  820. uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress) {
  821. const uint8_t DescriptorType = (wValue >> 8);
  822. const uint8_t DescriptorIndex = (wValue & 0xFF);
  823. const void* Address = NULL;
  824. uint16_t Size = NO_DESCRIPTOR;
  825. switch (DescriptorType) {
  826. case DTYPE_Device:
  827. Address = &DeviceDescriptor;
  828. Size = sizeof(USB_Descriptor_Device_t);
  829. break;
  830. case DTYPE_Configuration:
  831. Address = &ConfigurationDescriptor;
  832. Size = sizeof(USB_Descriptor_Configuration_t);
  833. break;
  834. case DTYPE_String:
  835. switch (DescriptorIndex) {
  836. case 0x00:
  837. Address = &LanguageString;
  838. Size = pgm_read_byte(&LanguageString.Header.Size);
  839. break;
  840. case 0x01:
  841. Address = &ManufacturerString;
  842. Size = pgm_read_byte(&ManufacturerString.Header.Size);
  843. break;
  844. case 0x02:
  845. Address = &ProductString;
  846. Size = pgm_read_byte(&ProductString.Header.Size);
  847. break;
  848. case 0x03:
  849. Address = &SerialNumberString;
  850. Size = pgm_read_byte(&SerialNumberString.Header.Size);
  851. break;
  852. }
  853. break;
  854. case HID_DTYPE_HID:
  855. switch (wIndex) {
  856. #ifndef KEYBOARD_SHARED_EP
  857. case KEYBOARD_INTERFACE:
  858. Address = &ConfigurationDescriptor.Keyboard_HID;
  859. Size = sizeof(USB_HID_Descriptor_HID_t);
  860. break;
  861. #endif
  862. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  863. case MOUSE_INTERFACE:
  864. Address = &ConfigurationDescriptor.Mouse_HID;
  865. Size = sizeof(USB_HID_Descriptor_HID_t);
  866. break;
  867. #endif
  868. #ifdef SHARED_EP_ENABLE
  869. case SHARED_INTERFACE:
  870. Address = &ConfigurationDescriptor.Shared_HID;
  871. Size = sizeof(USB_HID_Descriptor_HID_t);
  872. break;
  873. #endif
  874. #ifdef RAW_ENABLE
  875. case RAW_INTERFACE:
  876. Address = &ConfigurationDescriptor.Raw_HID;
  877. Size = sizeof(USB_HID_Descriptor_HID_t);
  878. break;
  879. #endif
  880. #ifdef CONSOLE_ENABLE
  881. case CONSOLE_INTERFACE:
  882. Address = &ConfigurationDescriptor.Console_HID;
  883. Size = sizeof(USB_HID_Descriptor_HID_t);
  884. break;
  885. #endif
  886. }
  887. break;
  888. case HID_DTYPE_Report:
  889. switch (wIndex) {
  890. #ifndef KEYBOARD_SHARED_EP
  891. case KEYBOARD_INTERFACE:
  892. Address = &KeyboardReport;
  893. Size = sizeof(KeyboardReport);
  894. break;
  895. #endif
  896. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  897. case MOUSE_INTERFACE:
  898. Address = &MouseReport;
  899. Size = sizeof(MouseReport);
  900. break;
  901. #endif
  902. #ifdef SHARED_EP_ENABLE
  903. case SHARED_INTERFACE:
  904. Address = &SharedReport;
  905. Size = sizeof(SharedReport);
  906. break;
  907. #endif
  908. #ifdef RAW_ENABLE
  909. case RAW_INTERFACE:
  910. Address = &RawReport;
  911. Size = sizeof(RawReport);
  912. break;
  913. #endif
  914. #ifdef CONSOLE_ENABLE
  915. case CONSOLE_INTERFACE:
  916. Address = &ConsoleReport;
  917. Size = sizeof(ConsoleReport);
  918. break;
  919. #endif
  920. }
  921. break;
  922. }
  923. *DescriptorAddress = Address;
  924. return Size;
  925. }