Keyboard firmwares for Atmel AVR and Cortex-M
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

USBHID_Types.h 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Copyright (c) 2010-2011 mbed.org, MIT License
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  4. * and associated documentation files (the "Software"), to deal in the Software without
  5. * restriction, including without limitation the rights to use, copy, modify, merge, publish,
  6. * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
  7. * Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or
  10. * substantial portions of the Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  13. * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. #ifndef USBCLASS_HID_TYPES
  19. #define USBCLASS_HID_TYPES
  20. #include <stdint.h>
  21. /* */
  22. #define HID_VERSION_1_11 (0x0111)
  23. /* HID Class */
  24. #define HID_CLASS (3)
  25. #define HID_SUBCLASS_NONE (0)
  26. #define HID_PROTOCOL_NONE (0)
  27. /* Descriptors */
  28. #define HID_DESCRIPTOR (33)
  29. #define HID_DESCRIPTOR_LENGTH (0x09)
  30. #define REPORT_DESCRIPTOR (34)
  31. /* Class requests */
  32. #define GET_REPORT (0x1)
  33. #define GET_IDLE (0x2)
  34. #define SET_REPORT (0x9)
  35. #define SET_IDLE (0xa)
  36. /* HID Class Report Descriptor */
  37. /* Short items: size is 0, 1, 2 or 3 specifying 0, 1, 2 or 4 (four) bytes */
  38. /* of data as per HID Class standard */
  39. /* Main items */
  40. #define INPUT(size) (0x80 | size)
  41. #define OUTPUT(size) (0x90 | size)
  42. #define FEATURE(size) (0xb0 | size)
  43. #define COLLECTION(size) (0xa0 | size)
  44. #define END_COLLECTION(size) (0xc0 | size)
  45. /* Global items */
  46. #define USAGE_PAGE(size) (0x04 | size)
  47. #define LOGICAL_MINIMUM(size) (0x14 | size)
  48. #define LOGICAL_MAXIMUM(size) (0x24 | size)
  49. #define PHYSICAL_MINIMUM(size) (0x34 | size)
  50. #define PHYSICAL_MAXIMUM(size) (0x44 | size)
  51. #define UNIT_EXPONENT(size) (0x54 | size)
  52. #define UNIT(size) (0x64 | size)
  53. #define REPORT_SIZE(size) (0x74 | size)
  54. #define REPORT_ID(size) (0x84 | size)
  55. #define REPORT_COUNT(size) (0x94 | size)
  56. #define PUSH(size) (0xa4 | size)
  57. #define POP(size) (0xb4 | size)
  58. /* Local items */
  59. #define USAGE(size) (0x08 | size)
  60. #define USAGE_MINIMUM(size) (0x18 | size)
  61. #define USAGE_MAXIMUM(size) (0x28 | size)
  62. #define DESIGNATOR_INDEX(size) (0x38 | size)
  63. #define DESIGNATOR_MINIMUM(size) (0x48 | size)
  64. #define DESIGNATOR_MAXIMUM(size) (0x58 | size)
  65. #define STRING_INDEX(size) (0x78 | size)
  66. #define STRING_MINIMUM(size) (0x88 | size)
  67. #define STRING_MAXIMUM(size) (0x98 | size)
  68. #define DELIMITER(size) (0xa8 | size)
  69. /* HID Report */
  70. /* Where report IDs are used the first byte of 'data' will be the */
  71. /* report ID and 'length' will include this report ID byte. */
  72. #define MAX_HID_REPORT_SIZE (64)
  73. typedef struct {
  74. uint32_t length;
  75. uint8_t data[MAX_HID_REPORT_SIZE];
  76. } HID_REPORT;
  77. #endif