2 * HID report helper macros.
4 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
43 #define Application 0x01
46 #define NamedArray 0x04
47 #define UsageSwitch 0x05
48 #define UsageModifier 0x06
50 #define SHORT_ITEM_0(tag,type) (((tag)<<4)|((type)<<2)|0)
51 #define SHORT_ITEM_1(tag,type,data) (((tag)<<4)|((type)<<2)|1),((data)&0xff)
52 #define SHORT_ITEM_2(tag,type,data) (((tag)<<4)|((type)<<2)|2),((data)&0xff),(((data)>>8)&0xff)
53 #define SHORT_ITEM_4(tag,type,data) (((tag)<<4)|((type)<<2)|3),((data)&0xff),(((data)>>8)&0xff),(((data)>>16)&0xff),(((data)>>24)&0xff)
55 #define LONG_ITEM(tag,size) SHORT_ITEM_2(0xf,0x3,((tag)<<8)|(size))
57 #define INPUT(n,data) SHORT_ITEM_##n(0x8,0,data)
58 #define OUTPUT(n,data) SHORT_ITEM_##n(0x9,0,data)
59 #define FEATURE(n,data) SHORT_ITEM_##n(0xb,0,data)
60 #define COLLECTION(n,data) SHORT_ITEM_##n(0xa,0,data)
61 #define END_COLLECTION SHORT_ITEM_0(0xc,0)
63 #define USAGE_PAGE(n,data) SHORT_ITEM_##n(0x0,1,data)
64 #define LOGICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x1,1,data)
65 #define LOGICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,1,data)
66 #define PHYSICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x3,1,data)
67 #define PHYSICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x4,1,data)
68 #define UNIT_EXPONENT(n,data) SHORT_ITEM_##n(0x5,1,data)
69 #define UNIT(n,data) SHORT_ITEM_##n(0x6,1,data)
70 #define REPORT_SIZE(n,data) SHORT_ITEM_##n(0x7,1,data)
71 #define REPORT_ID(n,data) SHORT_ITEM_##n(0x8,1,data)
72 #define REPORT_COUNT(n,data) SHORT_ITEM_##n(0x9,1,data)
73 #define PUSH(n,data) SHORT_ITEM_##n(0xa,1,data)
74 #define POP(n,data) SHORT_ITEM_##n(0xb,1,data)
76 #define USAGE(n,data) SHORT_ITEM_##n(0x0,2,data)
77 #define USAGE_MINIMUM(n,data) SHORT_ITEM_##n(0x1,2,data)
78 #define USAGE_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,2,data)
79 #define DESIGNATOR_INDEX(n,data) SHORT_ITEM_##n(0x3,2,data)
80 #define DESIGNATOR_MINIMUM(n,data) SHORT_ITEM_##n(0x4,2,data)
81 #define DESIGNATOR_MAXIMUM(n,data) SHORT_ITEM_##n(0x5,2,data)
82 #define STRING_INDEX(n,data) SHORT_ITEM_##n(0x6,2,data)
83 #define STRING_MINIMUM(n,data) SHORT_ITEM_##n(0x7,2,data)
84 #define STRING_MAXIMUM(n,data) SHORT_ITEM_##n(0x8,2,data)
85 #define DELIMITER(n,data) SHORT_ITEM_##n(0x9,2,data)