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.

258 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. HIDPARSE.H
  5. Abstract:
  6. This module contains the PRIVATE (driver-only) definitions for the
  7. code that implements the usbd driver.
  8. Environment:
  9. Kernel & user mode
  10. Revision History:
  11. Aug-96 : created by Kenneth Ray
  12. --*/
  13. #ifndef _HIDPARSE_H
  14. #define _HIDPARSE_H
  15. #include "hidtoken.h"
  16. #define HIDP_POOL_TAG (ULONG) 'PdiH'
  17. #undef ExAllocatePool
  18. #define ExAllocatePool(type, size) \
  19. ExAllocatePoolWithTag (type, size, HIDP_POOL_TAG);
  20. // ExAllocatePool is only called in the descript.c and hidparse.c code.
  21. // all other modules are linked into the user DLL. They cannot allocate any
  22. // memory.
  23. #pragma warning(error:4100) // Unreferenced formal parameter
  24. #pragma warning(error:4705) // Statement has no effect
  25. #define DEFAULT_DBG_LEVEL 1 // errors AND warnings
  26. #if DBG
  27. #define HidP_KdPrint(_level_,_x_) \
  28. if (DEFAULT_DBG_LEVEL <= _level_) { \
  29. DbgPrint ("'HidParse.SYS: "); \
  30. DbgPrint _x_; \
  31. }
  32. #define TRAP() DbgBreakPoint()
  33. #else
  34. #define HidP_KdPrint(_level_,_x_)
  35. #define TRAP()
  36. #endif
  37. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  38. #define MAX(a,b) (((a) < (b)) ? (b) : (a))
  39. #define HIDP_ISCONST(x) ((BOOLEAN) (( (x) & 0x01) ? TRUE : FALSE))
  40. #define HIDP_ISARRAY(x) ((BOOLEAN) ((!((x) & 0x02)) ? TRUE : FALSE))
  41. #define HIDP_ISABSOLUTE(x) ((BOOLEAN) ((!((x) & 0x04)) ? TRUE : FALSE))
  42. #define HIDP_HASNULL(x) ((BOOLEAN) (( (x) & 0x40) ? TRUE : FALSE))
  43. #define HIDP_MAX_UNKNOWN_ITEMS 4
  44. typedef struct _HIDP_CHANNEL_DESC
  45. {
  46. USHORT UsagePage;
  47. UCHAR ReportID;
  48. UCHAR BitOffset; // 0 to 8 value describing bit alignment
  49. USHORT ReportSize; // HID defined report size
  50. USHORT ReportCount; // HID defined report count
  51. USHORT ByteOffset; // byte position of start of field in report packet
  52. USHORT BitLength; // total bit length of this channel
  53. ULONG BitField; // The 8 (plus extra) bits associated with a main item
  54. USHORT ByteEnd; // First byte not containing bits of this channel.
  55. USHORT LinkCollection; // A unique internal index pointer
  56. USHORT LinkUsagePage;
  57. USHORT LinkUsage;
  58. ULONG MoreChannels: 1; // Are there more channel desc associated with
  59. // this array. This happens if there is a
  60. // several usages for one main item.
  61. ULONG IsConst: 1; // Does this channel represent filler
  62. ULONG IsButton: 1; // Is this a channel of binary usages, not value usages.
  63. ULONG IsAbsolute: 1; // As apposed to relative
  64. ULONG IsRange: 1;
  65. ULONG IsAlias: 1; // a usage described in a delimiter
  66. ULONG IsStringRange: 1;
  67. ULONG IsDesignatorRange: 1;
  68. ULONG Reserved: 20;
  69. ULONG NumGlobalUnknowns: 4;
  70. struct _HIDP_UNKNOWN_TOKEN GlobalUnknowns [HIDP_MAX_UNKNOWN_ITEMS];
  71. union {
  72. struct {
  73. USHORT UsageMin, UsageMax;
  74. USHORT StringMin, StringMax;
  75. USHORT DesignatorMin, DesignatorMax;
  76. USHORT DataIndexMin, DataIndexMax;
  77. } Range;
  78. struct {
  79. USHORT Usage, Reserved1;
  80. USHORT StringIndex, Reserved2;
  81. USHORT DesignatorIndex, Reserved3;
  82. USHORT DataIndex, Reserved4;
  83. } NotRange;
  84. };
  85. union {
  86. struct {
  87. LONG LogicalMin, LogicalMax;
  88. } button;
  89. struct {
  90. BOOLEAN HasNull; // Does this channel have a null report
  91. UCHAR Reserved[3];
  92. LONG LogicalMin, LogicalMax;
  93. LONG PhysicalMin, PhysicalMax;
  94. } Data;
  95. };
  96. ULONG Units;
  97. ULONG UnitExp;
  98. } HIDP_CHANNEL_DESC, *PHIDP_CHANNEL_DESC;
  99. struct _CHANNEL_REPORT_HEADER
  100. {
  101. USHORT Offset; // Position in the _CHANNEL_ITEM array
  102. USHORT Size; // Length in said array
  103. USHORT Index;
  104. USHORT ByteLen; // The length of the data including reportID.
  105. // This is the longest such report that might be received
  106. // for the given collection.
  107. };
  108. #define HIDP_PREPARSED_DATA_SIGNATURE1 'PdiH'
  109. #define HIDP_PREPARSED_DATA_SIGNATURE2 'RDK '
  110. typedef struct _HIDP_SYS_POWER_INFO {
  111. ULONG PowerButtonMask;
  112. } HIDP_SYS_POWER_INFO, *PHIDP_SYS_POWER_INFO;
  113. typedef struct _HIDP_PREPARSED_DATA
  114. {
  115. LONG Signature1, Signature2;
  116. USHORT Usage;
  117. USHORT UsagePage;
  118. HIDP_SYS_POWER_INFO;
  119. // The following channel report headers point to data within
  120. // the Data field below using array indices.
  121. struct _CHANNEL_REPORT_HEADER Input;
  122. struct _CHANNEL_REPORT_HEADER Output;
  123. struct _CHANNEL_REPORT_HEADER Feature;
  124. // After the CANNEL_DESC array the follows a LinkCollection array nodes.
  125. // LinkCollectionArrayOffset is the index given to RawBytes to find
  126. // the first location of the _HIDP_LINK_COLLECTION_NODE structure array
  127. // (index zero) and LinkCollectionArrayLength is the number of array
  128. // elements in that array.
  129. USHORT LinkCollectionArrayOffset;
  130. USHORT LinkCollectionArrayLength;
  131. union {
  132. HIDP_CHANNEL_DESC Data[];
  133. UCHAR RawBytes[];
  134. };
  135. } HIDP_PREPARSED_DATA;
  136. typedef struct _HIDP_PRIVATE_LINK_COLLECTION_NODE
  137. {
  138. USAGE LinkUsage;
  139. USAGE LinkUsagePage;
  140. USHORT Parent;
  141. USHORT NumberOfChildren;
  142. USHORT NextSibling;
  143. USHORT FirstChild;
  144. ULONG CollectionType: 8; // As defined in 6.2.2.6 of HID spec
  145. ULONG IsAlias : 1; // This link node is an allias of the next link node.
  146. ULONG Reserved: 23;
  147. } HIDP_PRIVATE_LINK_COLLECTION_NODE, *PHIDP_PRIVATE_LINK_COLLECTION_NODE;
  148. // +++++++++++++++++++++++++++++++++++
  149. // The ITEMS supported by this Parser
  150. // +++++++++++++++++++++++++++++++++++
  151. typedef UCHAR HIDP_ITEM;
  152. //
  153. // Power buttons supported by this parser
  154. //
  155. #define HIDP_USAGE_SYSCTL_PAGE HID_USAGE_PAGE_GENERIC
  156. #define HIDP_USAGE_SYSCTL_POWER HID_USAGE_GENERIC_SYSCTL_POWER
  157. #define HIDP_USAGE_SYSCTL_SLEEP HID_USAGE_GENERIC_SYSCTL_SLEEP
  158. #define HIDP_USAGE_SYSCTL_WAKE HID_USAGE_GENERIC_SYSCTL_WAKE
  159. //
  160. //
  161. // Keyboard Translation
  162. // translation tables from usages to i8042 scan codes.
  163. //
  164. typedef ULONG HIDP_LOOKUP_TABLE_PROC (
  165. IN PULONG Table,
  166. IN ULONG Usage
  167. );
  168. typedef HIDP_LOOKUP_TABLE_PROC * PHIDP_LOOKUP_TABLE_PROC;
  169. typedef BOOLEAN HIDP_SCANCODE_SUBTRANSLATION (
  170. IN ULONG * Table,
  171. IN UCHAR Index,
  172. IN PHIDP_INSERT_SCANCODES Insert,
  173. IN PVOID Context,
  174. IN HIDP_KEYBOARD_DIRECTION KeyAction,
  175. IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
  176. );
  177. typedef HIDP_SCANCODE_SUBTRANSLATION * PHIDP_SCANCODE_SUBTRANSLATION;
  178. typedef struct _HIDP_SCANCODE_SUBTABLE {
  179. PHIDP_SCANCODE_SUBTRANSLATION ScanCodeFcn;
  180. PULONG Table;
  181. } HIDP_SCANCODE_SUBTABLE, *PHIDP_SCANCODE_SUBTABLE;
  182. NTSTATUS HidP_TranslateUsage (
  183. USAGE Usage,
  184. HIDP_KEYBOARD_DIRECTION KeyAction,
  185. PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
  186. PHIDP_LOOKUP_TABLE_PROC LookupTableProc,
  187. PULONG TranslationTable,
  188. PHIDP_SCANCODE_SUBTABLE SubTranslationTable,
  189. PHIDP_INSERT_SCANCODES InsertCodesProcedure,
  190. PVOID InsertCodesContext
  191. );
  192. HIDP_LOOKUP_TABLE_PROC HidP_StraightLookup;
  193. HIDP_LOOKUP_TABLE_PROC HidP_AssociativeLookup;
  194. HIDP_SCANCODE_SUBTRANSLATION HidP_KeyboardKeypadCode;
  195. HIDP_SCANCODE_SUBTRANSLATION HidP_ModifierCode;
  196. HIDP_SCANCODE_SUBTRANSLATION HidP_VendorBreakCodesAsMakeCodes;
  197. HIDP_SCANCODE_SUBTRANSLATION HidP_PrintScreenCode;
  198. #endif