usb_descriptor.c 37 KB

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