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.

197 lines
4.9 KiB

  1. // @doc
  2. /**********************************************************************
  3. *
  4. * @module SWVKBD.h |
  5. *
  6. * Declarations related to SideWinder Virtual Keyboard.
  7. *
  8. * History
  9. * ----------------------------------------------------------
  10. * Mitchell S. Dernis Original
  11. *
  12. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  13. *
  14. * @topic SWVKBD |
  15. * The SideWinder Virtual Keyboard is designed to sit atop the SideWinder
  16. * Virtual Bus. It is a HID device, and relies on the loading of a dummy
  17. * HID driver.<nl>
  18. *
  19. **********************************************************************/
  20. #include "irpqueue.h"
  21. //----------------------------------------------------------------------------------
  22. // Virtual Keyboard structures
  23. //----------------------------------------------------------------------------------
  24. #define GCK_VKBD_MAX_KEYSTROKES 0x06 //HID spec. says this can be six at most.
  25. //Comments in HIDPARSE code suggest that the OS
  26. //supports up to fourteen.
  27. #define GCK_VKBD_STATE_BUFFER_SIZE 0x20 //Size of circular buffer for holding on to
  28. //key presses.
  29. //----------------------------------------------------------------------------------
  30. // Device States - an alternative to five different flags
  31. //----------------------------------------------------------------------------------
  32. #define VKBD_STATE_STARTED 0x01
  33. #define VKBD_STATE_STOPPED 0x02
  34. #define VKBD_STATE_REMOVED 0x03
  35. //
  36. // @struct GCK_VKBD_REPORT_PACKET |
  37. // The report format of the virtual keyboard. Any changes here must be
  38. // reflected in the report descriptor and vice-versa.
  39. typedef struct tagGCK_VKBD_REPORT_PACKET
  40. {
  41. UCHAR ucModifierByte; //@field Modifier Byte
  42. UCHAR rgucUsageIndex[GCK_VKBD_MAX_KEYSTROKES]; //@field List of keys that down
  43. } GCK_VKBD_REPORT_PACKET, *PGCK_VKBD_REPORT_PACKET;
  44. //
  45. // @struct GCK_VKBD_EXT |
  46. //
  47. typedef struct tagGCK_VKBD_EXT
  48. {
  49. UCHAR ucDeviceState; //@field State of device(Started, Stopped, Removed)
  50. USHORT usReportBufferCount; //@field Count of packets in buffer
  51. USHORT usReportBufferPos; //@field Next Packet in buffer
  52. GCK_VKBD_REPORT_PACKET rgReportBuffer[GCK_VKBD_STATE_BUFFER_SIZE]; //@field Buffer of pendind reports
  53. CGuardedIrpQueue IrpQueue; //@field Irp queue;
  54. GCK_REMOVE_LOCK RemoveLock; //@field RemoveLock for Outstanding IO
  55. } GCK_VKBD_EXT, *PGCK_VKBD_EXT;
  56. //----------------------------------------------------------------------------------
  57. // API for using the Virtual Keyboard
  58. //----------------------------------------------------------------------------------
  59. NTSTATUS
  60. GCK_VKBD_Create
  61. (
  62. OUT PDEVICE_OBJECT *ppDeviceObject
  63. );
  64. NTSTATUS
  65. GCK_VKBD_Close
  66. (
  67. IN PDEVICE_OBJECT pDeviceObject
  68. );
  69. NTSTATUS
  70. GCK_VKBD_SendReportPacket
  71. (
  72. IN PDEVICE_OBJECT pDeviceObject,
  73. IN PGCK_VKBD_REPORT_PACKET pReportPacket
  74. );
  75. //----------------------------------------------------------------------------------
  76. // Driver Initialization
  77. //----------------------------------------------------------------------------------
  78. //----------------------------------------------------------------------------------
  79. // Device Initialization
  80. //----------------------------------------------------------------------------------
  81. NTSTATUS
  82. GCK_VKBD_Init
  83. (
  84. IN PDEVICE_OBJECT pDeviceObject,
  85. IN ULONG ulInitContext
  86. );
  87. //----------------------------------------------------------------------------------
  88. // Entry points to handle IRPs from the Virtual Bus
  89. //----------------------------------------------------------------------------------
  90. NTSTATUS
  91. GCK_VKBD_CloseProc
  92. (
  93. IN PDEVICE_OBJECT pDeviceObject,
  94. PIRP pIrp
  95. );
  96. NTSTATUS
  97. GCK_VKBD_CreateProc
  98. (
  99. IN PDEVICE_OBJECT pDeviceObject,
  100. IN PIRP pIrp
  101. );
  102. NTSTATUS
  103. GCK_VKBD_IoctlProc
  104. (
  105. PDEVICE_OBJECT pDeviceObject,
  106. PIRP pIrp
  107. );
  108. NTSTATUS
  109. GCK_VKBD_ReadProc
  110. (
  111. PDEVICE_OBJECT pDeviceObject,
  112. PIRP pIrp
  113. );
  114. NTSTATUS
  115. GCK_VKBD_StartProc
  116. (
  117. PDEVICE_OBJECT pDeviceObject,
  118. PIRP pIrp
  119. );
  120. NTSTATUS
  121. GCK_VKBD_StopProc
  122. (
  123. PDEVICE_OBJECT pDeviceObject,
  124. PIRP pIrp
  125. );
  126. NTSTATUS
  127. GCK_VKBD_RemoveProc
  128. (
  129. IN PDEVICE_OBJECT pDeviceObject,
  130. IN PIRP pIrp
  131. );
  132. NTSTATUS
  133. GCK_VKBD_WriteProc
  134. (
  135. PDEVICE_OBJECT pDeviceObject,
  136. PIRP pIrp
  137. );
  138. //------------------------------------------------------------------
  139. // Ioctl sub-function handlers
  140. //------------------------------------------------------------------
  141. NTSTATUS
  142. GCK_VKBD_GetDeviceDescriptor
  143. (
  144. IN ULONG ulBufferLength,
  145. OUT PVOID pvUserBuffer,
  146. OUT PULONG pulBytesCopied
  147. );
  148. NTSTATUS
  149. GCK_VKBD_GetReportDescriptor
  150. (
  151. IN ULONG ulBufferLength,
  152. OUT PVOID pvUserBuffer,
  153. OUT PULONG pulBytesCopied
  154. );
  155. NTSTATUS
  156. GCK_VKBD_GetDeviceAttributes
  157. (
  158. IN ULONG ulBufferLength,
  159. OUT PVOID pvUserBuffer,
  160. OUT PULONG pulBytesCopied
  161. );
  162. NTSTATUS
  163. GCK_VKBD_ReadReport
  164. (
  165. PDEVICE_OBJECT pDeviceObject,
  166. PIRP pIrp
  167. );
  168. NTSTATUS
  169. GCK_VKBD_WriteToFakeLEDs
  170. (
  171. IN PIRP pIrp
  172. );