/usr/include/hidrd/item/local.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 | /** @file
* @brief HID report descriptor - local 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: local.h 87 2009-12-28 15:23:15Z spb_nick $
*/
#ifndef __HIDRD_ITEM_LOCAL_H__
#define __HIDRD_ITEM_LOCAL_H__
#include "hidrd/item/short.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HIDRD_ITEM_LOCAL_TAG_MIN HIDRD_ITEM_SHORT_TAG_MIN
typedef enum hidrd_item_local_tag {
HIDRD_ITEM_LOCAL_TAG_USAGE = HIDRD_ITEM_LOCAL_TAG_MIN,
HIDRD_ITEM_LOCAL_TAG_USAGE_MINIMUM,
HIDRD_ITEM_LOCAL_TAG_USAGE_MAXIMUM,
HIDRD_ITEM_LOCAL_TAG_DESIGNATOR_INDEX,
HIDRD_ITEM_LOCAL_TAG_DESIGNATOR_MINIMUM,
HIDRD_ITEM_LOCAL_TAG_DESIGNATOR_MAXIMUM,
HIDRD_ITEM_LOCAL_TAG_INVALID, /**< Specification has
a hole here */
HIDRD_ITEM_LOCAL_TAG_STRING_INDEX,
HIDRD_ITEM_LOCAL_TAG_STRING_MINIMUM,
HIDRD_ITEM_LOCAL_TAG_STRING_MAXIMUM,
HIDRD_ITEM_LOCAL_TAG_DELIMITER
} hidrd_item_local_tag;
#define HIDRD_ITEM_LOCAL_TAG_MAX HIDRD_ITEM_SHORT_TAG_MAX
#define HIDRD_ITEM_LOCAL_TAG_KNOWN_MAX HIDRD_ITEM_LOCAL_TAG_DELIMITER
#define HIDRD_ITEM_LOCAL_TAG_RESERVED_MIN \
(HIDRD_ITEM_LOCAL_TAG_KNOWN_MAX + 1)
#define HIDRD_ITEM_LOCAL_TAG_RESERVED_MAX \
HIDRD_ITEM_LOCAL_TAG_MAX
static inline bool
hidrd_item_local_tag_valid(hidrd_item_local_tag tag)
{
return (tag <= HIDRD_ITEM_LOCAL_TAG_MAX) &&
(tag != HIDRD_ITEM_LOCAL_TAG_INVALID);
}
static inline bool
hidrd_item_local_tag_known(hidrd_item_local_tag tag)
{
assert(hidrd_item_local_tag_valid(tag));
return (tag <= HIDRD_ITEM_LOCAL_TAG_KNOWN_MAX);
}
static inline bool
hidrd_item_local_tag_reserved(hidrd_item_local_tag tag)
{
assert(hidrd_item_local_tag_valid(tag));
return (tag >= HIDRD_ITEM_LOCAL_TAG_RESERVED_MIN) &&
(tag <= HIDRD_ITEM_LOCAL_TAG_RESERVED_MAX);
}
HIDRD_ITEM_SHORT_GEN_FUNCS(local, LOCAL)
#define HIDRD_ITEM_LOCAL_FUNCS(_name, _NAME, _int_type, _ext_type) \
static inline bool \
hidrd_item_##_name##_valid_class(const hidrd_item *item) \
{ \
return hidrd_item_local_valid_class(item) && \
hidrd_item_local_get_tag(item) == \
HIDRD_ITEM_LOCAL_TAG_##_NAME; \
} \
\
static inline bool \
hidrd_item_##_name##_valid_inst(const hidrd_item *item) \
{ \
assert(hidrd_item_##_name##_valid_class(item)); \
return hidrd_item_local_valid_inst(item) && \
hidrd_item_##_name##_value_valid( \
(_int_type)hidrd_item_local_get_unsigned(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; \
} \
\
static inline _ext_type \
hidrd_item_##_name##_get_value(const hidrd_item *item) \
{ \
_int_type value; \
assert(hidrd_item_##_name##_valid(item)); \
value = (_int_type)hidrd_item_local_get_unsigned(item); \
assert(hidrd_item_##_name##_value_valid(value)); \
return (_ext_type)value; \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_set_value(hidrd_item *item, _ext_type value) \
{ \
assert(hidrd_item_##_name##_valid(item)); \
assert(hidrd_item_##_name##_value_valid((_int_type)value)); \
return hidrd_item_local_set_unsigned(item, (_int_type)value); \
} \
\
static inline hidrd_item * \
hidrd_item_##_name##_init(hidrd_item *item, _ext_type value) \
{ \
assert(hidrd_item_##_name##_value_valid((_int_type)value)); \
\
return hidrd_item_##_name##_validate( \
hidrd_item_local_init_unsigned( \
item, HIDRD_ITEM_LOCAL_TAG_##_NAME, \
(_int_type)value)); \
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __HIDRD_ITEM_LOCAL_H__ */
|