Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.9 KiB

  1. /*++
  2. *
  3. * Component: hidserv.dll
  4. * File: hid.h
  5. * Purpose: routines to send and receive hid reports.
  6. *
  7. * Copyright (C) Microsoft Corporation 1997,1998. All rights reserved.
  8. *
  9. * WGJ
  10. --*/
  11. #include "hidserv.h"
  12. BOOL
  13. UnpackReport (
  14. IN PCHAR ReportBuffer,
  15. IN USHORT ReportBufferLength,
  16. IN HIDP_REPORT_TYPE ReportType,
  17. IN OUT PHID_DATA Data,
  18. IN ULONG DataLength,
  19. IN PHIDP_PREPARSED_DATA Ppd
  20. )
  21. /*++
  22. Routine Description:
  23. --*/
  24. {
  25. ULONG numUsages; // Number of usages returned from GetUsages.
  26. ULONG i;
  27. for (i = 0; i < DataLength; i++, Data++) {
  28. if (Data->IsButtonData) {
  29. numUsages = Data->ButtonData.MaxUsageLength;
  30. TRACE(("MaxUsageListLength (%d)", Data->ButtonData.MaxUsageLength));
  31. Data->Status = HidP_GetUsages (
  32. ReportType,
  33. Data->UsagePage,
  34. Data->LinkCollection,
  35. (PUSAGE) Data->ButtonData.Usages,
  36. &numUsages,
  37. Ppd,
  38. ReportBuffer,
  39. ReportBufferLength);
  40. if (HIDP_STATUS_SUCCESS != Data->Status){
  41. TRACE(("HidP_GetUsages failed (%x)", Data->Status));
  42. }
  43. //
  44. // Get usages writes the list of usages into the buffer
  45. // Data->ButtonData.Usages newUsage is set to the number of usages
  46. // written into this array.
  47. // We assume that there will not be a usage of zero.
  48. // (None have been defined to date.)
  49. // So lets assume that a zero indicates an end of the list of usages.
  50. //
  51. TRACE(("numUsages (%d)", numUsages));
  52. if (numUsages < Data->ButtonData.MaxUsageLength) {
  53. Data->ButtonData.Usages[numUsages].Usage = 0;
  54. Data->ButtonData.Usages[numUsages].UsagePage = 0;
  55. }
  56. } else {
  57. Data->Status = HidP_GetUsageValue (
  58. ReportType,
  59. Data->UsagePage,
  60. Data->LinkCollection,
  61. Data->ValueData.Usage,
  62. &Data->ValueData.Value,
  63. Ppd,
  64. ReportBuffer,
  65. ReportBufferLength);
  66. if (HIDP_STATUS_SUCCESS != Data->Status){
  67. TRACE(("HidP_GetUsageValue failed (%x)", Data->Status));
  68. TRACE(("Usage = %x", Data->ValueData.Usage));
  69. }
  70. Data->Status = HidP_GetScaledUsageValue (
  71. ReportType,
  72. Data->UsagePage,
  73. Data->LinkCollection,
  74. Data->ValueData.Usage,
  75. &Data->ValueData.ScaledValue,
  76. Ppd,
  77. ReportBuffer,
  78. ReportBufferLength);
  79. if (HIDP_STATUS_SUCCESS != Data->Status){
  80. TRACE(("HidP_GetScaledUsageValue failed (%x)", Data->Status));
  81. TRACE(("Usage = %x", Data->ValueData.Usage));
  82. }
  83. }
  84. }
  85. return (HIDP_STATUS_SUCCESS);
  86. }
  87. BOOL
  88. ParseReadReport (
  89. PHID_DEVICE HidDevice
  90. )
  91. /*++
  92. RoutineDescription:
  93. Given a struct _HID_DEVICE, unpack the read report values
  94. into to InputData array.
  95. --*/
  96. {
  97. return UnpackReport (HidDevice->InputReportBuffer,
  98. HidDevice->Caps.InputReportByteLength,
  99. HidP_Input,
  100. HidDevice->InputData,
  101. HidDevice->InputDataLength,
  102. HidDevice->Ppd);
  103. }