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
|
/*
* usb/hid.h -- USB HID definitions
*
* Copyright (C) 2017 Tomasz Kramkowski <tk@the-tk.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FMK_USB_HID_H
#define FMK_USB_HID_H
#define SHORT_ITEM(tag, type, size) (((tag) & 0xf) << 4 | \
((type) & 0x3) << 2 | \
((size) & 0x3) << 0)
#define HR_MAIN_ITEM(tag, size) SHORT_ITEM(tag, 0, size)
#define HR_GLOBAL_ITEM(tag, size) SHORT_ITEM(tag, 1, size)
#define HR_LOCAL_ITEM(tag, size) SHORT_ITEM(tag, 2, size)
#define HR_INPUT(size) HR_MAIN_ITEM(8, size)
#define HR_OUTPUT(size) HR_MAIN_ITEM(9, size)
#define HR_FEATURE(size) HR_MAIN_ITEM(11, size)
#define HR_COLLECTION(size) HR_MAIN_ITEM(10, size)
#define HR_END_COLLECTION(size) HR_MAIN_ITEM(12, size)
#define HR_USAGE_PAGE(size) HR_GLOBAL_ITEM(0, size)
#define HR_LOGICAL_MINIMUM(size) HR_GLOBAL_ITEM(1, size)
#define HR_LOGICAL_MAXIMUM(size) HR_GLOBAL_ITEM(2, size)
#define HR_PHYSICAL_MINIMUM(size) HR_GLOBAL_ITEM(3, size)
#define HR_PHYSICAL_MAXIMUM(size) HR_GLOBAL_ITEM(4, size)
#define HR_UNIT_EXPONENT(size) HR_GLOBAL_ITEM(5, size)
#define HR_UNIT(size) HR_GLOBAL_ITEM(6, size)
#define HR_REPORT_SIZE(size) HR_GLOBAL_ITEM(7, size)
#define HR_REPORT_ID(size) HR_GLOBAL_ITEM(8, size)
#define HR_REPORT_COUNT(size) HR_GLOBAL_ITEM(9, size)
#define HR_PUSH(size) HR_GLOBAL_ITEM(10, size)
#define HR_POP(size) HR_GLOBAL_ITEM(11, size)
#define HR_USAGE(size) HR_LOCAL_ITEM(0, size)
#define HR_USAGE_MINIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_USAGE_MAXIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_DESIGNATOR_INDEX(size) HR_LOCAL_ITEM(0, size)
#define HR_DESIGNATOR_MINIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_DESIGNATOR_MAXIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_STRING_INDEX(size) HR_LOCAL_ITEM(0, size)
#define HR_STRING_MINIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_STRING_MAXIMUM(size) HR_LOCAL_ITEM(0, size)
#define HR_DELIMITER(size) HR_LOCAL_ITEM(0, size)
#define HR_PHYSICAL 0x00
#define HR_APPLICATION 0x01
#define HR_LOGICAL 0x02
#define HR_REPORT 0x03
#define HR_NAMED_ARRAY 0x04
#define HR_USAGE_SWITCH 0x05
#define HR_USAGE_MODIFIER 0x06
#define HR_GENERIC_DESKTOP 0x01
#define HR_POINTER 0x01
#define HR_MOUSE 0x02
#define HR_KEYBOARD 0x06
#define HR_X 0x30
#define HR_Y 0x31
#define HR_WHEEL 0x38
#define HR_BUTTON 0x09
#define HR_DATA (0)
#define HR_CONSTANT (1 << 0)
#define HR_ARRAY (0)
#define HR_VARIABLE (1 << 1)
#define HR_ABSOLUTE (0)
#define HR_RELATIVE (1 << 2)
#define HR_NO_WRAP (0)
#define HR_WRAP (1 << 3)
#define HR_LINEAR (0)
#define HR_NON_LINEAR (1 << 4)
#define HR_PREFERRED_STATE (0)
#define HR_NO_PREFERRED (1 << 5)
#define HR_NO_NULL_POSITION (0)
#define HR_NULL_STATE (1 << 6)
#define HR_NON_VOLATILE (0)
#define HR_VOLATILE (1 << 7)
#define HR_BIT_FIELD (0)
#define HR_BUFFERED_BYTES (1 << 8)
#endif /* FMK_USB_HID_H */
|