hid_report_items.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Matej Klonfar
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 LIBUSB_HID_REPORT_ITEMS_H_
00036 #define LIBUSB_HID_REPORT_ITEMS_H_
00037 
00038 #include <stdint.h>
00039 
00040 /*---------------------------------------------------------------------------*/
00041 /*
00042  * Item prefix
00043  */
00044 
00046 #define USB_HID_ITEM_SIZE(data)         ((uint8_t)(data & 0x3))
00047 
00049 #define USB_HID_ITEM_TAG(data)          ((uint8_t)((data & 0xF0) >> 4))
00050 
00052 #define USB_HID_ITEM_TAG_CLASS(data)    ((uint8_t)((data & 0xC) >> 2))
00053 
00056 #define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
00057 
00058 /*---------------------------------------------------------------------------*/
00059 /*
00060  * Extended usage macros
00061  */
00062 
00064 #define USB_HID_IS_EXTENDED_USAGE(usage)        ((usage & 0xFFFF0000) != 0)
00065 
00067 #define USB_HID_EXTENDED_USAGE_PAGE(usage)      ((usage & 0xFFFF0000) >> 16)
00068 
00070 #define USB_HID_EXTENDED_USAGE(usage)           (usage & 0xFFFF)
00071 
00072 /*---------------------------------------------------------------------------*/
00073 /*
00074  * Input/Output/Feature Item flags
00075  */
00082 #define USB_HID_ITEM_FLAG_CONSTANT(flags)       ((flags & 0x1) == 0x1)
00083 
00088 #define USB_HID_ITEM_FLAG_VARIABLE(flags)       ((flags & 0x2) == 0x2)
00089 
00096 #define USB_HID_ITEM_FLAG_RELATIVE(flags)       ((flags & 0x4) == 0x4)
00097 
00104 #define USB_HID_ITEM_FLAG_WRAP(flags)           ((flags & 0x8) == 0x8)
00105 
00111 #define USB_HID_ITEM_FLAG_LINEAR(flags)         ((flags & 0x10) == 0x10)
00112 
00118 #define USB_HID_ITEM_FLAG_PREFERRED(flags)      ((flags & 0x20) == 0x20)
00119 
00126 #define USB_HID_ITEM_FLAG_POSITION(flags)       ((flags & 0x40) == 0x40)
00127 
00134 #define USB_HID_ITEM_FLAG_VOLATILE(flags)       ((flags & 0x80) == 0x80)
00135 
00142 #define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
00143 
00144 /*---------------------------------------------------------------------------*/
00145 
00146 /* MAIN ITEMS */
00147 
00152 #define USB_HID_TAG_CLASS_MAIN                  0x0
00153 
00160 #define USB_HID_REPORT_TAG_INPUT                0x8
00161 
00167 #define USB_HID_REPORT_TAG_OUTPUT               0x9
00168 
00173 #define USB_HID_REPORT_TAG_FEATURE              0xB
00174 
00179 #define USB_HID_REPORT_TAG_COLLECTION           0xA
00180 
00185 #define USB_HID_REPORT_TAG_END_COLLECTION       0xC
00186 
00187 /*---------------------------------------------------------------------------*/
00188 
00189 /* GLOBAL ITEMS */
00190 
00194 #define USB_HID_TAG_CLASS_GLOBAL                0x1
00195 
00203 #define USB_HID_REPORT_TAG_USAGE_PAGE           0x0
00204 
00211 #define USB_HID_REPORT_TAG_LOGICAL_MINIMUM      0x1
00212 
00217 #define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM      0x2
00218 
00223 #define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM     0x3
00224 
00228 #define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM     0x4
00229 
00234 #define USB_HID_REPORT_TAG_UNIT_EXPONENT        0x5
00235 
00239 #define USB_HID_REPORT_TAG_UNIT                 0x6
00240 
00245 #define USB_HID_REPORT_TAG_REPORT_SIZE          0x7
00246 
00255 #define USB_HID_REPORT_TAG_REPORT_ID            0x8
00256 
00262 #define USB_HID_REPORT_TAG_REPORT_COUNT         0x9
00263 
00267 #define USB_HID_REPORT_TAG_PUSH                 0xA
00268 
00272 #define USB_HID_REPORT_TAG_POP                  0xB
00273 
00274 /*---------------------------------------------------------------------------*/
00275 
00276 /* LOCAL ITEMS */
00277 
00285 #define USB_HID_TAG_CLASS_LOCAL                 0x2
00286 
00292 #define USB_HID_REPORT_TAG_USAGE                0x0
00293 
00297 #define USB_HID_REPORT_TAG_USAGE_MINIMUM        0x1
00298 
00302 #define USB_HID_REPORT_TAG_USAGE_MAXIMUM        0x2
00303 
00308 #define USB_HID_REPORT_TAG_DESIGNATOR_INDEX     0x3
00309 
00314 #define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM   0x4
00315 
00320 #define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM   0x5
00321 
00326 #define USB_HID_REPORT_TAG_STRING_INDEX         0x7
00327 
00332 #define USB_HID_REPORT_TAG_STRING_MINIMUM       0x8
00333 
00338 #define USB_HID_REPORT_TAG_STRING_MAXIMUM       0x9
00339 
00347 #define USB_HID_REPORT_TAG_DELIMITER            0xA
00348 
00349 /*---------------------------------------------------------------------------*/
00350 
00351 #endif
00352 

Generated on Thu Jun 2 07:45:48 2011 for HelenOS/USB by  doxygen 1.4.7