Kiibohd Controller
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

usb_desc.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. * Modified by Jacob Alexander (2013-2016)
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * 1. The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * 2. If the Software is incorporated into a build system that allows
  18. * selection among a list of target devices, then similar target
  19. * devices manufactured by PJRC.COM must be included in the list of
  20. * target devices and selectable in the same manner.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  26. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29. * SOFTWARE.
  30. */
  31. #pragma once
  32. // ----- Includes -----
  33. // Compiler Includes
  34. #include <stdint.h>
  35. #include <stddef.h>
  36. // Local Includes
  37. #include <output_com.h>
  38. // ----- Defines -----
  39. #define ENDPOINT_UNUSED 0x00
  40. #define ENDPOINT_TRANSIMIT_ONLY 0x15
  41. #define ENDPOINT_RECEIVE_ONLY 0x19
  42. #define ENDPOINT_TRANSMIT_AND_RECEIVE 0x1D
  43. #define DEVICE_CLASS 0x00 // Keep 0x00 to indicate each sub device will indicate what it is
  44. #define DEVICE_SUBCLASS 0x00
  45. #define DEVICE_PROTOCOL 0x00
  46. #define EP0_SIZE 64
  47. #define NUM_ENDPOINTS 10 // XXX Can save some space if this can be calculated using KLL
  48. #define NUM_USB_BUFFERS 30
  49. // XXX Remember to update total interface count, if it isn't correct some OSs will not initialize USB
  50. // Linux warns in dmesg
  51. // Mac OSX login screen will not initialize
  52. #define KEYBOARD_INTERFACES 3 // Boot, NKRO, SysCtrl
  53. #define CDC_INTERFACES 2
  54. #define MOUSE_INTERFACES 1
  55. #define JOYSTICK_INTERFACES 1
  56. #define RAWIO_INTERFACES 1
  57. #define KEYBOARD_INTERFACE 0 // Keyboard
  58. #define KEYBOARD_ENDPOINT 1
  59. #define KEYBOARD_SIZE 8
  60. #define KEYBOARD_INTERVAL 1
  61. #define KEYBOARD_NAME L"Boot Keyboard"
  62. #define NKRO_KEYBOARD_INTERFACE 1 // NKRO Keyboard
  63. #define NKRO_KEYBOARD_ENDPOINT 2
  64. #define NKRO_KEYBOARD_SIZE 64
  65. #define NKRO_KEYBOARD_INTERVAL 1
  66. #define NKRO_KEYBOARD_NAME L"NKRO Keyboard"
  67. #define SYS_CTRL_INTERFACE 2 // Media Keys
  68. #define SYS_CTRL_ENDPOINT 3
  69. #define SYS_CTRL_SIZE 8
  70. #define SYS_CTRL_INTERVAL 1
  71. #define SYS_CTRL_NAME L"Media Keys"
  72. #define CDC_IAD_DESCRIPTOR 1
  73. #define CDC_STATUS_INTERFACE 3
  74. #define CDC_DATA_INTERFACE 4 // Serial
  75. #define CDC_ACM_ENDPOINT 4
  76. #define CDC_RX_ENDPOINT 5
  77. #define CDC_TX_ENDPOINT 6
  78. #define CDC_ACM_SIZE 16
  79. #define CDC_RX_SIZE 64
  80. #define CDC_TX_SIZE 64
  81. #define CDC_STATUS_NAME L"Virtual Serial Port - Status"
  82. #define CDC_DATA_NAME L"Virtual Serial Port - Data"
  83. #define RAWIO_INTERFACE 5 // RawIO
  84. #define RAWIO_TX_ENDPOINT 7
  85. #define RAWIO_TX_SIZE 64
  86. #define RAWIO_TX_INTERVAL 1
  87. #define RAWIO_RX_ENDPOINT 8
  88. #define RAWIO_RX_SIZE 64
  89. #define RAWIO_RX_INTERVAL 1
  90. #define RAWIO_NAME L"API Interface"
  91. #define MOUSE_INTERFACE 6 // Mouse
  92. #define MOUSE_ENDPOINT 9
  93. #define MOUSE_SIZE 8
  94. #define MOUSE_INTERVAL 1
  95. #define MOUSE_NAME L"Mouse"
  96. #define JOYSTICK_INTERFACE 7 // Joystick
  97. #define JOYSTICK_ENDPOINT 10
  98. #define JOYSTICK_SIZE 16
  99. #define JOYSTICK_INTERVAL 1
  100. #define JOYSTICK_NAME L"Joystick"
  101. // Descriptor sizes
  102. #define BASE_DESC_SIZE (9)
  103. #define KEYBOARD_DESC_SIZE (9+9+7)
  104. #define NKRO_KEYBOARD_DESC_SIZE (9+9+7)
  105. #define SYS_CTRL_DESC_SIZE (9+9+7)
  106. #define SERIAL_CDC_DESC_SIZE (8+9+5+5+4+5+7+9+7+7)
  107. #define RAWIO_DESC_SIZE (9+7+7)
  108. #define MOUSE_DESC_SIZE (9+9+7)
  109. #define JOYSTICK_DESC_SIZE (9+9+7)
  110. // Descriptor offsets
  111. #define KEYBOARD_DESC_BASE_OFFSET ( \
  112. BASE_DESC_SIZE + \
  113. 9 \
  114. )
  115. #define SERIAL_CDC_DESC_BASE_OFFSET ( \
  116. BASE_DESC_SIZE + \
  117. KEYBOARD_DESC_TOTAL_OFFSET + \
  118. 8 \
  119. )
  120. #define RAWIO_DESC_BASE_OFFSET ( \
  121. BASE_DESC_SIZE + \
  122. KEYBOARD_DESC_TOTAL_OFFSET + \
  123. SERIAL_CDC_DESC_TOTAL_OFFSET + \
  124. 9 \
  125. )
  126. #define MOUSE_DESC_BASE_OFFSET ( \
  127. BASE_DESC_SIZE + \
  128. KEYBOARD_DESC_TOTAL_OFFSET + \
  129. SERIAL_CDC_DESC_TOTAL_OFFSET + \
  130. 9 \
  131. )
  132. #define JOYSTICK_DESC_BASE_OFFSET ( \
  133. BASE_DESC_SIZE + \
  134. KEYBOARD_DESC_TOTAL_OFFSET + \
  135. SERIAL_CDC_DESC_TOTAL_OFFSET + \
  136. MOUSE_DESC_TOTAL_OFFSET + \
  137. 9 \
  138. )
  139. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  140. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  141. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  142. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  143. #define ENDPOINT5_CONFIG ENDPOINT_RECEIVE_ONLY
  144. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  145. #define ENDPOINT7_CONFIG ENDPOINT_TRANSIMIT_ONLY
  146. #define ENDPOINT8_CONFIG ENDPOINT_RECEIVE_ONLY
  147. #define ENDPOINT9_CONFIG ENDPOINT_TRANSIMIT_ONLY
  148. #define ENDPOINT10_CONFIG ENDPOINT_TRANSIMIT_ONLY
  149. // ----- Enumerations -----
  150. typedef struct {
  151. uint16_t wValue;
  152. uint16_t wIndex;
  153. const uint8_t *addr;
  154. uint16_t length;
  155. } usb_descriptor_list_t;
  156. // ----- Variables -----
  157. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  158. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  159. extern const usb_descriptor_list_t usb_descriptor_list[];
  160. extern uint8_t *usb_bMaxPower;
  161. // ----- Functions -----
  162. void usb_set_config_descriptor_size();