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.

294 lines
9.1 KiB

  1. //**************************************************************************
  2. //
  3. // MSGAME.H -- Xena Gaming Project
  4. //
  5. // Version 3.XX
  6. //
  7. // Copyright (c) 1997 Microsoft Corporation. All rights reserved.
  8. //
  9. // @doc
  10. // @header MSGAME.H | Global includes and definitions for gameport driver.
  11. //**************************************************************************
  12. #ifndef __MSGAME_H__
  13. #define __MSGAME_H__
  14. #ifdef SAITEK
  15. #define MSGAME_NAME "SAIGAME"
  16. #else
  17. #define MSGAME_NAME "MSGAME"
  18. #endif
  19. //---------------------------------------------------------------------------
  20. // Public Include Files
  21. //---------------------------------------------------------------------------
  22. #include <wdm.h>
  23. #include <hidclass.h>
  24. #include <hidusage.h>
  25. #include <hidtoken.h>
  26. #include <hidport.h>
  27. #include <gameport.h>
  28. //---------------------------------------------------------------------------
  29. // Types
  30. //---------------------------------------------------------------------------
  31. // @type GAMEPORT | Retyped to avoid long function declarations
  32. typedef GAMEENUM_PORT_PARAMETERS GAMEPORT;
  33. typedef GAMEENUM_PORT_PARAMETERS *PGAMEPORT;
  34. typedef struct
  35. { // @struct GAME_WORK_ITEM | Game change structure
  36. WORK_QUEUE_ITEM QueueItem; // @field Work queue item for passive callback
  37. PDEVICE_OBJECT DeviceObject; // @field Device object for subsequent change
  38. GAMEPORT PortInfo; // @field Game port parameters
  39. } GAME_WORK_ITEM, *PGAME_WORK_ITEM;
  40. // @type HID_REPORT_ID | Retyped for portability and readability
  41. typedef UCHAR HID_REPORT_ID;
  42. typedef UCHAR *PHID_REPORT_ID;
  43. //---------------------------------------------------------------------------
  44. // Transaction Types
  45. //---------------------------------------------------------------------------
  46. typedef enum
  47. { // @enum MSGAME_TRANSACTION | Device transaction types
  48. MSGAME_TRANSACT_NONE, // @emem No transaction type
  49. MSGAME_TRANSACT_RESET, // @emem Reset transaction type
  50. MSGAME_TRANSACT_DATA, // @emem Data transaction type
  51. MSGAME_TRANSACT_ID, // @emem Id transaction type
  52. MSGAME_TRANSACT_STATUS, // @emem Status transaction type
  53. MSGAME_TRANSACT_SPEED, // @emem Speed transaction type
  54. MSGAME_TRANSACT_GODIGITAL, // @emem GoDigital transaction type
  55. MSGAME_TRANSACT_GOANALOG // @emem GoAnalog transaction type
  56. } MSGAME_TRANSACTION;
  57. //---------------------------------------------------------------------------
  58. // Local Include Files
  59. //---------------------------------------------------------------------------
  60. #include "debug.h"
  61. #include "device.h"
  62. #include "timer.h"
  63. #include "portio.h"
  64. #define public
  65. //---------------------------------------------------------------------------
  66. // Definitions
  67. //---------------------------------------------------------------------------
  68. #ifdef SAITEK
  69. #define MSGAME_VENDOR_ID ((USHORT)'SA')
  70. #else
  71. #define MSGAME_VENDOR_ID ((USHORT)0x045E)
  72. #endif
  73. #define MSGAME_VERSION_NUMBER ((USHORT)3)
  74. #define MSGAME_HID_VERSION 0x0100
  75. #define MSGAME_HID_COUNTRY 0x0000
  76. #define MSGAME_HID_DESCRIPTORS 0x0001
  77. #define MSGAME_AUTODETECT_ID L"Gameport\\SideWinderGameController\0\0"
  78. //---------------------------------------------------------------------------
  79. // Structures
  80. //---------------------------------------------------------------------------
  81. typedef struct
  82. { // @struct DEVICE_EXTENSION | Device extension data
  83. PDRIVER_OBJECT Driver; // @field A back pointer to the actual DriverObject
  84. PDEVICE_OBJECT Self; // @field A back pointer to the actual DeviceObject
  85. LONG IrpCount; // @field 1 biased count of why object sticks around
  86. BOOLEAN Started; // @field This device has been started
  87. BOOLEAN Removed; // @field This device has been removed
  88. BOOLEAN Surprised; // @field This device has been surprise removed
  89. BOOLEAN Removing; // @field This device is being removed
  90. PDEVICE_OBJECT TopOfStack; // @field The top of the device stack beneath this device
  91. GAMEPORT PortInfo; // @field Game resource info structure filled by GameEnumerator
  92. KEVENT StartEvent; // @field An event to sync the start IRP.
  93. KEVENT RemoveEvent; // @field An event to synch outstandIO to zero
  94. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  95. //---------------------------------------------------------------------------
  96. // Macros
  97. //---------------------------------------------------------------------------
  98. #define GET_MINIDRIVER_DEVICE_EXTENSION(DO) \
  99. ((PDEVICE_EXTENSION)(((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->MiniDeviceExtension))
  100. #define GET_NEXT_DEVICE_OBJECT(DO) \
  101. (((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->NextDeviceObject)
  102. #define STD0(txt) #txt
  103. #define STD1(txt) STD0(txt)
  104. #define STILL_TO_DO(txt) message("\nSTILL TO DO: "__FILE__"("STD1(__LINE__)"): "#txt"\n")
  105. #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
  106. #define EXCHANGE(x,y) ((x)^=(y)^=(x)^=(y))
  107. #define TOUPPER(x) ((x>='a'&&x<='z')?x-'a'+'A':x)
  108. //---------------------------------------------------------------------------
  109. // Procedures
  110. //---------------------------------------------------------------------------
  111. NTSTATUS
  112. DriverEntry (
  113. IN PDRIVER_OBJECT DriverObject,
  114. IN PUNICODE_STRING registryPath
  115. );
  116. NTSTATUS
  117. MSGAME_CreateClose (
  118. IN PDEVICE_OBJECT DeviceObject,
  119. IN PIRP pIrp
  120. );
  121. NTSTATUS
  122. MSGAME_SystemControl (
  123. IN PDEVICE_OBJECT DeviceObject,
  124. IN PIRP pIrp
  125. );
  126. NTSTATUS
  127. MSGAME_AddDevice (
  128. IN PDRIVER_OBJECT DriverObject,
  129. IN PDEVICE_OBJECT PhysicalDeviceObject
  130. );
  131. VOID
  132. MSGAME_Unload (
  133. IN PDRIVER_OBJECT DriverObject
  134. );
  135. VOID
  136. MSGAME_ReadRegistry (
  137. PCHAR DeviceName,
  138. PDEVICE_VALUES DeviceValues
  139. );
  140. NTSTATUS
  141. MSGAME_Internal_Ioctl (
  142. IN PDEVICE_OBJECT DeviceObject,
  143. IN PIRP pIrp
  144. );
  145. NTSTATUS
  146. MSGAME_GetDeviceDescriptor (
  147. IN PDEVICE_OBJECT DeviceObject,
  148. IN PIRP pIrp
  149. );
  150. NTSTATUS
  151. MSGAME_GetReportDescriptor (
  152. IN PDEVICE_OBJECT DeviceObject,
  153. IN PIRP pIrp
  154. );
  155. NTSTATUS
  156. MSGAME_GetAttributes (
  157. IN PDEVICE_OBJECT DeviceObject,
  158. IN PIRP Irp
  159. );
  160. NTSTATUS
  161. MSGAME_GetFeature (
  162. IN PDEVICE_OBJECT DeviceObject,
  163. IN PIRP Irp
  164. );
  165. NTSTATUS
  166. MSGAME_ReadReport (
  167. IN PDEVICE_OBJECT DeviceObject,
  168. IN PIRP pIrp
  169. );
  170. PWCHAR
  171. MSGAME_GetHardwareId (
  172. IN PDEVICE_OBJECT DeviceObject
  173. );
  174. BOOLEAN
  175. MSGAME_CompareHardwareIds (
  176. IN PWCHAR HardwareId,
  177. IN PWCHAR DeviceId
  178. );
  179. VOID
  180. MSGAME_FreeHardwareId (
  181. IN PWCHAR HardwareId
  182. );
  183. NTSTATUS
  184. MSGAME_PnP (
  185. IN PDEVICE_OBJECT DeviceObject,
  186. IN PIRP pIrp
  187. );
  188. NTSTATUS
  189. MSGAME_PnPComplete (
  190. IN PDEVICE_OBJECT DeviceObject,
  191. IN PIRP pIrp,
  192. IN PVOID Context
  193. );
  194. NTSTATUS
  195. MSGAME_StartDevice (
  196. IN PDEVICE_EXTENSION pDevExt,
  197. IN PIRP pIrp
  198. );
  199. VOID
  200. MSGAME_StopDevice (
  201. IN PDEVICE_EXTENSION pDevExt,
  202. IN BOOLEAN TouchTheHardware
  203. );
  204. NTSTATUS
  205. MSGAME_Power (
  206. IN PDEVICE_OBJECT DeviceObject,
  207. IN PIRP pIrp
  208. );
  209. NTSTATUS
  210. MSGAME_GetResources (
  211. IN PDEVICE_EXTENSION pDevExt,
  212. IN PIRP pIrp
  213. );
  214. NTSTATUS
  215. MSGAME_GetResourcesComplete (
  216. IN PDEVICE_OBJECT DeviceObject,
  217. IN PIRP pIrp,
  218. IN PVOID Context
  219. );
  220. VOID
  221. MSGAME_PostTransaction (
  222. IN PPACKETINFO PacketInfo
  223. );
  224. NTSTATUS
  225. MSGAME_CreateDevice (
  226. IN PDEVICE_OBJECT DeviceObject
  227. );
  228. NTSTATUS
  229. MSGAME_RemoveDevice (
  230. IN PDEVICE_OBJECT DeviceObject
  231. );
  232. NTSTATUS
  233. MSGAME_ChangeDevice (
  234. IN PDEVICE_OBJECT DeviceObject
  235. );
  236. //===========================================================================
  237. // End
  238. //===========================================================================
  239. #endif // __MSGAME_H__