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.

HIDReportData.h 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief Constants for HID report item attributes.
  28. *
  29. * HID report item constants for report item attributes. Refer to the HID specification for
  30. * details on each flag's meaning when applied to an IN, OUT or FEATURE item.
  31. */
  32. /** \ingroup Group_HIDParser
  33. * \defgroup Group_HIDReportItemConst HID Report Descriptor Item Constants
  34. *
  35. * General HID constant definitions for HID Report Descriptor elements.
  36. *
  37. * @{
  38. */
  39. #ifndef __HIDREPORTDATA_H__
  40. #define __HIDREPORTDATA_H__
  41. /* Private Interface - For use in library only: */
  42. #if !defined(__DOXYGEN__)
  43. /* Macros: */
  44. #define HID_RI_DATA_SIZE_MASK 0x03
  45. #define HID_RI_TYPE_MASK 0x0C
  46. #define HID_RI_TAG_MASK 0xF0
  47. #define HID_RI_TYPE_MAIN 0x00
  48. #define HID_RI_TYPE_GLOBAL 0x04
  49. #define HID_RI_TYPE_LOCAL 0x08
  50. #define HID_RI_DATA_BITS_0 0x00
  51. #define HID_RI_DATA_BITS_8 0x01
  52. #define HID_RI_DATA_BITS_16 0x02
  53. #define HID_RI_DATA_BITS_32 0x03
  54. #define HID_RI_DATA_BITS(DataBits) CONCAT_EXPANDED(HID_RI_DATA_BITS_, DataBits)
  55. #define _HID_RI_ENCODE_0(Data)
  56. #define _HID_RI_ENCODE_8(Data) , (Data & 0xFF)
  57. #define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data) _HID_RI_ENCODE_8(Data >> 8)
  58. #define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16)
  59. #define _HID_RI_ENCODE(DataBits, ...) CONCAT_EXPANDED(_HID_RI_ENCODE_, DataBits(__VA_ARGS__))
  60. #define _HID_RI_ENTRY(Type, Tag, DataBits, ...) (Type | Tag | HID_RI_DATA_BITS(DataBits)) _HID_RI_ENCODE(DataBits, (__VA_ARGS__))
  61. #endif
  62. /* Public Interface - May be used in end-application: */
  63. /* Macros: */
  64. /** \name HID Input, Output and Feature Report Descriptor Item Flags */
  65. //@{
  66. #define HID_IOF_CONSTANT (1 << 0)
  67. #define HID_IOF_DATA (0 << 0)
  68. #define HID_IOF_VARIABLE (1 << 1)
  69. #define HID_IOF_ARRAY (0 << 1)
  70. #define HID_IOF_RELATIVE (1 << 2)
  71. #define HID_IOF_ABSOLUTE (0 << 2)
  72. #define HID_IOF_WRAP (1 << 3)
  73. #define HID_IOF_NO_WRAP (0 << 3)
  74. #define HID_IOF_NON_LINEAR (1 << 4)
  75. #define HID_IOF_LINEAR (0 << 4)
  76. #define HID_IOF_NO_PREFERRED_STATE (1 << 5)
  77. #define HID_IOF_PREFERRED_STATE (0 << 5)
  78. #define HID_IOF_NULLSTATE (1 << 6)
  79. #define HID_IOF_NO_NULL_POSITION (0 << 6)
  80. #define HID_IOF_VOLATILE (1 << 7)
  81. #define HID_IOF_NON_VOLATILE (0 << 7)
  82. #define HID_IOF_BUFFERED_BYTES (1 << 8)
  83. #define HID_IOF_BITFIELD (0 << 8)
  84. //@}
  85. /** \name HID Report Descriptor Item Macros */
  86. //@{
  87. #define HID_RI_INPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x80, DataBits, __VA_ARGS__)
  88. #define HID_RI_OUTPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x90, DataBits, __VA_ARGS__)
  89. #define HID_RI_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xA0, DataBits, __VA_ARGS__)
  90. #define HID_RI_FEATURE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xB0, DataBits, __VA_ARGS__)
  91. #define HID_RI_END_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xC0, DataBits, __VA_ARGS__)
  92. #define HID_RI_USAGE_PAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x00, DataBits, __VA_ARGS__)
  93. #define HID_RI_LOGICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x10, DataBits, __VA_ARGS__)
  94. #define HID_RI_LOGICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x20, DataBits, __VA_ARGS__)
  95. #define HID_RI_PHYSICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x30, DataBits, __VA_ARGS__)
  96. #define HID_RI_PHYSICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x40, DataBits, __VA_ARGS__)
  97. #define HID_RI_UNIT_EXPONENT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x50, DataBits, __VA_ARGS__)
  98. #define HID_RI_UNIT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x60, DataBits, __VA_ARGS__)
  99. #define HID_RI_REPORT_SIZE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x70, DataBits, __VA_ARGS__)
  100. #define HID_RI_REPORT_ID(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x80, DataBits, __VA_ARGS__)
  101. #define HID_RI_REPORT_COUNT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x90, DataBits, __VA_ARGS__)
  102. #define HID_RI_PUSH(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xA0, DataBits, __VA_ARGS__)
  103. #define HID_RI_POP(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xB0, DataBits, __VA_ARGS__)
  104. #define HID_RI_USAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x00, DataBits, __VA_ARGS__)
  105. #define HID_RI_USAGE_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x10, DataBits, __VA_ARGS__)
  106. #define HID_RI_USAGE_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x20, DataBits, __VA_ARGS__)
  107. //@}
  108. /** @} */
  109. #endif