Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

descriptor.c 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*
  2. * Copyright 2012 Jun Wako <[email protected]>
  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 "descriptor.h"
  36. /*******************************************************************************
  37. * HID Report Descriptors
  38. ******************************************************************************/
  39. const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
  40. {
  41. HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
  42. HID_RI_USAGE(8, 0x06), /* Keyboard */
  43. HID_RI_COLLECTION(8, 0x01), /* Application */
  44. HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
  45. HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
  46. HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
  47. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  48. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  49. HID_RI_REPORT_SIZE(8, 0x01),
  50. HID_RI_REPORT_COUNT(8, 0x08),
  51. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  52. HID_RI_REPORT_COUNT(8, 0x01),
  53. HID_RI_REPORT_SIZE(8, 0x08),
  54. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  55. HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
  56. HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
  57. HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
  58. HID_RI_REPORT_COUNT(8, 0x05),
  59. HID_RI_REPORT_SIZE(8, 0x01),
  60. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  61. HID_RI_REPORT_COUNT(8, 0x01),
  62. HID_RI_REPORT_SIZE(8, 0x03),
  63. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  64. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  65. HID_RI_LOGICAL_MAXIMUM(8, 0x65),
  66. HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
  67. HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
  68. HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
  69. HID_RI_REPORT_COUNT(8, 0x06),
  70. HID_RI_REPORT_SIZE(8, 0x08),
  71. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  72. HID_RI_END_COLLECTION(0),
  73. };
  74. const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
  75. {
  76. HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
  77. HID_RI_USAGE(8, 0x02), /* Mouse */
  78. HID_RI_COLLECTION(8, 0x01), /* Application */
  79. HID_RI_USAGE(8, 0x01), /* Pointer */
  80. HID_RI_COLLECTION(8, 0x00), /* Physical */
  81. HID_RI_USAGE_PAGE(8, 0x09), /* Button */
  82. HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */
  83. HID_RI_USAGE_MAXIMUM(8, 0x05), /* Button 5 */
  84. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  85. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  86. HID_RI_REPORT_COUNT(8, 0x05),
  87. HID_RI_REPORT_SIZE(8, 0x01),
  88. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  89. HID_RI_REPORT_COUNT(8, 0x01),
  90. HID_RI_REPORT_SIZE(8, 0x03),
  91. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  92. HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
  93. HID_RI_USAGE(8, 0x30), /* Usage X */
  94. HID_RI_USAGE(8, 0x31), /* Usage Y */
  95. HID_RI_LOGICAL_MINIMUM(8, -127),
  96. HID_RI_LOGICAL_MAXIMUM(8, 127),
  97. HID_RI_REPORT_COUNT(8, 0x02),
  98. HID_RI_REPORT_SIZE(8, 0x08),
  99. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  100. HID_RI_USAGE(8, 0x38), /* Wheel */
  101. HID_RI_LOGICAL_MINIMUM(8, -127),
  102. HID_RI_LOGICAL_MAXIMUM(8, 127),
  103. HID_RI_REPORT_COUNT(8, 0x01),
  104. HID_RI_REPORT_SIZE(8, 0x08),
  105. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  106. HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */
  107. HID_RI_USAGE(16, 0x0238), /* AC Pan (Horizontal wheel) */
  108. HID_RI_LOGICAL_MINIMUM(8, -127),
  109. HID_RI_LOGICAL_MAXIMUM(8, 127),
  110. HID_RI_REPORT_COUNT(8, 0x01),
  111. HID_RI_REPORT_SIZE(8, 0x08),
  112. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  113. HID_RI_END_COLLECTION(0),
  114. HID_RI_END_COLLECTION(0),
  115. };
  116. const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
  117. {
  118. HID_RI_USAGE_PAGE(16, 0xFF00), /* Vendor Page 0 */
  119. HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */
  120. HID_RI_COLLECTION(8, 0x01), /* Application */
  121. HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
  122. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  123. HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
  124. HID_RI_REPORT_SIZE(8, 0x08),
  125. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  126. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  127. HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
  128. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  129. HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
  130. HID_RI_REPORT_SIZE(8, 0x08),
  131. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  132. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  133. HID_RI_END_COLLECTION(0),
  134. };
  135. const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] =
  136. {
  137. HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
  138. HID_RI_USAGE(8, 0x80), /* System Control */
  139. HID_RI_COLLECTION(8, 0x01), /* Application */
  140. HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
  141. HID_RI_LOGICAL_MINIMUM(16, 0x0081),
  142. HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
  143. HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */
  144. HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */
  145. HID_RI_REPORT_SIZE(8, 16),
  146. HID_RI_REPORT_COUNT(8, 1),
  147. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  148. HID_RI_END_COLLECTION(0),
  149. HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */
  150. HID_RI_USAGE(8, 0x01), /* Consumer Control */
  151. HID_RI_COLLECTION(8, 0x01), /* Application */
  152. HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
  153. HID_RI_LOGICAL_MINIMUM(16, 0x0010),
  154. HID_RI_LOGICAL_MAXIMUM(16, 0x029C),
  155. HID_RI_USAGE_MINIMUM(16, 0x0010), /* +10 */
  156. HID_RI_USAGE_MAXIMUM(16, 0x029C), /* AC Distribute Vertically */
  157. HID_RI_REPORT_SIZE(8, 16),
  158. HID_RI_REPORT_COUNT(8, 1),
  159. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  160. HID_RI_END_COLLECTION(0),
  161. };
  162. /*******************************************************************************
  163. * Device Descriptors
  164. ******************************************************************************/
  165. const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
  166. {
  167. .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
  168. .USBSpecification = VERSION_BCD(01.10),
  169. .Class = USB_CSCP_NoDeviceClass,
  170. .SubClass = USB_CSCP_NoDeviceSubclass,
  171. .Protocol = USB_CSCP_NoDeviceProtocol,
  172. .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
  173. .VendorID = VENDOR_ID,
  174. .ProductID = PRODUCT_ID,
  175. .ReleaseNumber = DEVICE_VER,
  176. .ManufacturerStrIndex = 0x01,
  177. .ProductStrIndex = 0x02,
  178. .SerialNumStrIndex = NO_DESCRIPTOR,
  179. .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
  180. };
  181. /*******************************************************************************
  182. * Configuration Descriptors
  183. ******************************************************************************/
  184. const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
  185. {
  186. .Config =
  187. {
  188. .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
  189. .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
  190. .TotalInterfaces = TOTAL_INTERFACES,
  191. .ConfigurationNumber = 1,
  192. .ConfigurationStrIndex = NO_DESCRIPTOR,
  193. .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP),
  194. .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
  195. },
  196. /*
  197. * Keyboard
  198. */
  199. .Keyboard_Interface =
  200. {
  201. .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
  202. .InterfaceNumber = KEYBOARD_INTERFACE,
  203. .AlternateSetting = 0x00,
  204. .TotalEndpoints = 1,
  205. .Class = HID_CSCP_HIDClass,
  206. .SubClass = HID_CSCP_BootSubclass,
  207. .Protocol = HID_CSCP_KeyboardBootProtocol,
  208. .InterfaceStrIndex = NO_DESCRIPTOR
  209. },
  210. .Keyboard_HID =
  211. {
  212. .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
  213. .HIDSpec = VERSION_BCD(01.11),
  214. .CountryCode = 0x00,
  215. .TotalReportDescriptors = 1,
  216. .HIDReportType = HID_DTYPE_Report,
  217. .HIDReportLength = sizeof(KeyboardReport)
  218. },
  219. .Keyboard_INEndpoint =
  220. {
  221. .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  222. .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
  223. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  224. .EndpointSize = KEYBOARD_EPSIZE,
  225. .PollingIntervalMS = 0x01
  226. },
  227. /*
  228. * Mouse
  229. */
  230. .Mouse_Interface =
  231. {
  232. .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
  233. .InterfaceNumber = MOUSE_INTERFACE,
  234. .AlternateSetting = 0x00,
  235. .TotalEndpoints = 1,
  236. .Class = HID_CSCP_HIDClass,
  237. .SubClass = HID_CSCP_BootSubclass,
  238. .Protocol = HID_CSCP_MouseBootProtocol,
  239. .InterfaceStrIndex = NO_DESCRIPTOR
  240. },
  241. .Mouse_HID =
  242. {
  243. .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
  244. .HIDSpec = VERSION_BCD(01.11),
  245. .CountryCode = 0x00,
  246. .TotalReportDescriptors = 1,
  247. .HIDReportType = HID_DTYPE_Report,
  248. .HIDReportLength = sizeof(MouseReport)
  249. },
  250. .Mouse_INEndpoint =
  251. {
  252. .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  253. .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
  254. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  255. .EndpointSize = MOUSE_EPSIZE,
  256. .PollingIntervalMS = 0x01
  257. },
  258. /*
  259. * Console
  260. */
  261. .Console_Interface =
  262. {
  263. .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
  264. .InterfaceNumber = CONSOLE_INTERFACE,
  265. .AlternateSetting = 0x00,
  266. .TotalEndpoints = 2,
  267. .Class = HID_CSCP_HIDClass,
  268. .SubClass = HID_CSCP_NonBootSubclass,
  269. .Protocol = HID_CSCP_NonBootProtocol,
  270. .InterfaceStrIndex = NO_DESCRIPTOR
  271. },
  272. .Console_HID =
  273. {
  274. .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
  275. .HIDSpec = VERSION_BCD(01.11),
  276. .CountryCode = 0x00,
  277. .TotalReportDescriptors = 1,
  278. .HIDReportType = HID_DTYPE_Report,
  279. .HIDReportLength = sizeof(ConsoleReport)
  280. },
  281. .Console_INEndpoint =
  282. {
  283. .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  284. .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
  285. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  286. .EndpointSize = CONSOLE_EPSIZE,
  287. .PollingIntervalMS = 0x01
  288. },
  289. .Console_OUTEndpoint =
  290. {
  291. .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  292. .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
  293. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  294. .EndpointSize = CONSOLE_EPSIZE,
  295. .PollingIntervalMS = 0x01
  296. },
  297. /*
  298. * Extra
  299. */
  300. .Extra_Interface =
  301. {
  302. .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
  303. .InterfaceNumber = EXTRA_INTERFACE,
  304. .AlternateSetting = 0x00,
  305. .TotalEndpoints = 1,
  306. .Class = HID_CSCP_HIDClass,
  307. .SubClass = HID_CSCP_NonBootSubclass,
  308. .Protocol = HID_CSCP_NonBootProtocol,
  309. .InterfaceStrIndex = NO_DESCRIPTOR
  310. },
  311. .Extra_HID =
  312. {
  313. .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
  314. .HIDSpec = VERSION_BCD(01.11),
  315. .CountryCode = 0x00,
  316. .TotalReportDescriptors = 1,
  317. .HIDReportType = HID_DTYPE_Report,
  318. .HIDReportLength = sizeof(ExtraReport)
  319. },
  320. .Extra_INEndpoint =
  321. {
  322. .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  323. .EndpointAddress = (ENDPOINT_DIR_IN | EXTRA_IN_EPNUM),
  324. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  325. .EndpointSize = EXTRA_EPSIZE,
  326. .PollingIntervalMS = 0x01
  327. },
  328. };
  329. /*******************************************************************************
  330. * String Descriptors
  331. ******************************************************************************/
  332. const USB_Descriptor_String_t PROGMEM LanguageString =
  333. {
  334. .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
  335. .UnicodeString = {LANGUAGE_ID_ENG}
  336. };
  337. const USB_Descriptor_String_t PROGMEM ManufacturerString =
  338. {
  339. .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
  340. .UnicodeString = LSTR(MANUFACTURER)
  341. };
  342. const USB_Descriptor_String_t PROGMEM ProductString =
  343. {
  344. .Header = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String},
  345. .UnicodeString = LSTR(PRODUCT)
  346. };
  347. /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  348. * documentation) by the application code so that the address and size of a requested descriptor can be given
  349. * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
  350. * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
  351. * USB host.
  352. */
  353. uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
  354. const uint8_t wIndex,
  355. const void** const DescriptorAddress)
  356. {
  357. const uint8_t DescriptorType = (wValue >> 8);
  358. const uint8_t DescriptorIndex = (wValue & 0xFF);
  359. const void* Address = NULL;
  360. uint16_t Size = NO_DESCRIPTOR;
  361. switch (DescriptorType)
  362. {
  363. case DTYPE_Device:
  364. Address = &DeviceDescriptor;
  365. Size = sizeof(USB_Descriptor_Device_t);
  366. break;
  367. case DTYPE_Configuration:
  368. Address = &ConfigurationDescriptor;
  369. Size = sizeof(USB_Descriptor_Configuration_t);
  370. break;
  371. case DTYPE_String:
  372. switch (DescriptorIndex )
  373. {
  374. case 0x00:
  375. Address = &LanguageString;
  376. Size = pgm_read_byte(&LanguageString.Header.Size);
  377. break;
  378. case 0x01:
  379. Address = &ManufacturerString;
  380. Size = pgm_read_byte(&ManufacturerString.Header.Size);
  381. break;
  382. case 0x02:
  383. Address = &ProductString;
  384. Size = pgm_read_byte(&ProductString.Header.Size);
  385. break;
  386. }
  387. break;
  388. case HID_DTYPE_HID:
  389. switch (wIndex) {
  390. case KEYBOARD_INTERFACE:
  391. Address = &ConfigurationDescriptor.Keyboard_HID;
  392. Size = sizeof(USB_HID_Descriptor_HID_t);
  393. break;
  394. case MOUSE_INTERFACE:
  395. Address = &ConfigurationDescriptor.Mouse_HID;
  396. Size = sizeof(USB_HID_Descriptor_HID_t);
  397. break;
  398. case CONSOLE_INTERFACE:
  399. Address = &ConfigurationDescriptor.Console_HID;
  400. Size = sizeof(USB_HID_Descriptor_HID_t);
  401. break;
  402. case EXTRA_INTERFACE:
  403. Address = &ConfigurationDescriptor.Extra_HID;
  404. Size = sizeof(USB_HID_Descriptor_HID_t);
  405. break;
  406. }
  407. break;
  408. case HID_DTYPE_Report:
  409. switch (wIndex) {
  410. case KEYBOARD_INTERFACE:
  411. Address = &KeyboardReport;
  412. Size = sizeof(KeyboardReport);
  413. break;
  414. case MOUSE_INTERFACE:
  415. Address = &MouseReport;
  416. Size = sizeof(MouseReport);
  417. break;
  418. case CONSOLE_INTERFACE:
  419. Address = &ConsoleReport;
  420. Size = sizeof(ConsoleReport);
  421. break;
  422. case EXTRA_INTERFACE:
  423. Address = &ExtraReport;
  424. Size = sizeof(ExtraReport);
  425. break;
  426. }
  427. break;
  428. }
  429. *DescriptorAddress = Address;
  430. return Size;
  431. }