/usr/include/hidrd/item/main.h is in libhidrd0-dev 0.2.0-11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /** @file
* @brief HID report descriptor - main item
*
* Copyright (C) 2009 Nikolai Kondrashov
*
* This file is part of hidrd.
*
* Hidrd 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 2 of the License, or
* (at your option) any later version.
*
* Hidrd 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 hidrd; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @author Nikolai Kondrashov <spbnick@gmail.com>
*
* @(#) $Id: main.h 264 2010-03-12 12:56:14Z spb_nick $
*/
#ifndef __HIDRD_ITEM_MAIN_H__
#define __HIDRD_ITEM_MAIN_H__
#include "hidrd/item/short.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HIDRD_ITEM_MAIN_TAG_MIN (HIDRD_ITEM_SHORT_TAG_MIN + 0x08)
typedef enum hidrd_item_main_tag {
HIDRD_ITEM_MAIN_TAG_INPUT = HIDRD_ITEM_MAIN_TAG_MIN,
HIDRD_ITEM_MAIN_TAG_OUTPUT,
HIDRD_ITEM_MAIN_TAG_COLLECTION,
HIDRD_ITEM_MAIN_TAG_FEATURE,
HIDRD_ITEM_MAIN_TAG_END_COLLECTION
} hidrd_item_main_tag;
#define HIDRD_ITEM_MAIN_TAG_MAX HIDRD_ITEM_SHORT_TAG_MAX
#define HIDRD_ITEM_MAIN_TAG_KNOWN_MAX HIDRD_ITEM_MAIN_TAG_END_COLLECTION
#define HIDRD_ITEM_MAIN_TAG_RESERVED_MIN \
(HIDRD_ITEM_MAIN_TAG_KNOWN_MAX + 1)
#define HIDRD_ITEM_MAIN_TAG_RESERVED_MAX \
HIDRD_ITEM_MAIN_TAG_MAX
static inline bool
hidrd_item_main_tag_valid(hidrd_item_main_tag tag)
{
return (tag >= HIDRD_ITEM_MAIN_TAG_MIN) &&
(tag <= HIDRD_ITEM_MAIN_TAG_MAX);
}
static inline bool
hidrd_item_main_tag_known(hidrd_item_main_tag tag)
{
assert(hidrd_item_main_tag_valid(tag));
return (tag <= HIDRD_ITEM_MAIN_TAG_KNOWN_MAX);
}
static inline bool
hidrd_item_main_tag_reserved(hidrd_item_main_tag tag)
{
assert(hidrd_item_main_tag_valid(tag));
return (tag >= HIDRD_ITEM_MAIN_TAG_RESERVED_MIN) &&
(tag <= HIDRD_ITEM_MAIN_TAG_RESERVED_MAX);
}
HIDRD_ITEM_SHORT_GEN_FUNCS(main, MAIN)
static inline hidrd_item *
hidrd_item_main_set_bit(hidrd_item *item, uint8_t idx, bool val)
{
assert(hidrd_item_main_valid(item));
assert(idx <= 31);
return hidrd_item_short_set_bit(item, idx, val);
}
static inline bool
hidrd_item_main_get_bit(const hidrd_item *item, uint8_t idx)
{
assert(hidrd_item_main_valid(item));
assert(idx <= 31);
return hidrd_item_short_get_bit(item, idx);
}
#define HIDRD_ITEM_MAIN_GEN_FUNCS(_name, _NAME) \
static inline bool \
hidrd_item_##_name##_valid_class(const hidrd_item *item) \
{ \
return hidrd_item_main_valid_class(item) && \
hidrd_item_main_get_tag(item) == \
HIDRD_ITEM_MAIN_TAG_##_NAME; \
} \
\
static inline bool \
hidrd_item_##_name##_valid_inst(const hidrd_item *item) \
{ \
assert(hidrd_item_##_name##_valid_class(item)); \
return hidrd_item_main_valid_inst(item); \
} \
\
static inline bool \
hidrd_item_##_name##_valid(const hidrd_item *item) \
{ \
return hidrd_item_##_name##_valid_class(item) && \
hidrd_item_##_name##_valid_inst(item); \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_validate(hidrd_item *item) \
{ \
assert(hidrd_item_##_name##_valid(item)); \
return item; \
}
#define HIDRD_ITEM_MAIN_BIT_FUNCS(_name, _NAME) \
static inline hidrd_item * \
hidrd_item_##_name##_init(hidrd_item *item, \
uint32_t bitmask) \
{ \
return hidrd_item_##_name##_validate( \
hidrd_item_main_init_unsigned( \
item, \
HIDRD_ITEM_MAIN_TAG_##_NAME, \
bitmask)); \
} \
\
static inline bool \
hidrd_item_##_name##_get_bit(const hidrd_item *item, \
uint8_t idx) \
{ \
assert(hidrd_item_##_name##_valid(item)); \
assert(idx <= 31); \
return hidrd_item_main_get_bit(item, idx); \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_set_bit(hidrd_item *item, \
uint8_t idx, bool val) \
{ \
assert(hidrd_item_##_name##_valid(item)); \
assert(idx <= 31); \
return hidrd_item_main_set_bit(item, idx, val); \
}
#define HIDRD_ITEM_MAIN_BIT_ACC(_name, _idx, _off_name, _on_name) \
static inline bool \
hidrd_item_##_name##_is_##_off_name(const hidrd_item *item) \
{ \
return !hidrd_item_##_name##_get_bit(item, _idx); \
} \
\
static inline bool \
hidrd_item_##_name##_is_##_on_name(const hidrd_item *item) \
{ \
return hidrd_item_##_name##_get_bit(item, _idx); \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_set_##_off_name(hidrd_item *item, \
bool is_##_off_name) \
{ \
return hidrd_item_##_name##_set_bit(item, _idx, \
!is_##_off_name); \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_set_##_on_name(hidrd_item *item, \
bool is_##_on_name) \
{ \
return hidrd_item_##_name##_set_bit(item, _idx, \
is_##_on_name); \
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __HIDRD_ITEM_MAIN_H__ */
|