1 /* 2 * types.h: HID Parser types definitions 3 * 4 * This file is part of the MGE UPS SYSTEMS HID Parser 5 * 6 * Copyright (C) 7 * 1998-2003 MGE UPS SYSTEMS, Luc Descotils 8 * 2015 Eaton, Arnaud Quette (Update MAX_REPORT) 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * 24 * -------------------------------------------------------------------------- */ 25 26 #ifndef HIDTYPES_H 27 #define HIDTYPES_H 28 29 #ifdef __cplusplus 30 /* *INDENT-OFF* */ 31 extern "C" { 32 /* *INDENT-ON* */ 33 #endif /* __cplusplus */ 34 35 #include <sys/types.h> 36 37 #include "nut_stdint.h" 38 39 /* 40 * Constants 41 * -------------------------------------------------------------------------- */ 42 #define PATH_SIZE 10 /* Deep max for Path */ 43 #define USAGE_TAB_SIZE 50 /* Size of usage stack */ 44 #define MAX_REPORT 500 /* Including FEATURE, INPUT and OUTPUT */ 45 #define REPORT_DSC_SIZE 6144 /* Size max of Report Descriptor */ 46 #define MAX_REPORT_TS 3 /* Max time validity of a report */ 47 48 /* 49 * Items 50 * -------------------------------------------------------------------------- */ 51 #define SIZE_0 0x00 52 #define SIZE_1 0x01 53 #define SIZE_2 0x02 54 #define SIZE_4 0x03 55 #define SIZE_MASK 0x03 56 57 #define TYPE_MAIN 0x00 58 #define TYPE_GLOBAL 0x04 59 #define TYPE_LOCAL 0x08 60 #define TYPE_MASK 0x0C 61 62 /* Main items */ 63 #define ITEM_COLLECTION 0xA0 64 #define ITEM_END_COLLECTION 0xC0 65 #define ITEM_FEATURE 0xB0 66 #define ITEM_INPUT 0x80 67 #define ITEM_OUTPUT 0x90 68 69 /* Global items */ 70 #define ITEM_UPAGE 0x04 71 #define ITEM_LOG_MIN 0x14 72 #define ITEM_LOG_MAX 0x24 73 #define ITEM_PHY_MIN 0x34 74 #define ITEM_PHY_MAX 0x44 75 #define ITEM_UNIT_EXP 0x54 76 #define ITEM_UNIT 0x64 77 #define ITEM_REP_SIZE 0x74 78 #define ITEM_REP_ID 0x84 79 #define ITEM_REP_COUNT 0x94 80 81 /* Local items */ 82 #define ITEM_USAGE 0x08 83 #define ITEM_STRING 0x78 84 85 /* Long item */ 86 #define ITEM_LONG 0xFC 87 88 #define ITEM_MASK 0xFC 89 90 /* Attribute Flags */ 91 #define ATTR_DATA_CST 0x01 92 #define ATTR_NVOL_VOL 0x80 93 94 /* 95 * HIDNode_t struct 96 * 97 * Describe a HID Path point: Usage = bits 0..15, UPage = bits 16..31 98 * -------------------------------------------------------------------------- */ 99 typedef uint32_t HIDNode_t; 100 101 /* 102 * HIDPath struct 103 * 104 * Describe a HID Path 105 * -------------------------------------------------------------------------- */ 106 typedef struct { 107 uint8_t Size; /* HID Path size */ 108 HIDNode_t Node[PATH_SIZE]; /* HID Path */ 109 } HIDPath_t; 110 111 /* 112 * HIDData struct 113 * 114 * Describe a HID Data with its location in report 115 * -------------------------------------------------------------------------- */ 116 typedef struct { 117 HIDPath_t Path; /* HID Path */ 118 119 uint8_t ReportID; /* Report ID */ 120 uint8_t Offset; /* Offset of data in report */ 121 uint8_t Size; /* Size of data in bit */ 122 123 uint8_t Type; /* Type : FEATURE / INPUT / OUTPUT */ 124 uint8_t Attribute; /* Report field attribute */ 125 126 long Unit; /* HID Unit */ 127 int8_t UnitExp; /* Unit exponent */ 128 129 long LogMin; /* Logical Min */ 130 long LogMax; /* Logical Max */ 131 long PhyMin; /* Physical Min */ 132 long PhyMax; /* Physical Max */ 133 int8_t have_PhyMin; /* Physical Min defined? */ 134 int8_t have_PhyMax; /* Physical Max defined? */ 135 } HIDData_t; 136 137 /* 138 * HIDDesc struct 139 * 140 * Holds a parsed report descriptor 141 * -------------------------------------------------------------------------- */ 142 typedef struct { 143 int nitems; /* number of items in descriptor */ 144 HIDData_t *item; /* list of items */ 145 int replen[256]; /* list of report lengths, in byte */ 146 } HIDDesc_t; 147 148 #ifdef __cplusplus 149 /* *INDENT-OFF* */ 150 } /* extern "C" */ 151 /* *INDENT-ON* */ 152 #endif /* __cplusplus */ 153 154 #endif /* HIDTYPES_H */ 155