[5247411] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 Vojtech Horky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[679a135] | 29 | /** @addtogroup usbvirtkbd
|
---|
[5247411] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief HID Item related functions.
|
---|
| 34 | */
|
---|
| 35 | #ifndef VUK_ITEM_H_
|
---|
| 36 | #define VUK_ITEM_H_
|
---|
| 37 |
|
---|
[8d2dd7f2] | 38 | #include <stdint.h>
|
---|
[5247411] | 39 |
|
---|
[bbf79e0] | 40 | typedef uint8_t report_descriptor_data_t[];
|
---|
[5247411] | 41 |
|
---|
| 42 | /* Item types. */
|
---|
| 43 | #define ITEM_MAIN 0
|
---|
| 44 | #define ITEM_GLOBAL 1
|
---|
| 45 | #define ITEM_LOCAL 2
|
---|
| 46 |
|
---|
| 47 | /* Item tags. */
|
---|
| 48 |
|
---|
| 49 | /* Main item tags. */
|
---|
| 50 | #define TAG_INPUT 8
|
---|
| 51 | #define TAG_OUTPUT 9
|
---|
| 52 | #define TAG_FEATURE 11
|
---|
| 53 | #define TAG_COLLECTION 10
|
---|
| 54 | #define TAG_END_COLLECTION 12
|
---|
| 55 |
|
---|
| 56 | /* Global item tags. */
|
---|
| 57 | #define TAG_USAGE_PAGE 0
|
---|
| 58 | #define TAG_LOGICAL_MINIMUM 1
|
---|
| 59 | #define TAG_LOGICAL_MAXIMUM 2
|
---|
| 60 | #define TAG_REPORT_SIZE 7
|
---|
| 61 | #define TAG_REPORT_COUNT 9
|
---|
| 62 |
|
---|
| 63 | /* Local item tags. */
|
---|
| 64 | #define TAG_USAGE 0
|
---|
| 65 | #define TAG_USAGE_MINIMUM 1
|
---|
| 66 | #define TAG_USAGE_MAXIMUM 2
|
---|
| 67 |
|
---|
| 68 | /* Bits for Input, Output and Feature items. */
|
---|
| 69 | #define _IOF(value, shift) ((value) << (shift))
|
---|
| 70 | #define IOF_DATA _IOF(0, 0)
|
---|
| 71 | #define IOF_CONSTANT _IOF(1, 0)
|
---|
| 72 | #define IOF_ARRAY _IOF(0, 1)
|
---|
| 73 | #define IOF_VARIABLE _IOF(1, 1)
|
---|
| 74 | #define IOF_ABSOLUTE _IOF(0, 2)
|
---|
| 75 | #define IOF_RELATIVE _IOF(1, 2)
|
---|
| 76 | /* ... */
|
---|
| 77 |
|
---|
| 78 | /* Collection types. */
|
---|
| 79 | #define COLLECTION_PHYSICAL 0x00
|
---|
| 80 | #define COLLECTION_APPLICATION 0x01
|
---|
| 81 |
|
---|
| 82 | /** Creates item prefix.
|
---|
| 83 | * @param size Item size.
|
---|
| 84 | * @param type Item type.
|
---|
| 85 | * @param tag Item tag.
|
---|
| 86 | */
|
---|
| 87 | #define BUILD_ITEM_PREFIX(size, type, tag) \
|
---|
| 88 | ((size) | ((type) << 2) | ((tag) << 4))
|
---|
| 89 |
|
---|
| 90 | /** Create no-data item.
|
---|
| 91 | * @param type Item type.
|
---|
| 92 | * @param tag Item tag.
|
---|
| 93 | */
|
---|
| 94 | #define ITEM_CREATE0(type, tag) \
|
---|
| 95 | BUILD_ITEM_PREFIX(0, type, tag)
|
---|
| 96 |
|
---|
| 97 | /** Create item with 1-byte data.
|
---|
| 98 | * @param type Item type.
|
---|
| 99 | * @param tag Item tag.
|
---|
| 100 | * @param data Item data (single byte).
|
---|
| 101 | */
|
---|
| 102 | #define ITEM_CREATE1(type, tag, data) \
|
---|
| 103 | BUILD_ITEM_PREFIX(1, type, tag), data
|
---|
| 104 |
|
---|
| 105 | #endif
|
---|
| 106 | /**
|
---|
| 107 | * @}
|
---|
| 108 | */
|
---|