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.

351 lines
8.6 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: digsport.h
  6. * Content: DirectInput internal include file for HID
  7. *
  8. ***************************************************************************/
  9. #ifndef __DIPORT_H
  10. #define __DIPORT_H
  11. /* Forward define */
  12. typedef struct _BUSDEVICE BUSDEVICE, *PBUSDEVICE;
  13. /*****************************************************************************
  14. *
  15. * @doc INTERNAL
  16. *
  17. * @struct BUS_REGDATA
  18. * Persistent Data, written to the registry for each gameport device.
  19. * Contains information on how to reexpose the analog joystick device
  20. * on reboot.
  21. *
  22. * @field DWORD | dwSize |
  23. * Size of the structure.
  24. *
  25. * @field USHORT | uVID |
  26. * Vendor ID.
  27. *
  28. * @field USHORT | uPID |
  29. * Product ID.
  30. *
  31. * @field USHORT | nJoysticks |
  32. * Number of joysticks attached to this gameport.
  33. *
  34. * @field USHORT | nAxes |
  35. * Number of axes in each joystick.
  36. *
  37. * @field PVOID | hHardwareHandle |
  38. * Hardware handle returned by EXPOSE IOCTL to gameenum.
  39. * Needed to remove the joystick device.
  40. *
  41. * @field BOOLEAN | fAttachOnReboot |
  42. * Flag that is cleared when a device is exposed and set when
  43. * the device is found to be OK. Used to prevent reloading
  44. * of a device that crashes immediately.
  45. *
  46. * @field JOYREGHWSSETTINGS | hws |
  47. * Joystick Hardware settings.
  48. *
  49. * @field WCHAR | wszHardwareId |
  50. * PnP hardware ID for the joystick.
  51. *
  52. *****************************************************************************/
  53. typedef struct _BUS_REGDATA
  54. {
  55. /* Size of structure */
  56. DWORD dwSize;
  57. /* VID PID for this device */
  58. USHORT uVID;
  59. USHORT uPID;
  60. /* Number of joysticks to expose */
  61. USHORT nJoysticks;
  62. USHORT nAxes;
  63. /* Hardware settings for joystick */
  64. PVOID hHardware;
  65. /* Flag whether or not device should be re-exposed */
  66. BOOLEAN fAttachOnReboot;
  67. /* Joystick Hardware settings */
  68. JOYREGHWSETTINGS hws;
  69. DWORD dwFlags1;
  70. /* An array of (zero terminated wide character
  71. * strings). The array itself also null terminated
  72. */
  73. WCHAR wszHardwareId[MAX_JOYSTRING];
  74. } BUS_REGDATA, *PBUS_REGDATA;
  75. /*****************************************************************************
  76. *
  77. * @doc INTERNAL
  78. *
  79. * @struct BUSDEVICEINFO
  80. * Data about each instance of bus devices ( gameport / serial port, etc .. )
  81. *
  82. * @field PBUSDEVICE | pBusDevice |
  83. * Address of the BusDevice struct.
  84. *
  85. * @field PSP_DEVICE_INTERFACE_DETAIL_DATA | pdidd |
  86. * Device interface detail data.
  87. *
  88. * @field GUID | guid |
  89. * Instance GUID for the device.
  90. *
  91. * @field int | idPort |
  92. * Unique ID for the gameport.
  93. *
  94. * @field int | idJoy |
  95. * Id of one of the joysticks attached to this gameport.
  96. *
  97. * @field HKEY | hk |
  98. * Registry key that contains configuration information.
  99. * Sadly, we must keep it open because there is no way to
  100. * obtain the name of the key, and the only way to open the
  101. * key is inside an enumeration.
  102. *
  103. * @field LPTSTR | ptszId |
  104. * Device path to access the gameport for read / write.
  105. *
  106. * @field BOOL | fAttached |
  107. * True is device is attached.
  108. *
  109. * @field BOOL | fDeleteIfNotConnected |
  110. * Flag that indicates that the device should be deleted if it
  111. * is not connected.
  112. *
  113. *******************************************************************************/
  114. typedef struct _BUSDEVICEINFO
  115. {
  116. PBUSDEVICE pBusDevice;
  117. PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd;
  118. GUID guid;
  119. int idPort;
  120. int idJoy;
  121. HKEY hk;
  122. LPTSTR ptszId;
  123. BOOL fAttached;
  124. BOOL fDeleteIfNotConnected;
  125. } BUSDEVICEINFO, *PBUSDEVICEINFO;
  126. /*****************************************************************************
  127. *
  128. * @doc INTERNAL
  129. *
  130. * @struct BUSDEVICELIST |
  131. *
  132. * Records information about all the HID devices.
  133. *
  134. * @field int | cbdi |
  135. *
  136. * Number of items in the list that are in use.
  137. *
  138. * @field int | cbdiAlloc |
  139. *
  140. * Number of items allocated in the list.
  141. *
  142. * @field BUSDEVICEINFO | rgbdi[0] |
  143. *
  144. * Variable-size array of device information structures.
  145. *
  146. *****************************************************************************/
  147. typedef struct _BUSDEVICELIST
  148. {
  149. int cgbi;
  150. int cgbiAlloc;
  151. BUSDEVICEINFO rgbdi[0];
  152. } BUSDEVICELIST, *PBUSDEVICELIST;
  153. /*****************************************************************************
  154. *
  155. * @doc INTERNAL
  156. *
  157. * @struct BUSDEVICE |
  158. *
  159. * Data specific to each bus ( gameport / serialPort ).
  160. *
  161. * @field PBUSDEVICE | pbdl |
  162. * List of devices on a bus.
  163. *
  164. * @field PCGUID | pcGuid |
  165. * Device GUID for the bus.
  166. *
  167. * @field DWORD | tmLastRebuild |
  168. * Last time the bus device list was rebuild.
  169. *
  170. * @field const int | ioctl_EXPOSE |
  171. * IOCTL to expose a device.
  172. *
  173. * @field const int | ioclt_REMOVE |
  174. * IOCTL to remove a device.
  175. *
  176. * @field const int | ioctl_DESC |
  177. * IOCTL to obtain description of the bus.
  178. *
  179. * @field const int | ioctl_PARAMETERS |
  180. *
  181. * @field const int | ioctl_EXPOSE_SIBLING |
  182. *
  183. * @field const int | ioctl_REMOVE_SELF |
  184. *
  185. * @field const int | dw_IDS_STDPORT |
  186. * index into the IDS String table for text associated with device.
  187. *
  188. * @field const int | dw_JOY_HWS_ISPORTBUS |
  189. *
  190. *****************************************************************************/
  191. typedef struct _BUSDEVICE
  192. {
  193. D(TCHAR wszBusType[MAX_PATH];)
  194. PBUSDEVICELIST pbdl;
  195. PCGUID pcGuid;
  196. DWORD tmLastRebuild;
  197. const int ioctl_EXPOSE;
  198. const int ioctl_REMOVE;
  199. const int ioctl_DESC;
  200. const int ioctl_PARAMETERS;
  201. const int ioctl_EXPOSE_SIBLING;
  202. const int ioctl_REMOVE_SELF;
  203. const int dwIDS_STDPORT;
  204. const int dwJOY_HWS_ISPORTBUS;
  205. } BUSDEVICE, *PBUSDEVICE;
  206. extern BUSDEVICE g_pBusDevice[];
  207. #define cbGdlCbdi(cbdi) FIELD_OFFSET(BUSDEVICELIST, rgbdi[cbdi])
  208. /*
  209. * We choose our starting point at 2 devices, since most machines
  210. * will have one gameport/serialport bus.
  211. * The maximum number is chosen at randomn
  212. */
  213. #define cgbiMax 32
  214. #define cgbiInit 2 // Most machines will have only one gameport bus, two serialports
  215. #define MAX_PORT_BUSES 16
  216. PBUSDEVICEINFO INTERNAL
  217. pbdiFromphdi
  218. (
  219. IN PHIDDEVICEINFO phdi
  220. );
  221. PHIDDEVICEINFO INTERNAL
  222. phdiFrompbdi
  223. (
  224. IN PBUSDEVICEINFO pbdi
  225. );
  226. PBUSDEVICEINFO EXTERNAL
  227. pbdiFromJoyId
  228. (
  229. IN int idJoy
  230. );
  231. PBUSDEVICEINFO EXTERNAL
  232. pbdiFromGUID
  233. (
  234. IN PCGUID pguid
  235. );
  236. HRESULT EXTERNAL
  237. DIBusDevice_Expose
  238. (
  239. IN HANDLE hf,
  240. IN OUT PBUS_REGDATA pRegData
  241. );
  242. HRESULT INTERNAL
  243. DIBusDevice_Remove
  244. (
  245. IN PBUSDEVICEINFO pbdi
  246. );
  247. HRESULT INTERNAL
  248. DIBusDevice_SetRegData
  249. (
  250. IN HKEY hk,
  251. IN PBUS_REGDATA pRegData
  252. );
  253. HRESULT INTERNAL
  254. DIBusDevice_GetRegData
  255. (
  256. IN HKEY hk,
  257. OUT PBUS_REGDATA pRegData
  258. );
  259. BOOL INTERNAL
  260. DIBusDevice_BuildListEntry
  261. (
  262. HDEVINFO hdev,
  263. PSP_DEVICE_INTERFACE_DATA pdid,
  264. PBUSDEVICE pBusDevice
  265. );
  266. void INTERNAL
  267. DIBus_EmptyList
  268. (
  269. PBUSDEVICELIST *ppbdl
  270. );
  271. void EXTERNAL
  272. DIBus_FreeMemory();
  273. HRESULT EXTERNAL
  274. DIBus_InitId
  275. (
  276. PBUSDEVICELIST pbdl
  277. );
  278. ULONG EXTERNAL
  279. DIBus_BuildList
  280. (
  281. IN BOOL fForce
  282. );
  283. PBUSDEVICELIST EXTERNAL
  284. pbdlFromGUID
  285. (
  286. IN PCGUID pcGuid
  287. );
  288. HRESULT EXTERNAL
  289. DIBusDevice_ExposeEx
  290. (
  291. IN PBUSDEVICELIST pbdl,
  292. IN PBUS_REGDATA pRegData
  293. );
  294. HRESULT EXTERNAL
  295. DIBusDevice_GetTypeInfo
  296. (
  297. PCGUID guid,
  298. LPDIJOYTYPEINFO pjti,
  299. DWORD fl
  300. );
  301. HRESULT EXTERNAL DIPort_SnapTypes(LPWSTR *ppwszz);
  302. #endif /* __DIPORT_H */
  303.