Statistics
| Branch: | Tag: | Revision:

root / LUFA / Drivers / USB / Class / Common / HIDReportData.h @ 978b99e5

History | View | Annotate | Download (6.61 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2011.
4

5
  dean [at] fourwalledcubicle [dot] com
6
           www.lufa-lib.org
7
*/
8

    
9
/*
10
  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
11

12
  Permission to use, copy, modify, distribute, and sell this
13
  software and its documentation for any purpose is hereby granted
14
  without fee, provided that the above copyright notice appear in
15
  all copies and that both that the copyright notice and this
16
  permission notice and warranty disclaimer appear in supporting
17
  documentation, and that the name of the author not be used in
18
  advertising or publicity pertaining to distribution of the
19
  software without specific, written prior permission.
20

21
  The author disclaim all warranties with regard to this
22
  software, including all implied warranties of merchantability
23
  and fitness.  In no event shall the author be liable for any
24
  special, indirect or consequential damages or any damages
25
  whatsoever resulting from loss of use, data or profits, whether
26
  in an action of contract, negligence or other tortious action,
27
  arising out of or in connection with the use or performance of
28
  this software.
29
*/
30

    
31
/** \file
32
 *  \brief Constants for HID report item attributes.
33
 *
34
 *  HID report item constants for report item attributes. Refer to the HID specification for
35
 *  details on each flag's meaning when applied to an IN, OUT or FEATURE item.
36
 */
37

    
38
/** \ingroup Group_HIDParser
39
 *  \defgroup Group_HIDReportItemConst HID Report Descriptor Item Constants
40
 *
41
 *  General HID constant definitions for HID Report Descriptor elements.
42
 *
43
 *  @{
44
 */
45

    
46
#ifndef __HIDREPORTDATA_H__
47
#define __HIDREPORTDATA_H__
48

    
49
        /* Private Interface - For use in library only: */
50
        #if !defined(__DOXYGEN__)
51
                /* Macros: */
52
                        #define HID_RI_DATA_SIZE_MASK                   0x03
53
                        #define HID_RI_TYPE_MASK                        0x0C
54
                        #define HID_RI_TAG_MASK                         0xF0
55

    
56
                        #define HID_RI_TYPE_MAIN                        0x00
57
                        #define HID_RI_TYPE_GLOBAL                      0x04
58
                        #define HID_RI_TYPE_LOCAL                       0x08
59

    
60
                        #define HID_RI_DATA_BITS_0                      0x00
61
                        #define HID_RI_DATA_BITS_8                      0x01
62
                        #define HID_RI_DATA_BITS_16                     0x02
63
                        #define HID_RI_DATA_BITS_32                     0x03
64
                        #define HID_RI_DATA_BITS(DataBits)              HID_RI_DATA_BITS_ ## DataBits
65

    
66
                        #define _HID_RI_ENCODE_0(Data)                  
67
                        #define _HID_RI_ENCODE_8(Data)                  , (Data & 0xFF)
68
                        #define _HID_RI_ENCODE_16(Data)                 _HID_RI_ENCODE_8(Data)  _HID_RI_ENCODE_8(Data >> 8)
69
                        #define _HID_RI_ENCODE_32(Data)                 _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16)
70
                        #define _HID_RI_ENCODE(DataBits, ...)           _HID_RI_ENCODE_ ## DataBits(__VA_ARGS__)
71
                        
72
                        #define _HID_RI_ENTRY(Type, Tag, DataBits, ...) \
73
                                                                        (Type | Tag | HID_RI_DATA_BITS(DataBits)) _HID_RI_ENCODE(DataBits, (__VA_ARGS__))
74
        #endif
75
        
76
        /* Public Interface - May be used in end-application: */
77
                /* Macros: */
78
                /** \name HID Input, Output and Feature Report Descriptor Item Flags */
79
                //@{
80
                        #define HID_IOF_CONSTANT                        (1 << 0)
81
                        #define HID_IOF_DATA                            (0 << 0)
82
                        #define HID_IOF_VARIABLE                        (1 << 1)
83
                        #define HID_IOF_ARRAY                           (0 << 1)
84
                        #define HID_IOF_RELATIVE                        (1 << 2)
85
                        #define HID_IOF_ABSOLUTE                        (0 << 2)
86
                        #define HID_IOF_WRAP                            (1 << 3)
87
                        #define HID_IOF_NO_WRAP                         (0 << 3)
88
                        #define HID_IOF_NON_LINEAR                      (1 << 4)
89
                        #define HID_IOF_LINEAR                          (0 << 4)
90
                        #define HID_IOF_NO_PREFERRED_STATE              (1 << 5)
91
                        #define HID_IOF_PREFERRED_STATE                 (0 << 5)
92
                        #define HID_IOF_NULLSTATE                       (1 << 6)
93
                        #define HID_IOF_NO_NULL_POSITION                (0 << 6)
94
                        #define HID_IOF_VOLATILE                        (1 << 7)
95
                        #define HID_IOF_NON_VOLATILE                    (0 << 7)
96
                        #define HID_IOF_BUFFERED_BYTES                  (1 << 8)
97
                        #define HID_IOF_BITFIELD                        (0 << 8)
98
                //@}
99
                
100
                /** \name HID Report Descriptor Item Macros */
101
                //@{
102
                        #define HID_RI_INPUT(DataBits, ...)             _HID_RI_ENTRY(HID_RI_TYPE_MAIN  , 0x80, DataBits, __VA_ARGS__)
103
                        #define HID_RI_OUTPUT(DataBits, ...)            _HID_RI_ENTRY(HID_RI_TYPE_MAIN  , 0x90, DataBits, __VA_ARGS__)
104
                        #define HID_RI_COLLECTION(DataBits, ...)        _HID_RI_ENTRY(HID_RI_TYPE_MAIN  , 0xA0, DataBits, __VA_ARGS__)
105
                        #define HID_RI_FEATURE(DataBits, ...)           _HID_RI_ENTRY(HID_RI_TYPE_MAIN  , 0xB0, DataBits, __VA_ARGS__)
106
                        #define HID_RI_END_COLLECTION(DataBits, ...)    _HID_RI_ENTRY(HID_RI_TYPE_MAIN  , 0xC0, DataBits, __VA_ARGS__)
107
                        #define HID_RI_USAGE_PAGE(DataBits, ...)        _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x00, DataBits, __VA_ARGS__)
108
                        #define HID_RI_LOGICAL_MINIMUM(DataBits, ...)   _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x10, DataBits, __VA_ARGS__)
109
                        #define HID_RI_LOGICAL_MAXIMUM(DataBits, ...)   _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x20, DataBits, __VA_ARGS__)
110
                        #define HID_RI_PHYSICAL_MINIMUM(DataBits, ...)  _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x30, DataBits, __VA_ARGS__)
111
                        #define HID_RI_PHYSICAL_MAXIMUM(DataBits, ...)  _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x40, DataBits, __VA_ARGS__)
112
                        #define HID_RI_UNIT_EXPONENT(DataBits, ...)     _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x50, DataBits, __VA_ARGS__)
113
                        #define HID_RI_UNIT(DataBits, ...)              _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x60, DataBits, __VA_ARGS__)
114
                        #define HID_RI_REPORT_SIZE(DataBits, ...)       _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x70, DataBits, __VA_ARGS__)
115
                        #define HID_RI_REPORT_ID(DataBits, ...)         _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x80, DataBits, __VA_ARGS__)
116
                        #define HID_RI_REPORT_COUNT(DataBits, ...)      _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x90, DataBits, __VA_ARGS__)
117
                        #define HID_RI_PUSH(DataBits, ...)              _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xA0, DataBits, __VA_ARGS__)
118
                        #define HID_RI_POP(DataBits, ...)               _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xB0, DataBits, __VA_ARGS__)
119
                        #define HID_RI_USAGE(DataBits, ...)             _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x00, DataBits, __VA_ARGS__)
120
                        #define HID_RI_USAGE_MINIMUM(DataBits, ...)     _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x10, DataBits, __VA_ARGS__)
121
                        #define HID_RI_USAGE_MAXIMUM(DataBits, ...)     _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x20, DataBits, __VA_ARGS__)
122
                //@}
123

    
124
/** @} */
125

    
126
#endif
127