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.

441 lines
9.9 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. gameport.h
  5. Abstract:
  6. This module contains the common public declarations for the game port
  7. enumerator.
  8. @@BEGIN_DDKSPLIT
  9. Author:
  10. Kenneth Ray
  11. @@END_DDKSPLIT
  12. Environment:
  13. kernel mode only
  14. Notes:
  15. Revision History:
  16. --*/
  17. #ifndef __GAMEPORT_H
  18. #define __GAMEPORT_H
  19. #define FILE_DEVICE_GAMEENUM FILE_DEVICE_BUS_EXTENDER
  20. // ***************************************************************************
  21. // IOCTL interface to the bus (fdo)
  22. //
  23. // Clients use this to tell the enumerator what gaming devices on legacy ports
  24. // exist. (like for instance a control panel)
  25. // ***************************************************************************
  26. //
  27. // Define an Interface Guid to access the game port enumerator
  28. //
  29. #undef FAR
  30. #define FAR
  31. #undef PHYSICAL_ADDRESS
  32. #define PHYSICAL_ADDRESS LARGE_INTEGER
  33. DEFINE_GUID (GUID_GAMEENUM_BUS_ENUMERATOR, 0xcae56030, 0x684a, 0x11d0, 0xd6, 0xf6, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda);
  34. // cae56030-684a-11d0-b6f6-00a0c90f57da
  35. #define GAMEENUM_IOCTL(_index_) \
  36. CTL_CODE (FILE_DEVICE_GAMEENUM, _index_, METHOD_BUFFERED, FILE_ANY_ACCESS)
  37. #define GAMEENUM_INTERNAL_IOCTL(_index_) \
  38. CTL_CODE (FILE_DEVICE_GAMEENUM, _index_, METHOD_NEITHER, FILE_ANY_ACCESS)
  39. #define IOCTL_GAMEENUM_EXPOSE_HARDWARE GAMEENUM_IOCTL (0x0)
  40. #define IOCTL_GAMEENUM_REMOVE_HARDWARE GAMEENUM_IOCTL (0x1)
  41. #define IOCTL_GAMEENUM_PORT_DESC GAMEENUM_IOCTL (0x2)
  42. //
  43. // Private data storage area for OEM devices. Values preserved if supplied to
  44. // IOCTL_GAMEENUM_EXPOSE_HARDWARE and GAMEENUM_INTERNAL_IOCTL_EXPOSE_SIBLING,
  45. // and set to zero otherwise on initial mini-driver invocation (DriverEntry).
  46. //
  47. #define SIZE_GAMEENUM_OEM_DATA 8
  48. typedef ULONG GAMEENUM_OEM_DATA[SIZE_GAMEENUM_OEM_DATA];
  49. #if _MSC_VER >= 1200
  50. #pragma warning(push)
  51. #endif
  52. #pragma warning(disable:4200)
  53. typedef struct _GAMEENUM_EXPOSE_HARDWARE
  54. {
  55. //
  56. // sizeof (struct _GAMEENUM_HARDWARE)
  57. //
  58. IN ULONG Size;
  59. //
  60. // The handle of the port found in the port desc
  61. //
  62. IN PVOID PortHandle;
  63. //
  64. // A handle to the exposed PDO
  65. //
  66. OUT PVOID HardwareHandle;
  67. //
  68. // For legacy joysticks only
  69. //
  70. IN USHORT NumberJoysticks;
  71. //
  72. // legacy joysticks only (joysticks * axis <= 4).
  73. //
  74. IN USHORT NumberAxis;
  75. //
  76. // Unique ID
  77. //
  78. IN USHORT UnitID;
  79. //
  80. // Number of buttons present on the device
  81. //
  82. IN USHORT NumberButtons;
  83. //
  84. // Bit flags controlling the behavior of the device
  85. //
  86. USHORT Flags;
  87. //
  88. // Reserved for future use
  89. //
  90. USHORT Reserved[5];
  91. //
  92. // Specific OEM Data
  93. //
  94. IN GAMEENUM_OEM_DATA OemData;
  95. //
  96. // An array of (zero terminated wide character strings). The array itself
  97. // also null terminated (ie, MULTI_SZ)
  98. //
  99. IN WCHAR HardwareIDs[];
  100. } GAMEENUM_EXPOSE_HARDWARE, *PGAMEENUM_EXPOSE_HARDWARE;
  101. //
  102. // Bit values defined for the Flags field
  103. // GAMEENUM_FLAG_NOCOMPATID the default compatibility hardware ID should
  104. // not be exposed for this device.
  105. // GAMEENUM_FLAG_COMPATIDCTRL if this is zero GAMEENUM_FLAG_NOCOMPATID is
  106. // ignored
  107. // GAMEENUM_FLAG_RESERVED reserved bits, should be set to zero
  108. //
  109. #define GAMEENUM_FLAG_NOCOMPATID 0x0001
  110. #define GAMEENUM_FLAG_COMPATIDCTRL 0x0002
  111. #define GAMEENUM_FLAG_RESERVED 0xFFFC
  112. #if _MSC_VER >= 1200
  113. #pragma warning(pop)
  114. #endif
  115. typedef struct _GAMEENUM_REMOVE_HARDWARE
  116. {
  117. //
  118. // sizeof (struct _REMOVE_HARDWARE)
  119. //
  120. IN ULONG Size;
  121. //
  122. // Same value as HardwareHandle in GAMEENUM_EXPOSE_HARDWARE
  123. //
  124. IN PVOID HardwareHandle;
  125. } GAMEENUM_REMOVE_HARDWARE, *PGAMEENUM_REMOVE_HARDWARE;
  126. typedef struct _GAMEENUM_PORT_DESC
  127. {
  128. IN ULONG Size; // sizeof (struct _PORT_DESC)
  129. OUT PVOID PortHandle;
  130. OUT PHYSICAL_ADDRESS PortAddress;
  131. ULONG Reserved [5];
  132. } GAMEENUM_PORT_DESC, *PGAMEENUM_PORT_DESC;
  133. // **************************************************************************
  134. // Internal IOCTL interface for (pdo)
  135. // The HID to legacy game port minidriver uses this interface to
  136. // find the address of the device.
  137. // **************************************************************************
  138. #define IOCTL_GAMEENUM_PORT_PARAMETERS GAMEENUM_INTERNAL_IOCTL (0x100)
  139. #define IOCTL_GAMEENUM_EXPOSE_SIBLING GAMEENUM_INTERNAL_IOCTL (0x101)
  140. #define IOCTL_GAMEENUM_REMOVE_SELF GAMEENUM_INTERNAL_IOCTL (0x102)
  141. #define IOCTL_GAMEENUM_ACQUIRE_ACCESSORS GAMEENUM_INTERNAL_IOCTL (0x103)
  142. // Of which IO_STACK_LOCATION->Parameters.Others.Argument1 is set to
  143. // a pointer to struct _GAMEENUM_GAME_PARAMETERS
  144. typedef
  145. UCHAR
  146. (*PGAMEENUM_READPORT) (
  147. PVOID GameContext
  148. );
  149. typedef
  150. VOID
  151. (*PGAMEENUM_WRITEPORT) (
  152. PVOID GameContext,
  153. UCHAR Value
  154. );
  155. #define GAMEENUM_BUTTON_1 0x01
  156. #define GAMEENUM_BUTTON_2 0x02
  157. #define GAMEENUM_BUTTON_3 0x04
  158. #define GAMEENUM_BUTTON_4 0x08
  159. #define GAMEENUM_AXIS_X 0x10
  160. #define GAMEENUM_AXIS_Y 0x20
  161. #define GAMEENUM_AXIS_R 0x40
  162. #define GAMEENUM_AXIS_Z 0x80
  163. #ifndef NTSTATUS
  164. typedef LONG NTSTATUS;
  165. #endif
  166. typedef
  167. NTSTATUS
  168. (*PGAMEENUM_READPORT_DIGITAL) (
  169. IN PVOID Context,
  170. IN UCHAR ButtonAxisMask,
  171. IN BOOLEAN Approximate,
  172. IN OUT ULONG AxisState[4],
  173. OUT UCHAR ButtonState[4]
  174. );
  175. /*++
  176. Routine Description.
  177. Will read from the gameport digitally.
  178. Arguments:
  179. Context - value passed in GAME_PORT_PARAMETERS.GameContext
  180. ButtonAxisMask - Mask indicating which axis and buttons are expected to
  181. have valid data
  182. Approximate - OK to approximate (if polling times out, etc)
  183. AxisState - IN = Last valid axis state
  184. OUT = Current Axis state
  185. Index Maps to Axis
  186. 0 X
  187. 1 Y
  188. 2 R
  189. 3 Z
  190. ButtonState - OUT = Current button state.
  191. --*/
  192. typedef
  193. NTSTATUS
  194. (*PGAMEENUM_ACQUIRE_PORT) (
  195. PVOID GameContext
  196. );
  197. typedef
  198. VOID
  199. (*PGAMEENUM_RELEASE_PORT) (
  200. PVOID GameContext
  201. );
  202. typedef enum _GAMEENUM_PORTION
  203. {
  204. GameenumFirstHalf,
  205. GameenumSecondHalf,
  206. GameenumWhole
  207. } GAMEENUM_PORTION;
  208. typedef struct _GAMEENUM_PORT_PARAMETERS
  209. {
  210. //
  211. // sizeof (GAMEENUM_GET_PORT_PARAMETERS)
  212. //
  213. IN ULONG Size;
  214. //
  215. // read the game port (analog)
  216. //
  217. OUT PGAMEENUM_READPORT ReadAccessor;
  218. //
  219. // write the game port (analog)
  220. //
  221. OUT PGAMEENUM_WRITEPORT WriteAccessor;
  222. //
  223. // token to read/write this game port
  224. //
  225. OUT PVOID GameContext;
  226. //
  227. // Which joystick is it?
  228. //
  229. OUT GAMEENUM_PORTION Portion;
  230. //
  231. // legacy joysticks only
  232. //
  233. OUT USHORT NumberAxis;
  234. //
  235. // unique id
  236. //
  237. IN USHORT UnitID;
  238. //
  239. // OEM specific data
  240. //
  241. IN GAMEENUM_OEM_DATA OemData;
  242. //
  243. // Number of buttons
  244. //
  245. OUT USHORT NumberButtons;
  246. //
  247. // Reserved for future use
  248. //
  249. USHORT Reserved2;
  250. //
  251. // Read the game port (digital)
  252. //
  253. OUT PGAMEENUM_READPORT_DIGITAL ReadAccessorDigital;
  254. //
  255. // Function to call before reading/writing to the port
  256. //
  257. OUT PGAMEENUM_ACQUIRE_PORT AcquirePort;
  258. //
  259. // Function to call when done reading/writing to the port
  260. //
  261. OUT PGAMEENUM_RELEASE_PORT ReleasePort;
  262. //
  263. // Context to pass to AcquirePort and ReleasePort
  264. //
  265. OUT PVOID PortContext;
  266. ULONG Reserved[3];
  267. } GAMEENUM_PORT_PARAMETERS, *PGAMEENUM_PORT_PARAMETERS;
  268. typedef struct _GAMEENUM_EXPOSE_SIBLING
  269. {
  270. //
  271. // sizeof (struct _GAMEENUM_EXPOSE_SIBLING)
  272. //
  273. IN ULONG Size;
  274. //
  275. // A handle to the exposed PDO
  276. //
  277. OUT PVOID HardwareHandle;
  278. //
  279. // OEM specific data
  280. //
  281. IN GAMEENUM_OEM_DATA OemData;
  282. //
  283. // The id of this device object
  284. //
  285. IN USHORT UnitID;
  286. USHORT Reserved[3];
  287. //
  288. // An array of (zero terminated wide character strings). The array itself
  289. // also null terminated (ie, MULTI_SZ),
  290. //
  291. IN PWCHAR HardwareIDs OPTIONAL;
  292. } GAMEENUM_EXPOSE_SIBLING, *PGAMEENUM_EXPOSE_SIBLING;
  293. //
  294. // This struct is sent down to the PDO/lower filters of gameenum via
  295. // the internal IOCTL IOCTL_GAMEENUM_ACQUIRE_ACCESSORS. If this IOCTL is
  296. // handled, GameContext, ReadAccessor, and WriteAccessor must be filled in.
  297. // ReadAccessorDigital is optional
  298. //
  299. typedef struct _GAMEENUM_ACQUIRE_ACCESSORS
  300. {
  301. //
  302. // sizeof (struct _GAMEENUM_ACQUIRE_ACCESSORS)
  303. //
  304. IN ULONG Size;
  305. //
  306. // token to read/write this game port
  307. //
  308. OUT PVOID GameContext;
  309. //
  310. // read the game port (analog)
  311. //
  312. OUT PGAMEENUM_READPORT ReadAccessor;
  313. //
  314. // write the game port (analog)
  315. //
  316. OUT PGAMEENUM_WRITEPORT WriteAccessor;
  317. //
  318. // Read the game port (digital)
  319. //
  320. OUT PGAMEENUM_READPORT_DIGITAL ReadAccessorDigital;
  321. //
  322. // Function to call before reading/writing to the port
  323. //
  324. OUT PGAMEENUM_ACQUIRE_PORT AcquirePort;
  325. //
  326. // Function to call when done reading/writing to the port
  327. //
  328. OUT PGAMEENUM_RELEASE_PORT ReleasePort;
  329. //
  330. // Context to pass to AcquirePort and ReleasePort
  331. //
  332. OUT PVOID PortContext;
  333. OUT ULONG Reserved[3];
  334. } GAMEENUM_ACQUIRE_ACCESSORS, *PGAMEENUM_ACQUIRE_ACCESSORS;
  335. #endif