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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * 1. The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * 2. If the Software is incorporated into a build system that allows
  17. * selection among a list of target devices, then similar target
  18. * devices manufactured by PJRC.COM must be included in the list of
  19. * target devices and selectable in the same manner.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. #ifndef _usb_desc_h_
  31. #define _usb_desc_h_
  32. // This header is NOT meant to be included when compiling
  33. // user sketches in Arduino. The low-level functions
  34. // provided by usb_dev.c are meant to be called only by
  35. // code which provides higher-level interfaces to the user.
  36. #include <stdint.h>
  37. #include <stddef.h>
  38. #include "output_com.h"
  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. /*
  44. To modify a USB Type to have different interfaces, start in this
  45. file. Delete the XYZ_INTERFACE lines for any interfaces you
  46. wish to remove, and copy them from another USB Type for any you
  47. want to add.
  48. Give each interface a unique number, and edit NUM_INTERFACE to
  49. reflect the number of interfaces.
  50. Within each interface, make sure it uses a unique set of endpoints.
  51. Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
  52. Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured
  53. the proper way (transmit, receive, or both).
  54. The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be
  55. edited to the correct sizes. See usb_desc.c for the giant array
  56. of bytes. Someday these may be done automatically..... (but how?)
  57. If you are using existing interfaces, the code in each file should
  58. automatically adapt to the changes you specify. If you need to
  59. create a new type of interface, you'll need to write the code which
  60. sends and receives packets, and presents an API to the user.
  61. Finally, edit usb_inst.cpp, which creats instances of the C++
  62. objects for each combination.
  63. Some operating systems, especially Windows, may cache USB device
  64. info. Changes to the device name may not update on the same
  65. computer unless the vendor or product ID numbers change, or the
  66. "bcdDevice" revision code is increased.
  67. If these instructions are missing steps or could be improved, please
  68. let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
  69. */
  70. #define DEVICE_CLASS 0xEF
  71. #define DEVICE_SUBCLASS 0x02
  72. #define DEVICE_PROTOCOL 0x01
  73. #define EP0_SIZE 64
  74. #define NUM_ENDPOINTS 6
  75. #define NUM_USB_BUFFERS 30
  76. #define NUM_INTERFACE 4
  77. #define CDC_IAD_DESCRIPTOR 1
  78. #define CDC_STATUS_INTERFACE 0
  79. #define CDC_DATA_INTERFACE 1 // Serial
  80. #define CDC_ACM_ENDPOINT 2
  81. #define CDC_RX_ENDPOINT 3
  82. #define CDC_TX_ENDPOINT 4
  83. #define CDC_ACM_SIZE 16
  84. #define CDC_RX_SIZE 64
  85. #define CDC_TX_SIZE 64
  86. #define KEYBOARD_INTERFACE 2 // Keyboard
  87. #define KEYBOARD_ENDPOINT 1
  88. #define KEYBOARD_SIZE 8
  89. #define KEYBOARD_INTERVAL 1
  90. #define MOUSE_INTERFACE 3 // Mouse
  91. #define MOUSE_ENDPOINT 5
  92. #define MOUSE_SIZE 8
  93. #define MOUSE_INTERVAL 2
  94. #define JOYSTICK_INTERFACE 4 // Joystick
  95. #define JOYSTICK_ENDPOINT 6
  96. #define JOYSTICK_SIZE 16
  97. #define JOYSTICK_INTERVAL 1
  98. #define KEYBOARD_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9)
  99. #define MOUSE_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9)
  100. #define JOYSTICK_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9)
  101. #define CONFIG_DESC_SIZE (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7)
  102. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  103. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  104. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  105. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  106. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  107. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  108. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  109. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  110. typedef struct {
  111. uint16_t wValue;
  112. uint16_t wIndex;
  113. const uint8_t *addr;
  114. uint16_t length;
  115. } usb_descriptor_list_t;
  116. extern const usb_descriptor_list_t usb_descriptor_list[];
  117. #endif