1 #define _HIDPI_ 2 #define _HIDPI_NO_FUNCTION_MACROS_ 3 #include <ntddk.h> 4 #include <hidpddi.h> 5 6 #include "hidparser.h" 7 #include "hidp.h" 8 9 #define UNIMPLEMENTED DebugFunction("%s is UNIMPLEMENTED\n", __FUNCTION__) 10 11 VOID 12 NTAPI 13 HidP_FreeCollectionDescription( 14 IN PHIDP_DEVICE_DESC DeviceDescription) 15 { 16 // 17 // free collection 18 // 19 HidParser_FreeCollectionDescription(DeviceDescription); 20 } 21 22 23 HIDAPI 24 NTSTATUS 25 NTAPI 26 HidP_GetCaps( 27 IN PHIDP_PREPARSED_DATA PreparsedData, 28 OUT PHIDP_CAPS Capabilities) 29 { 30 // 31 // get caps 32 // 33 return HidParser_GetCaps(PreparsedData, Capabilities); 34 } 35 36 NTSTATUS 37 TranslateStatusForUpperLayer( 38 IN NTSTATUS Status) 39 { 40 // 41 // now we are handling only this values, for others just return 42 // status as it is. 43 // 44 switch (Status) 45 { 46 case HIDP_STATUS_INTERNAL_ERROR: 47 return STATUS_INSUFFICIENT_RESOURCES; 48 case HIDP_STATUS_INVALID_REPORT_TYPE: 49 return HIDP_STATUS_INVALID_REPORT_TYPE; 50 case HIDP_STATUS_BUFFER_TOO_SMALL: 51 return STATUS_BUFFER_TOO_SMALL; 52 case HIDP_STATUS_USAGE_NOT_FOUND: 53 return STATUS_NO_DATA_DETECTED; 54 default: 55 return Status; 56 } 57 } 58 59 NTSTATUS 60 NTAPI 61 HidP_GetCollectionDescription( 62 IN PHIDP_REPORT_DESCRIPTOR ReportDesc, 63 IN ULONG DescLength, 64 IN POOL_TYPE PoolType, 65 OUT PHIDP_DEVICE_DESC DeviceDescription) 66 { 67 NTSTATUS Status; 68 69 // 70 // get description; 71 // 72 Status = HidParser_GetCollectionDescription(ReportDesc, DescLength, PoolType, DeviceDescription); 73 return TranslateStatusForUpperLayer(Status); 74 } 75 76 HIDAPI 77 ULONG 78 NTAPI 79 HidP_MaxUsageListLength( 80 IN HIDP_REPORT_TYPE ReportType, 81 IN USAGE UsagePage OPTIONAL, 82 IN PHIDP_PREPARSED_DATA PreparsedData) 83 { 84 // 85 // sanity check 86 // 87 ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); 88 89 // 90 // get usage length 91 // 92 return HidParser_MaxUsageListLength(PreparsedData, ReportType, UsagePage); 93 } 94 95 HIDAPI 96 NTSTATUS 97 NTAPI 98 HidP_GetSpecificValueCaps( 99 IN HIDP_REPORT_TYPE ReportType, 100 IN USAGE UsagePage, 101 IN USHORT LinkCollection, 102 IN USAGE Usage, 103 OUT PHIDP_VALUE_CAPS ValueCaps, 104 IN OUT PUSHORT ValueCapsLength, 105 IN PHIDP_PREPARSED_DATA PreparsedData) 106 { 107 // 108 // sanity check 109 // 110 ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); 111 112 // 113 // get value caps 114 // 115 return HidParser_GetSpecificValueCaps(PreparsedData, ReportType, UsagePage, LinkCollection, Usage, ValueCaps, ValueCapsLength); 116 } 117 118 HIDAPI 119 NTSTATUS 120 NTAPI 121 HidP_GetUsages( 122 IN HIDP_REPORT_TYPE ReportType, 123 IN USAGE UsagePage, 124 IN USHORT LinkCollection OPTIONAL, 125 OUT PUSAGE UsageList, 126 IN OUT PULONG UsageLength, 127 IN PHIDP_PREPARSED_DATA PreparsedData, 128 IN PCHAR Report, 129 IN ULONG ReportLength) 130 { 131 // 132 // sanity check 133 // 134 ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); 135 136 // 137 // get usages 138 // 139 return HidParser_GetUsages(PreparsedData, ReportType, UsagePage, LinkCollection, UsageList, UsageLength, Report, ReportLength); 140 } 141 142 143 #undef HidP_GetButtonCaps 144 145 HIDAPI 146 NTSTATUS 147 NTAPI 148 HidP_UsageListDifference( 149 IN PUSAGE PreviousUsageList, 150 IN PUSAGE CurrentUsageList, 151 OUT PUSAGE BreakUsageList, 152 OUT PUSAGE MakeUsageList, 153 IN ULONG UsageListLength) 154 { 155 return HidParser_UsageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); 156 } 157 158 HIDAPI 159 NTSTATUS 160 NTAPI 161 HidP_GetUsagesEx( 162 IN HIDP_REPORT_TYPE ReportType, 163 IN USHORT LinkCollection, 164 OUT PUSAGE_AND_PAGE ButtonList, 165 IN OUT ULONG *UsageLength, 166 IN PHIDP_PREPARSED_DATA PreparsedData, 167 IN PCHAR Report, 168 IN ULONG ReportLength) 169 { 170 return HidP_GetUsages(ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, &ButtonList->Usage, UsageLength, PreparsedData, Report, ReportLength); 171 } 172 173 HIDAPI 174 NTSTATUS 175 NTAPI 176 HidP_UsageAndPageListDifference( 177 IN PUSAGE_AND_PAGE PreviousUsageList, 178 IN PUSAGE_AND_PAGE CurrentUsageList, 179 OUT PUSAGE_AND_PAGE BreakUsageList, 180 OUT PUSAGE_AND_PAGE MakeUsageList, 181 IN ULONG UsageListLength) 182 { 183 return HidParser_UsageAndPageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); 184 } 185 186 HIDAPI 187 NTSTATUS 188 NTAPI 189 HidP_GetScaledUsageValue( 190 IN HIDP_REPORT_TYPE ReportType, 191 IN USAGE UsagePage, 192 IN USHORT LinkCollection OPTIONAL, 193 IN USAGE Usage, 194 OUT PLONG UsageValue, 195 IN PHIDP_PREPARSED_DATA PreparsedData, 196 IN PCHAR Report, 197 IN ULONG ReportLength) 198 { 199 // 200 // sanity check 201 // 202 ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); 203 204 // 205 // get scaled usage value 206 // 207 return HidParser_GetScaledUsageValue(PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); 208 } 209 210 HIDAPI 211 NTSTATUS 212 NTAPI 213 HidP_GetUsageValue( 214 IN HIDP_REPORT_TYPE ReportType, 215 IN USAGE UsagePage, 216 IN USHORT LinkCollection, 217 IN USAGE Usage, 218 OUT PULONG UsageValue, 219 IN PHIDP_PREPARSED_DATA PreparsedData, 220 IN PCHAR Report, 221 IN ULONG ReportLength) 222 { 223 // 224 // sanity check 225 // 226 ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); 227 228 // 229 // get scaled usage value 230 // 231 return HidParser_GetUsageValue(PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); 232 } 233 234 235 HIDAPI 236 NTSTATUS 237 NTAPI 238 HidP_TranslateUsageAndPagesToI8042ScanCodes( 239 IN PUSAGE_AND_PAGE ChangedUsageList, 240 IN ULONG UsageListLength, 241 IN HIDP_KEYBOARD_DIRECTION KeyAction, 242 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, 243 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, 244 IN PVOID InsertCodesContext) 245 { 246 // 247 // translate usage pages 248 // 249 return HidParser_TranslateUsageAndPagesToI8042ScanCodes(ChangedUsageList, UsageListLength, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext); 250 } 251 252 HIDAPI 253 NTSTATUS 254 NTAPI 255 HidP_GetButtonCaps( 256 HIDP_REPORT_TYPE ReportType, 257 PHIDP_BUTTON_CAPS ButtonCaps, 258 PUSHORT ButtonCapsLength, 259 PHIDP_PREPARSED_DATA PreparsedData) 260 { 261 return HidP_GetSpecificButtonCaps(ReportType, HID_USAGE_PAGE_UNDEFINED, 0, 0, ButtonCaps, ButtonCapsLength, PreparsedData); 262 } 263 264 HIDAPI 265 NTSTATUS 266 NTAPI 267 HidP_GetSpecificButtonCaps( 268 IN HIDP_REPORT_TYPE ReportType, 269 IN USAGE UsagePage, 270 IN USHORT LinkCollection, 271 IN USAGE Usage, 272 OUT PHIDP_BUTTON_CAPS ButtonCaps, 273 IN OUT PUSHORT ButtonCapsLength, 274 IN PHIDP_PREPARSED_DATA PreparsedData) 275 { 276 UNIMPLEMENTED; 277 ASSERT(FALSE); 278 return STATUS_NOT_IMPLEMENTED; 279 } 280 281 HIDAPI 282 NTSTATUS 283 NTAPI 284 HidP_GetData( 285 IN HIDP_REPORT_TYPE ReportType, 286 OUT PHIDP_DATA DataList, 287 IN OUT PULONG DataLength, 288 IN PHIDP_PREPARSED_DATA PreparsedData, 289 IN PCHAR Report, 290 IN ULONG ReportLength) 291 { 292 UNIMPLEMENTED; 293 ASSERT(FALSE); 294 return STATUS_NOT_IMPLEMENTED; 295 } 296 297 HIDAPI 298 NTSTATUS 299 NTAPI 300 HidP_GetExtendedAttributes( 301 IN HIDP_REPORT_TYPE ReportType, 302 IN USHORT DataIndex, 303 IN PHIDP_PREPARSED_DATA PreparsedData, 304 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, 305 IN OUT PULONG LengthAttributes) 306 { 307 UNIMPLEMENTED; 308 ASSERT(FALSE); 309 return STATUS_NOT_IMPLEMENTED; 310 } 311 312 HIDAPI 313 NTSTATUS 314 NTAPI 315 HidP_GetLinkCollectionNodes( 316 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, 317 IN OUT PULONG LinkCollectionNodesLength, 318 IN PHIDP_PREPARSED_DATA PreparsedData) 319 { 320 UNIMPLEMENTED; 321 ASSERT(FALSE); 322 return STATUS_NOT_IMPLEMENTED; 323 } 324 325 NTSTATUS 326 NTAPI 327 HidP_SysPowerEvent( 328 IN PCHAR HidPacket, 329 IN USHORT HidPacketLength, 330 IN PHIDP_PREPARSED_DATA Ppd, 331 OUT PULONG OutputBuffer) 332 { 333 UNIMPLEMENTED; 334 ASSERT(FALSE); 335 return STATUS_NOT_IMPLEMENTED; 336 } 337 338 NTSTATUS 339 NTAPI 340 HidP_SysPowerCaps( 341 IN PHIDP_PREPARSED_DATA Ppd, 342 OUT PULONG OutputBuffer) 343 { 344 UNIMPLEMENTED; 345 ASSERT(FALSE); 346 return STATUS_NOT_IMPLEMENTED; 347 } 348 349 HIDAPI 350 NTSTATUS 351 NTAPI 352 HidP_GetUsageValueArray( 353 IN HIDP_REPORT_TYPE ReportType, 354 IN USAGE UsagePage, 355 IN USHORT LinkCollection OPTIONAL, 356 IN USAGE Usage, 357 OUT PCHAR UsageValue, 358 IN USHORT UsageValueByteLength, 359 IN PHIDP_PREPARSED_DATA PreparsedData, 360 IN PCHAR Report, 361 IN ULONG ReportLength) 362 { 363 UNIMPLEMENTED; 364 ASSERT(FALSE); 365 return STATUS_NOT_IMPLEMENTED; 366 } 367 368 369 HIDAPI 370 NTSTATUS 371 NTAPI 372 HidP_UnsetUsages( 373 IN HIDP_REPORT_TYPE ReportType, 374 IN USAGE UsagePage, 375 IN USHORT LinkCollection, 376 IN PUSAGE UsageList, 377 IN OUT PULONG UsageLength, 378 IN PHIDP_PREPARSED_DATA PreparsedData, 379 IN OUT PCHAR Report, 380 IN ULONG ReportLength) 381 { 382 UNIMPLEMENTED; 383 ASSERT(FALSE); 384 return STATUS_NOT_IMPLEMENTED; 385 } 386 387 HIDAPI 388 NTSTATUS 389 NTAPI 390 HidP_TranslateUsagesToI8042ScanCodes( 391 IN PUSAGE ChangedUsageList, 392 IN ULONG UsageListLength, 393 IN HIDP_KEYBOARD_DIRECTION KeyAction, 394 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, 395 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, 396 IN PVOID InsertCodesContext) 397 { 398 UNIMPLEMENTED; 399 ASSERT(FALSE); 400 return STATUS_NOT_IMPLEMENTED; 401 } 402 403 HIDAPI 404 NTSTATUS 405 NTAPI 406 HidP_SetUsages( 407 IN HIDP_REPORT_TYPE ReportType, 408 IN USAGE UsagePage, 409 IN USHORT LinkCollection, 410 IN PUSAGE UsageList, 411 IN OUT PULONG UsageLength, 412 IN PHIDP_PREPARSED_DATA PreparsedData, 413 IN OUT PCHAR Report, 414 IN ULONG ReportLength) 415 { 416 UNIMPLEMENTED; 417 ASSERT(FALSE); 418 return STATUS_NOT_IMPLEMENTED; 419 } 420 421 HIDAPI 422 NTSTATUS 423 NTAPI 424 HidP_SetUsageValueArray( 425 IN HIDP_REPORT_TYPE ReportType, 426 IN USAGE UsagePage, 427 IN USHORT LinkCollection OPTIONAL, 428 IN USAGE Usage, 429 IN PCHAR UsageValue, 430 IN USHORT UsageValueByteLength, 431 IN PHIDP_PREPARSED_DATA PreparsedData, 432 OUT PCHAR Report, 433 IN ULONG ReportLength) 434 { 435 UNIMPLEMENTED; 436 ASSERT(FALSE); 437 return STATUS_NOT_IMPLEMENTED; 438 } 439 440 HIDAPI 441 NTSTATUS 442 NTAPI 443 HidP_SetUsageValue( 444 IN HIDP_REPORT_TYPE ReportType, 445 IN USAGE UsagePage, 446 IN USHORT LinkCollection, 447 IN USAGE Usage, 448 IN ULONG UsageValue, 449 IN PHIDP_PREPARSED_DATA PreparsedData, 450 IN OUT PCHAR Report, 451 IN ULONG ReportLength) 452 { 453 UNIMPLEMENTED; 454 ASSERT(FALSE); 455 return STATUS_NOT_IMPLEMENTED; 456 } 457 458 HIDAPI 459 NTSTATUS 460 NTAPI 461 HidP_SetScaledUsageValue( 462 IN HIDP_REPORT_TYPE ReportType, 463 IN USAGE UsagePage, 464 IN USHORT LinkCollection OPTIONAL, 465 IN USAGE Usage, 466 IN LONG UsageValue, 467 IN PHIDP_PREPARSED_DATA PreparsedData, 468 IN OUT PCHAR Report, 469 IN ULONG ReportLength) 470 { 471 UNIMPLEMENTED; 472 ASSERT(FALSE); 473 return STATUS_NOT_IMPLEMENTED; 474 } 475 476 HIDAPI 477 NTSTATUS 478 NTAPI 479 HidP_SetData( 480 IN HIDP_REPORT_TYPE ReportType, 481 IN PHIDP_DATA DataList, 482 IN OUT PULONG DataLength, 483 IN PHIDP_PREPARSED_DATA PreparsedData, 484 IN OUT PCHAR Report, 485 IN ULONG ReportLength) 486 { 487 UNIMPLEMENTED; 488 ASSERT(FALSE); 489 return STATUS_NOT_IMPLEMENTED; 490 } 491 492 HIDAPI 493 ULONG 494 NTAPI 495 HidP_MaxDataListLength( 496 IN HIDP_REPORT_TYPE ReportType, 497 IN PHIDP_PREPARSED_DATA PreparsedData) 498 { 499 UNIMPLEMENTED; 500 ASSERT(FALSE); 501 return STATUS_NOT_IMPLEMENTED; 502 } 503 504 HIDAPI 505 NTSTATUS 506 NTAPI 507 HidP_InitializeReportForID( 508 IN HIDP_REPORT_TYPE ReportType, 509 IN UCHAR ReportID, 510 IN PHIDP_PREPARSED_DATA PreparsedData, 511 IN OUT PCHAR Report, 512 IN ULONG ReportLength) 513 { 514 UNIMPLEMENTED; 515 ASSERT(FALSE); 516 return STATUS_NOT_IMPLEMENTED; 517 } 518 519 #undef HidP_GetValueCaps 520 521 HIDAPI 522 NTSTATUS 523 NTAPI 524 HidP_GetValueCaps( 525 HIDP_REPORT_TYPE ReportType, 526 PHIDP_VALUE_CAPS ValueCaps, 527 PUSHORT ValueCapsLength, 528 PHIDP_PREPARSED_DATA PreparsedData) 529 { 530 return HidP_GetSpecificValueCaps(ReportType, 531 HID_USAGE_PAGE_UNDEFINED, 532 HIDP_LINK_COLLECTION_UNSPECIFIED, 533 0, 534 ValueCaps, 535 ValueCapsLength, 536 PreparsedData); 537 } 538