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 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. * Modified by Jacob Alexander (2013-2014)
  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. #ifndef _usb_desc_h_
  32. #define _usb_desc_h_
  33. // This header is NOT meant to be included when compiling
  34. // user sketches in Arduino. The low-level functions
  35. // provided by usb_dev.c are meant to be called only by
  36. // code which provides higher-level interfaces to the user.
  37. #include <stdint.h>
  38. #include <stddef.h>
  39. #include "output_com.h"
  40. #define ENDPOINT_UNUSED 0x00
  41. #define ENDPOINT_TRANSIMIT_ONLY 0x15
  42. #define ENDPOINT_RECEIVE_ONLY 0x19
  43. #define ENDPOINT_TRANSMIT_AND_RECEIVE 0x1D
  44. /*
  45. To modify a USB Type to have different interfaces, start in this
  46. file. Delete the XYZ_INTERFACE lines for any interfaces you
  47. wish to remove, and copy them from another USB Type for any you
  48. want to add.
  49. Give each interface a unique number, and edit NUM_INTERFACE to
  50. reflect the number of interfaces.
  51. Within each interface, make sure it uses a unique set of endpoints.
  52. Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
  53. Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured
  54. the proper way (transmit, receive, or both).
  55. The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be
  56. edited to the correct sizes. See usb_desc.c for the giant array
  57. of bytes. Someday these may be done automatically..... (but how?)
  58. If you are using existing interfaces, the code in each file should
  59. automatically adapt to the changes you specify. If you need to
  60. create a new type of interface, you'll need to write the code which
  61. sends and receives packets, and presents an API to the user.
  62. Finally, edit usb_inst.cpp, which creats instances of the C++
  63. objects for each combination.
  64. Some operating systems, especially Windows, may cache USB device
  65. info. Changes to the device name may not update on the same
  66. computer unless the vendor or product ID numbers change, or the
  67. "bcdDevice" revision code is increased.
  68. If these instructions are missing steps or could be improved, please
  69. let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
  70. */
  71. #define DEVICE_CLASS 0xEF
  72. #define DEVICE_SUBCLASS 0x02
  73. #define DEVICE_PROTOCOL 0x01
  74. #define EP0_SIZE 64
  75. #define NUM_ENDPOINTS 6
  76. #define NUM_USB_BUFFERS 30
  77. #define NUM_INTERFACE 4
  78. #define CDC_IAD_DESCRIPTOR 1
  79. #define CDC_STATUS_INTERFACE 0
  80. #define CDC_DATA_INTERFACE 1 // Serial
  81. #define CDC_ACM_ENDPOINT 2
  82. #define CDC_RX_ENDPOINT 3
  83. #define CDC_TX_ENDPOINT 4
  84. #define CDC_ACM_SIZE 16
  85. #define CDC_RX_SIZE 64
  86. #define CDC_TX_SIZE 64
  87. #define KEYBOARD_INTERFACE 2 // Keyboard
  88. #define KEYBOARD_ENDPOINT 1
  89. #define KEYBOARD_SIZE 8
  90. #define KEYBOARD_INTERVAL 1
  91. #define MOUSE_INTERFACE 3 // Mouse
  92. #define MOUSE_ENDPOINT 5
  93. #define MOUSE_SIZE 8
  94. #define MOUSE_INTERVAL 2
  95. #define JOYSTICK_INTERFACE 4 // Joystick
  96. #define JOYSTICK_ENDPOINT 6
  97. #define JOYSTICK_SIZE 16
  98. #define JOYSTICK_INTERVAL 1
  99. #define KEYBOARD_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9)
  100. #define MOUSE_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9)
  101. #define JOYSTICK_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9)
  102. #define CONFIG_DESC_SIZE (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7)
  103. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  104. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  105. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  106. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  107. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  108. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  109. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  110. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  111. typedef struct {
  112. uint16_t wValue;
  113. uint16_t wIndex;
  114. const uint8_t *addr;
  115. uint16_t length;
  116. } usb_descriptor_list_t;
  117. extern const usb_descriptor_list_t usb_descriptor_list[];
  118. #endif