| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
use shared::hidusage::{PUSAGE, USAGE}; |
| 7 |
use shared::minwindef::{PUCHAR, PULONG, PUSHORT, UCHAR, ULONG, USHORT}; |
| 8 |
use shared::ntdef::NTSTATUS; |
| 9 |
use shared::ntstatus::FACILITY_HID_ERROR_CODE; |
| 10 |
use um::winnt::{BOOLEAN, LONG, PCHAR, PLONG, PVOID}; |
| 11 |
pub const HIDP_LINK_COLLECTION_ROOT: USHORT = -1i16 as u16; |
| 12 |
pub const HIDP_LINK_COLLECTION_UNSPECIFIED: USHORT = 0; |
| 13 |
ENUM!{enum HIDP_REPORT_TYPE { |
| 14 |
HidP_Input, |
| 15 |
HidP_Output, |
| 16 |
HidP_Feature, |
| 17 |
}} |
| 18 |
STRUCT!{struct USAGE_AND_PAGE { |
| 19 |
Usage: USAGE, |
| 20 |
UsagePage: USAGE, |
| 21 |
}} |
| 22 |
pub type PUSAGE_AND_PAGE = *mut USAGE_AND_PAGE; |
| 23 |
// HidP_IsSameUsageAndPage |
| 24 |
STRUCT!{struct HIDP_CAPS_Range { |
| 25 |
UsageMin: USAGE, |
| 26 |
UsageMax: USAGE, |
| 27 |
StringMin: USHORT, |
| 28 |
StringMax: USHORT, |
| 29 |
DesignatorMin: USHORT, |
| 30 |
DesignatorMax: USHORT, |
| 31 |
DataIndexMin: USHORT, |
| 32 |
DataIndexMax: USHORT, |
| 33 |
}} |
| 34 |
STRUCT!{struct HIDP_CAPS_NotRange { |
| 35 |
Usage: USAGE, |
| 36 |
Reserved1: USAGE, |
| 37 |
StringIndex: USHORT, |
| 38 |
Reserved2: USHORT, |
| 39 |
DesignatorIndex: USHORT, |
| 40 |
Reserved3: USHORT, |
| 41 |
DataIndex: USHORT, |
| 42 |
Reserved4: USHORT, |
| 43 |
}} |
| 44 |
UNION!{union HIDP_CAPS_u { |
| 45 |
[u16; 8], |
| 46 |
Range Range_mut: HIDP_CAPS_Range, |
| 47 |
NotRange NotRange_mut: HIDP_CAPS_NotRange, |
| 48 |
}} |
| 49 |
STRUCT!{struct HIDP_BUTTON_CAPS { |
| 50 |
UsagePage: USAGE, |
| 51 |
ReportID: UCHAR, |
| 52 |
IsAlias: BOOLEAN, |
| 53 |
BitField: USHORT, |
| 54 |
LinkCollection: USHORT, |
| 55 |
LinkUsage: USAGE, |
| 56 |
LinkUsagePage: USAGE, |
| 57 |
IsRange: BOOLEAN, |
| 58 |
IsStringRange: BOOLEAN, |
| 59 |
IsDesignatorRange: BOOLEAN, |
| 60 |
IsAbsolute: BOOLEAN, |
| 61 |
Reserved: [ULONG; 10], |
| 62 |
u: HIDP_CAPS_u, |
| 63 |
}} |
| 64 |
pub type PHIDP_BUTTON_CAPS = *mut HIDP_BUTTON_CAPS; |
| 65 |
STRUCT!{struct HIDP_VALUE_CAPS { |
| 66 |
UsagePage: USAGE, |
| 67 |
ReportID: UCHAR, |
| 68 |
IsAlias: BOOLEAN, |
| 69 |
BitField: USHORT, |
| 70 |
LinkCollection: USHORT, |
| 71 |
LinkUsage: USAGE, |
| 72 |
LinkUsagePage: USAGE, |
| 73 |
IsRange: BOOLEAN, |
| 74 |
IsStringRange: BOOLEAN, |
| 75 |
IsDesignatorRange: BOOLEAN, |
| 76 |
IsAbsolute: BOOLEAN, |
| 77 |
HasNull: BOOLEAN, |
| 78 |
Reserved: UCHAR, |
| 79 |
BitSize: USHORT, |
| 80 |
ReportCount: USHORT, |
| 81 |
Reserved2: [USHORT; 5], |
| 82 |
UnitsExp: ULONG, |
| 83 |
Units: ULONG, |
| 84 |
LogicalMin: LONG, |
| 85 |
LogicalMax: LONG, |
| 86 |
PhysicalMin: LONG, |
| 87 |
PhysicalMax: LONG, |
| 88 |
u: HIDP_CAPS_u, |
| 89 |
}} |
| 90 |
pub type PHIDP_VALUE_CAPS = *mut HIDP_VALUE_CAPS; |
| 91 |
STRUCT!{struct HIDP_LINK_COLLECTION_NODE { |
| 92 |
LinkUsage: USAGE, |
| 93 |
LinkUsagePage: USAGE, |
| 94 |
Parent: USHORT, |
| 95 |
NumberOfChildren: USHORT, |
| 96 |
NextSibling: USHORT, |
| 97 |
FirstChild: USHORT, |
| 98 |
bit_fields: ULONG, |
| 99 |
UserContext: PVOID, |
| 100 |
}} |
| 101 |
BITFIELD!{HIDP_LINK_COLLECTION_NODE bit_fields: ULONG [ |
| 102 |
CollectionType set_CollectionType[0..8], |
| 103 |
IsAlias set_IsAlias[8..9], |
| 104 |
]} |
| 105 |
pub type PHIDP_LINK_COLLECTION_NODE = *mut HIDP_LINK_COLLECTION_NODE; |
| 106 |
pub type PHIDP_REPORT_DESCRIPTOR = PUCHAR; |
| 107 |
pub enum HIDP_PREPARSED_DATA {} |
| 108 |
pub type PHIDP_PREPARSED_DATA = *mut HIDP_PREPARSED_DATA; |
| 109 |
STRUCT!{struct HIDP_CAPS { |
| 110 |
Usage: USAGE, |
| 111 |
UsagePage: USAGE, |
| 112 |
InputReportByteLength: USHORT, |
| 113 |
OutputReportByteLength: USHORT, |
| 114 |
FeatureReportByteLength: USHORT, |
| 115 |
Reserved: [USHORT; 17], |
| 116 |
NumberLinkCollectionNodes: USHORT, |
| 117 |
NumberInputButtonCaps: USHORT, |
| 118 |
NumberInputValueCaps: USHORT, |
| 119 |
NumberInputDataIndices: USHORT, |
| 120 |
NumberOutputButtonCaps: USHORT, |
| 121 |
NumberOutputValueCaps: USHORT, |
| 122 |
NumberOutputDataIndices: USHORT, |
| 123 |
NumberFeatureButtonCaps: USHORT, |
| 124 |
NumberFeatureValueCaps: USHORT, |
| 125 |
NumberFeatureDataIndices: USHORT, |
| 126 |
}} |
| 127 |
pub type PHIDP_CAPS = *mut HIDP_CAPS; |
| 128 |
UNION!{union HIDP_DATA_u { |
| 129 |
[u32; 1], |
| 130 |
RawValue RawValue_mut: ULONG, |
| 131 |
On On_mut: BOOLEAN, |
| 132 |
}} |
| 133 |
STRUCT!{struct HIDP_DATA { |
| 134 |
DataIndex: USHORT, |
| 135 |
Reserved: USHORT, |
| 136 |
u: HIDP_DATA_u, |
| 137 |
}} |
| 138 |
pub type PHIDP_DATA = *mut HIDP_DATA; |
| 139 |
STRUCT!{struct HIDP_UNKNOWN_TOKEN { |
| 140 |
Token: UCHAR, |
| 141 |
Reserved: [UCHAR; 3], |
| 142 |
BitField: ULONG, |
| 143 |
}} |
| 144 |
pub type PHIDP_UNKNOWN_TOKEN = *mut HIDP_UNKNOWN_TOKEN; |
| 145 |
STRUCT!{struct HIDP_EXTENDED_ATTRIBUTES { |
| 146 |
NumGlobalUnknowns: UCHAR, |
| 147 |
Reserved: [UCHAR; 3], |
| 148 |
GlobalUnknowns: PHIDP_UNKNOWN_TOKEN, |
| 149 |
Data: [ULONG; 1], |
| 150 |
}} |
| 151 |
pub type PHIDP_EXTENDED_ATTRIBUTES = *mut HIDP_EXTENDED_ATTRIBUTES; |
| 152 |
extern "system" { |
| 153 |
pub fn HidP_GetCaps( |
| 154 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 155 |
Capabilities: PHIDP_CAPS, |
| 156 |
) -> NTSTATUS; |
| 157 |
pub fn HidP_GetLinkCollectionNodes( |
| 158 |
LinkCollectionNodes: PHIDP_LINK_COLLECTION_NODE, |
| 159 |
LinkCollectionNodesLength: PULONG, |
| 160 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 161 |
) -> NTSTATUS; |
| 162 |
pub fn HidP_GetSpecificButtonCaps( |
| 163 |
ReportType: HIDP_REPORT_TYPE, |
| 164 |
UsagePage: USAGE, |
| 165 |
LinkCollection: USHORT, |
| 166 |
Usage: USAGE, |
| 167 |
ButtonCaps: PHIDP_BUTTON_CAPS, |
| 168 |
ButtonCapsLength: PUSHORT, |
| 169 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 170 |
) -> NTSTATUS; |
| 171 |
pub fn HidP_GetButtonCaps( |
| 172 |
ReportType: HIDP_REPORT_TYPE, |
| 173 |
ButtonCaps: PHIDP_BUTTON_CAPS, |
| 174 |
ButtonCapsLength: PUSHORT, |
| 175 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 176 |
) -> NTSTATUS; |
| 177 |
pub fn HidP_GetSpecificValueCaps( |
| 178 |
ReportType: HIDP_REPORT_TYPE, |
| 179 |
UsagePage: USAGE, |
| 180 |
LinkCollection: USHORT, |
| 181 |
Usage: USAGE, |
| 182 |
ValueCaps: PHIDP_VALUE_CAPS, |
| 183 |
ValueCapsLength: PUSHORT, |
| 184 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 185 |
) -> NTSTATUS; |
| 186 |
pub fn HidP_GetValueCaps( |
| 187 |
ReportType: HIDP_REPORT_TYPE, |
| 188 |
ValueCaps: PHIDP_VALUE_CAPS, |
| 189 |
ValueCapsLength: PUSHORT, |
| 190 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 191 |
) -> NTSTATUS; |
| 192 |
pub fn HidP_GetExtendedAttributes( |
| 193 |
ReportType: HIDP_REPORT_TYPE, |
| 194 |
DataIndex: USHORT, |
| 195 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 196 |
Attributes: PHIDP_EXTENDED_ATTRIBUTES, |
| 197 |
LengthAttributes: PULONG, |
| 198 |
) -> NTSTATUS; |
| 199 |
pub fn HidP_InitializeReportForID( |
| 200 |
ReportType: HIDP_REPORT_TYPE, |
| 201 |
ReportID: UCHAR, |
| 202 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 203 |
Report: PCHAR, |
| 204 |
ReportLength: ULONG, |
| 205 |
) -> NTSTATUS; |
| 206 |
pub fn HidP_SetData( |
| 207 |
ReportType: HIDP_REPORT_TYPE, |
| 208 |
DataList: PHIDP_DATA, |
| 209 |
DataLength: PULONG, |
| 210 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 211 |
Report: PCHAR, |
| 212 |
ReportLength: ULONG, |
| 213 |
) -> NTSTATUS; |
| 214 |
pub fn HidP_GetData( |
| 215 |
ReportType: HIDP_REPORT_TYPE, |
| 216 |
DataList: PHIDP_DATA, |
| 217 |
DataLength: PULONG, |
| 218 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 219 |
Report: PCHAR, |
| 220 |
ReportLength: ULONG, |
| 221 |
) -> NTSTATUS; |
| 222 |
pub fn HidP_MaxDataListLength( |
| 223 |
ReportType: HIDP_REPORT_TYPE, |
| 224 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 225 |
) -> ULONG; |
| 226 |
pub fn HidP_SetUsages( |
| 227 |
ReportType: HIDP_REPORT_TYPE, |
| 228 |
UsagePage: USAGE, |
| 229 |
LinkCollection: USHORT, |
| 230 |
UsageList: PUSAGE, |
| 231 |
UsageLength: PULONG, |
| 232 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 233 |
Report: PCHAR, |
| 234 |
ReportLength: ULONG, |
| 235 |
) -> NTSTATUS; |
| 236 |
pub fn HidP_UnsetUsages( |
| 237 |
ReportType: HIDP_REPORT_TYPE, |
| 238 |
UsagePage: USAGE, |
| 239 |
LinkCollection: USHORT, |
| 240 |
UsageList: PUSAGE, |
| 241 |
UsageLength: PULONG, |
| 242 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 243 |
Report: PCHAR, |
| 244 |
ReportLength: ULONG, |
| 245 |
) -> NTSTATUS; |
| 246 |
pub fn HidP_GetUsages( |
| 247 |
ReportType: HIDP_REPORT_TYPE, |
| 248 |
UsagePage: USAGE, |
| 249 |
LinkCollection: USHORT, |
| 250 |
UsageList: PUSAGE, |
| 251 |
UsageLength: PULONG, |
| 252 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 253 |
Report: PCHAR, |
| 254 |
ReportLength: ULONG, |
| 255 |
) -> NTSTATUS; |
| 256 |
pub fn HidP_GetUsagesEx( |
| 257 |
ReportType: HIDP_REPORT_TYPE, |
| 258 |
LinkCollection: USHORT, |
| 259 |
ButtonList: PUSAGE_AND_PAGE, |
| 260 |
UsageLength: *mut ULONG, |
| 261 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 262 |
Report: PCHAR, |
| 263 |
ReportLength: ULONG, |
| 264 |
) -> NTSTATUS; |
| 265 |
pub fn HidP_MaxUsageListLength( |
| 266 |
ReportType: HIDP_REPORT_TYPE, |
| 267 |
UsagePage: USAGE, |
| 268 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 269 |
) -> ULONG; |
| 270 |
pub fn HidP_SetUsageValue( |
| 271 |
ReportType: HIDP_REPORT_TYPE, |
| 272 |
UsagePage: USAGE, |
| 273 |
LinkCollection: USHORT, |
| 274 |
Usage: USAGE, |
| 275 |
UsageValue: ULONG, |
| 276 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 277 |
Report: PCHAR, |
| 278 |
ReportLength: ULONG, |
| 279 |
) -> NTSTATUS; |
| 280 |
pub fn HidP_SetScaledUsageValue( |
| 281 |
ReportType: HIDP_REPORT_TYPE, |
| 282 |
UsagePage: USAGE, |
| 283 |
LinkCollection: USHORT, |
| 284 |
Usage: USAGE, |
| 285 |
UsageValue: LONG, |
| 286 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 287 |
Report: PCHAR, |
| 288 |
ReportLength: ULONG, |
| 289 |
) -> NTSTATUS; |
| 290 |
pub fn HidP_SetUsageValueArray( |
| 291 |
ReportType: HIDP_REPORT_TYPE, |
| 292 |
UsagePage: USAGE, |
| 293 |
LinkCollection: USHORT, |
| 294 |
Usage: USAGE, |
| 295 |
UsageValue: PCHAR, |
| 296 |
UsageValueByteLength: USHORT, |
| 297 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 298 |
Report: PCHAR, |
| 299 |
ReportLength: ULONG, |
| 300 |
) -> NTSTATUS; |
| 301 |
pub fn HidP_GetUsageValue( |
| 302 |
ReportType: HIDP_REPORT_TYPE, |
| 303 |
UsagePage: USAGE, |
| 304 |
LinkCollection: USHORT, |
| 305 |
Usage: USAGE, |
| 306 |
UsageValue: PULONG, |
| 307 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 308 |
Report: PCHAR, |
| 309 |
ReportLength: ULONG, |
| 310 |
) -> NTSTATUS; |
| 311 |
pub fn HidP_GetScaledUsageValue( |
| 312 |
ReportType: HIDP_REPORT_TYPE, |
| 313 |
UsagePage: USAGE, |
| 314 |
LinkCollection: USHORT, |
| 315 |
Usage: USAGE, |
| 316 |
UsageValue: PLONG, |
| 317 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 318 |
Report: PCHAR, |
| 319 |
ReportLength: ULONG, |
| 320 |
) -> NTSTATUS; |
| 321 |
pub fn HidP_GetUsageValueArray( |
| 322 |
ReportType: HIDP_REPORT_TYPE, |
| 323 |
UsagePage: USAGE, |
| 324 |
LinkCollection: USHORT, |
| 325 |
Usage: USAGE, |
| 326 |
UsageValue: PCHAR, |
| 327 |
UsageValueByteLength: USHORT, |
| 328 |
PreparsedData: PHIDP_PREPARSED_DATA, |
| 329 |
Report: PCHAR, |
| 330 |
ReportLength: ULONG, |
| 331 |
) -> NTSTATUS; |
| 332 |
pub fn HidP_UsageListDifference( |
| 333 |
PreviousUsageList: PUSAGE, |
| 334 |
CurrentUsageList: PUSAGE, |
| 335 |
BreakUsageList: PUSAGE, |
| 336 |
MakeUsageList: PUSAGE, |
| 337 |
UsageListLength: ULONG, |
| 338 |
) -> NTSTATUS; |
| 339 |
pub fn HidP_TranslateUsagesToI8042ScanCodes( |
| 340 |
ChangedUsageList: PUSAGE, |
| 341 |
UsageListLength: ULONG, |
| 342 |
KeyAction: HIDP_KEYBOARD_DIRECTION, |
| 343 |
ModifierState: PHIDP_KEYBOARD_MODIFIER_STATE, |
| 344 |
InsertCodesProcedure: PHIDP_INSERT_SCANCODES, |
| 345 |
InsertCodesContext: PVOID, |
| 346 |
) -> NTSTATUS; |
| 347 |
} |
| 348 |
ENUM!{enum HIDP_KEYBOARD_DIRECTION { |
| 349 |
HidP_Keyboard_Break, |
| 350 |
HidP_Keyboard_Make, |
| 351 |
}} |
| 352 |
STRUCT!{struct HIDP_KEYBOARD_MODIFIER_STATE { |
| 353 |
ul: ULONG, |
| 354 |
}} |
| 355 |
BITFIELD!{HIDP_KEYBOARD_MODIFIER_STATE ul: ULONG [ |
| 356 |
LeftControl set_LeftControl[0..1], |
| 357 |
LeftShift set_LeftShift[1..2], |
| 358 |
LeftAlt set_LeftAlt[2..3], |
| 359 |
LeftGUI set_LeftGUI[3..4], |
| 360 |
RightControl set_RightControl[4..5], |
| 361 |
RightShift set_RightShift[5..6], |
| 362 |
RightAlt set_RightAlt[6..7], |
| 363 |
RigthGUI set_RigthGUI[7..8], |
| 364 |
CapsLock set_CapsLock[8..9], |
| 365 |
ScollLock set_ScollLock[9..10], |
| 366 |
NumLock set_NumLock[10..11], |
| 367 |
]} |
| 368 |
pub type PHIDP_KEYBOARD_MODIFIER_STATE = *mut HIDP_KEYBOARD_MODIFIER_STATE; |
| 369 |
FN!{stdcall PHIDP_INSERT_SCANCODES( |
| 370 |
Context: PVOID, |
| 371 |
NewScanCodes: PCHAR, |
| 372 |
Length: ULONG, |
| 373 |
) -> BOOLEAN} |
| 374 |
pub const HIDP_STATUS_SUCCESS: NTSTATUS = HIDP_ERROR_CODES!(0x0, 0); |
| 375 |
pub const HIDP_STATUS_NULL: NTSTATUS = HIDP_ERROR_CODES!(0x8, 1); |
| 376 |
pub const HIDP_STATUS_INVALID_PREPARSED_DATA: NTSTATUS = HIDP_ERROR_CODES!(0xC, 1); |
| 377 |
pub const HIDP_STATUS_INVALID_REPORT_TYPE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 2); |
| 378 |
pub const HIDP_STATUS_INVALID_REPORT_LENGTH: NTSTATUS = HIDP_ERROR_CODES!(0xC, 3); |
| 379 |
pub const HIDP_STATUS_USAGE_NOT_FOUND: NTSTATUS = HIDP_ERROR_CODES!(0xC, 4); |
| 380 |
pub const HIDP_STATUS_VALUE_OUT_OF_RANGE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 5); |
| 381 |
pub const HIDP_STATUS_BAD_LOG_PHY_VALUES: NTSTATUS = HIDP_ERROR_CODES!(0xC, 6); |
| 382 |
pub const HIDP_STATUS_BUFFER_TOO_SMALL: NTSTATUS = HIDP_ERROR_CODES!(0xC, 7); |
| 383 |
pub const HIDP_STATUS_INTERNAL_ERROR: NTSTATUS = HIDP_ERROR_CODES!(0xC, 8); |
| 384 |
pub const HIDP_STATUS_I8042_TRANS_UNKNOWN: NTSTATUS = HIDP_ERROR_CODES!(0xC, 9); |
| 385 |
pub const HIDP_STATUS_INCOMPATIBLE_REPORT_ID: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xA); |
| 386 |
pub const HIDP_STATUS_NOT_VALUE_ARRAY: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xB); |
| 387 |
pub const HIDP_STATUS_IS_VALUE_ARRAY: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xC); |
| 388 |
pub const HIDP_STATUS_DATA_INDEX_NOT_FOUND: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xD); |
| 389 |
pub const HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xE); |
| 390 |
pub const HIDP_STATUS_BUTTON_NOT_PRESSED: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0xF); |
| 391 |
pub const HIDP_STATUS_REPORT_DOES_NOT_EXIST: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0x10); |
| 392 |
pub const HIDP_STATUS_NOT_IMPLEMENTED: NTSTATUS = HIDP_ERROR_CODES!(0xC, 0x20); |
| 393 |
pub const HIDP_STATUS_I8242_TRANS_UNKNOWN: NTSTATUS = HIDP_STATUS_I8042_TRANS_UNKNOWN; |