| 1 | /* |
| 2 | * hidpi.h |
| 3 | * |
| 4 | * Public Interface for HID parsing library. |
| 5 | * |
| 6 | * This file is part of the mingw-w64 package. |
| 7 | * |
| 8 | * Contributors: |
| 9 | * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> |
| 10 | * Extended by Kai Tietz |
| 11 | * |
| 12 | * THIS SOFTWARE IS NOT COPYRIGHTED |
| 13 | * |
| 14 | * This source code is offered for use in the public domain. You may |
| 15 | * use, modify or distribute it freely. |
| 16 | * |
| 17 | * This code is distributed in the hope that it will be useful but |
| 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY |
| 19 | * DISCLAIMED. This includes but is not limited to warranties of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <winapifamily.h> |
| 25 | |
| 26 | #ifndef __HIDPI_H__ |
| 27 | #define __HIDPI_H__ |
| 28 | |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
| 33 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) |
| 34 | |
| 35 | #include <pshpack4.h> |
| 36 | |
| 37 | #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1) |
| 38 | #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0) |
| 39 | |
| 40 | #define HidP_IsSameUsageAndPage(u1, u2) ((*((PULONG) &u1)) == (*((PULONG) &u2))) |
| 41 | #define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) HidP_SetUsages (Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) |
| 42 | #define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) HidP_UnsetUsages (Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) |
| 43 | #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) HidP_GetUsages (Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) |
| 44 | #define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe) HidP_GetUsagesEx (Rty, LCo, BLi, ULe, Ppd, Rep, RLe) |
| 45 | |
| 46 | typedef PUCHAR PHIDP_REPORT_DESCRIPTOR; |
| 47 | typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA; |
| 48 | |
| 49 | typedef enum _HIDP_REPORT_TYPE { |
| 50 | HidP_Input, |
| 51 | HidP_Output, |
| 52 | HidP_Feature |
| 53 | } HIDP_REPORT_TYPE; |
| 54 | |
| 55 | typedef struct _USAGE_AND_PAGE { |
| 56 | USAGE Usage; |
| 57 | USAGE UsagePage; |
| 58 | } USAGE_AND_PAGE,*PUSAGE_AND_PAGE; |
| 59 | |
| 60 | typedef struct _HIDP_BUTTON_CAPS { |
| 61 | USAGE UsagePage; |
| 62 | UCHAR ReportID; |
| 63 | BOOLEAN IsAlias; |
| 64 | USHORT BitField; |
| 65 | USHORT LinkCollection; |
| 66 | USAGE LinkUsage; |
| 67 | USAGE LinkUsagePage; |
| 68 | BOOLEAN IsRange; |
| 69 | BOOLEAN IsStringRange; |
| 70 | BOOLEAN IsDesignatorRange; |
| 71 | BOOLEAN IsAbsolute; |
| 72 | ULONG Reserved[10]; |
| 73 | __C89_NAMELESS union { |
| 74 | struct { |
| 75 | USAGE UsageMin, UsageMax; |
| 76 | USHORT StringMin, StringMax; |
| 77 | USHORT DesignatorMin, DesignatorMax; |
| 78 | USHORT DataIndexMin, DataIndexMax; |
| 79 | } Range; |
| 80 | struct { |
| 81 | USAGE Usage, Reserved1; |
| 82 | USHORT StringIndex, Reserved2; |
| 83 | USHORT DesignatorIndex, Reserved3; |
| 84 | USHORT DataIndex, Reserved4; |
| 85 | } NotRange; |
| 86 | }; |
| 87 | } HIDP_BUTTON_CAPS,*PHIDP_BUTTON_CAPS; |
| 88 | |
| 89 | typedef struct _HIDP_VALUE_CAPS { |
| 90 | USAGE UsagePage; |
| 91 | UCHAR ReportID; |
| 92 | BOOLEAN IsAlias; |
| 93 | USHORT BitField; |
| 94 | USHORT LinkCollection; |
| 95 | USAGE LinkUsage; |
| 96 | USAGE LinkUsagePage; |
| 97 | BOOLEAN IsRange; |
| 98 | BOOLEAN IsStringRange; |
| 99 | BOOLEAN IsDesignatorRange; |
| 100 | BOOLEAN IsAbsolute; |
| 101 | BOOLEAN HasNull; |
| 102 | UCHAR Reserved; |
| 103 | USHORT BitSize; |
| 104 | USHORT ReportCount; |
| 105 | USHORT Reserved2[5]; |
| 106 | ULONG UnitsExp; |
| 107 | ULONG Units; |
| 108 | LONG LogicalMin, LogicalMax; |
| 109 | LONG PhysicalMin, PhysicalMax; |
| 110 | __C89_NAMELESS union { |
| 111 | struct { |
| 112 | USAGE UsageMin, UsageMax; |
| 113 | USHORT StringMin, StringMax; |
| 114 | USHORT DesignatorMin, DesignatorMax; |
| 115 | USHORT DataIndexMin, DataIndexMax; |
| 116 | } Range; |
| 117 | struct { |
| 118 | USAGE Usage, Reserved1; |
| 119 | USHORT StringIndex, Reserved2; |
| 120 | USHORT DesignatorIndex, Reserved3; |
| 121 | USHORT DataIndex, Reserved4; |
| 122 | } NotRange; |
| 123 | }; |
| 124 | } HIDP_VALUE_CAPS,*PHIDP_VALUE_CAPS; |
| 125 | |
| 126 | typedef struct _HIDP_LINK_COLLECTION_NODE { |
| 127 | USAGE LinkUsage; |
| 128 | USAGE LinkUsagePage; |
| 129 | USHORT Parent; |
| 130 | USHORT NumberOfChildren; |
| 131 | USHORT NextSibling; |
| 132 | USHORT FirstChild; |
| 133 | ULONG CollectionType: 8; |
| 134 | ULONG IsAlias : 1; |
| 135 | ULONG Reserved: 23; |
| 136 | PVOID UserContext; |
| 137 | } HIDP_LINK_COLLECTION_NODE,*PHIDP_LINK_COLLECTION_NODE; |
| 138 | |
| 139 | typedef struct _HIDP_CAPS { |
| 140 | USAGE Usage; |
| 141 | USAGE UsagePage; |
| 142 | USHORT InputReportByteLength; |
| 143 | USHORT OutputReportByteLength; |
| 144 | USHORT FeatureReportByteLength; |
| 145 | USHORT Reserved[17]; |
| 146 | USHORT NumberLinkCollectionNodes; |
| 147 | USHORT NumberInputButtonCaps; |
| 148 | USHORT NumberInputValueCaps; |
| 149 | USHORT NumberInputDataIndices; |
| 150 | USHORT NumberOutputButtonCaps; |
| 151 | USHORT NumberOutputValueCaps; |
| 152 | USHORT NumberOutputDataIndices; |
| 153 | USHORT NumberFeatureButtonCaps; |
| 154 | USHORT NumberFeatureValueCaps; |
| 155 | USHORT NumberFeatureDataIndices; |
| 156 | } HIDP_CAPS,*PHIDP_CAPS; |
| 157 | |
| 158 | typedef struct _HIDP_DATA { |
| 159 | USHORT DataIndex; |
| 160 | USHORT Reserved; |
| 161 | __C89_NAMELESS union { |
| 162 | ULONG RawValue; |
| 163 | BOOLEAN On; |
| 164 | }; |
| 165 | } HIDP_DATA,*PHIDP_DATA; |
| 166 | |
| 167 | typedef struct _HIDP_UNKNOWN_TOKEN { |
| 168 | UCHAR Token; |
| 169 | UCHAR Reserved[3]; |
| 170 | ULONG BitField; |
| 171 | } HIDP_UNKNOWN_TOKEN,*PHIDP_UNKNOWN_TOKEN; |
| 172 | |
| 173 | typedef struct _HIDP_EXTENDED_ATTRIBUTES { |
| 174 | UCHAR NumGlobalUnknowns; |
| 175 | UCHAR Reserved [3]; |
| 176 | PHIDP_UNKNOWN_TOKEN GlobalUnknowns; |
| 177 | ULONG Data [1]; |
| 178 | } HIDP_EXTENDED_ATTRIBUTES,*PHIDP_EXTENDED_ATTRIBUTES; |
| 179 | |
| 180 | typedef enum _HIDP_KEYBOARD_DIRECTION { |
| 181 | HidP_Keyboard_Break, |
| 182 | HidP_Keyboard_Make |
| 183 | } HIDP_KEYBOARD_DIRECTION; |
| 184 | |
| 185 | typedef struct _HIDP_KEYBOARD_MODIFIER_STATE { |
| 186 | __C89_NAMELESS union { |
| 187 | struct { |
| 188 | ULONG LeftControl: 1; |
| 189 | ULONG LeftShift: 1; |
| 190 | ULONG LeftAlt: 1; |
| 191 | ULONG LeftGUI: 1; |
| 192 | ULONG RightControl: 1; |
| 193 | ULONG RightShift: 1; |
| 194 | ULONG RightAlt: 1; |
| 195 | ULONG RigthGUI: 1; |
| 196 | ULONG CapsLock: 1; |
| 197 | ULONG ScollLock: 1; |
| 198 | ULONG NumLock: 1; |
| 199 | ULONG Reserved: 21; |
| 200 | }; |
| 201 | ULONG ul; |
| 202 | }; |
| 203 | } HIDP_KEYBOARD_MODIFIER_STATE,*PHIDP_KEYBOARD_MODIFIER_STATE; |
| 204 | |
| 205 | typedef BOOLEAN (*PHIDP_INSERT_SCANCODES) (PVOID Context, PCHAR NewScanCodes, ULONG Length); |
| 206 | |
| 207 | NTSTATUS NTAPI HidP_GetCaps (PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities); |
| 208 | NTSTATUS NTAPI HidP_GetLinkCollectionNodes (PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, PULONG LinkCollectionNodesLength, PHIDP_PREPARSED_DATA PreparsedData); |
| 209 | NTSTATUS NTAPI HidP_GetSpecificButtonCaps (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData); |
| 210 | NTSTATUS NTAPI HidP_GetButtonCaps (HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData); |
| 211 | NTSTATUS NTAPI HidP_GetSpecificValueCaps (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData); |
| 212 | NTSTATUS NTAPI HidP_GetValueCaps (HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData); |
| 213 | NTSTATUS NTAPI HidP_GetExtendedAttributes (HIDP_REPORT_TYPE ReportType, USHORT DataIndex, PHIDP_PREPARSED_DATA PreparsedData, PHIDP_EXTENDED_ATTRIBUTES Attributes, PULONG LengthAttributes); |
| 214 | NTSTATUS NTAPI HidP_InitializeReportForID (HIDP_REPORT_TYPE ReportType, UCHAR ReportID, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 215 | NTSTATUS NTAPI HidP_SetData (HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 216 | NTSTATUS NTAPI HidP_GetData (HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 217 | ULONG NTAPI HidP_MaxDataListLength (HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData); |
| 218 | NTSTATUS NTAPI HidP_SetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 219 | NTSTATUS NTAPI HidP_UnsetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 220 | NTSTATUS NTAPI HidP_GetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 221 | NTSTATUS NTAPI HidP_GetUsagesEx (HIDP_REPORT_TYPE ReportType, USHORT LinkCollection, PUSAGE_AND_PAGE ButtonList, ULONG *UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 222 | ULONG NTAPI HidP_MaxUsageListLength (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, PHIDP_PREPARSED_DATA PreparsedData); |
| 223 | NTSTATUS NTAPI HidP_SetUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, ULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 224 | NTSTATUS NTAPI HidP_SetScaledUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, LONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 225 | NTSTATUS NTAPI HidP_SetUsageValueArray (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PCHAR UsageValue, USHORT UsageValueByteLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 226 | NTSTATUS NTAPI HidP_GetUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 227 | NTSTATUS NTAPI HidP_GetScaledUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PLONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 228 | NTSTATUS NTAPI HidP_GetUsageValueArray (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PCHAR UsageValue, USHORT UsageValueByteLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); |
| 229 | NTSTATUS NTAPI HidP_UsageListDifference (PUSAGE PreviousUsageList, PUSAGE CurrentUsageList, PUSAGE BreakUsageList, PUSAGE MakeUsageList, ULONG UsageListLength); |
| 230 | NTSTATUS NTAPI HidP_UsageAndPageListDifference (PUSAGE_AND_PAGE PreviousUsageList, PUSAGE_AND_PAGE CurrentUsageList, PUSAGE_AND_PAGE BreakUsageList, PUSAGE_AND_PAGE MakeUsageList, ULONG UsageListLength); |
| 231 | NTSTATUS NTAPI HidP_TranslateUsageAndPagesToI8042ScanCodes (PUSAGE_AND_PAGE ChangedUsageList, ULONG UsageListLength, HIDP_KEYBOARD_DIRECTION KeyAction, PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, PHIDP_INSERT_SCANCODES InsertCodesProcedure, PVOID InsertCodesContext); |
| 232 | NTSTATUS NTAPI HidP_TranslateUsagesToI8042ScanCodes (PUSAGE ChangedUsageList, ULONG UsageListLength, HIDP_KEYBOARD_DIRECTION KeyAction, PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, PHIDP_INSERT_SCANCODES InsertCodesProcedure, PVOID InsertCodesContext); |
| 233 | |
| 234 | #ifndef FACILITY_HID_ERROR_CODE |
| 235 | #define FACILITY_HID_ERROR_CODE 0x11 |
| 236 | #endif |
| 237 | |
| 238 | #define HIDP_ERROR_CODES(SEV, CODE) ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE))) |
| 239 | |
| 240 | #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES (0x0, 0)) |
| 241 | #define HIDP_STATUS_NULL (HIDP_ERROR_CODES (0x8, 1)) |
| 242 | #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES (0xc, 1)) |
| 243 | #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES (0xc, 2)) |
| 244 | #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES (0xc, 3)) |
| 245 | #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES (0xc, 4)) |
| 246 | #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES (0xc, 5)) |
| 247 | #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES (0xc, 6)) |
| 248 | #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES (0xc, 7)) |
| 249 | #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES (0xc, 8)) |
| 250 | #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES (0xc, 9)) |
| 251 | #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES (0xc, 0xa)) |
| 252 | #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES (0xc, 0xb)) |
| 253 | #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES (0xc, 0xc)) |
| 254 | #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES (0xc, 0xd)) |
| 255 | #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES (0xc, 0xe)) |
| 256 | #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES (0xc, 0xf)) |
| 257 | #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES (0xc, 0x10)) |
| 258 | #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES (0xc, 0x20)) |
| 259 | |
| 260 | #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN |
| 261 | |
| 262 | #include <poppack.h> |
| 263 | |
| 264 | #endif |
| 265 | |
| 266 | #ifdef __cplusplus |
| 267 | } |
| 268 | #endif |
| 269 | #endif |