Source code of Windows XP (NT5)
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.

303 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. Dinputs.h
  5. Abstract:
  6. This module contains the common private declarations for the keyboard
  7. packet filter
  8. Environment:
  9. kernel mode only
  10. Notes:
  11. Revision History:
  12. --*/
  13. #ifndef DINPUTS_H
  14. #define DINPUTS_H
  15. //#ifdef _WIN32
  16. //#define COM_NO_WINDOWS_H
  17. //#include <objbase.h>
  18. //#endif
  19. #include "ntddk.h"
  20. #include "kbdmou.h"
  21. #include <ntddkbd.h>
  22. #include <ntddmou.h>
  23. #include <ntdd8042.h>
  24. #define DIRECTINPUT_VERSION 0x800
  25. #define KbdMou_POOL_TAG (ULONG) 'PNID'
  26. #undef ExAllocatePool
  27. #define ExAllocatePool(type, size) \
  28. ExAllocatePoolWithTag (type, size, KbdMou_POOL_TAG)
  29. DEFINE_GUID(DINPUT_INTERFACE_GUID,0x0C64D244,0xCBE4,0x4F74,0xA2,0x13,0x99,0x65,0xBC,0x84,0x6E,0x03);
  30. #if DBG
  31. #define TRAP() DbgBreakPoint()
  32. #define DbgRaiseIrql(_x_,_y_) KeRaiseIrql(_x_,_y_)
  33. #define DbgLowerIrql(_x_) KeLowerIrql(_x_)
  34. #define DebugPrint(_x_) DbgPrint _x_
  35. #else // DBG
  36. #define TRAP()
  37. #define DbgRaiseIrql(_x_,_y_)
  38. #define DbgLowerIrql(_x_)
  39. #define DebugPrint(_x_)
  40. #endif
  41. #define MIN(_A_,_B_) (((_A_) < (_B_)) ? (_A_) : (_B_))
  42. /*typedef struct _DEVICELIST
  43. {
  44. PDEVICE_OBJECT pDev;
  45. struct _DEVICELIST *pLink; // Links to the next device
  46. struct _DEVICELIST *pPrev; // Back link
  47. } DEVICELIST, *PDEVICELIST;
  48. */
  49. typedef struct _DEVICE_EXTENSION
  50. {
  51. //
  52. // A backpointer to the device object for which this is the extension
  53. //
  54. PDEVICE_OBJECT Self;
  55. //
  56. // "THE PDO" (ejected by the root bus or ACPI)
  57. //
  58. PDEVICE_OBJECT PDO;
  59. //
  60. // The top of the stack before this filter was added. AKA the location
  61. // to which all IRPS should be directed.
  62. //
  63. PDEVICE_OBJECT TopOfStack;
  64. //
  65. // The secondary device object to IO control
  66. //
  67. PDEVICE_OBJECT IoctlDevice;
  68. //
  69. // Number of creates sent down
  70. //
  71. LONG EnableCount;
  72. //
  73. // The real connect data that this driver reports to
  74. //
  75. CONNECT_DATA UpperConnectData;
  76. //
  77. // Previous initialization and hook routines (and context)
  78. //
  79. PVOID UpperContext;
  80. PI8042_KEYBOARD_INITIALIZATION_ROUTINE UpperInitializationRoutine;
  81. union {
  82. PI8042_KEYBOARD_ISR UpperKbdIsrHook;
  83. PI8042_MOUSE_ISR UpperMouIsrHook;
  84. };
  85. //
  86. // Write function from within KbdMou_IsrHook
  87. //
  88. IN PI8042_ISR_WRITE_PORT IsrWritePort;
  89. //
  90. // Queue the current packet (ie the one passed into KbdMou_IsrHook)
  91. //
  92. IN PI8042_QUEUE_PACKET QueuePacket;
  93. //
  94. // Context for IsrWritePort, QueueKeyboardPacket
  95. //
  96. IN PVOID CallContext;
  97. //
  98. // current power state of the device
  99. //
  100. DEVICE_POWER_STATE DeviceState;
  101. BOOLEAN Started;
  102. BOOLEAN SurpriseRemoved;
  103. BOOLEAN Removed;
  104. // Link to the next and previous PDEVICE_OBJECT of the same type
  105. PDEVICE_OBJECT pLink;
  106. PDEVICE_OBJECT pPrevLink;
  107. // Current device state (for detecting state change)
  108. union
  109. {
  110. UCHAR arbKbdState[256];
  111. DIMOUSESTATE_INT MouseState;
  112. };
  113. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  114. typedef struct SYSDEVICEFORMAT { /* devf */
  115. ULONG cbData; /* Size of device data */
  116. ULONG cObj; /* Number of objects in data format */
  117. DIOBJECTDATAFORMAT *rgodf; /* Array of descriptions */
  118. void *pExtra; /* Extra pointer for private communication */
  119. DWORD dwEmulation; /* Flags controlling emulation */
  120. } SYSDEVICEFORMAT, *PSYSDEVICEFORMAT;
  121. ///////////////////////////////////////////////////
  122. // Definitions for device instances
  123. ///////////////////////////////////////////////////
  124. typedef struct VXDINSTANCE;
  125. typedef struct _DI_DEVINSTANCE
  126. {
  127. PDEVICE_OBJECT pDev; // Pointer to the device object that this instance is interested in
  128. void *pState; // Indicate the current state of the device (Kernel mode virtual address)
  129. PMDL pMdlForState; // Mdl for state buffer
  130. ULONG ulBufferSize; // Size of the buffer to hold events
  131. PRKEVENT pEvent; // pointer to event that receives notification
  132. // If pHead == pTail, no data are in the buffer
  133. // The buffer can actually only hold ulBufferSize - 1 objects, as if ulBufferSize objects
  134. // are in buffer, pHead == pTail and it can be confusing with the empty buffer case.
  135. DIDEVICEOBJECTDATA_DX3 *pBuffer; // Array of DIDEVICEOBJECTDATA_DX3 to store key events
  136. DIDEVICEOBJECTDATA_DX3 *pEnd; // One past the last element in the array
  137. DIDEVICEOBJECTDATA_DX3 *pHead; // Where the next entry is to be written
  138. DIDEVICEOBJECTDATA_DX3 *pTail; // Oldest data
  139. PMDL pMdlForBuffer; // Mdl for device data buffer
  140. ULONG ulEventCount; // Number of events queued in buffer
  141. ULONG ulSequence; // Records the sequence number for the next event
  142. ULONG ulOverflow; // Whether overflow occurred (0 or 1)
  143. void *pExtra; // For extra information (translation table for keyboard devices; NULL if no translation needed)
  144. HWND hWnd; // Window
  145. ULONG ulDataFormatSize; // Size of data format array
  146. ULONG *pulOffsets; // Offsets of the data format
  147. struct VXDINSTANCE *pVIUser; // Points to the corresponding VXDINSTANCE for this instance (User mode virtual address)
  148. struct VXDINSTANCE *pVI; // Points to the corresponding VXDINSTANCE for this instance (Kernel mode virtual address)
  149. PMDL pMdlForVI; // Mdl for pVI
  150. struct _DI_DEVINSTANCE *pLink; // Link to the next device instance on the list
  151. struct _DI_DEVINSTANCE *pPrevLink; // Link to the previous device instance on the list
  152. } DI_DEVINSTANCE, *LPDI_DEVINSTANCE;
  153. //
  154. // Prototypes
  155. //
  156. NTSTATUS
  157. KbdMou_AddDevice(
  158. IN PDRIVER_OBJECT DriverObject,
  159. IN PDEVICE_OBJECT BusDeviceObject
  160. );
  161. NTSTATUS
  162. KbdMou_CreateClose (
  163. IN PDEVICE_OBJECT DeviceObject,
  164. IN PIRP Irp
  165. );
  166. NTSTATUS
  167. KbdMou_DispatchPassThrough(
  168. IN PDEVICE_OBJECT DeviceObject,
  169. IN PIRP Irp
  170. );
  171. NTSTATUS
  172. KbdMou_InternIoCtl (
  173. IN PDEVICE_OBJECT DeviceObject,
  174. IN PIRP Irp
  175. );
  176. NTSTATUS
  177. KbdMou_IoCtl (
  178. IN PDEVICE_OBJECT DeviceObject,
  179. IN PIRP Irp
  180. );
  181. NTSTATUS
  182. KbdMou_PnP (
  183. IN PDEVICE_OBJECT DeviceObject,
  184. IN PIRP Irp
  185. );
  186. NTSTATUS
  187. KbdMou_Power (
  188. IN PDEVICE_OBJECT DeviceObject,
  189. IN PIRP Irp
  190. );
  191. NTSTATUS
  192. Kbd_InitializationRoutine(
  193. IN PDEVICE_OBJECT DeviceObject, // InitializationContext
  194. IN PVOID SynchFuncContext,
  195. IN PI8042_SYNCH_READ_PORT ReadPort,
  196. IN PI8042_SYNCH_WRITE_PORT WritePort,
  197. OUT PBOOLEAN TurnTranslationOn
  198. );
  199. BOOLEAN
  200. Kbd_IsrHook(
  201. PDEVICE_OBJECT DeviceObject, // IsrContext
  202. PKEYBOARD_INPUT_DATA CurrentInput,
  203. POUTPUT_PACKET CurrentOutput,
  204. UCHAR StatusByte,
  205. PUCHAR DataByte,
  206. PBOOLEAN ContinueProcessing,
  207. PKEYBOARD_SCAN_STATE ScanState
  208. );
  209. BOOLEAN
  210. Mou_IsrHook(
  211. PDEVICE_OBJECT DeviceObject,
  212. PMOUSE_INPUT_DATA CurrentInput,
  213. POUTPUT_PACKET CurrentOutput,
  214. UCHAR StatusByte,
  215. PUCHAR DataByte,
  216. PBOOLEAN ContinueProcessing,
  217. PMOUSE_STATE MouseState,
  218. PMOUSE_RESET_SUBSTATE ResetSubState
  219. );
  220. VOID
  221. Kbd_ServiceCallback(
  222. IN PDEVICE_OBJECT DeviceObject,
  223. IN PKEYBOARD_INPUT_DATA InputDataStart,
  224. IN PKEYBOARD_INPUT_DATA InputDataEnd,
  225. IN OUT PULONG InputDataConsumed
  226. );
  227. VOID
  228. Mou_ServiceCallback(
  229. IN PDEVICE_OBJECT DeviceObject,
  230. IN PMOUSE_INPUT_DATA InputDataStart,
  231. IN PMOUSE_INPUT_DATA InputDataEnd,
  232. IN OUT PULONG InputDataConsumed
  233. );
  234. VOID
  235. KbdMou_Unload (
  236. IN PDRIVER_OBJECT DriverObject
  237. );
  238. #endif // DINPUTS_H