summaryrefslogtreecommitdiff
path: root/modules/sensors/dynamic_sensor/HidUtils/HidDefs.h
blob: 05445dba05f5f1b511e20bc7cd216d1f1b63cb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef HIDUTIL_HIDDEFS_H_
#define HIDUTIL_HIDDEFS_H_

namespace HidUtil {

// HID specification constants definition
//
// Definitions are from HID specification v1.11, which can be obtained from http://www.usb.org
//
// Preferred namespace for namespace restriction than enum class as enum class has strong type
// which is inconvenient in a parser, in which input binary values has to be compared with these
// definitions frequnetly.
namespace HidDef {
// Hid spec 6.2.2.3
namespace TagType {
enum {
    MAIN,
    GLOBAL,
    LOCAL,
    RESERVED
};
} // namespace TagType

// HID spec 6.2.2.4
namespace ReportFlag {
enum {
    DATA_CONST = 1,
    ARRAY_VARIABLE = 2,
    WRAP = 4,
    NONLINEAR = 8,
    NO_PREFERRED = 0x10,
    NULL_STATE = 0x20,
    VOLATILE = 0x40,
    // bit 7 reserved
    BUFFERED_BYTES = 0x100
};
} // namespace ReportFlag

// HID spec 6.2.2.5
namespace MainTag {
enum {
    INPUT = 8,
    OUTPUT = 9,
    COLLECTION = 10,
    FEATURE = 11,
    END_COLLECTION = 12,
    LONG_ITEM = 15,
};
} // namespace MainTag

// HID spec 6.2.2.6
namespace CollectionType {
enum {
    PHYSICAL = 0,
    APPLICATION,
    LOGICAL,
    REPORT,
    NAMED_ARRAY,
    USAGE_SWITCH,
    USAGE_MODIFIER
};
} // namespace CollectionType

// HID spec 6.2.2.7
namespace GlobalTag {
enum {
    USAGE_PAGE,
    LOGICAL_MINIMUM,
    LOGICAL_MAXIMUM,
    PHYSICAL_MINIMUM,
    PHYSICAL_MAXIMUM,
    UNIT_EXPONENT,
    UNIT,
    REPORT_SIZE,
    REPORT_ID,
    REPORT_COUNT,
    PUSH,
    POP
};
} //namespace GlobalTag

// HID spec 6.2.2.8
namespace LocalTag {
enum HidLocalTag {
    USAGE,
    USAGE_MINIMUM,
    USAGE_MAXIMUM,
    DESIGNATOR_INDEX,
    DESIGNATOR_MINIMUM,
    DESIGNATOR_MAXIMUM,
    // there is a hole here in the spec
    STRING_INDEX = 7,
    STRING_MINIMUM,
    STRING_MAXIMUM,
    DELIMITOR
};
} // namespace LocalTag

} //namespace HidDef
} //namespace HidUtil

#endif // HIDUTIL_HIDDEFS_H_