00001 /* 00002 * Copyright (c) 2010 Vojtech Horky 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * - Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * - The name of the author may not be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00019 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00020 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00035 #ifndef VUK_ITEM_H_ 00036 #define VUK_ITEM_H_ 00037 00038 #include <sys/types.h> 00039 00040 typedef uint8_t report_descriptor_data_t[]; 00041 00042 /* Item types. */ 00043 #define ITEM_MAIN 0 00044 #define ITEM_GLOBAL 1 00045 #define ITEM_LOCAL 2 00046 00047 00048 00049 /* Item tags. */ 00050 00051 /* Main item tags. */ 00052 #define TAG_INPUT 8 00053 #define TAG_OUTPUT 9 00054 #define TAG_FEATURE 11 00055 #define TAG_COLLECTION 10 00056 #define TAG_END_COLLECTION 12 00057 00058 /* Global item tags. */ 00059 #define TAG_USAGE_PAGE 0 00060 #define TAG_LOGICAL_MINIMUM 1 00061 #define TAG_LOGICAL_MAXIMUM 2 00062 #define TAG_REPORT_SIZE 7 00063 #define TAG_REPORT_COUNT 9 00064 00065 /* Local item tags. */ 00066 #define TAG_USAGE 0 00067 #define TAG_USAGE_MINIMUM 1 00068 #define TAG_USAGE_MAXIMUM 2 00069 00070 00071 /* Bits for Input, Output and Feature items. */ 00072 #define _IOF(value, shift) ((value) << (shift)) 00073 #define IOF_DATA _IOF(0, 0) 00074 #define IOF_CONSTANT _IOF(1, 0) 00075 #define IOF_ARRAY _IOF(0, 1) 00076 #define IOF_VARIABLE _IOF(1, 1) 00077 #define IOF_ABSOLUTE _IOF(0, 2) 00078 #define IOF_RELATIVE _IOF(1, 2) 00079 /* ... */ 00080 00081 /* Collection types. */ 00082 #define COLLECTION_PHYSICAL 0x00 00083 #define COLLECTION_APPLICATION 0x01 00084 00085 00091 #define BUILD_ITEM_PREFIX(size, type, tag) \ 00092 ((size) | ((type) << 2) | ((tag) << 4)) 00093 00098 #define ITEM_CREATE0(type, tag) \ 00099 BUILD_ITEM_PREFIX(0, type, tag) 00100 00106 #define ITEM_CREATE1(type, tag, data) \ 00107 BUILD_ITEM_PREFIX(1, type, tag), data 00108 00109 00110 #endif 00111